Advertisement
MasWag

PAPI_highlevel_flops.c

Jun 22nd, 2015
1,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <sys/time.h>
  5. #include <papi.h>
  6.  
  7. void
  8. LU (double * mat,int num);
  9.  
  10. #define SIZE 11
  11. double mat[(1 << SIZE) * (1 << SIZE)];
  12.  
  13. int
  14. main ()
  15. {
  16.   srand (time (NULL));
  17.   int i;
  18.  
  19.   puts ("Size\tReal_Time\tProcess_Time\tFLPops\tMFlops");
  20.  
  21.   for (i = 1;i <= SIZE; ++i)
  22.     {
  23.       // 要素には-1を代入しておく
  24.       float rtime = -1,ptime = -1,mflops = -1;
  25.       long long flpops = -1;
  26.       const int num = 1 << i;
  27.       int j;
  28.       // 適当に行列に要素を入れる
  29.       for (j = 0;j < num * num; ++j)
  30.         {
  31.           mat[j] = rand () / 1000.0;
  32.         }
  33.  
  34.  
  35.       // 1回目の呼び出し
  36.       PAPI_flops (&rtime,&ptime,&flpops,&mflops);
  37.       LU (mat,num);
  38.       // 2回目の呼び出し
  39.       PAPI_flops (&rtime,&ptime,&flpops,&mflops);
  40.  
  41.       printf ("%d\t%f\t%f\t%lld\t%f\n",num,rtime,ptime,flpops,mflops);
  42.     }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement