Skip to content

Commit 8aa2e76

Browse files
Allow device allocs for timestamp events
Signed-off-by: Aravind Gopalakrishnan <[email protected]>
1 parent d603bb2 commit 8aa2e76

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

level_zero/core/source/event/event.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uin
8585
useDeviceAlloc = false;
8686
}
8787

88-
if (useDeviceAlloc && !isEventPoolTimestampFlagSet()) {
88+
if (useDeviceAlloc) {
8989
allocationType = NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER;
9090
}
9191

level_zero/core/test/unit_tests/sources/event/test_event.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,42 @@ TEST_F(TimestampEventCreate, givenEventWithStaticPartitionOffThenQueryTimestampE
935935
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
936936
}
937937

938+
class TimestampDeviceEventCreate : public Test<DeviceFixture> {
939+
public:
940+
void SetUp() override {
941+
DeviceFixture::SetUp();
942+
ze_event_pool_desc_t eventPoolDesc = {};
943+
eventPoolDesc.count = 1;
944+
eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP;
945+
946+
ze_event_desc_t eventDesc = {};
947+
eventDesc.index = 0;
948+
eventDesc.signal = 0;
949+
eventDesc.wait = 0;
950+
951+
ze_result_t result = ZE_RESULT_SUCCESS;
952+
eventPool = std::unique_ptr<L0::EventPool>(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, result));
953+
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
954+
ASSERT_NE(nullptr, eventPool);
955+
event = std::unique_ptr<L0::EventImp<uint32_t>>(static_cast<L0::EventImp<uint32_t> *>(L0::Event::create<uint32_t>(eventPool.get(), &eventDesc, device)));
956+
ASSERT_NE(nullptr, event);
957+
}
958+
959+
void TearDown() override {
960+
DeviceFixture::TearDown();
961+
}
962+
963+
std::unique_ptr<L0::EventPool> eventPool;
964+
std::unique_ptr<L0::EventImp<uint32_t>> event;
965+
};
966+
967+
TEST_F(TimestampDeviceEventCreate, givenTimestampDeviceEventThenAllocationsIsOfGpuDeviceTimestampType) {
968+
auto allocation = &eventPool->getAllocation();
969+
ASSERT_NE(nullptr, allocation);
970+
971+
EXPECT_EQ(NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER, allocation->getAllocationType());
972+
}
973+
938974
using EventQueryTimestampExpWithSubDevice = Test<MultiDeviceFixture>;
939975

940976
TEST_F(EventQueryTimestampExpWithSubDevice, givenEventWhenQuerytimestampExpWithSubDeviceThenReturnsCorrectValueReturned) {

0 commit comments

Comments
 (0)