Skip to content

Commit

Permalink
fix: ipc timeout issue (#112)
Browse files Browse the repository at this point in the history
* fix: ipc timeout issue

* fix: ipc timeout issue
  • Loading branch information
shreyaskunder authored Nov 25, 2024
1 parent 0f06586 commit 94a0f40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions conformance_tests/core/test_ipc/src/test_ipc_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifdef __linux__
#include <unistd.h>
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/sync/named_semaphore.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/process.hpp>
#endif
Expand Down Expand Up @@ -39,6 +40,9 @@ static void run_ipc_mem_access_test(ipc_mem_access_test_t test_type, int size,
LOG_DEBUG << "[Parent] Driver initialized\n";
lzt::print_platform_overview();

bipc::named_semaphore::remove("ipc_memory_test_semaphore");
bipc::named_semaphore semaphore(bipc::create_only, "ipc_memory_test_semaphore", 0);

bipc::shared_memory_object::remove("ipc_memory_test");
// launch child
boost::process::child c("./ipc/test_ipc_memory_helper");
Expand Down Expand Up @@ -76,6 +80,10 @@ static void run_ipc_mem_access_test(ipc_mem_access_test_t test_type, int size,
ze_ipc_mem_handle_t ipc_handle_zero{};
ASSERT_NE(0, memcmp((void *)&ipc_handle, (void *)&ipc_handle_zero,
sizeof(ipc_handle)));

// Wait until the child is ready to receive the IPC handle
semaphore.wait();

lzt::send_ipc_handle(ipc_handle);

// Free device memory once receiver is done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "net/test_ipc_comm.hpp"

#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/sync/named_semaphore.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/process.hpp>

Expand All @@ -30,6 +31,10 @@ static void child_device_access_test(int size, ze_ipc_memory_flags_t flags,
ze_ipc_mem_handle_t ipc_handle;
void *memory = nullptr;

bipc::named_semaphore semaphore(bipc::open_only, "ipc_memory_test_semaphore");
// Signal parent to send IPC handle
semaphore.post();

int ipc_descriptor =
lzt::receive_ipc_handle<ze_ipc_mem_handle_t>(ipc_handle.data);
memcpy(&ipc_handle, static_cast<void *>(&ipc_descriptor),
Expand Down Expand Up @@ -71,6 +76,10 @@ static void child_subdevice_access_test(int size, ze_ipc_memory_flags_t flags,
ze_ipc_mem_handle_t ipc_handle;
void *memory = nullptr;

bipc::named_semaphore semaphore(bipc::open_only, "ipc_memory_test_semaphore");
// Signal parent to send IPC handle
semaphore.post();

int ipc_descriptor =
lzt::receive_ipc_handle<ze_ipc_mem_handle_t>(ipc_handle.data);
memcpy(&ipc_handle, static_cast<void *>(&ipc_descriptor),
Expand Down

0 comments on commit 94a0f40

Please sign in to comment.