From 8b585536ef8fb9148c8f6bae1209169935603ecc Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Sat, 5 Mar 2016 13:06:37 -0600 Subject: [PATCH] Added canMapHostMemory feature [ROCm/hip commit: af4edd277f24e4b50891d1a93e91047774b7e0e4] --- .../hip/include/nvcc_detail/hip_runtime_api.h | 1 + projects/hip/tests/src/hipHostAlloc.cpp | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 projects/hip/tests/src/hipHostAlloc.cpp diff --git a/projects/hip/include/nvcc_detail/hip_runtime_api.h b/projects/hip/include/nvcc_detail/hip_runtime_api.h index a8408211b2..1413d735f6 100644 --- a/projects/hip/include/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/nvcc_detail/hip_runtime_api.h @@ -177,6 +177,7 @@ inline static hipError_t hipDeviceGetProperties(hipDeviceProp_t *p_prop, int dev p_prop->l2CacheSize = cdprop.l2CacheSize ; p_prop->maxThreadsPerMultiProcessor = cdprop.maxThreadsPerMultiProcessor ; p_prop->computeMode = cdprop.computeMode ; + p_prop->canMapHostMemory = cdprop.canMapHostMemory; // Same as clock-rate: p_prop->clockInstructionRate = cdprop.clockRate; diff --git a/projects/hip/tests/src/hipHostAlloc.cpp b/projects/hip/tests/src/hipHostAlloc.cpp new file mode 100644 index 0000000000..b8acdeb0b3 --- /dev/null +++ b/projects/hip/tests/src/hipHostAlloc.cpp @@ -0,0 +1,20 @@ +#include +#include"test_common.h" + +__global__ void Add(hipLaunchParm lp, float *Ad, float *Bd, float *Cd){ +int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; +Cd[tx] = Ad[tx] + Bd[tx]; +} + +int main(){ +float *A, *B, *C; +float *Ad, *Bd, *Cd; + +hipDeviceProp_t prop; +int device; +hipGetDevice(&device); +hipDeviceGetProperties(&prop, device); +if(prop.canMapHostMemory != 1){ +std::cout<<"Exiting.."<