Skip to content

Commit

Permalink
Merge pull request #1429 from nrspruit/l0_p2p_device_query
Browse files Browse the repository at this point in the history
[L0] Support for urUsmP2PPeerAccessGetInfoExp to query p2p access info
  • Loading branch information
kbenzie committed Mar 14, 2024
2 parents bb589ca + e9f855d commit 09be088
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions source/adapters/level_zero/usm_p2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,36 @@ UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp(
ur_exp_peer_info_t propName, size_t propSize, void *pPropValue,
size_t *pPropSizeRet) {

std::ignore = commandDevice;
std::ignore = peerDevice;
std::ignore = propName;

UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
// Zero return value indicates that all of the queries currently return false.
return ReturnValue(uint32_t{0});

bool propertyValue = false;
switch (propName) {
case UR_EXP_PEER_INFO_UR_PEER_ACCESS_SUPPORTED: {
bool p2pAccessSupported = false;
ze_device_p2p_properties_t p2pProperties;
ZE2UR_CALL(zeDeviceGetP2PProperties,
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pProperties));
if (p2pProperties.flags & ZE_DEVICE_P2P_PROPERTY_FLAG_ACCESS) {
p2pAccessSupported = true;
}
ze_bool_t p2pDeviceSupported = false;
ZE2UR_CALL(
zeDeviceCanAccessPeer,
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pDeviceSupported));
propertyValue = p2pAccessSupported && p2pDeviceSupported;
break;
}
case UR_EXP_PEER_INFO_UR_PEER_ATOMICS_SUPPORTED: {
ze_device_p2p_properties_t p2pProperties;
ZE2UR_CALL(zeDeviceGetP2PProperties,
(commandDevice->ZeDevice, peerDevice->ZeDevice, &p2pProperties));
propertyValue = p2pProperties.flags & ZE_DEVICE_P2P_PROPERTY_FLAG_ATOMICS;
break;
}
default: {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
}

return ReturnValue(propertyValue);
}

0 comments on commit 09be088

Please sign in to comment.