Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include "cutil.h"
  4.  
  5. __global__ void kernel_launch(int size)
  6. {
  7. }
  8.  
  9.  
  10. int main(int argc, char** argv)
  11. {
  12. CUT_DEVICE_INIT(argc,argv);
  13.  
  14. int size= 65536 * 512;//512 * 8192 * 8;
  15.  
  16.  
  17. unsigned int timer=0,timer1=0;
  18. CUT_SAFE_CALL( cutCreateTimer( &timer));
  19. CUT_SAFE_CALL( cutCreateTimer( &timer1));
  20.  
  21. float avg_timer=0,avg_timer1=0;
  22. for(int i=0;i<100;i++ )
  23. {
  24. CUT_SAFE_CALL( cutStartTimer( timer));
  25. kernel_launch<<<size/512,512>>>(size);
  26. cudaThreadSynchronize();
  27. CUT_SAFE_CALL( cutStopTimer( timer));
  28. avg_timer += cutGetTimerValue( timer);
  29. }
  30. for(int i=0;i<200;i++ )
  31. {
  32. CUT_SAFE_CALL( cutStartTimer( timer1));
  33. kernel_launch<<<size/(512*2),512>>>(size);
  34. cudaThreadSynchronize();
  35. CUT_SAFE_CALL( cutStopTimer( timer1));
  36. avg_timer1 += cutGetTimerValue( timer1);
  37. }
  38.  
  39. printf( "Time with num of blocks = %d kernel launch %f (ms)\n",size / 512, avg_timer / 100);
  40. printf( "Time with num of blocks = %d kernel launch %f (ms)\n",size / (512*2) , avg_timer1 / 100);
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement