From c666fdaa086d9be2add2f66244ce22bedccb5a56 Mon Sep 17 00:00:00 2001 From: wkwchau Date: Thu, 1 Aug 2019 12:03:35 -0400 Subject: [PATCH] =?UTF-8?q?Added=20query=20of=20hipDeviceAttributeHdpMemFl?= =?UTF-8?q?ushCntl=20and=20hipDeviceAttribu=E2=80=A6=20(#1238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added query of hipDeviceAttributeHdpMemFlushCntl and hipDeviceAttributeHdpRegFlushCntl * Added NVCC blocker for the hip*FlushCntl test cases [ROCm/hip commit: e7447d5809cc50f5660ae704f5ba90af83e06c1f] --- projects/hip/include/hip/hip_runtime_api.h | 8 ++++++-- projects/hip/src/hip_device.cpp | 11 ++++++++++ projects/hip/src/hip_hcc.cpp | 9 +++++++++ .../device/hipGetDeviceAttribute.cpp | 20 +++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index 637de712b3..c067f5bf54 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -117,10 +117,12 @@ typedef struct hipDeviceProp_t { int integrated; ///< APU vs dGPU int cooperativeLaunch; ///< HIP device supports cooperative launch int cooperativeMultiDeviceLaunch; ///< HIP device supports cooperative launch on multiple devices -#if !__HIP_VDI__ // Temporarily disable the following three new fields for HIP/VDI runtime +#if !__HIP_VDI__ // Temporarily disable the following five new fields for HIP/VDI runtime int maxTexture1D; ///< Maximum number of elements in 1D images int maxTexture2D[2]; ///< Maximum dimensions (width, height) of 2D images, in image elements int maxTexture3D[3]; ///< Maximum dimensions (width, height, depth) of 3D images, in image elements + unsigned int* hdpMemFlushCntl; ///< Addres of HDP_MEM_COHERENCY_FLUSH_CNTL register + unsigned int* hdpRegFlushCntl; ///< Addres of HDP_REG_COHERENCY_FLUSH_CNTL register #endif } hipDeviceProp_t; @@ -306,8 +308,10 @@ typedef enum hipDeviceAttribute_t { hipDeviceAttributeMaxTexture2DHeight, ///< Maximum dimension height of 2D images in image elements hipDeviceAttributeMaxTexture3DWidth, ///< Maximum dimension width of 3D images in image elements hipDeviceAttributeMaxTexture3DHeight, ///< Maximum dimensions height of 3D images in image elements - hipDeviceAttributeMaxTexture3DDepth ///< Maximum dimensions depth of 3D images in image elements + hipDeviceAttributeMaxTexture3DDepth, ///< Maximum dimensions depth of 3D images in image elements + hipDeviceAttributeHdpMemFlushCntl, ///< Address of the HDP_MEM_COHERENCY_FLUSH_CNTL register + hipDeviceAttributeHdpRegFlushCntl ///< Address of the HDP_REG_COHERENCY_FLUSH_CNTL register } hipDeviceAttribute_t; enum hipComputeMode { diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 5c19ad42c6..1c0e5c9109 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -293,6 +293,17 @@ hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device break; case hipDeviceAttributeMaxTexture3DDepth: *pi = prop->maxTexture3D[2]; + case hipDeviceAttributeHdpMemFlushCntl: + { + uint32_t** hdp = reinterpret_cast(pi); + *hdp = prop->hdpMemFlushCntl; + } + break; + case hipDeviceAttributeHdpRegFlushCntl: + { + uint32_t** hdp = reinterpret_cast(pi); + *hdp = prop->hdpRegFlushCntl; + } break; default: e = hipErrorInvalidValue; diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 1b2f895f7d..f3d6eae6b7 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -915,6 +915,15 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) { err = hsa_agent_get_info(_hsaAgent, (hsa_agent_info_t)HSA_EXT_AGENT_INFO_IMAGE_3D_MAX_ELEMENTS, prop->maxTexture3D); DeviceErrorCheck(err); + + // Get Agent HDP Flush Register Memory + hsa_amd_hdp_flush_t hdpinfo; + err = hsa_agent_get_info(_hsaAgent, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_HDP_FLUSH, &hdpinfo); + DeviceErrorCheck(err); + + prop->hdpMemFlushCntl = hdpinfo.HDP_MEM_FLUSH_CNTL; + prop->hdpRegFlushCntl = hdpinfo.HDP_REG_FLUSH_CNTL; + return e; } diff --git a/projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp b/projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp index 1e1076b806..27947339cb 100644 --- a/projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp +++ b/projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp @@ -56,6 +56,22 @@ hipError_t test_hipDeviceGetAttribute(int deviceId, hipDeviceAttribute_t attr, return hipSuccess; } +hipError_t test_hipDeviceGetHdpAddress(int deviceId, hipDeviceAttribute_t attr, + uint32_t* expectedValue = (uint32_t*)0xdeadbeef) { + uint32_t* value = 0; + std::cout << "Test hipDeviceGetHdpAddress attribute " << attr; + if (expectedValue != (uint32_t*)0xdeadbeef) { + std::cout << " expected value " << expectedValue; + } + hipError_t e = hipDeviceGetAttribute((int*) &value, attr, deviceId); + std::cout << " actual value " << value << std::endl; + if ((expectedValue != (uint32_t*)0xdeadbeef) && value != expectedValue) { + std::cout << "fail" << std::endl; + return hipErrorInvalidValue; + } + return hipSuccess; +} + int main(int argc, char* argv[]) { int deviceId; CHECK(hipGetDevice(&deviceId)); @@ -116,5 +132,9 @@ int main(int argc, char* argv[]) { CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture3DWidth, props.maxTexture3D[0])); CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture3DHeight, props.maxTexture3D[1])); CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture3DDepth, props.maxTexture3D[2])); +#ifndef __HIP_PLATFORM_NVCC__ + CHECK(test_hipDeviceGetHdpAddress(deviceId, hipDeviceAttributeHdpMemFlushCntl, props.hdpMemFlushCntl)); + CHECK(test_hipDeviceGetHdpAddress(deviceId, hipDeviceAttributeHdpRegFlushCntl, props.hdpRegFlushCntl)); +#endif passed(); };