Skip to content

Commit edf9f4d

Browse files
committed
[L0] Support for urUsmP2PPeerAccessGetInfoExp to query p2p access info
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent 91c9e91 commit edf9f4d

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

source/adapters/level_zero/usm_p2p.cpp

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,38 @@ 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;
38+
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
39+
40+
bool propertyValue = 0;
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(
46+
zeDeviceGetP2PProperties,
47+
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pProperties));
48+
if (p2pProperties.flags & ZE_DEVICE_P2P_PROPERTY_FLAG_ACCESS) {
49+
p2pAccessSupported = true;
50+
}
51+
ze_bool_t p2pDeviceSupported = false;
52+
ZE2UR_CALL(
53+
zeDeviceCanAccessPeer,
54+
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pDeviceSupported));
55+
propertyValue = p2pAccessSupported && p2pDeviceSupported;
56+
break;
57+
}
58+
case UR_EXP_PEER_INFO_UR_PEER_ATOMICS_SUPPORTED: {
59+
ze_device_p2p_properties_t p2pProperties;
60+
ZE2UR_CALL(
61+
zeDeviceGetP2PProperties,
62+
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pProperties));
63+
propertyValue = p2pProperties.flags & ZE_DEVICE_P2P_PROPERTY_FLAG_ATOMICS;
64+
break;
65+
}
66+
default: {
67+
return UR_RESULT_ERROR_INVALID_ENUMERATION;
68+
}
69+
}
4170

42-
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
43-
// Zero return value indicates that all of the queries currently return false.
44-
return ReturnValue(uint32_t{0});
71+
return ReturnValue(propertyValue);
4572
}

0 commit comments

Comments
 (0)