Skip to content

Commit a7e9b5d

Browse files
committed
[L0] Add IPC tests
1 parent 222a511 commit a7e9b5d

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

test/adapters/level_zero/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,16 @@ if(NOT WIN32)
6969
target_link_libraries(test-adapter-level_zero_multi_queue PRIVATE zeCallMap)
7070
endif()
7171

72+
add_adapter_test(level_zero_ipc
73+
FIXTURE DEVICES
74+
SOURCES
75+
ipc.cpp
76+
ENVIRONMENT
77+
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_level_zero>\""
78+
)
79+
80+
target_link_libraries(test-adapter-level_zero_ipc PRIVATE
81+
ur_umf
82+
)
83+
7284
add_subdirectory(v2)

test/adapters/level_zero/ipc.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (C) 2024 Intel Corporation
2+
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
3+
// See LICENSE.TXT
4+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
#include <umf/memory_pool.h>
7+
#include <umf/memory_provider.h>
8+
#include <uur/fixtures.h>
9+
10+
#ifndef ASSERT_UMF_SUCCESS
11+
#define ASSERT_UMF_SUCCESS(ACTUAL) ASSERT_EQ(ACTUAL, UMF_RESULT_SUCCESS)
12+
#endif
13+
14+
using urL0IpcTest = uur::urContextTest;
15+
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urL0IpcTest);
16+
17+
TEST_P(urL0IpcTest, SuccessHostL0Ipc) {
18+
ur_device_usm_access_capability_flags_t hostUSMSupport = 0;
19+
ASSERT_SUCCESS(uur::GetDeviceUSMHostSupport(device, hostUSMSupport));
20+
if (!hostUSMSupport) {
21+
GTEST_SKIP() << "Host USM is not supported.";
22+
}
23+
24+
void *ptr = nullptr;
25+
size_t allocSize = sizeof(int);
26+
ASSERT_SUCCESS(urUSMHostAlloc(context, nullptr, nullptr, allocSize, &ptr));
27+
ASSERT_NE(ptr, nullptr);
28+
29+
umf_memory_pool_handle_t umfPool = umfPoolByPtr(ptr);
30+
ASSERT_NE(umfPool, nullptr);
31+
32+
umf_memory_provider_handle_t umfProvider = nullptr;
33+
ASSERT_UMF_SUCCESS(umfPoolGetMemoryProvider(umfPool, &umfProvider));
34+
35+
size_t ipcHandleSize = 0;
36+
ASSERT_UMF_SUCCESS(
37+
umfMemoryProviderGetIPCHandleSize(umfProvider, &ipcHandleSize));
38+
39+
void *ipcHandle = nullptr;
40+
ASSERT_UMF_SUCCESS(
41+
umfMemoryProviderAlloc(umfProvider, ipcHandleSize, 0, &ipcHandle));
42+
ASSERT_UMF_SUCCESS(
43+
umfMemoryProviderGetIPCHandle(umfProvider, ptr, allocSize, ipcHandle));
44+
45+
ASSERT_UMF_SUCCESS(umfMemoryProviderPutIPCHandle(umfProvider, ipcHandle));
46+
47+
ASSERT_UMF_SUCCESS(
48+
umfMemoryProviderFree(umfProvider, ipcHandle, ipcHandleSize));
49+
50+
ASSERT_SUCCESS(urUSMFree(context, ptr));
51+
}

0 commit comments

Comments
 (0)