38#include <hip/hip_runtime.h>
64 void *
dx,
void *
dy,
void *
dz,
void *
h1,
71 void *
u,
void *
v,
void *
w,
72 void *
dx,
void *
dy,
void *
dz,
void *
h1,
99#define CASE_1D(LX, C) \
100 hipLaunchKernelGGL(HIP_KERNEL_NAME( \
101 ax_helm_kernel_1d<real, LX, NEKO_CHUNKS(LX, C)> ), \
102 nblcks_1d, NEKO_CHUNKS_NTHRDS(LX, C), 0, \
103 (hipStream_t) glb_cmd_queue, \
104 (real *) w, (real *) u, \
105 (real *) dx, (real *) dy, (real *) dz, \
106 (real *) dxt, (real *) dyt, (real *) dzt, (real *) h1, \
107 (real *) g11, (real *) g22, (real *) g33, \
108 (real *) g12, (real *) g13, (real *) g23); \
109 HIP_CHECK(hipGetLastError());
112#define CASE_1D_SEL(LX, SEL) \
114 case 0: CASE_1D(LX, 0); break; \
115 case 1: CASE_1D(LX, 1); break; \
116 case 2: CASE_1D(LX, 2); break; \
117 default: CASE_1D(LX, 3); break; \
120#define CASE_KSTEP(LX, C) \
121 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
122 ax_helm_kernel_kstep<real, LX, NEKO_EB(LX, C)> ), \
123 NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, \
124 (hipStream_t) glb_cmd_queue, \
125 (real *) w, (real *) u, \
126 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
127 (real *) g11, (real *) g22, (real *) g33, \
128 (real *) g12, (real *) g13, (real *) g23, *nelv); \
129 HIP_CHECK(hipGetLastError());
131#define CASE_KSTEP_PADDED(LX, C) \
132 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
133 ax_helm_kernel_kstep_padded<real, LX, NEKO_EB(LX, C)> ),\
134 NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, \
135 (hipStream_t) glb_cmd_queue, \
136 (real *) w, (real *) u, \
137 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
138 (real *) g11, (real *) g22, (real *) g33, \
139 (real *) g12, (real *) g13, (real *) g23, *nelv); \
140 HIP_CHECK(hipGetLastError());
142#define CASE_MFMA(LX, C) \
143 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
144 ax_helm_kernel_mfma<real, LX, NEKO_MFMA_NWF(C), \
145 NEKO_MFMA_TILE(C)> ), \
146 NEKO_MFMA_NBLCKS(*nelv, LX, C), NEKO_MFMA_NTHRDS(C), 0, \
147 (hipStream_t) glb_cmd_queue, \
148 (real *) w, (real *) u, \
149 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
150 (real *) g11, (real *) g22, (real *) g33, \
151 (real *) g12, (real *) g13, (real *) g23, *nelv); \
152 HIP_CHECK(hipGetLastError());
156#define CASE_MFMA_SEL(LX, SEL) \
158 case 0: CASE_MFMA(LX, 0); break; \
159 case 1: CASE_MFMA(LX, 1); break; \
160 case 2: CASE_MFMA(LX, 2); break; \
161 case 3: CASE_MFMA(LX, 3); break; \
162 case 4: CASE_MFMA(LX, 4); break; \
163 case 5: CASE_MFMA(LX, 5); break; \
164 case 6: CASE_MFMA(LX, 6); break; \
165 case 7: CASE_MFMA(LX, 7); break; \
166 case 8: CASE_MFMA(LX, 8); break; \
167 default: CASE_MFMA(LX, 9); break; \
177 "CASE_MFMA_SEL does not cover the candidate space");
180#define CASE_KSTEP_SEL(LX, SEL) \
182 case 0: CASE_KSTEP(LX, 0); break; \
183 case 1: CASE_KSTEP(LX, 1); break; \
184 default: CASE_KSTEP(LX, 2); break; \
187#define CASE_KSTEP_PADDED_SEL(LX, SEL) \
189 case 0: CASE_KSTEP_PADDED(LX, 0); break; \
190 case 1: CASE_KSTEP_PADDED(LX, 1); break; \
191 default: CASE_KSTEP_PADDED(LX, 2); break; \
196 if(autotune[LX] == 0 ) { \
197 autotune[LX]=tune<LX>( w, u, \
201 g12, g13, g23, nelv, lx, \
202 &autotune_eb[LX], &autotune_ch[LX], \
203 &autotune_nwf[LX]); \
204 } else if (autotune[LX] == 1 ) { \
205 CASE_1D_SEL(LX, autotune_ch[LX]); \
206 } else if (autotune[LX] == 2 ) { \
207 CASE_KSTEP_SEL(LX, autotune_eb[LX]); \
208 } else if (autotune[LX] == 3 ) { \
209 CASE_MFMA_SEL(LX, autotune_nwf[LX]); \
213#define CASE_PADDED(LX) \
215 if(autotune[LX] == 0 ) { \
216 autotune[LX]=tune_padded<LX>(w, u, \
220 g12, g13, g23,nelv,lx, \
221 &autotune_eb[LX], &autotune_ch[LX], \
222 &autotune_nwf[LX]); \
223 } else if (autotune[LX] == 1 ) { \
224 CASE_1D_SEL(LX, autotune_ch[LX]); \
225 } else if (autotune[LX] == 2 ) { \
226 CASE_KSTEP_PADDED_SEL(LX, autotune_eb[LX]); \
227 } else if (autotune[LX] == 3 ) { \
228 CASE_MFMA_SEL(LX, autotune_nwf[LX]); \
237#define CASE_LARGE(LX) \
242#define CASE_LARGE_PADDED(LX) \
244 CASE_KSTEP_PADDED(LX, 0); \
285 void *
u,
void *
v,
void *
w,
286 void *
dx,
void *
dy,
void *
dz,
290 void *
g23,
int *
nelv,
int *lx) {
301#define CASE_VECTOR_KSTEP(LX, C) \
302 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
303 ax_helm_kernel_vector_kstep<real, LX, \
305 NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, \
306 (hipStream_t) glb_cmd_queue, \
307 (real *) au, (real *) av, (real *) aw, \
308 (real *) u, (real *) v, (real *) w, \
309 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
310 (real *) g11, (real *) g22, (real *) g33, \
311 (real *) g12, (real *) g13, (real *) g23, *nelv); \
312 HIP_CHECK(hipGetLastError());
314#define CASE_VECTOR_KSTEP_PADDED(LX, C) \
315 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
316 ax_helm_kernel_vector_kstep_padded<real, LX, \
318 NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, \
319 (hipStream_t) glb_cmd_queue, \
320 (real *) au, (real *) av, (real *) aw, \
321 (real *) u, (real *) v, (real *) w, \
322 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
323 (real *) g11, (real *) g22, (real *) g33, \
324 (real *) g12, (real *) g13, (real *) g23, *nelv); \
325 HIP_CHECK(hipGetLastError());
329#define CASE_VECTOR_MFMA(LX, C) \
330 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
331 ax_helm_kernel_mfma_vector<real, LX, \
333 NEKO_MFMA_TILE(C)> ), \
334 NEKO_MFMA_NBLCKS(*nelv, LX, C), NEKO_MFMA_NTHRDS(C), 0, \
335 (hipStream_t) glb_cmd_queue, \
336 (real *) au, (real *) av, (real *) aw, \
337 (real *) u, (real *) v, (real *) w, \
338 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
339 (real *) g11, (real *) g22, (real *) g33, \
340 (real *) g12, (real *) g13, (real *) g23, *nelv); \
341 HIP_CHECK(hipGetLastError());
343#define CASE_VECTOR_KSTEP_SEL(LX, SEL) \
345 case 0: CASE_VECTOR_KSTEP(LX, 0); break; \
346 case 1: CASE_VECTOR_KSTEP(LX, 1); break; \
347 default: CASE_VECTOR_KSTEP(LX, 2); break; \
350#define CASE_VECTOR_KSTEP_PADDED_SEL(LX, SEL) \
352 case 0: CASE_VECTOR_KSTEP_PADDED(LX, 0); break; \
353 case 1: CASE_VECTOR_KSTEP_PADDED(LX, 1); break; \
354 default: CASE_VECTOR_KSTEP_PADDED(LX, 2); break; \
358#define CASE_VECTOR_MFMA_SEL(LX, SEL) \
360 case 0: CASE_VECTOR_MFMA(LX, 0); break; \
361 case 1: CASE_VECTOR_MFMA(LX, 1); break; \
362 case 2: CASE_VECTOR_MFMA(LX, 2); break; \
363 case 3: CASE_VECTOR_MFMA(LX, 3); break; \
364 case 4: CASE_VECTOR_MFMA(LX, 4); break; \
365 case 5: CASE_VECTOR_MFMA(LX, 5); break; \
366 case 6: CASE_VECTOR_MFMA(LX, 6); break; \
367 case 7: CASE_VECTOR_MFMA(LX, 7); break; \
368 case 8: CASE_VECTOR_MFMA(LX, 8); break; \
369 default: CASE_VECTOR_MFMA(LX, 9); break; \
379 "CASE_VECTOR_MFMA_SEL does not cover the candidate space");
381#define CASE_VECTOR(LX) \
383 if (autotune_v[LX] == 0) { \
384 autotune_v[LX] = tune_vector<LX>(au, av, aw, u, v, w, \
387 g12, g13, g23, nelv, lx, \
388 &autotune_v_eb[LX], \
389 &autotune_v_nwf[LX]); \
390 } else if (autotune_v[LX] == 2) { \
391 CASE_VECTOR_KSTEP_SEL(LX, autotune_v_eb[LX]); \
392 } else if (autotune_v[LX] == 3) { \
393 CASE_VECTOR_MFMA_SEL(LX, autotune_v_nwf[LX]); \
397#define CASE_VECTOR_PADDED(LX) \
399 if (autotune_v[LX] == 0) { \
400 autotune_v[LX] = tune_vector_padded<LX>(au, av, aw, u, v, w, \
403 g12, g13, g23, nelv, lx, \
404 &autotune_v_eb[LX], \
405 &autotune_v_nwf[LX]); \
406 } else if (autotune_v[LX] == 2) { \
407 CASE_VECTOR_KSTEP_PADDED_SEL(LX, autotune_v_eb[LX]); \
408 } else if (autotune_v[LX] == 3) { \
409 CASE_VECTOR_MFMA_SEL(LX, autotune_v_nwf[LX]); \
441 void *
u,
void *
v,
void *
w,
442 void *h2,
void *B,
int *n) {
445 const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
457template < const
int LX >
603 for (
int r = 0; r <
rounds; r++) {
666template < const
int LX >
801 for (
int r = 0; r <
rounds; r++) {
877template < const
int LX >
879 void *
dx,
void *
dy,
void *
dz,
void *
h1,
1000 for (
int r = 0; r <
rounds; r++) {
1044template < const
int LX >
1046 void *
u,
void *
v,
void *
w,
1047 void *
dx,
void *
dy,
void *
dz,
void *
h1,
1167 for (
int r = 0; r <
rounds; r++) {
int tune_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, int *nelv, int *lx, int *eb_sel, int *ch_sel, int *nwf_sel)
#define CASE_VECTOR_MFMA_SEL(LX, SEL)
#define CASE_KSTEP_SEL(LX, SEL)
void hip_ax_helm_vector_part2(void *au, void *av, void *aw, void *u, void *v, void *w, void *h2, void *B, int *n)
#define CASE_1D_SEL(LX, SEL)
#define CASE_VECTOR_KSTEP(LX, C)
#define CASE_MFMA_SEL(LX, SEL)
#define CASE_KSTEP_PADDED_SEL(LX, SEL)
void hip_ax_helm_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, int *nelv, int *lx)
void hip_ax_helm(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, int *nelv, int *lx)
#define CASE_LARGE_PADDED(LX)
int tune_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, int *nelv, int *lx, int *eb_sel, int *nwf_sel)
#define CASE_VECTOR_KSTEP_PADDED(LX, C)
#define CASE_VECTOR_KSTEP_SEL(LX, SEL)
#define CASE_VECTOR_PADDED(LX)
#define CASE_VECTOR_KSTEP_PADDED_SEL(LX, SEL)
int tune(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, int *nelv, int *lx, int *eb_sel, int *ch_sel, int *nwf_sel)
int tune_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, int *nelv, int *lx, int *eb_sel, int *nwf_sel)
__global__ void ale_add_kinematics_kernel(const int n, T *__restrict__ wx, T *__restrict__ wy, T *__restrict__ wz, const T *__restrict__ x_ref, const T *__restrict__ y_ref, const T *__restrict__ z_ref, const T *__restrict__ phi, const T *__restrict__ x, const T *__restrict__ y, const T *__restrict__ z, const kinematics_params_t kin_params)
__global__ void T *__restrict__ T *__restrict__ aw
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ u
__global__ void T *__restrict__ av
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ v
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ 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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g23
__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__ g13
__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 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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g33
__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__ 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)
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_TUNE_LOG_KSTEP(LX, T2)
#define NEKO_TUNE_LOG_MFMA_VEC(LX, T3)
#define NEKO_TUNE_LOG_MFMA(LX, T3)
static const char * mfma_tile_name(const int c)
#define NEKO_MFMA_CANDIDATES
static int neko_mfma_pin()
static int neko_mfma_candidates()
static bool hip_have_mfma()
#define NEKO_MFMA_EB(LX, C)
static int neko_mfma_sweep()
void log_error(char *msg)
void log_message(char *msg)
void log_section(char *msg)