mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Updated events to store CommandStreamReceiver at init
- Updated Event Class to store a pointer to the associated device's command stream receiver to use during query status and host synchronize Change-Id: I130df8541ca6a13396669c75fefd135d5ad1ef7d Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
9015a518dc
commit
e01b9e0c86
@ -41,13 +41,12 @@ struct EventImp : public Event {
|
||||
ze_result_t queryStatus() override {
|
||||
uint64_t *hostAddr = static_cast<uint64_t *>(hostAddress);
|
||||
auto alloc = &(this->eventPool->getAllocation());
|
||||
auto csr = static_cast<DeviceImp *>(this->device)->neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||
|
||||
if (metricTracer != nullptr) {
|
||||
*hostAddr = metricTracer->getNotificationState();
|
||||
}
|
||||
|
||||
csr->downloadAllocation(*alloc);
|
||||
this->csr->downloadAllocation(*alloc);
|
||||
|
||||
if (isTimestampEvent) {
|
||||
auto baseAddr = reinterpret_cast<uint64_t>(hostAddress);
|
||||
@ -168,6 +167,7 @@ Event *Event::create(EventPool *eventPool, const ze_event_desc_t *desc, Device *
|
||||
|
||||
event->signalScope = desc->signal;
|
||||
event->waitScope = desc->wait;
|
||||
event->csr = static_cast<DeviceImp *>(device)->neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||
|
||||
event->reset();
|
||||
|
||||
@ -250,9 +250,8 @@ ze_result_t EventImp::hostSynchronize(uint32_t timeout) {
|
||||
std::chrono::high_resolution_clock::time_point time1, time2;
|
||||
int64_t timeDiff = 0;
|
||||
ze_result_t ret = ZE_RESULT_NOT_READY;
|
||||
auto csr = static_cast<DeviceImp *>(this->device)->neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||
|
||||
if (csr->getType() == NEO::CommandStreamReceiverType::CSR_AUB) {
|
||||
if (this->csr->getType() == NEO::CommandStreamReceiverType::CSR_AUB) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,8 @@ struct Event : _ze_event_handle_t {
|
||||
// Metric tracer instance associated with the event.
|
||||
MetricTracer *metricTracer = nullptr;
|
||||
|
||||
NEO::CommandStreamReceiver *csr = nullptr;
|
||||
|
||||
protected:
|
||||
NEO::GraphicsAllocation *allocation = nullptr;
|
||||
};
|
||||
|
@ -15,6 +15,7 @@ namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
using EventPoolCreate = Test<DeviceFixture>;
|
||||
using EventCreate = Test<DeviceFixture>;
|
||||
|
||||
TEST_F(EventPoolCreate, allocationContainsAtLeast16Bytes) {
|
||||
ze_event_pool_desc_t eventPoolDesc = {
|
||||
@ -45,6 +46,49 @@ TEST_F(EventPoolCreate, givenTimestampEventsThenVerifyNumTimestampsToRead) {
|
||||
EXPECT_EQ(numTimestamps, eventPool->getNumEventTimestampsToRead());
|
||||
}
|
||||
|
||||
TEST_F(EventPoolCreate, givenAnEventIsCreatedFromThisEventPoolThenEventContainsDeviceCommandStreamReceiver) {
|
||||
ze_event_pool_desc_t eventPoolDesc = {
|
||||
ZE_EVENT_POOL_DESC_VERSION_CURRENT,
|
||||
ZE_EVENT_POOL_FLAG_HOST_VISIBLE,
|
||||
1};
|
||||
const ze_event_desc_t eventDesc = {
|
||||
ZE_EVENT_DESC_VERSION_CURRENT,
|
||||
0,
|
||||
ZE_EVENT_SCOPE_FLAG_HOST,
|
||||
ZE_EVENT_SCOPE_FLAG_HOST};
|
||||
|
||||
ze_event_handle_t event = nullptr;
|
||||
|
||||
std::unique_ptr<L0::EventPool> eventPool(EventPool::create(device, &eventPoolDesc));
|
||||
ASSERT_NE(nullptr, eventPool);
|
||||
|
||||
eventPool->createEvent(&eventDesc, &event);
|
||||
|
||||
std::unique_ptr<L0::Event> event_object(L0::Event::fromHandle(event));
|
||||
ASSERT_NE(nullptr, event_object->csr);
|
||||
ASSERT_EQ(static_cast<DeviceImp *>(device)->neoDevice->getDefaultEngine().commandStreamReceiver, event_object->csr);
|
||||
}
|
||||
|
||||
TEST_F(EventCreate, givenAnEventCreatedThenTheEventHasTheDeviceCommandStreamReceiverSet) {
|
||||
ze_event_pool_desc_t eventPoolDesc = {
|
||||
ZE_EVENT_POOL_DESC_VERSION_CURRENT,
|
||||
ZE_EVENT_POOL_FLAG_HOST_VISIBLE,
|
||||
1};
|
||||
const ze_event_desc_t eventDesc = {
|
||||
ZE_EVENT_DESC_VERSION_CURRENT,
|
||||
0,
|
||||
ZE_EVENT_SCOPE_FLAG_DEVICE,
|
||||
ZE_EVENT_SCOPE_FLAG_DEVICE};
|
||||
|
||||
std::unique_ptr<L0::EventPool> eventPool(EventPool::create(device, &eventPoolDesc));
|
||||
ASSERT_NE(nullptr, eventPool);
|
||||
|
||||
std::unique_ptr<L0::Event> event(Event::create(eventPool.get(), &eventDesc, device));
|
||||
ASSERT_NE(nullptr, event);
|
||||
ASSERT_NE(nullptr, event.get()->csr);
|
||||
ASSERT_EQ(static_cast<DeviceImp *>(device)->neoDevice->getDefaultEngine().commandStreamReceiver, event.get()->csr);
|
||||
}
|
||||
|
||||
class TimestampEventCreate : public Test<DeviceFixture> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
|
Reference in New Issue
Block a user