67 int *eb_sel,
int *ch_sel,
int *nw_sel,
int *tw_sel);
73 int *
nelv,
int *lx,
int *eb_sel,
int *ch_sel,
int *nw_sel,
80 void *
ind,
int *
nelv,
int *lx,
int *eb_sel,
int *nw_sel,
81 int *tw_sel,
int *bw_sel);
85 void *
w,
void *
dx,
void *
dy,
void *
dz,
void *
h1,
88 int *lx,
int *eb_sel,
int *nw_sel,
int *tw_sel,
100 void *
ind,
int *
nelv,
int *lx) {
102 static int autotune[17] = { 0 };
105 static int autotune_eb[17] = { 0 };
107 static int autotune_ch[17] = { 0 };
109 static int autotune_nw[17] = { 0 };
111 static int autotune_tw[17] = { 0 };
113 const dim3 nblcks_1d((*
nelv), 1, 1);
116#define CASE_1D(LX, C) \
117 ax_helm_compr_kernel_1d<real, LX, NEKO_CHUNKS(LX, C)> \
118 <<<nblcks_1d, NEKO_CHUNKS_NTHRDS(LX, C), 0, stream>>> \
119 ((real *) w, (real *) u, \
120 (real *) dx, (real *) dy, (real *) dz, \
121 (real *) dxt, (real *) dyt, (real *) dzt, (real *) h1,\
122 (real *) g11, (real *) g22, (real *) g33, \
123 (real *) g12, (real *) g13, (real *) g23, \
124 (const int *) ind); \
125 CUDA_CHECK(cudaGetLastError());
128#define CASE_1D_SEL(LX, SEL) \
130 case 0: CASE_1D(LX, 0); break; \
131 case 1: CASE_1D(LX, 1); break; \
132 case 2: CASE_1D(LX, 2); break; \
133 default: CASE_1D(LX, 3); break; \
136#define CASE_KSTEP(LX, C) \
137 ax_helm_compr_kernel_kstep<real, LX, NEKO_EB(LX, C)> \
138 <<<NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, stream>>> \
139 ((real *) w, (real *) u, \
140 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
141 (real *) g11, (real *) g22, (real *) g33, \
142 (real *) g12, (real *) g13, (real *) g23, \
143 (const int *) ind, *nelv); \
144 CUDA_CHECK(cudaGetLastError());
146#define CASE_KSTEP_PADDED(LX, C) \
147 ax_helm_compr_kernel_kstep_padded<real, LX, NEKO_EB(LX, C)> \
148 <<<NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, stream>>> \
149 ((real *) w, (real *) u, \
150 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
151 (real *) g11, (real *) g22, (real *) g33, \
152 (real *) g12, (real *) g13, (real *) g23, \
153 (const int *) ind, *nelv); \
154 CUDA_CHECK(cudaGetLastError());
157#define CASE_KSTEP_SEL(LX, SEL) \
159 case 0: CASE_KSTEP(LX, 0); break; \
160 case 1: CASE_KSTEP(LX, 1); break; \
161 default: CASE_KSTEP(LX, 2); break; \
164#define CASE_KSTEP_PADDED_SEL(LX, SEL) \
166 case 0: CASE_KSTEP_PADDED(LX, 0); break; \
167 case 1: CASE_KSTEP_PADDED(LX, 1); break; \
168 default: CASE_KSTEP_PADDED(LX, 2); break; \
171#define CASE_DMMA(LX, C) \
172 ax_helm_compr_kernel_dmma<real, LX, NEKO_DMMA_NW(C)> \
173 <<<NEKO_DMMA_NBLCKS(*nelv, LX), NEKO_DMMA_NTHRDS(C), 0, stream>>> \
174 ((real *) w, (real *) u, \
175 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
176 (real *) g11, (real *) g22, (real *) g33, \
177 (real *) g12, (real *) g13, (real *) g23, \
178 (const int *) ind, *nelv); \
179 CUDA_CHECK(cudaGetLastError());
182#define CASE_DMMA_SEL(LX, SEL) \
184 case 0: CASE_DMMA(LX, 0); break; \
185 case 1: CASE_DMMA(LX, 1); break; \
186 default: CASE_DMMA(LX, 2); break; \
195#define CASE_DMMA_TMA(LX, C) \
196 ax_helm_compr_kernel_dmma_tma<real, LX, NEKO_DMMA_NW(C)> \
197 <<<NEKO_DMMA_NBLCKS(*nelv, LX), NEKO_DMMA_NTHRDS(C), 0, stream>>> \
198 ((real *) w, (real *) u, \
199 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
200 (real *) g11, (real *) g22, (real *) g33, \
201 (real *) g12, (real *) g13, (real *) g23, \
202 (const int *) ind); \
203 CUDA_CHECK(cudaGetLastError());
206#define CASE_DMMA_TMA_SEL(LX, SEL) \
208 case 0: CASE_DMMA_TMA(LX, 0); break; \
209 case 1: CASE_DMMA_TMA(LX, 1); break; \
210 default: CASE_DMMA_TMA(LX, 2); break; \
215 if(autotune[LX] == 0 ) { \
216 autotune[LX]=tune_compr<LX>( w, u, \
220 g12, g13, g23, ind, nelv, lx, \
221 &autotune_eb[LX], &autotune_ch[LX], \
222 &autotune_nw[LX], &autotune_tw[LX]); \
223 } else if (autotune[LX] == 1 ) { \
224 CASE_1D_SEL(LX, autotune_ch[LX]); \
225 } else if (autotune[LX] == 2 ) { \
226 CASE_KSTEP_SEL(LX, autotune_eb[LX]); \
227 } else if (autotune[LX] == 3 ) { \
228 CASE_DMMA_SEL(LX, autotune_nw[LX]); \
229 } else if (autotune[LX] == 4 ) { \
230 CASE_DMMA_TMA_SEL(LX, autotune_tw[LX]); \
234#define CASE_PADDED(LX) \
236 if(autotune[LX] == 0 ) { \
237 autotune[LX]=tune_compr_padded<LX>(w, u, \
241 g12, g13, g23, ind,nelv,lx, \
242 &autotune_eb[LX], &autotune_ch[LX], \
243 &autotune_nw[LX], &autotune_tw[LX]); \
244 } else if (autotune[LX] == 1 ) { \
245 CASE_1D_SEL(LX, autotune_ch[LX]); \
246 } else if (autotune[LX] == 2 ) { \
247 CASE_KSTEP_PADDED_SEL(LX, autotune_eb[LX]); \
248 } else if (autotune[LX] == 3 ) { \
249 CASE_DMMA_SEL(LX, autotune_nw[LX]); \
250 } else if (autotune[LX] == 4 ) { \
251 CASE_DMMA_TMA_SEL(LX, autotune_tw[LX]); \
260#define CASE_LARGE(LX) \
265#define CASE_LARGE_PADDED(LX) \
267 CASE_KSTEP_PADDED(LX, 0); \
284 fprintf(stderr, __FILE__
": size not supported: %d\n", *lx);
298 fprintf(stderr, __FILE__
": size not supported: %d\n", *lx);
310 void *
w,
void *
dx,
void *
dy,
void *
dz,
317 static int autotune_vec[17] = { 0 };
319 static int autotune_vec_eb[17] = { 0 };
321 static int autotune_vec_nw[17] = { 0 };
323 static int autotune_vec_tw[17] = { 0 };
325 static int autotune_vec_bw[17] = { 0 };
327 const dim3 nblcks_dmma((*
nelv), 1, 1);
342#define CASE_VECTOR_KSTEP(LX, C) \
343 ax_helm_compr_kernel_vector_kstep<real, LX, NEKO_EB(LX, C)> \
344 <<<NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, stream>>> \
345 ((real *) au, (real *) av, (real *) aw, \
346 (real *) u, (real *) v, (real *) w, \
347 (real *) dx, (real *) dy, (real *) dz, \
348 (real *) h1, (real *) g11, (real *) g22, \
349 (real *) g33, (real *) g12, (real *) g13, \
351 (const int *) ind, *nelv); \
352 CUDA_CHECK(cudaGetLastError());
354#define CASE_VECTOR_KSTEP_PADDED(LX, C) \
355 ax_helm_compr_kernel_vector_kstep_padded<real, LX, NEKO_EB(LX, C)> \
356 <<<NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, stream>>> \
357 ((real *) au, (real *) av, (real *) aw, \
358 (real *) u, (real *) v, (real *) w, \
359 (real *) dx, (real *) dy, (real *) dz, \
360 (real *) h1, (real *) g11, (real *) g22, \
361 (real *) g33, (real *) g12, (real *) g13, \
363 (const int *) ind, *nelv); \
364 CUDA_CHECK(cudaGetLastError());
367#define CASE_VECTOR_KSTEP_SEL(LX, SEL) \
369 case 0: CASE_VECTOR_KSTEP(LX, 0); break; \
370 case 1: CASE_VECTOR_KSTEP(LX, 1); break; \
371 default: CASE_VECTOR_KSTEP(LX, 2); break; \
374#define CASE_VECTOR_KSTEP_PADDED_SEL(LX, SEL) \
376 case 0: CASE_VECTOR_KSTEP_PADDED(LX, 0); break; \
377 case 1: CASE_VECTOR_KSTEP_PADDED(LX, 1); break; \
378 default: CASE_VECTOR_KSTEP_PADDED(LX, 2); break; \
381#define CASE_VECTOR_DMMA(LX, C) \
382 ax_helm_compr_kernel_dmma_vector<real, LX, NEKO_DMMA_NW(C)> \
383 <<<nblcks_dmma, NEKO_DMMA_NTHRDS(C), 0, stream>>> \
384 ((real *) au, (real *) av, (real *) aw, \
385 (real *) u, (real *) v, (real *) w, \
386 (real *) dx, (real *) dy, (real *) dz, \
387 (real *) h1, (real *) g11, (real *) g22, \
388 (real *) g33, (real *) g12, (real *) g13, \
390 (const int *) ind); \
391 CUDA_CHECK(cudaGetLastError());
394#define CASE_VECTOR_DMMA_SEL(LX, SEL) \
396 case 0: CASE_VECTOR_DMMA(LX, 0); break; \
397 case 1: CASE_VECTOR_DMMA(LX, 1); break; \
398 default: CASE_VECTOR_DMMA(LX, 2); break; \
403#define CASE_VECTOR_DMMA_TMA(LX, C) \
404 ax_helm_compr_kernel_dmma_tma_vector<real, LX, NEKO_DMMA_NW(C)> \
405 <<<nblcks_dmma, NEKO_DMMA_NTHRDS(C), 0, stream>>> \
406 ((real *) au, (real *) av, (real *) aw, \
407 (real *) u, (real *) v, (real *) w, \
408 (real *) dx, (real *) dy, (real *) dz, \
409 (real *) h1, (real *) g11, (real *) g22, \
410 (real *) g33, (real *) g12, (real *) g13, \
412 (const int *) ind); \
413 CUDA_CHECK(cudaGetLastError());
416#define CASE_VECTOR_DMMA_TMA_SEL(LX, SEL) \
418 case 0: CASE_VECTOR_DMMA_TMA(LX, 0); break; \
419 case 1: CASE_VECTOR_DMMA_TMA(LX, 1); break; \
420 default: CASE_VECTOR_DMMA_TMA(LX, 2); break; \
430#define CASE_VECTOR_DMMA_TMA_BATCH(LX, C) \
431 (void) ax_helm_compr_dmma_tma_batch_optin<real, LX, NEKO_DMMA_NW(C)>(); \
432 ax_helm_compr_kernel_dmma_tma_batch<real, LX, NEKO_DMMA_NW(C)> \
433 <<<nblcks_dmma, NEKO_DMMA_NTHRDS(C), \
434 NEKO_DMMA_TMA_BATCH_SMEM, stream>>> \
435 ((real *) au, (real *) av, (real *) aw, \
436 (real *) u, (real *) v, (real *) w, \
437 (real *) dx, (real *) dy, (real *) dz, \
438 (real *) h1, (real *) g11, (real *) g22, \
439 (real *) g33, (real *) g12, (real *) g13, \
441 (const int *) ind); \
442 CUDA_CHECK(cudaGetLastError());
445#define CASE_VECTOR_DMMA_TMA_BATCH_SEL(LX, SEL) \
447 case 0: CASE_VECTOR_DMMA_TMA_BATCH(LX, 0); break; \
448 case 1: CASE_VECTOR_DMMA_TMA_BATCH(LX, 1); break; \
449 default: CASE_VECTOR_DMMA_TMA_BATCH(LX, 2); break; \
452#define CASE_VECTOR(LX) \
454 if (autotune_vec[LX] == 0 ) { \
455 autotune_vec[LX] = tune_compr_vector<LX>(au, av, aw, u, v, w, dx, dy, \
456 dz, h1, g11, g22, g33, g12, \
457 g13, g23, ind, nelv, lx, \
458 &autotune_vec_eb[LX], \
459 &autotune_vec_nw[LX], \
460 &autotune_vec_tw[LX], \
461 &autotune_vec_bw[LX]); \
462 } else if (autotune_vec[LX] == 2 ) { \
463 CASE_VECTOR_KSTEP_SEL(LX, autotune_vec_eb[LX]); \
464 } else if (autotune_vec[LX] == 3 ) { \
465 CASE_VECTOR_DMMA_SEL(LX, autotune_vec_nw[LX]); \
466 } else if (autotune_vec[LX] == 4 ) { \
467 CASE_VECTOR_DMMA_TMA_SEL(LX, autotune_vec_tw[LX]); \
468 } else if (autotune_vec[LX] == 5 ) { \
469 CASE_VECTOR_DMMA_TMA_BATCH_SEL(LX, autotune_vec_bw[LX]); \
473#define CASE_VECTOR_PADDED(LX) \
475 if (autotune_vec[LX] == 0 ) { \
476 autotune_vec[LX] = tune_compr_vector_padded<LX>(au, av, aw, u, v, w, \
479 g12, g13, g23, ind, \
481 &autotune_vec_eb[LX], \
482 &autotune_vec_nw[LX], \
483 &autotune_vec_tw[LX], \
484 &autotune_vec_bw[LX]); \
485 } else if (autotune_vec[LX] == 2 ) { \
486 CASE_VECTOR_KSTEP_PADDED_SEL(LX, autotune_vec_eb[LX]); \
487 } else if (autotune_vec[LX] == 3 ) { \
488 CASE_VECTOR_DMMA_SEL(LX, autotune_vec_nw[LX]); \
489 } else if (autotune_vec[LX] == 4 ) { \
490 CASE_VECTOR_DMMA_TMA_SEL(LX, autotune_vec_tw[LX]); \
491 } else if (autotune_vec[LX] == 5 ) { \
492 CASE_VECTOR_DMMA_TMA_BATCH_SEL(LX, autotune_vec_bw[LX]); \
514 fprintf(stderr, __FILE__
": size not supported: %d\n", *lx);
521template < const
int LX >
525 int *eb_sel,
int *ch_sel,
int *nw_sel,
int *tw_sel) {
526 cudaEvent_t start,stop;
567 const dim3 nblcks_1d((*
nelv), 1, 1);
570 char *env_value = NULL;
571 char neko_log_buf[80];
573 env_value=getenv(
"NEKO_AUTOTUNE");
575 sprintf(neko_log_buf,
"Autotune Ax compr (lx: %d)", *lx);
591 if( !strcmp(env_value,
"1D") ) {
593 }
else if( !strcmp(env_value,
"KSTEP") ) {
595 }
else if( !strcmp(env_value,
"DMMA") ) {
599 sprintf(neko_log_buf,
"DMMA strategy not available for this config");
602 }
else if( !strcmp(env_value,
"DMMA_TMA") ) {
606 sprintf(neko_log_buf,
607 "DMMA_TMA strategy not available for this config");
611 sprintf(neko_log_buf,
"Invalid value set for NEKO_AUTOTUNE");
619 const int pin = (strat == 1) ? ch_pin : (strat == 2) ? eb_pin :
620 (strat == 3) ? nw_pin : (strat == 4) ? tw_pin : -1;
627 sprintf(neko_log_buf,
"Set by env : 1 (1D, %d chunk)",
633 sprintf(neko_log_buf,
"Set by env : 2 (KSTEP, %d elem/block)",
639 sprintf(neko_log_buf,
"Set by env : 3 (DMMA, %d warps)",
645 sprintf(neko_log_buf,
"Set by env : 4 (DMMA_TMA, %d warps)",
655 sprintf(neko_log_buf,
"Set by env : %d (%s)", strat, env_value);
660 const bool try_1d = (strat == 0 || strat == 1);
661 const bool try_kstep = (strat == 0 || strat == 2);
662 const bool try_dmma = dmma && (strat == 0 || strat == 3);
663 const bool try_tma = tma && (strat == 0 || strat == 4);
665 cudaEventCreate(&start);
666 cudaEventCreate(&stop);
688 for (
int r = 0; r < rounds; r++) {
716 if (time1[best1] < time2[best]) {
724 float tbest = (retval == 1) ? time1[best1] : time2[best];
726 if (time3[best3] < tbest) {
728 tbest = time3[best3];
730 if (time4[best4] < tbest) {
734 cudaEventDestroy(start);
735 cudaEventDestroy(stop);
741 }
else if (retval == 2) {
743 }
else if (retval == 3) {
750 sprintf(neko_log_buf,
"Chose : 1 (1D, %d chunk)",
752 }
else if (retval == 2) {
753 sprintf(neko_log_buf,
"Chose : 2 (KSTEP, %d elem/block)",
755 }
else if (retval == 3) {
756 sprintf(neko_log_buf,
"Chose : 3 (DMMA, %d warps, %d elem/blk)",
759 sprintf(neko_log_buf,
"Chose : 4 (DMMA_TMA, %d warps)",
767template < const
int LX >
771 int *
nelv,
int *lx,
int *eb_sel,
int *ch_sel,
int *nw_sel,
773 cudaEvent_t start, stop;
812 const dim3 nblcks_1d((*
nelv), 1, 1);
815 char *env_value = NULL;
816 char neko_log_buf[80];
818 env_value=getenv(
"NEKO_AUTOTUNE");
820 sprintf(neko_log_buf,
"Autotune Ax compr (lx: %d)", *lx);
830 if( !strcmp(env_value,
"1D") ) {
832 }
else if( !strcmp(env_value,
"KSTEP") ) {
834 }
else if( !strcmp(env_value,
"DMMA") ) {
838 sprintf(neko_log_buf,
"DMMA strategy not available for this config");
841 }
else if( !strcmp(env_value,
"DMMA_TMA") ) {
845 sprintf(neko_log_buf,
846 "DMMA_TMA strategy not available for this config");
850 sprintf(neko_log_buf,
"Invalid value set for NEKO_AUTOTUNE");
856 const int pin = (strat == 1) ? ch_pin : (strat == 2) ? eb_pin :
857 (strat == 3) ? nw_pin : (strat == 4) ? tw_pin : -1;
864 sprintf(neko_log_buf,
"Set by env : 1 (1D, %d chunk)",
870 sprintf(neko_log_buf,
"Set by env : 2 (KSTEP, %d elem/block)",
876 sprintf(neko_log_buf,
"Set by env : 3 (DMMA, %d warps)",
882 sprintf(neko_log_buf,
"Set by env : 4 (DMMA_TMA, %d warps)",
892 sprintf(neko_log_buf,
"Set by env : %d (%s)", strat, env_value);
897 const bool try_1d = (strat == 0 || strat == 1);
898 const bool try_kstep = (strat == 0 || strat == 2);
899 const bool try_dmma = dmma && (strat == 0 || strat == 3);
900 const bool try_tma = tma && (strat == 0 || strat == 4);
902 cudaEventCreate(&start);
903 cudaEventCreate(&stop);
925 for (
int r = 0; r < rounds; r++) {
953 if (time1[best1] < time2[best]) {
961 float tbest = (retval == 1) ? time1[best1] : time2[best];
963 if (time3[best3] < tbest) {
965 tbest = time3[best3];
967 if (time4[best4] < tbest) {
971 cudaEventDestroy(start);
972 cudaEventDestroy(stop);
977 }
else if (retval == 2) {
979 }
else if (retval == 3) {
986 sprintf(neko_log_buf,
"Chose : 1 (1D, %d chunk)",
988 }
else if (retval == 2) {
989 sprintf(neko_log_buf,
"Chose : 2 (KSTEP, %d elem/block)",
991 }
else if (retval == 3) {
992 sprintf(neko_log_buf,
"Chose : 3 (DMMA, %d warps, %d elem/blk)",
995 sprintf(neko_log_buf,
"Chose : 4 (DMMA_TMA, %d warps)",
1019template < const
int LX >
1021 void *
dx,
void *
dy,
void *
dz,
void *
h1,
void *
g11,
1023 void *
ind,
int *
nelv,
int *lx,
int *eb_sel,
int *nw_sel,
1024 int *tw_sel,
int *bw_sel) {
1025 cudaEvent_t start, stop;
1067 const dim3 nblcks_dmma((*
nelv), 1, 1);
1070 char *env_value = NULL;
1071 char neko_log_buf[80];
1073 env_value=getenv(
"NEKO_AUTOTUNE");
1075 sprintf(neko_log_buf,
"Autotune Ax compr vec (lx: %d)", *lx);
1085 if( !strcmp(env_value,
"KSTEP") || !strcmp(env_value,
"1D") ) {
1088 }
else if( !strcmp(env_value,
"DMMA") ) {
1092 sprintf(neko_log_buf,
"DMMA strategy not available for this config");
1095 }
else if( !strcmp(env_value,
"DMMA_TMA") ) {
1099 sprintf(neko_log_buf,
1100 "DMMA_TMA strategy not available for this config");
1103 }
else if( !strcmp(env_value,
"DMMA_TMA_BATCH") ) {
1107 sprintf(neko_log_buf,
1108 "DMMA_TMA_BATCH strategy not available for this config");
1112 sprintf(neko_log_buf,
"Invalid value set for NEKO_AUTOTUNE");
1119 const int pin = (strat == 2) ? eb_pin : (strat == 3) ? nw_pin :
1120 (strat == 4 || strat == 5) ? tw_pin : -1;
1127 sprintf(neko_log_buf,
"Set by env : 2 (KSTEP, %d elem/block)",
1133 sprintf(neko_log_buf,
"Set by env : 3 (DMMA, %d warps)",
1139 sprintf(neko_log_buf,
"Set by env : 4 (DMMA_TMA, %d warps)",
1145 sprintf(neko_log_buf,
"Set by env : 5 (DMMA_TMA_BATCH, %d warps)",
1155 sprintf(neko_log_buf,
"Set by env : %d (%s)", strat, env_value);
1160 const bool try_kstep = (strat == 0 || strat == 2);
1161 const bool try_dmma = dmma && (strat == 0 || strat == 3);
1162 const bool try_tma = tma && (strat == 0 || strat == 4);
1163 const bool try_batch = batch && (strat == 0 || strat == 5);
1165 cudaEventCreate(&start);
1166 cudaEventCreate(&stop);
1184 for (
int r = 0; r < rounds; r++) {
1201 sprintf(neko_log_buf,
"KSTEP eb=%-4d: %9.2f us/call",
1220 float tbest = time2[best2];
1223 if (time3[best3] < tbest) { retval = 3; tbest = time3[best3]; }
1224 if (time4[best4] < tbest) { retval = 4; tbest = time4[best4]; }
1225 if (time5[best5] < tbest) { retval = 5; }
1227 cudaEventDestroy(start);
1228 cudaEventDestroy(stop);
1235 sprintf(neko_log_buf,
"Chose : 2 (KSTEP, %d elem/block)",
1237 }
else if (retval == 3) {
1239 sprintf(neko_log_buf,
"Chose : 3 (DMMA, %d warps, %d elem/blk)",
1241 }
else if (retval == 4) {
1243 sprintf(neko_log_buf,
"Chose : 4 (DMMA_TMA, %d warps)",
1247 sprintf(neko_log_buf,
"Chose : 5 (DMMA_TMA_BATCH, %d warps)",
1257template < const
int LX >
1259 void *
w,
void *
dx,
void *
dy,
void *
dz,
void *
h1,
1262 int *lx,
int *eb_sel,
int *nw_sel,
int *tw_sel,
1264 cudaEvent_t start, stop;
1306 const dim3 nblcks_dmma((*
nelv), 1, 1);
1309 char *env_value = NULL;
1310 char neko_log_buf[80];
1312 env_value=getenv(
"NEKO_AUTOTUNE");
1314 sprintf(neko_log_buf,
"Autotune Ax compr vec (lx: %d)", *lx);
1324 if( !strcmp(env_value,
"KSTEP") || !strcmp(env_value,
"1D") ) {
1327 }
else if( !strcmp(env_value,
"DMMA") ) {
1331 sprintf(neko_log_buf,
"DMMA strategy not available for this config");
1334 }
else if( !strcmp(env_value,
"DMMA_TMA") ) {
1338 sprintf(neko_log_buf,
1339 "DMMA_TMA strategy not available for this config");
1342 }
else if( !strcmp(env_value,
"DMMA_TMA_BATCH") ) {
1346 sprintf(neko_log_buf,
1347 "DMMA_TMA_BATCH strategy not available for this config");
1351 sprintf(neko_log_buf,
"Invalid value set for NEKO_AUTOTUNE");
1358 const int pin = (strat == 2) ? eb_pin : (strat == 3) ? nw_pin :
1359 (strat == 4 || strat == 5) ? tw_pin : -1;
1366 sprintf(neko_log_buf,
"Set by env : 2 (KSTEP, %d elem/block)",
1372 sprintf(neko_log_buf,
"Set by env : 3 (DMMA, %d warps)",
1378 sprintf(neko_log_buf,
"Set by env : 4 (DMMA_TMA, %d warps)",
1384 sprintf(neko_log_buf,
"Set by env : 5 (DMMA_TMA_BATCH, %d warps)",
1394 sprintf(neko_log_buf,
"Set by env : %d (%s)", strat, env_value);
1399 const bool try_kstep = (strat == 0 || strat == 2);
1400 const bool try_dmma = dmma && (strat == 0 || strat == 3);
1401 const bool try_tma = tma && (strat == 0 || strat == 4);
1402 const bool try_batch = batch && (strat == 0 || strat == 5);
1404 cudaEventCreate(&start);
1405 cudaEventCreate(&stop);
1423 for (
int r = 0; r < rounds; r++) {
1440 sprintf(neko_log_buf,
"KSTEP eb=%-4d: %9.2f us/call",
1459 float tbest = time2[best2];
1462 if (time3[best3] < tbest) { retval = 3; tbest = time3[best3]; }
1463 if (time4[best4] < tbest) { retval = 4; tbest = time4[best4]; }
1464 if (time5[best5] < tbest) { retval = 5; }
1466 cudaEventDestroy(start);
1467 cudaEventDestroy(stop);
1472 sprintf(neko_log_buf,
"Chose : 2 (KSTEP, %d elem/block)",
1474 }
else if (retval == 3) {
1476 sprintf(neko_log_buf,
"Chose : 3 (DMMA, %d warps, %d elem/blk)",
1478 }
else if (retval == 4) {
1480 sprintf(neko_log_buf,
"Chose : 4 (DMMA_TMA, %d warps)",
1484 sprintf(neko_log_buf,
"Chose : 5 (DMMA_TMA_BATCH, %d warps)",
#define CASE_DMMA_SEL(LX, SEL)
#define CASE_KSTEP_SEL(LX, SEL)
#define CASE_1D_SEL(LX, SEL)
#define CASE_KSTEP_PADDED_SEL(LX, SEL)
#define CASE_DMMA_TMA_SEL(LX, SEL)
#define CASE_VECTOR_DMMA_TMA_SEL(LX, SEL)
#define CASE_VECTOR_KSTEP_SEL(LX, SEL)
#define CASE_VECTOR_KSTEP_PADDED_SEL(LX, SEL)
#define CASE_VECTOR_DMMA_TMA_BATCH_SEL(LX, SEL)
#define CASE_VECTOR_DMMA_SEL(LX, SEL)
void cuda_ax_helm_compr_vector(void *au, void *av, void *aw, void *u, void *v, void *w, void *dx, void *dy, void *dz, void *dxt, void *dyt, void *dzt, void *h1, void *g11, void *g22, void *g33, void *g12, void *g13, void *g23, void *ind, int *nelv, int *lx)
#define CASE_DMMA_SEL(LX, SEL)
#define CASE_KSTEP_SEL(LX, SEL)
int tune_compr_vector_padded(void *au, void *av, void *aw, void *u, void *v, void *w, void *dx, void *dy, void *dz, void *h1, void *g11, void *g22, void *g33, void *g12, void *g13, void *g23, void *ind, int *nelv, int *lx, int *eb_sel, int *nw_sel, int *tw_sel, int *bw_sel)
int tune_compr(void *w, void *u, void *dx, void *dy, void *dz, void *dxt, void *dyt, void *dzt, void *h1, void *g11, void *g22, void *g33, void *g12, void *g13, void *g23, void *ind, int *nelv, int *lx, int *eb_sel, int *ch_sel, int *nw_sel, int *tw_sel)
#define CASE_1D_SEL(LX, SEL)
#define CASE_KSTEP_PADDED_SEL(LX, SEL)
#define CASE_DMMA_TMA_SEL(LX, SEL)
#define CASE_LARGE_PADDED(LX)
void cuda_ax_helm_compr(void *w, void *u, void *dx, void *dy, void *dz, void *dxt, void *dyt, void *dzt, void *h1, void *g11, void *g22, void *g33, void *g12, void *g13, void *g23, void *ind, int *nelv, int *lx)
#define CASE_VECTOR_DMMA_TMA_SEL(LX, SEL)
#define CASE_VECTOR_KSTEP_SEL(LX, SEL)
#define CASE_VECTOR_PADDED(LX)
int tune_compr_padded(void *w, void *u, void *dx, void *dy, void *dz, void *dxt, void *dyt, void *dzt, void *h1, void *g11, void *g22, void *g33, void *g12, void *g13, void *g23, void *ind, int *nelv, int *lx, int *eb_sel, int *ch_sel, int *nw_sel, int *tw_sel)
int tune_compr_vector(void *au, void *av, void *aw, void *u, void *v, void *w, void *dx, void *dy, void *dz, void *h1, void *g11, void *g22, void *g33, void *g12, void *g13, void *g23, void *ind, int *nelv, int *lx, int *eb_sel, int *nw_sel, int *tw_sel, int *bw_sel)
#define CASE_VECTOR_KSTEP_PADDED_SEL(LX, SEL)
#define CASE_VECTOR_DMMA_TMA_BATCH_SEL(LX, SEL)
#define CASE_VECTOR_DMMA_SEL(LX, SEL)
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g23
__global__ void T *__restrict__ T *__restrict__ aw
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g22
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const int *__restrict__ ind
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g13
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const int *__restrict__ const int nelv
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g12
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dz
__global__ void const T *__restrict__ const T *__restrict__ dx
__global__ void const T *__restrict__ u
__global__ void T *__restrict__ av
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ dy
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g33
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ v
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g11
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ h1
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dyt
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dzt
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dxt
#define NEKO_CHUNKS_CANDIDATES
#define NEKO_EB_CANDIDATES
#define NEKO_EB_SEL(LX, SEL)
#define NEKO_CHUNKS_SEL(LX, SEL)
static int neko_chunks_pin()
#define NEKO_TUNE_TIME(T, LAUNCH, LX, C, ITERS)
#define NEKO_TUNE_US(T, ITERS)
static int neko_tune_rounds()
#define NEKO_TUNE_LOG(LX, T1, T2)
#define NEKO_TUNE_BEST(T, BEST, N)
static int neko_tune_iters()
#define NEKO_TUNE_FOR(C, ON, PIN, N)
static int neko_eb_sweep()
#define NEKO_DMMA_CANDIDATES
static bool dmma_vector_lx_supported()
static bool cuda_have_dmma()
#define NEKO_DMMA_PACK(LX)
static bool dmma_lx_supported()
#define NEKO_TUNE_LOG_DMMA(LX, T3)
static int neko_dmma_pin()
#define NEKO_TUNE_LOG_DMMA_TMA_BATCH(LX, T5)
static bool dmma_tma_aligned(const void *w, const void *u, const void *h1, const void *g11, const void *g22, const void *g33, const void *g12, const void *g13, const void *g23)
static bool dmma_tma_vector_aligned(const void *au, const void *av, const void *aw, const void *u, const void *v, const void *w, const void *h1, const void *g11, const void *g22, const void *g33, const void *g12, const void *g13, const void *g23)
static bool cuda_have_tma_batch()
static bool dmma_tma_batch_lx_supported()
#define NEKO_TUNE_LOG_DMMA_TMA(LX, T4)
static bool dmma_tma_vector_lx_supported()
static bool dmma_tma_lx_supported()
static int neko_dmma_tma_pin()
static bool cuda_have_tma()
void log_error(char *msg)
void log_message(char *msg)
void log_section(char *msg)