Skip to content

Commit

Permalink
fix: context creation in zeIPCEventTests group
Browse files Browse the repository at this point in the history
Running affected tests:

`$ ./test_ipc --gtest_filter="*zeIPCEventTests.GivenTwoProcessesWhenEvent*"`

The affected tests use two processes to exercise the IPC features:
* the parent process creates an event-pool and sends all needed handlers
  to the child process via socket
* the child, in turn, uses the received data to open the same event-pool
  and then use it.

When the parent _creates_ the event-pool, the list of associated devices
is passed as an argument to `zeEventPoolCreate()`. On the other hand,
when the child later _opens_ the same event-pool, the
`zeEventPoolOpenIpcHandle()` does not accept any list of devices to
specify. Instead, under the hood, the list of devices is derived from
the `context` instance.

In addition to that:
1) With the current implementation the context is created using
   `zeContextCreate()` and then the `context` instance in the child
   process is associated with the root-device (instead of its
   subdevice[0]!).
2) Also, in NEO the method `DeviceImp::isImplicitScalingCapable()`
   returns `true` for root-device and `false` for a subdevice.

The method `DeviceImp::isImplicitScalingCapable()` is used by both the
parent process (`EventPool::initialize()`) and the child process
(`EventPool::openEventPoolIpcHandle()`) and the different values
returned (the latter derives devices from context, see above) cause
different results computed by `DeviceImp::getEventMaxPacketCount()`.

This, eventually, leads to an error when opening the event-pool because
a following check for computed and expected parameter equality fails:
`if (eventPool->getEventMaxPackets() != poolData.maxEventPackets) {...}`

Fix the problem in child process by using `zeContextCreateEx()`, which
accepts additional parameters - the list of devices (here,
a subdevice[0] only) a context should be associated with.

Related-To: NEO-9837

Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>
  • Loading branch information
MaciejBielski authored and Jemale committed Jan 10, 2024
1 parent c3ad0ef commit 566080e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions conformance_tests/core/test_ipc/src/test_ipc_event_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ int main() {
throw ex;
}
}
auto context = lzt::create_context(lzt::get_default_driver());
shm.truncate(sizeof(shared_data_t));
bipc::mapped_region region(shm, bipc::read_only);
std::memcpy(&shared_data, region.get_address(), sizeof(shared_data_t));
Expand All @@ -257,7 +256,15 @@ int main() {
memcpy(&(hIpcEventPool), static_cast<void *>(&ipc_descriptor),
sizeof(ipc_descriptor));

const bool isImmediate = shared_data.is_immediate;
std::vector<ze_device_handle_t> devices;
if (shared_data.multi_device) {
devices = lzt::get_devices(lzt::get_default_driver());
} else {
ze_device_handle_t device =
lzt::get_default_device(lzt::get_default_driver());
devices.push_back(device);
}
auto context = lzt::create_context_ex(lzt::get_default_driver(), std::move(devices));
ze_event_pool_handle_t hEventPool = 0;
LOG_INFO << "IPC Child open event handle";
lzt::open_ipc_event_handle(context, hIpcEventPool, &hEventPool);
Expand All @@ -272,6 +279,8 @@ int main() {
shared_data.child_type == CHILD_TEST_DEVICE_READS) {
device_events = true;
}

const bool isImmediate = shared_data.is_immediate;
LOG_INFO << "IPC Child open event handle success";
switch (shared_data.child_type) {

Expand Down

0 comments on commit 566080e

Please sign in to comment.