Added hipHostRegister feature for CUDA backend and its tests

This commit is contained in:
Aditya Atluri
2016-03-07 03:42:50 -06:00
parent de85c80eb0
commit 4ed0b1cb1a
3 changed files with 40 additions and 1 deletions
+2 -1
View File
@@ -129,6 +129,7 @@ make_hip_executable (hipMultiThreadStreams2 hipMultiThreadStreams2.cpp)
make_hip_executable (hipHostAlloc hipHostAlloc.cpp)
make_hip_executable (hipStreamL5 hipStreamL5.cpp)
make_hip_executable (hipHostGetFlags hipHostGetFlags.cpp)
make_hip_executable (hipHostRegister hipHostRegister.cpp)
target_link_libraries(hipMathFunctionsHost m)
make_test(hip_ballot " " )
@@ -152,7 +153,7 @@ make_test(hipMemcpy " " )
make_test(hipMemcpyAsync " " )
make_test(hipHostGetFlags " ")
make_test(hipHcc " " )
make_test(hipHostRegister " ")
make_test(hipStreamL5 " ")
make_hipify_test(specialFunc.cu )
+30
View File
@@ -0,0 +1,30 @@
#include"test_common.h"
__global__ void Inc(hipLaunchParm lp, float *Ad){
int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x;
Ad[tx] = Ad[tx] + float(1);
}
int main(){
float *A, *Ad;
const size_t size = N * sizeof(float);
A = (float*)malloc(size);
HIPCHECK(hipHostRegister(A, size, 0));
for(int i=0;i<N;i++){
A[i] = float(1);
}
HIPCHECK(hipMalloc(&Ad, size));
HIPCHECK(hipMemcpy(Ad, A, size, hipMemcpyHostToDevice));
hipLaunchKernel(HIP_KERNEL_NAME(Inc), dim3(N/512), dim3(512), 0, 0, Ad);
HIPCHECK(hipDeviceSynchronize());
HIPCHECK(hipMemcpy(A, Ad, size, hipMemcpyDeviceToHost));
HIPASSERT(A[10] == 2.0f);
HIPCHECK(hipHostUnregister(A));
passed();
}