Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <sys/time.h>
- #include <papi.h>
- void
- LU (double * mat,int num);
- #define SIZE 11
- double mat[(1 << SIZE) * (1 << SIZE)];
- int
- main ()
- {
- srand (time (NULL));
- int i;
- puts ("Size\tReal_Time\tProcess_Time\tFLPops\tMFlops");
- for (i = 1;i <= SIZE; ++i)
- {
- // 要素には-1を代入しておく
- float rtime = -1,ptime = -1,mflops = -1;
- long long flpops = -1;
- const int num = 1 << i;
- int j;
- // 適当に行列に要素を入れる
- for (j = 0;j < num * num; ++j)
- {
- mat[j] = rand () / 1000.0;
- }
- // 1回目の呼び出し
- PAPI_flops (&rtime,&ptime,&flpops,&mflops);
- LU (mat,num);
- // 2回目の呼び出し
- PAPI_flops (&rtime,&ptime,&flpops,&mflops);
- printf ("%d\t%f\t%f\t%lld\t%f\n",num,rtime,ptime,flpops,mflops);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement