From 6cbeeb8e59cb3107cb46cf8fc6f467de97f7a857 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 7 Mar 2017 11:24:32 -0600 Subject: [PATCH] added new field to hipDeviceProp_t structure gcnArch. 1. It is an integer containing gfx values 701, 801, 802, 803 2. On NV path, it is zero Change-Id: I2b4c7f48981d0214d8c6b1905d2cc85b16203419 [ROCm/hip commit: f86f3b3b33ce43035ae95ad201e7409e3416259e] --- projects/hip/include/hip/hip_runtime_api.h | 1 + .../samples/0_Intro/square/square.hipref.cpp | 10 +++++---- projects/hip/src/hip_hcc.cpp | 21 +++++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index 28d67fc01a..818c0b7c34 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -106,6 +106,7 @@ typedef struct hipDeviceProp_t { size_t maxSharedMemoryPerMultiProcessor; ///< Maximum Shared Memory Per Multiprocessor. int isMultiGpuBoard; ///< 1 if device is on a multi-GPU board, 0 if not. int canMapHostMemory; ///< Check whether HIP can map host memory + int gcnArch; ///< AMD GCN Arch Value. Eg: 803, 701 } hipDeviceProp_t; diff --git a/projects/hip/samples/0_Intro/square/square.hipref.cpp b/projects/hip/samples/0_Intro/square/square.hipref.cpp index 0073c1399a..e694bfb8a4 100644 --- a/projects/hip/samples/0_Intro/square/square.hipref.cpp +++ b/projects/hip/samples/0_Intro/square/square.hipref.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. }\ } -/* +/* * Square each element in the array A and write to array C. */ template @@ -58,16 +58,18 @@ int main(int argc, char *argv[]) hipDeviceProp_t props; CHECK(hipGetDeviceProperties(&props, 0/*deviceID*/)); printf ("info: running on device %s\n", props.name); - + #ifdef __HIP_PLATFORM_HCC__ + printf ("info: architecture on AMD GPU device is: %d\n",props.gcnArch); + #endif printf ("info: allocate host mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); A_h = (float*)malloc(Nbytes); CHECK(A_h == 0 ? hipErrorMemoryAllocation : hipSuccess ); C_h = (float*)malloc(Nbytes); CHECK(C_h == 0 ? hipErrorMemoryAllocation : hipSuccess ); // Fill with Phi + i - for (size_t i=0; iisMultiGpuBoard = 0 ? gpuAgentsCount < 2 : 1; // Get agent name -#if HIP_USE_PRODUCT_NAME + err = hsa_agent_get_info(_hsaAgent, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME, &(prop->name)); -#else - err = hsa_agent_get_info(_hsaAgent, HSA_AGENT_INFO_NAME, &(prop->name)); -#endif + char archName[256]; + err = hsa_agent_get_info(_hsaAgent, HSA_AGENT_INFO_NAME, &archName); + + if(strcmp(archName,"gfx701")==0){ + prop->gcnArch = 701; + } + if(strcmp(archName,"gfx801")==0){ + prop->gcnArch = 801; + } + if(strcmp(archName,"gfx802")==0){ + prop->gcnArch = 802; + } + if(strcmp(archName,"gfx803")==0){ + prop->gcnArch = 803; + } + DeviceErrorCheck(err); // Get agent node