From 2fc13070525b2fa0120ba580248d01b980911c27 Mon Sep 17 00:00:00 2001 From: eric100lin Date: Sat, 27 Dec 2014 22:37:40 +0800 Subject: [PATCH] Update VectorCopy.cpp Correct the order of in/out for the OpenCL kernel code --- examples/snack/vector_copy/VectorCopy.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/snack/vector_copy/VectorCopy.cpp b/examples/snack/vector_copy/VectorCopy.cpp index ec1e779..770566e 100644 --- a/examples/snack/vector_copy/VectorCopy.cpp +++ b/examples/snack/vector_copy/VectorCopy.cpp @@ -11,17 +11,21 @@ int main(int argc, char **argv) //Setup kernel arguments int* in=(int*)malloc(1024*1024*4); int* out=(int*)malloc(1024*1024*4); - memset(out, 0, 1024*1024*4); - memset(in, 1, 1024*1024*4); - - Launch_params_t lparm={ .ndim=1, .gdims={1024*1024}, .ldims={256} }; - vcopy(out,in,lparm); + memset(out, -1, 1024*1024*4); + for(int i=0; i<1024*1024; i++) + in[i] = i; + + Launch_params_t lparm={ .ndim=1, .gdims={1024*1024}, .ldims={256} }; + vcopy(in, out, lparm); //Validate bool valid=true; int failIndex=0; - for(int i=0; i<1024*1024; i++) { - if(out[i]!=in[i]) { + for(int i=0; i<1024*1024; i++) + { + int in_i = in[i]; + int out_i = out[i]; + if(out_i!=in_i) { failIndex=i; valid=false; break; @@ -38,4 +42,3 @@ int main(int argc, char **argv) return 0; } -