Skip to content

Commit

Permalink
USM P2P draft impl on hip for testing.
Browse files Browse the repository at this point in the history
Signed-off-by: JackAKirk <jack.kirk@codeplay.com>
  • Loading branch information
JackAKirk committed Jan 3, 2024
1 parent 810a577 commit 0725f7d
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions source/adapters/hip/usm_p2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,56 @@

UR_APIEXPORT ur_result_t UR_APICALL
urUsmP2PEnablePeerAccessExp(ur_device_handle_t, ur_device_handle_t) {
detail::ur::die(
"urUsmP2PEnablePeerAccessExp is not implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
ur_result_t result = UR_RESULT_SUCCESS;
try {
ScopedContext active(commandDevice->getContext());
UR_CHECK_ERROR(hipDeviceEnablePeerAccess(peerDevice->get(), 0));
} catch (ur_result_t err) {
result = err;
}
return result;
}

UR_APIEXPORT ur_result_t UR_APICALL
urUsmP2PDisablePeerAccessExp(ur_device_handle_t, ur_device_handle_t) {
detail::ur::die(
"urUsmP2PDisablePeerAccessExp is not implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
ur_result_t result = UR_RESULT_SUCCESS;
try {
ScopedContext active(commandDevice->getContext());
UR_CHECK_ERROR(hipDeviceDisablePeerAccess(peerDevice->get()));
} catch (ur_result_t err) {
result = err;
}
return result;
}

UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp(
ur_device_handle_t, ur_device_handle_t, ur_exp_peer_info_t, size_t propSize,
void *pPropValue, size_t *pPropSizeRet) {
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
// Zero return value indicates that all of the queries currently return false.
return ReturnValue(uint32_t{0});

int value;
CUdevice_P2PAttribute cu_attr;
try {
ScopedContext active(commandDevice->getContext());
switch (propName) {
case UR_EXP_PEER_INFO_UR_PEER_ACCESS_SUPPORTED: {
cu_attr = hipDeviceP2PAttributeAccessSupported;
break;
}
case UR_EXP_PEER_INFO_UR_PEER_ATOMICS_SUPPORTED: {
cu_attr = hipDeviceP2PAttributeNativeAtomicSupported;
break;
}
default: {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
}


UR_CHECK_ERROR(hipDeviceGetP2PAttribute(
&value, cu_attr, commandDevice->get(), peerDevice->get()));
} catch (ur_result_t err) {
return err;
}
return ReturnValue(value);
}

0 comments on commit 0725f7d

Please sign in to comment.