Skip to content

Commit e977de5

Browse files
Add L0 event ULTs (2)
Signed-off-by: Aravind Gopalakrishnan <[email protected]>
1 parent f9197d4 commit e977de5

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

level_zero/core/source/event/event.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, uint32_t numDevices,
4747
if (this->devices.empty()) {
4848
ze_device_handle_t hDevice;
4949
uint32_t count = 1;
50-
ze_result_t result = driver->getDevice(&count, &hDevice);
51-
if (result) {
52-
return result;
53-
}
50+
driver->getDevice(&count, &hDevice);
5451
this->devices.push_back(Device::fromHandle(hDevice));
5552
rootDeviceIndices.push_back(this->devices[0]->getNEODevice()->getRootDeviceIndex());
5653
maxRootDeviceIndex = rootDeviceIndices[0];

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
*
66
*/
77

8+
#include "opencl/test/unit_test/mocks/mock_csr.h"
89
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
910
#include "opencl/test/unit_test/mocks/mock_memory_operations_handler.h"
1011
#include "test.h"
1112

1213
#include "level_zero/core/source/driver/driver_handle_imp.h"
1314
#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"
1417
#include "level_zero/core/test/unit_tests/mocks/mock_event.h"
1518

1619
namespace L0 {
@@ -122,6 +125,18 @@ TEST_F(EventPoolCreate, givenCloseIpcHandleCalledReturnsNotSupported) {
122125
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
123126
}
124127

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+
125140
TEST_F(EventCreate, givenAnEventCreatedThenTheEventHasTheDeviceCommandStreamReceiverSet) {
126141
ze_event_pool_desc_t eventPoolDesc = {
127142
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
@@ -219,6 +234,46 @@ TEST_F(EventSynchronizeTest, givenCallToEventHostSynchronizeWithTimeoutNonZeroAn
219234
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
220235
}
221236

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+
222277
struct EventCreateAllocationResidencyTest : public ::testing::Test {
223278
void SetUp() override {
224279
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());

0 commit comments

Comments
 (0)