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 event timstamp test cases #133

Merged
merged 1 commit into from
Jan 22, 2025
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
10 changes: 9 additions & 1 deletion conformance_tests/core/test_ipc/src/test_ipc_event.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2019-2023 Intel Corporation
* Copyright (C) 2019-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -12,6 +12,7 @@
#include "logging/logging.hpp"
#include "test_ipc_event.hpp"
#include "net/test_ipc_comm.hpp"
#include <boost/interprocess/sync/named_semaphore.hpp>

#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
Expand Down Expand Up @@ -171,6 +172,9 @@ static void run_workload(ze_event_handle_t &timestamp_event,

lzt::synchronize(command_queue, UINT64_MAX);

bipc::named_semaphore semaphore(bipc::open_only, "ipc_event_test_semaphore");
semaphore.post();

// get time data
if (mapped_timestamp) {
std::vector<ze_kernel_timestamp_result_t> kernel_timestamp_buffer{};
Expand All @@ -197,6 +201,9 @@ static void run_ipc_event_test(parent_test_t parent_test,
child_test_t child_test, bool multi_device,
bool isImmediate) {
#ifdef __linux__
bipc::named_semaphore::remove("ipc_event_test_semaphore");
bipc::named_semaphore semaphore(bipc::create_only, "ipc_event_test_semaphore", 0);

bipc::shared_memory_object::remove("ipc_event_test");
// launch child
boost::process::child c("./ipc/test_ipc_event_helper");
Expand Down Expand Up @@ -272,6 +279,7 @@ static void run_ipc_event_test(parent_test_t parent_test,

if (parent_test == PARENT_TEST_HOST_LAUNCHES_KERNEL) {
// ensure the timestamps match
std::memcpy(&test_data, region.get_address(), sizeof(shared_data_t));
EXPECT_EQ(test_data.start_time, startTime);
EXPECT_EQ(test_data.end_time, endTime);
}
Expand Down
15 changes: 13 additions & 2 deletions conformance_tests/core/test_ipc/src/test_ipc_event_helper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2019-2023 Intel Corporation
* Copyright (C) 2019-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -11,6 +11,7 @@
#include "logging/logging.hpp"
#include "test_ipc_event.hpp"
#include "net/test_ipc_comm.hpp"
#include <boost/interprocess/sync/named_semaphore.hpp>

#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
Expand Down Expand Up @@ -228,6 +229,7 @@ int main() {
LOG_DEBUG << "Child exit due to zeInit failure";
exit(1);
}

LOG_INFO << "IPC Child zeInit";

shared_data_t shared_data;
Expand All @@ -247,7 +249,7 @@ int main() {
}
}
shm.truncate(sizeof(shared_data_t));
bipc::mapped_region region(shm, bipc::read_only);
bipc::mapped_region region(shm, bipc::read_write);
std::memcpy(&shared_data, region.get_address(), sizeof(shared_data_t));

ze_ipc_event_pool_handle_t hIpcEventPool{};
Expand Down Expand Up @@ -281,6 +283,12 @@ int main() {
device_events = true;
}

if (shared_data.parent_type == PARENT_TEST_HOST_LAUNCHES_KERNEL) {
// Wait until the child is ready to query the time stamp
bipc::named_semaphore semaphore(bipc::open_only, "ipc_event_test_semaphore");
semaphore.wait();
}

const bool isImmediate = shared_data.is_immediate;
LOG_INFO << "IPC Child open event handle success";
switch (shared_data.child_type) {
Expand All @@ -299,13 +307,16 @@ int main() {
break;
case CHILD_TEST_HOST_TIMESTAMP_READS:
child_host_query_timestamp(hEventPool, shared_data, false);
std::memcpy(region.get_address(), &shared_data, sizeof(shared_data_t));
break;
case CHILD_TEST_DEVICE_TIMESTAMP_READS:
child_device_query_timestamp(hEventPool, device_events, context,
shared_data, isImmediate);
std::memcpy(region.get_address(), &shared_data, sizeof(shared_data_t));
break;
case CHILD_TEST_HOST_MAPPED_TIMESTAMP_READS:
child_host_query_timestamp(hEventPool, shared_data, true);
std::memcpy(region.get_address(), &shared_data, sizeof(shared_data_t));
break;
default:
LOG_DEBUG << "Unrecognized test case";
Expand Down
1 change: 1 addition & 0 deletions conformance_tests/tools/debug/src/test_debug_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <chrono>
#include <thread>
#include <map>
#include <cmath>
bellekal marked this conversation as resolved.
Show resolved Hide resolved

#include "test_debug.hpp"
#include "test_debug_utils.hpp"
Expand Down
1 change: 1 addition & 0 deletions conformance_tests/tools/metrics/src/test_metric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <ctime>
#include <thread>
#include <atomic>
#include <cmath>
bellekal marked this conversation as resolved.
Show resolved Hide resolved

#include <boost/filesystem.hpp>
#include <boost/interprocess/shared_memory_object.hpp>
Expand Down
Loading