X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/book_gpu.git/blobdiff_plain/fc4670d0de6814f682df0ce247905cba40b9d547..21ada473e001305cb2a05a34a2da6c2fb1ecd126:/BookGPU/Chapters/chapter2/ex2.cu?ds=sidebyside diff --git a/BookGPU/Chapters/chapter2/ex2.cu b/BookGPU/Chapters/chapter2/ex2.cu index 762654c..62931cd 100644 --- a/BookGPU/Chapters/chapter2/ex2.cu +++ b/BookGPU/Chapters/chapter2/ex2.cu @@ -6,7 +6,6 @@ #include "cutil_inline.h" #include - const int nbThreadsPerBloc=256; __global__ @@ -28,19 +27,15 @@ void inverse(int size, double *d_x) { int main( int argc, char** argv) { - if(argc!=2) { printf("usage: ex2 nb_components\n"); exit(0); } int size=atoi(argv[1]); - cublasStatus_t stat; cublasHandle_t handle; stat=cublasCreate(&handle); - - int i; double *h_arrayA=(double*)malloc(size*sizeof(double)); double *h_arrayB=(double*)malloc(size*sizeof(double)); @@ -48,7 +43,6 @@ int main( int argc, char** argv) double *h_arrayCgpu=(double*)malloc(size*sizeof(double)); double *d_arrayA, *d_arrayB, *d_arrayC; - cudaMalloc((void**)&d_arrayA,size*sizeof(double)); cudaMalloc((void**)&d_arrayB,size*sizeof(double)); cudaMalloc((void**)&d_arrayC,size*sizeof(double)); @@ -58,10 +52,9 @@ int main( int argc, char** argv) h_arrayB[i]=2*(i+1); } - unsigned int timer_cpu = 0; cutilCheckError(cutCreateTimer(&timer_cpu)); - cutilCheckError(cutStartTimer(timer_cpu)); + cutilCheckError(cutStartTimer(timer_cpu)); double dot=0; for(i=0;i