Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include "cutil.h"
- __global__ void kernel_launch(int size)
- {
- }
- int main(int argc, char** argv)
- {
- CUT_DEVICE_INIT(argc,argv);
- int size= 65536 * 512;//512 * 8192 * 8;
- unsigned int timer=0,timer1=0;
- CUT_SAFE_CALL( cutCreateTimer( &timer));
- CUT_SAFE_CALL( cutCreateTimer( &timer1));
- float avg_timer=0,avg_timer1=0;
- for(int i=0;i<100;i++ )
- {
- CUT_SAFE_CALL( cutStartTimer( timer));
- kernel_launch<<<size/512,512>>>(size);
- cudaThreadSynchronize();
- CUT_SAFE_CALL( cutStopTimer( timer));
- avg_timer += cutGetTimerValue( timer);
- }
- for(int i=0;i<200;i++ )
- {
- CUT_SAFE_CALL( cutStartTimer( timer1));
- kernel_launch<<<size/(512*2),512>>>(size);
- cudaThreadSynchronize();
- CUT_SAFE_CALL( cutStopTimer( timer1));
- avg_timer1 += cutGetTimerValue( timer1);
- }
- printf( "Time with num of blocks = %d kernel launch %f (ms)\n",size / 512, avg_timer / 100);
- printf( "Time with num of blocks = %d kernel launch %f (ms)\n",size / (512*2) , avg_timer1 / 100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement