Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ipc timeout issue #112

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading