|
5 | 5 | * |
6 | 6 | */ |
7 | 7 |
|
| 8 | +#include "opencl/test/unit_test/mocks/mock_csr.h" |
8 | 9 | #include "opencl/test/unit_test/mocks/mock_memory_manager.h" |
9 | 10 | #include "opencl/test/unit_test/mocks/mock_memory_operations_handler.h" |
10 | 11 | #include "test.h" |
11 | 12 |
|
12 | 13 | #include "level_zero/core/source/driver/driver_handle_imp.h" |
13 | 14 | #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" |
| 15 | +#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h" |
| 16 | +#include "level_zero/core/test/unit_tests/mocks/mock_device.h" |
14 | 17 | #include "level_zero/core/test/unit_tests/mocks/mock_event.h" |
15 | 18 |
|
16 | 19 | namespace L0 { |
@@ -122,6 +125,18 @@ TEST_F(EventPoolCreate, givenCloseIpcHandleCalledReturnsNotSupported) { |
122 | 125 | EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result); |
123 | 126 | } |
124 | 127 |
|
| 128 | +TEST_F(EventPoolCreate, GivenAtLeastOneValidDeviceHandleWhenCreatingEventPoolThenEventPoolCreated) { |
| 129 | + ze_event_pool_desc_t eventPoolDesc = { |
| 130 | + ZE_STRUCTURE_TYPE_EVENT_POOL_DESC, |
| 131 | + nullptr, |
| 132 | + ZE_EVENT_POOL_FLAG_HOST_VISIBLE, |
| 133 | + 1}; |
| 134 | + |
| 135 | + ze_device_handle_t devices[] = {nullptr, device->toHandle()}; |
| 136 | + std::unique_ptr<L0::EventPool> eventPool(EventPool::create(driverHandle.get(), 2, devices, &eventPoolDesc)); |
| 137 | + ASSERT_NE(nullptr, eventPool); |
| 138 | +} |
| 139 | + |
125 | 140 | TEST_F(EventCreate, givenAnEventCreatedThenTheEventHasTheDeviceCommandStreamReceiverSet) { |
126 | 141 | ze_event_pool_desc_t eventPoolDesc = { |
127 | 142 | ZE_STRUCTURE_TYPE_EVENT_POOL_DESC, |
@@ -219,6 +234,46 @@ TEST_F(EventSynchronizeTest, givenCallToEventHostSynchronizeWithTimeoutNonZeroAn |
219 | 234 | EXPECT_EQ(ZE_RESULT_SUCCESS, result); |
220 | 235 | } |
221 | 236 |
|
| 237 | +using EventAubCsrTest = Test<DeviceFixture>; |
| 238 | + |
| 239 | +HWTEST_F(EventAubCsrTest, givenCallToEventHostSynchronizeWithAubModeCsrReturnsSuccess) { |
| 240 | + std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle; |
| 241 | + NEO::MockDevice *neoDevice = nullptr; |
| 242 | + L0::Device *device = nullptr; |
| 243 | + |
| 244 | + neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get()); |
| 245 | + auto mockBuiltIns = new MockBuiltins(); |
| 246 | + neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns); |
| 247 | + NEO::DeviceVector devices; |
| 248 | + devices.push_back(std::unique_ptr<NEO::Device>(neoDevice)); |
| 249 | + driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>(); |
| 250 | + driverHandle->initialize(std::move(devices)); |
| 251 | + device = driverHandle->devices[0]; |
| 252 | + int32_t tag; |
| 253 | + auto aubCsr = new MockCsrAub<FamilyType>(tag, *neoDevice->executionEnvironment, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()); |
| 254 | + neoDevice->resetCommandStreamReceiver(aubCsr); |
| 255 | + |
| 256 | + std::unique_ptr<L0::EventPool> eventPool = nullptr; |
| 257 | + std::unique_ptr<L0::Event> event; |
| 258 | + |
| 259 | + ze_event_pool_desc_t eventPoolDesc = {}; |
| 260 | + eventPoolDesc.count = 1; |
| 261 | + eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; |
| 262 | + |
| 263 | + ze_event_desc_t eventDesc = {}; |
| 264 | + eventDesc.index = 0; |
| 265 | + eventDesc.signal = 0; |
| 266 | + eventDesc.wait = 0; |
| 267 | + |
| 268 | + eventPool = std::unique_ptr<L0::EventPool>(L0::EventPool::create(driverHandle.get(), 0, nullptr, &eventPoolDesc)); |
| 269 | + ASSERT_NE(nullptr, eventPool); |
| 270 | + event = std::unique_ptr<L0::Event>(L0::Event::create(eventPool.get(), &eventDesc, device)); |
| 271 | + ASSERT_NE(nullptr, event); |
| 272 | + |
| 273 | + ze_result_t result = event->hostSynchronize(10); |
| 274 | + EXPECT_EQ(ZE_RESULT_SUCCESS, result); |
| 275 | +} |
| 276 | + |
222 | 277 | struct EventCreateAllocationResidencyTest : public ::testing::Test { |
223 | 278 | void SetUp() override { |
224 | 279 | neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get()); |
|
0 commit comments