SWDEV-240800 - Adding initial support for hipDeviceGetP2PAttribute. Some attr support still pending.

Change-Id: I0611aed136270db497dfa374144f6f5e35352a8f


[ROCm/clr commit: 311fc8c513]
Dieser Commit ist enthalten in:
kjayapra-amd
2020-07-17 17:29:32 -04:00
committet von Karthik Jayaprakash
Ursprung d1e3736fc3
Commit 7aa68bc3cb
6 geänderte Dateien mit 69 neuen und 11 gelöschten Zeilen
+20
Datei anzeigen
@@ -95,6 +95,13 @@ typedef struct ihipCtx_t* hipCtx_t;
// Note many APIs also use integer deviceIds as an alternative to the device pointer:
typedef int hipDevice_t;
typedef enum hipDeviceP2PAttr {
hipDevP2PAttrPerformanceRank = 0,
hipDevP2PAttrAccessSupported,
hipDevP2PAttrNativeAtomicSupported,
hipDevP2PAttrHipArrayAccessSupported
} hipDeviceP2PAttr;
typedef struct ihipStream_t* hipStream_t;
#define hipIpcMemLazyEnablePeerAccess 0
@@ -2799,6 +2806,19 @@ hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device
*/
hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device);
/**
* @brief Returns a value for attr of link between two devices
* @param [out] value
* @param [in] attr
* @param [in] srcDevice
* @param [in] dstDevice
*
* @returns #hipSuccess, #hipErrorInavlidDevice
*/
hipError_t hipDeviceGetP2PAttribute(int* value, hipDeviceP2PAttr attr,
int srcDevice, int dstDevice);
/**
* @brief Returns a PCI Bus Id string for the device, overloaded to take int device ID.
* @param [out] pciBusId
+6
Datei anzeigen
@@ -179,6 +179,7 @@ typedef enum cudaSharedMemConfig hipSharedMemConfig;
typedef CUfunc_cache hipFuncCache;
typedef CUjit_option hipJitOption;
typedef CUdevice hipDevice_t;
typedef enum cudaDeviceP2PAttr hipDeviceP2PAttr;
typedef CUmodule hipModule_t;
typedef CUfunction hipFunction_t;
typedef CUdeviceptr hipDeviceptr_t;
@@ -1606,6 +1607,11 @@ inline static hipError_t hipDeviceGetName(char* name, int len, hipDevice_t devic
return hipCUResultTohipError(cuDeviceGetName(name, len, device));
}
inline static hipError_t hipDeviceGetP2PAttribute(int* value, hipDeviceP2PAttr attr,
int srcDevice, int dstDevice) {
return hipCUDAErrorTohipError(cudaDeviceGetP2PAttribute(value, attr, srcDevice, dstDevice));
}
inline static hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, hipDevice_t device) {
return hipCUDAErrorTohipError(cudaDeviceGetPCIBusId(pciBusId, len, device));
}
Normale Datei → Ausführbare Datei
-7
Datei anzeigen
@@ -367,13 +367,6 @@ hipError_t hipDeviceGetLimit ( size_t* pValue, hipLimit_t limit ) {
}
}
/**
hipError_t hipDeviceGetP2PAttribute ( int* value, hipDeviceP2PAttr attr, int srcDevice, int dstDevice ) {
assert(0);
HIP_RETURN(hipSuccess);
}
**/
hipError_t hipDeviceGetPCIBusId ( char* pciBusId, int len, int device ) {
HIP_INIT_API(hipDeviceGetPCIBusId, (void*)pciBusId, len, device);
@@ -29,6 +29,7 @@ hipDeviceGetLimit
hipDeviceGetName
hipDeviceGetPCIBusId
hipDeviceGetSharedMemConfig
hipDeviceGetP2PAttribute
hipDevicePrimaryCtxGetState
hipDevicePrimaryCtxRelease
hipDevicePrimaryCtxReset
@@ -30,6 +30,7 @@ global:
hipDeviceGetName;
hipDeviceGetPCIBusId;
hipDeviceGetSharedMemConfig;
hipDeviceGetP2PAttribute;
hipDevicePrimaryCtxGetState;
hipDevicePrimaryCtxRelease;
hipDevicePrimaryCtxReset;
+41 -4
Datei anzeigen
@@ -52,24 +52,61 @@ hipError_t canAccessPeer(int* canAccessPeer, int deviceId, int peerDeviceId){
amd::Device* device = nullptr;
amd::Device* peer_device = nullptr;
if (canAccessPeer == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
return hipErrorInvalidValue;
}
/* Peer cannot be self */
if (deviceId == peerDeviceId) {
*canAccessPeer = 0;
HIP_RETURN(hipSuccess);
return hipSuccess;
}
/* Cannot exceed the max number of devices */
if (static_cast<size_t>(deviceId) >= g_devices.size()
|| static_cast<size_t>(peerDeviceId) >= g_devices.size()) {
HIP_RETURN(hipErrorInvalidDevice);
return hipErrorInvalidDevice;
}
device = g_devices[deviceId]->devices()[0];
peer_device = g_devices[peerDeviceId]->devices()[0];
*canAccessPeer = static_cast<int>(std::find(device->p2pDevices_.begin(),
device->p2pDevices_.end(), as_cl(peer_device))
!= device->p2pDevices_.end());
HIP_RETURN(hipSuccess);
return hipSuccess;
}
hipError_t hipDeviceGetP2PAttribute(int* value, hipDeviceP2PAttr attr,
int srcDevice, int dstDevice) {
HIP_INIT_API(hipDeviceGetP2PAttribute, value, attr, srcDevice, dstDevice);
hipError_t hip_error = hipSuccess;
if (value == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
}
if (srcDevice >= static_cast<int>(g_devices.size())
|| dstDevice >= static_cast<int>(g_devices.size())) {
HIP_RETURN(hipErrorInvalidDevice);
}
switch (attr) {
case hipDevP2PAttrPerformanceRank :
assert(0 && "Unimplemented");
break;
case hipDevP2PAttrAccessSupported :
hip_error = canAccessPeer(value, srcDevice, dstDevice);
break;
case hipDevP2PAttrNativeAtomicSupported :
assert(0 && "Unimplemented");
break;
case hipDevP2PAttrHipArrayAccessSupported :
assert(0 && "Unimplemented");
break;
default :
DevLogPrintfError("Invalid attribute attr: %d ", attr);
hip_error = hipErrorInvalidValue;
break;
}
HIP_RETURN(hip_error);
}
hipError_t hipDeviceCanAccessPeer(int* canAccess, int deviceId, int peerDeviceId) {