]> AND Private Git Repository - snake_gpu.git/blob - src/lib_test_gpu.cu~
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
test tex
[snake_gpu.git] / src / lib_test_gpu.cu~
1 void verif_cumuls(int ** img_in, uint64 ** d_img_1, uint64 ** d_img_x, uint64 ** d_img_x2){
2 //allocation memoire CPU
3   uint64  img_1[H][L];
4   uint64  img_x[H][L];
5   uint64  img_x2[H][L];
6
7   /*pour test comparaison*/
8   uint64  img_1b[H][L];
9   uint64  img_xb[H][L];
10   uint64  img_x2b[H][L];
11   cudaMemcpy( img_1b, *d_img_1, taille*sizeof(uint64), cudaMemcpyDeviceToHost );
12   cudaMemcpy( img_xb, *d_img_x, taille*sizeof(uint64), cudaMemcpyDeviceToHost);
13   cudaMemcpy( img_x2b, *d_img_x2, taille*sizeof(uint64), cudaMemcpyDeviceToHost);
14  
15   for (int i=0; i<H; i++)
16         {
17           img_1[i][0] = 1 ;
18           img_x[i][0] = img_in[i][0] ;
19           img_x2[i][0]= img_in[i][0]*img_in[i][0] ;
20           for (int j=1; j<L; j++)
21                 {
22                   img_1[i][j]  = img_1[i][j-1]  + 1 ;
23                   img_x[i][j]  = img_x[i][j-1]  + img_in[i][j] ;
24                   img_x2[i][j] = img_x2[i][j-1] + img_in[i][j]*img_in[i][j] ;
25                 }
26         }
27   
28   int cpt = 0;
29   int cpt_err = 0;
30   for (int i=0; i<H; i++){
31         for (int j=0; j<L; j++){
32           if( (img_1[i][j] !=  img_1b[i][j]) ||  (img_x[i][j] !=  img_xb[i][j]) ||  (img_x2[i][j] !=  img_x2b[i][j]) )
33                 {
34                   if (!(j%BS)) printf("\n");
35 #ifdef DISPLAY_ERR_IMG_CUMUL
36                   printf("(%d,%d)CPU:%lu GPU:%lu\n",i, j, img_x2[i][j], img_x2b[i][j]);
37                   printf("(%d,%d):CPU=%lu  GPU=%lu\n",i,j,img_x[i][j], img_xb[i][j]);
38 #endif
39                   cpt_err++;
40                 }
41           cpt++;
42         }
43   }
44   printf("%d erreurs / %d points\n", cpt_err, cpt );
45 }