From ceebda15efbdebce32c4ed2781e2e258aa3cfb6e Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 12 Nov 2019 12:55:17 -0500 Subject: [PATCH] P4 to Git Change 2029039 by kjayapra@0_HIPWS_LNX1_ROCM on 2019/11/12 12:52:46 SWDEV-210844 - Implementing hipExtGetLinkTypeAndHopCount Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_device_runtime.cpp#22 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#344 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#47 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#141 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#44 edit --- api/hip/hip_device_runtime.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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);