diff --git a/api/hip/hip_device_runtime.cpp b/api/hip/hip_device_runtime.cpp index e0bed1742c..d3d0b10b87 100644 --- a/api/hip/hip_device_runtime.cpp +++ b/api/hip/hip_device_runtime.cpp @@ -518,17 +518,23 @@ hipError_t hipSetValidDevices ( int* device_arr, int len ) { hipError_t hipExtGetLinkTypeAndHopCount(int device1, int device2, uint32_t* linktype, uint32_t* hopcount) { HIP_INIT_API(hipExtGetLinkTypeAndHopCount, device1, device2, linktype, hopcount); + amd::Device* amd_dev_obj1 = nullptr; + amd::Device* amd_dev_obj2 = nullptr; const int numDevices = static_cast(g_devices.size()); if ((device1 < 0) || (device1 >= numDevices) || (device2 < 0) || (device2 >= numDevices)) { HIP_RETURN(hipErrorInvalidDevice); } - if (linktype != nullptr) { - *linktype = 0; + if ((linktype == nullptr) || (hopcount == nullptr)) { + HIP_RETURN(hipErrorInvalidValue); } - if (hopcount != nullptr) { - *hopcount = 1; + + amd_dev_obj1 = g_devices[device1]->devices()[0]; + amd_dev_obj2 = g_devices[device2]->devices()[0]; + + if (!amd_dev_obj1->findLinkTypeAndHopCount(amd_dev_obj2, linktype, hopcount)) { + HIP_RETURN(hipErrorInvalidResourceHandle); } HIP_RETURN(hipSuccess);