|
| 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