From 82900a18885161f7eeeaf8b00c4f709049d06e51 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 25 Feb 2016 23:44:39 +0300 Subject: [PATCH 1/2] Attribute hipDeviceAttributeIsMultiGpuBoard for obtaining Device property isMultiGpuBoard is added. On HIP path property obtaining done through hsa_iterate_agents and counting the devices of HSA_DEVICE_TYPE_GPU type. P.S. On multi-boards systems it might be problems with detection what board a GPU plugged into (not tested). [ROCm/hip commit: 57e212606d104277c04b813c9501590b0ceef316] --- projects/hip/include/hip_runtime_api.h | 2 ++ .../hip/include/nvcc_detail/hip_runtime_api.h | 2 ++ .../hip/samples/1_Utils/hipInfo/hipInfo.cpp | 1 + projects/hip/src/hip_hcc.cpp | 25 +++++++++++++++++++ .../hip/tests/src/hipGetDeviceAttribute.cpp | 1 + 5 files changed, 31 insertions(+) diff --git a/projects/hip/include/hip_runtime_api.h b/projects/hip/include/hip_runtime_api.h index 2b5c98bc2a..1fc00299f4 100644 --- a/projects/hip/include/hip_runtime_api.h +++ b/projects/hip/include/hip_runtime_api.h @@ -98,6 +98,7 @@ typedef struct hipDeviceProp_t { int pciBusID; ///< PCI Bus ID. int pciDeviceID; ///< PCI Device ID. size_t maxSharedMemoryPerMultiProcessor; ///< Maximum Shared Memory Per Multiprocessor. + int isMultiGpuBoard; ///< 1 if device is on a multi-GPU board, 0 if not. } hipDeviceProp_t; @@ -161,6 +162,7 @@ typedef enum hipDeviceAttribute_t { hipDeviceAttributePciBusId, ///< PCI Bus ID. hipDeviceAttributePciDeviceId, ///< PCI Device ID. hipDeviceAttributeMaxSharedMemoryPerMultiprocessor, ///< Maximum Shared Memory Per Multiprocessor. + hipDeviceAttributeIsMultiGpuBoard, ///< Multiple GPU devices. } hipDeviceAttribute_t; /** diff --git a/projects/hip/include/nvcc_detail/hip_runtime_api.h b/projects/hip/include/nvcc_detail/hip_runtime_api.h index fac9380bfd..b4d9b06ad6 100644 --- a/projects/hip/include/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/nvcc_detail/hip_runtime_api.h @@ -266,6 +266,8 @@ inline static hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t att cdattr = cudaDevAttrPciDeviceId; break; case hipDeviceAttributeMaxSharedMemoryPerMultiprocessor: cdattr = cudaDevAttrMaxSharedMemoryPerMultiprocessor; break; + case hipDeviceAttributeIsMultiGpuBoard: + cdattr = cudaDevAttrIsMultiGpuBoard; break; default: cerror = cudaErrorInvalidValue; break; } diff --git a/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp b/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp index c7b298705b..19e8cfc210 100644 --- a/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp +++ b/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp @@ -80,6 +80,7 @@ void printDeviceProp (int deviceId) cout << setw(w1) << "pciDeviceID: " << props.pciDeviceID << endl; cout << setw(w1) << "multiProcessorCount: " << props.multiProcessorCount << endl; cout << setw(w1) << "maxThreadsPerMultiProcessor: " << props.maxThreadsPerMultiProcessor << endl; + cout << setw(w1) << "isMultiGpuBoard: " << props.isMultiGpuBoard << endl; cout << setw(w1) << "clockRate: " << (float)props.clockRate / 1000.0 << " Mhz" << endl; #ifdef USE_ROCR_20 cout << setw(w1) << "memoryClockRate: " << (float)props.memoryClockRate / 1000.0 << " Mhz" << endl; diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index ee208bcced..25e2ec30d7 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -227,6 +227,21 @@ hsa_status_t get_region_info(hsa_region_t region, void* data) return HSA_STATUS_SUCCESS; } +// Determines if the given agent is of type HSA_DEVICE_TYPE_GPU and counts it. +static hsa_status_t countGpuAgents(hsa_agent_t agent, void *data) { + if (data == NULL) { + return HSA_STATUS_ERROR_INVALID_ARGUMENT; + } + hsa_device_type_t device_type; + hsa_status_t status = hsa_agent_get_info(agent, HSA_AGENT_INFO_DEVICE, &device_type); + if (status != HSA_STATUS_SUCCESS) { + return status; + } + if (device_type == HSA_DEVICE_TYPE_GPU) { + (*static_cast(data))++; + } + return HSA_STATUS_SUCCESS; +} // Internal version, hipError_t ihipDevice_t::getProperties(hipDeviceProp_t* prop) @@ -245,6 +260,14 @@ hipError_t ihipDevice_t::getProperties(hipDeviceProp_t* prop) return hipErrorInvalidDevice; } + // Iterates over the agents to determine Multiple GPU devices + // using the countGpuAgents callback. + int gpuAgentsCount = 0; + err = hsa_iterate_agents(countGpuAgents, &gpuAgentsCount); + if (err == HSA_STATUS_INFO_BREAK) { err = HSA_STATUS_SUCCESS; } + DeviceErrorCheck(err); + prop->isMultiGpuBoard = 0 ? gpuAgentsCount < 2 : 1; + // Get agent name err = hsa_agent_get_info(_hsa_agent, HSA_AGENT_INFO_NAME, &(prop->name)); DeviceErrorCheck(err); @@ -846,6 +869,8 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) *pi = prop->pciDeviceID; break; case hipDeviceAttributeMaxSharedMemoryPerMultiprocessor: *pi = prop->maxSharedMemoryPerMultiProcessor; break; + case hipDeviceAttributeIsMultiGpuBoard: + *pi = prop->isMultiGpuBoard; break; default: e = hipErrorInvalidValue; break; } diff --git a/projects/hip/tests/src/hipGetDeviceAttribute.cpp b/projects/hip/tests/src/hipGetDeviceAttribute.cpp index dfd5c28f99..4471f532f5 100644 --- a/projects/hip/tests/src/hipGetDeviceAttribute.cpp +++ b/projects/hip/tests/src/hipGetDeviceAttribute.cpp @@ -72,6 +72,7 @@ int main(int argc, char *argv[]) CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMemoryBusWidth, props.memoryBusWidth)); #endif CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMultiprocessorCount, props.multiProcessorCount)); + CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeIsMultiGpuBoard, props.isMultiGpuBoard)); CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeMode, props.computeMode)); CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeL2CacheSize, props.l2CacheSize)); CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerMultiProcessor, props.maxThreadsPerMultiProcessor)); From 6bb5485bebc8ffaf9793b3097b9002fc555d1fb0 Mon Sep 17 00:00:00 2001 From: Aditya Avinash Atluri Date: Thu, 25 Feb 2016 14:49:58 -0600 Subject: [PATCH 2/2] Update hip.vim Added d2d and h2h highlights [ROCm/hip commit: 29c385ed7213262b9d0b7e90bd4240673936b543] --- projects/hip/util/vim/hip.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/util/vim/hip.vim b/projects/hip/util/vim/hip.vim index 5264461ce9..6c0b9a8d33 100644 --- a/projects/hip/util/vim/hip.vim +++ b/projects/hip/util/vim/hip.vim @@ -64,6 +64,7 @@ syn keyword hipFunctionName expf __expf exp logf __logf log " Runtime Data Types syn keyword hipType hipDeviceProp_t syn keyword hipType hipError_t +syn keyword hipType hipStream_t " Runtime functions syn keyword hipFunctionName hipBindTexture hipBindTextureToArray @@ -153,6 +154,8 @@ syn keyword hipFunctionName hipUnbindTexture " HIP Flags syn keyword hipFlags hipFilterModePoint syn keyword hipFlags hipMemcpyHostToDevice +syn keyword hipFlags hipMemcpyDeviceToDevice +syn keyword hipFlags hipMemcpyHostToHost syn keyword hipFlags hipMemcpyDeviceToHost syn keyword hipFlags hipReadModeElementType syn keyword hipFlags hipSuccess