Skip to content

Commit 09be088

Browse files
authored
Merge pull request intel#1429 from nrspruit/l0_p2p_device_query
[L0] Support for urUsmP2PPeerAccessGetInfoExp to query p2p access info
2 parents bb589ca + e9f855d commit 09be088

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

source/adapters/level_zero/usm_p2p.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,36 @@ UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp(
3535
ur_exp_peer_info_t propName, size_t propSize, void *pPropValue,
3636
size_t *pPropSizeRet) {
3737

38-
std::ignore = commandDevice;
39-
std::ignore = peerDevice;
40-
std::ignore = propName;
41-
4238
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
43-
// Zero return value indicates that all of the queries currently return false.
44-
return ReturnValue(uint32_t{0});
39+
40+
bool propertyValue = false;
41+
switch (propName) {
42+
case UR_EXP_PEER_INFO_UR_PEER_ACCESS_SUPPORTED: {
43+
bool p2pAccessSupported = false;
44+
ze_device_p2p_properties_t p2pProperties;
45+
ZE2UR_CALL(zeDeviceGetP2PProperties,
46+
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pProperties));
47+
if (p2pProperties.flags & ZE_DEVICE_P2P_PROPERTY_FLAG_ACCESS) {
48+
p2pAccessSupported = true;
49+
}
50+
ze_bool_t p2pDeviceSupported = false;
51+
ZE2UR_CALL(
52+
zeDeviceCanAccessPeer,
53+
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pDeviceSupported));
54+
propertyValue = p2pAccessSupported && p2pDeviceSupported;
55+
break;
56+
}
57+
case UR_EXP_PEER_INFO_UR_PEER_ATOMICS_SUPPORTED: {
58+
ze_device_p2p_properties_t p2pProperties;
59+
ZE2UR_CALL(zeDeviceGetP2PProperties,
60+
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pProperties));
61+
propertyValue = p2pProperties.flags & ZE_DEVICE_P2P_PROPERTY_FLAG_ATOMICS;
62+
break;
63+
}
64+
default: {
65+
return UR_RESULT_ERROR_INVALID_ENUMERATION;
66+
}
67+
}
68+
69+
return ReturnValue(propertyValue);
4570
}

0 commit comments

Comments
 (0)