Skip to content

Commit d9434c7

Browse files
JackAKirkkbenzie
authored andcommitted
Add conformance test for exp_usm_p2p.
Signed-off-by: JackAKirk <[email protected]>
1 parent c46745e commit d9434c7

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

test/conformance/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ if(UR_DPCXX)
120120
add_subdirectory(program)
121121
add_subdirectory(enqueue)
122122
add_subdirectory(exp_command_buffer)
123+
add_subdirectory(exp_usm_p2p)
123124
else()
124125
message(WARNING
125126
"UR_DPCXX is not defined, the following conformance test executables \
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
add_conformance_test_with_devices_environment(exp_usm_p2p
7+
usm_p2p.cpp
8+
)

test/conformance/exp_usm_p2p/exp_usm_p2p_adapter_hip.match

Whitespace-only changes.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (C) 2024 Intel Corporation
2+
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
3+
// Exceptions. See LICENSE.TXT SPDX-License-Identifier: Apache-2.0 WITH
4+
// LLVM-exception
5+
6+
#include "uur/fixtures.h"
7+
#include "uur/raii.h"
8+
9+
using urP2PTest = uur::urAllDevicesTest;
10+
11+
TEST_F(urP2PTest, Success) {
12+
13+
if (devices.size() < 2) {
14+
GTEST_SKIP();
15+
}
16+
17+
size_t returned_size;
18+
ASSERT_SUCCESS(urDeviceGetInfo(devices[0], UR_DEVICE_INFO_EXTENSIONS, 0,
19+
nullptr, &returned_size));
20+
21+
std::unique_ptr<char[]> returned_extensions(new char[returned_size]);
22+
23+
ASSERT_SUCCESS(urDeviceGetInfo(devices[0], UR_DEVICE_INFO_EXTENSIONS,
24+
returned_size, returned_extensions.get(),
25+
nullptr));
26+
27+
std::string_view extensions_string(returned_extensions.get());
28+
bool usm_p2p_support =
29+
extensions_string.find(UR_USM_P2P_EXTENSION_STRING_EXP) !=
30+
std::string::npos;
31+
32+
if (!usm_p2p_support) {
33+
GTEST_SKIP() << "EXP usm p2p feature is not supported.";
34+
}
35+
36+
int value;
37+
ASSERT_SUCCESS(urUsmP2PPeerAccessGetInfoExp(
38+
devices[0], ///< [in] handle of the command device object
39+
devices[1], ///< [in] handle of the peer device object
40+
UR_EXP_PEER_INFO_UR_PEER_ACCESS_SUPPORTED, sizeof(int), &value,
41+
&returned_size));
42+
// Note that whilst it is not currently specified to be a requirement in the
43+
// specification, currently all supported backends return value = 1 for the
44+
// UR_EXP_PEER_INFO_UR_PEER_ACCESS_SUPPORTED query when the query is true
45+
// (matching the native query return values). Generally different backends can
46+
// return different values for a given device query; however it is
47+
// advisable that for boolean queries they return the same values to indicate
48+
// true/false. When this extension is moved out of experimental status such
49+
// boolean return values should be specified by the extension.
50+
ASSERT_EQ(value, 1);
51+
52+
// Just check that this doesn't throw since supporting peer atomics is
53+
// optional and can depend on backend/device.
54+
ASSERT_SUCCESS(urUsmP2PPeerAccessGetInfoExp(
55+
devices[0], devices[1], UR_EXP_PEER_INFO_UR_PEER_ATOMICS_SUPPORTED,
56+
sizeof(int), &value, &returned_size));
57+
58+
ASSERT_SUCCESS(urUsmP2PEnablePeerAccessExp(devices[0], devices[1]));
59+
ASSERT_SUCCESS(urUsmP2PDisablePeerAccessExp(devices[0], devices[1]));
60+
}

0 commit comments

Comments
 (0)