Skip to content

Commit 19f474c

Browse files
committed
Fix ipc event timestamp test cases
Related-To: NEO-12313 Signed-off-by: Bellekallu Rajkiran <[email protected]>
1 parent 50350fd commit 19f474c

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

conformance_tests/core/test_ipc/src/test_ipc_event.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2019-2023 Intel Corporation
3+
* Copyright (C) 2019-2025 Intel Corporation
44
*
55
* SPDX-License-Identifier: MIT
66
*
@@ -12,6 +12,7 @@
1212
#include "logging/logging.hpp"
1313
#include "test_ipc_event.hpp"
1414
#include "net/test_ipc_comm.hpp"
15+
#include <boost/interprocess/sync/named_semaphore.hpp>
1516

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

172173
lzt::synchronize(command_queue, UINT64_MAX);
173174

175+
bipc::named_semaphore semaphore(bipc::open_only, "ipc_event_test_semaphore");
176+
semaphore.post();
177+
174178
// get time data
175179
if (mapped_timestamp) {
176180
std::vector<ze_kernel_timestamp_result_t> kernel_timestamp_buffer{};
@@ -197,6 +201,9 @@ static void run_ipc_event_test(parent_test_t parent_test,
197201
child_test_t child_test, bool multi_device,
198202
bool isImmediate) {
199203
#ifdef __linux__
204+
bipc::named_semaphore::remove("ipc_event_test_semaphore");
205+
bipc::named_semaphore semaphore(bipc::create_only, "ipc_event_test_semaphore", 0);
206+
200207
bipc::shared_memory_object::remove("ipc_event_test");
201208
// launch child
202209
boost::process::child c("./ipc/test_ipc_event_helper");
@@ -272,6 +279,7 @@ static void run_ipc_event_test(parent_test_t parent_test,
272279

273280
if (parent_test == PARENT_TEST_HOST_LAUNCHES_KERNEL) {
274281
// ensure the timestamps match
282+
std::memcpy(&test_data, region.get_address(), sizeof(shared_data_t));
275283
EXPECT_EQ(test_data.start_time, startTime);
276284
EXPECT_EQ(test_data.end_time, endTime);
277285
}

conformance_tests/core/test_ipc/src/test_ipc_event_helper.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2019-2023 Intel Corporation
3+
* Copyright (C) 2019-2025 Intel Corporation
44
*
55
* SPDX-License-Identifier: MIT
66
*
@@ -11,6 +11,7 @@
1111
#include "logging/logging.hpp"
1212
#include "test_ipc_event.hpp"
1313
#include "net/test_ipc_comm.hpp"
14+
#include <boost/interprocess/sync/named_semaphore.hpp>
1415

1516
#include <boost/interprocess/shared_memory_object.hpp>
1617
#include <boost/interprocess/mapped_region.hpp>
@@ -228,6 +229,7 @@ int main() {
228229
LOG_DEBUG << "Child exit due to zeInit failure";
229230
exit(1);
230231
}
232+
231233
LOG_INFO << "IPC Child zeInit";
232234

233235
shared_data_t shared_data;
@@ -247,7 +249,7 @@ int main() {
247249
}
248250
}
249251
shm.truncate(sizeof(shared_data_t));
250-
bipc::mapped_region region(shm, bipc::read_only);
252+
bipc::mapped_region region(shm, bipc::read_write);
251253
std::memcpy(&shared_data, region.get_address(), sizeof(shared_data_t));
252254

253255
ze_ipc_event_pool_handle_t hIpcEventPool{};
@@ -281,6 +283,12 @@ int main() {
281283
device_events = true;
282284
}
283285

286+
if (shared_data.parent_type == PARENT_TEST_HOST_LAUNCHES_KERNEL) {
287+
// Wait until the child is ready to query the time stamp
288+
bipc::named_semaphore semaphore(bipc::open_only, "ipc_event_test_semaphore");
289+
semaphore.wait();
290+
}
291+
284292
const bool isImmediate = shared_data.is_immediate;
285293
LOG_INFO << "IPC Child open event handle success";
286294
switch (shared_data.child_type) {
@@ -299,13 +307,16 @@ int main() {
299307
break;
300308
case CHILD_TEST_HOST_TIMESTAMP_READS:
301309
child_host_query_timestamp(hEventPool, shared_data, false);
310+
std::memcpy(region.get_address(), &shared_data, sizeof(shared_data_t));
302311
break;
303312
case CHILD_TEST_DEVICE_TIMESTAMP_READS:
304313
child_device_query_timestamp(hEventPool, device_events, context,
305314
shared_data, isImmediate);
315+
std::memcpy(region.get_address(), &shared_data, sizeof(shared_data_t));
306316
break;
307317
case CHILD_TEST_HOST_MAPPED_TIMESTAMP_READS:
308318
child_host_query_timestamp(hEventPool, shared_data, true);
319+
std::memcpy(region.get_address(), &shared_data, sizeof(shared_data_t));
309320
break;
310321
default:
311322
LOG_DEBUG << "Unrecognized test case";

conformance_tests/tools/debug/src/test_debug_helper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <chrono>
99
#include <thread>
1010
#include <map>
11+
#include <cmath>
1112

1213
#include "test_debug.hpp"
1314
#include "test_debug_utils.hpp"

conformance_tests/tools/metrics/src/test_metric.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <ctime>
1111
#include <thread>
1212
#include <atomic>
13+
#include <cmath>
1314

1415
#include <boost/filesystem.hpp>
1516
#include <boost/interprocess/shared_memory_object.hpp>

0 commit comments

Comments
 (0)