From ec921786f7d0d71b173e7f5a8b8e24f91342fd92 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 16 Mar 2016 05:15:03 -0500 Subject: [PATCH 1/4] added cudaHostRegister test [ROCm/hip commit: e67133ce2169aa79763187218c094943ec6dd6a3] --- projects/hip/tests/src/cudaRegister.cu | 80 ++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 projects/hip/tests/src/cudaRegister.cu diff --git a/projects/hip/tests/src/cudaRegister.cu b/projects/hip/tests/src/cudaRegister.cu new file mode 100644 index 0000000000..1fc456f5fa --- /dev/null +++ b/projects/hip/tests/src/cudaRegister.cu @@ -0,0 +1,80 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include +#include +#include +#include +#include + +#define LEN 1024*1024 +#define SIZE LEN * sizeof(float) +#define ITER 1024*128 + +#define check(msg, status){ \ +if(status != cudaSuccess) { \ + printf("%s failed. \n", #msg); \ +} \ +} + +__global__ void Inc1(float *Ad){ + int tx = threadIdx.x + blockIdx.x * blockDim.x; + if(tx < 1 ){ + for(int i=0;i>>(Ad); + A[1] = -(ITER*1.0f); + cudaDeviceSynchronize(); + std::cout<>>(Ad); + A[1] = -(ITER*1.0f); + cudaDeviceSynchronize(); + std::cout< Date: Wed, 16 Mar 2016 05:24:08 -0500 Subject: [PATCH 2/4] increased iteration size [ROCm/hip commit: 89eb2a7b520562bd3a15c2f4446fdd2b74061f0d] --- projects/hip/tests/src/cudaRegister.cu | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/projects/hip/tests/src/cudaRegister.cu b/projects/hip/tests/src/cudaRegister.cu index 1fc456f5fa..6ea038a71a 100644 --- a/projects/hip/tests/src/cudaRegister.cu +++ b/projects/hip/tests/src/cudaRegister.cu @@ -26,7 +26,7 @@ THE SOFTWARE. #define LEN 1024*1024 #define SIZE LEN * sizeof(float) -#define ITER 1024*128 +#define ITER 1024*1024 #define check(msg, status){ \ if(status != cudaSuccess) { \ @@ -66,15 +66,16 @@ int main(){ dim3 dimGrid(LEN/512,1,1); dim3 dimBlock(512,1,1); Inc1<<>>(Ad); - A[1] = -(ITER*1.0f); + A[0] = -(ITER*1.0f); + std::cout<>>(Ad); - A[1] = -(ITER*1.0f); + A[0] = -(ITER*1.0f); cudaDeviceSynchronize(); - std::cout< Date: Wed, 16 Mar 2016 05:30:29 -0500 Subject: [PATCH 3/4] test/src [v3] clean up [ROCm/hip commit: 62b8351f02ca8c75dc9b30a2bac40b7d949853ab] --- projects/hip/tests/src/cudaRegister.cu | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/hip/tests/src/cudaRegister.cu b/projects/hip/tests/src/cudaRegister.cu index 6ea038a71a..8d97c7ae59 100644 --- a/projects/hip/tests/src/cudaRegister.cu +++ b/projects/hip/tests/src/cudaRegister.cu @@ -24,7 +24,7 @@ THE SOFTWARE. #include #include -#define LEN 1024*1024 +#define LEN 1024 #define SIZE LEN * sizeof(float) #define ITER 1024*1024 @@ -67,15 +67,16 @@ int main(){ dim3 dimBlock(512,1,1); Inc1<<>>(Ad); A[0] = -(ITER*1.0f); - std::cout<>>(Ad); A[0] = -(ITER*1.0f); + std::cout<<"Diff cache line before completion: \t"< Date: Wed, 16 Mar 2016 07:04:40 -0500 Subject: [PATCH 4/4] tests/src [v4] Added feature for partial writes on CPU [ROCm/hip commit: 451cd9f876bcc89f8b11a0daf7f020c2b8ff70f6] --- projects/hip/tests/src/cudaRegister.cu | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/projects/hip/tests/src/cudaRegister.cu b/projects/hip/tests/src/cudaRegister.cu index 8d97c7ae59..b9953a5a3f 100644 --- a/projects/hip/tests/src/cudaRegister.cu +++ b/projects/hip/tests/src/cudaRegister.cu @@ -34,26 +34,32 @@ if(status != cudaSuccess) { \ } \ } -__global__ void Inc1(float *Ad){ +__global__ void Inc1(float *Ad, float *Bd){ int tx = threadIdx.x + blockIdx.x * blockDim.x; if(tx < 1 ){ for(int i=0;i>>(Ad); + Inc1<<>>(Ad, Bd); + sleep(3); A[0] = -(ITER*1.0f); std::cout<<"Same cache line before completion: \t"<< A[0]<>>(Ad); + Inc2<<>>(Ad, Bd); + sleep(3); A[0] = -(ITER*1.0f); std::cout<<"Diff cache line before completion: \t"<