66const uint32_t colors[] = { 0x0000ff00 , 0x000000ff , 0x00ffff00 , 0x00ff00ff , 0x0000ffff , 0x00ff0000 , 0x00ffffff };
77const int num_colors = sizeof (colors)/sizeof (uint32_t );
88
9- #define START_RANGE (name,cid ) { \
9+ #define PUSH_RANGE (name,cid ) { \
1010 int color_id = cid; \
1111 color_id = color_id%num_colors;\
1212 nvtxEventAttributes_t eventAttrib = {0 }; \
@@ -18,10 +18,10 @@ const int num_colors = sizeof(colors)/sizeof(uint32_t);
1818 eventAttrib.message .ascii = name; \
1919 nvtxRangePushEx (&eventAttrib); \
2020}
21- #define END_RANGE nvtxRangePop ();
21+ #define POP_RANGE nvtxRangePop ();
2222#else
23- #define START_RANGE (name,cid )
24- #define END_RANGE
23+ #define PUSH_RANGE (name,cid )
24+ #define POP_RANGE
2525#endif
2626
2727__global__ void init_data_kernel ( int n, double * x)
@@ -57,17 +57,17 @@ __global__ void check_results_kernel( int n, double correctvalue, double * x )
5757
5858void init_host_data ( int n, double * x )
5959{
60- START_RANGE (" init_host_data" ,1 )
60+ PUSH_RANGE (" init_host_data" ,1 )
6161 for (int i=0 ; i<n; ++i)
6262 {
6363 x[i] = i;
6464 }
65- END_RANGE
65+ POP_RANGE
6666}
6767
6868void init_data (int n, double * x, double * x_d, double * y_d)
6969{
70- START_RANGE (" init_data" ,2 )
70+ PUSH_RANGE (" init_data" ,2 )
7171 cudaStream_t copy_stream;
7272 cudaStream_t compute_stream;
7373 cudaStreamCreate (©_stream);
@@ -81,27 +81,27 @@ void init_data(int n, double* x, double* x_d, double* y_d)
8181
8282 cudaStreamDestroy (compute_stream);
8383 cudaStreamDestroy (copy_stream);
84- END_RANGE
84+ POP_RANGE
8585}
8686
8787void daxpy (int n, double a, double * x_d, double * y_d)
8888{
89- START_RANGE (" daxpy" ,3 )
89+ PUSH_RANGE (" daxpy" ,3 )
9090 daxpy_kernel<<<ceil(n/256 ),256 >>> (n,a,x_d,y_d);
9191 cudaDeviceSynchronize ();
92- END_RANGE
92+ POP_RANGE
9393}
9494
9595void check_results ( int n, double correctvalue, double * x_d )
9696{
97- START_RANGE (" check_results" ,4 )
97+ PUSH_RANGE (" check_results" ,4 )
9898 check_results_kernel<<<ceil(n/256 ),256 >>> (n,correctvalue,x_d);
99- END_RANGE
99+ POP_RANGE
100100}
101101
102102void run_test (int n)
103103{
104- START_RANGE (" run_test" ,0 )
104+ PUSH_RANGE (" run_test" ,0 )
105105 double * x;
106106 double * x_d;
107107 double * y_d;
@@ -122,7 +122,7 @@ void run_test(int n)
122122 cudaFree (x_d);
123123 cudaFreeHost (x);
124124 cudaDeviceSynchronize ();
125- END_RANGE
125+ POP_RANGE
126126}
127127
128128int main ()
0 commit comments