38#include <hip/hip_runtime.h>
64 void *
dx,
void *
dy,
void *
dz,
void *
h1,
70 void *
u,
void *
v,
void *
w,
71 void *
dx,
void *
dy,
void *
dz,
void *
h1,
97#define CASE_1D(LX, C) \
98 hipLaunchKernelGGL(HIP_KERNEL_NAME( \
99 ax_helm_kernel_1d<real, LX, NEKO_CHUNKS(LX, C)> ), \
100 nblcks_1d, NEKO_CHUNKS_NTHRDS(LX, C), 0, \
101 (hipStream_t) glb_cmd_queue, \
102 (real *) w, (real *) u, \
103 (real *) dx, (real *) dy, (real *) dz, \
104 (real *) dxt, (real *) dyt, (real *) dzt, (real *) h1, \
105 (real *) g11, (real *) g22, (real *) g33, \
106 (real *) g12, (real *) g13, (real *) g23); \
107 HIP_CHECK(hipGetLastError());
110#define CASE_1D_SEL(LX, SEL) \
112 case 0: CASE_1D(LX, 0); break; \
113 case 1: CASE_1D(LX, 1); break; \
114 case 2: CASE_1D(LX, 2); break; \
115 default: CASE_1D(LX, 3); break; \
118#define CASE_KSTEP(LX, C) \
119 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
120 ax_helm_kernel_kstep<real, LX, NEKO_EB(LX, C)> ), \
121 NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, \
122 (hipStream_t) glb_cmd_queue, \
123 (real *) w, (real *) u, \
124 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
125 (real *) g11, (real *) g22, (real *) g33, \
126 (real *) g12, (real *) g13, (real *) g23, *nelv); \
127 HIP_CHECK(hipGetLastError());
129#define CASE_KSTEP_PADDED(LX, C) \
130 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
131 ax_helm_kernel_kstep_padded<real, LX, NEKO_EB(LX, C)> ),\
132 NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, \
133 (hipStream_t) glb_cmd_queue, \
134 (real *) w, (real *) u, \
135 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
136 (real *) g11, (real *) g22, (real *) g33, \
137 (real *) g12, (real *) g13, (real *) g23, *nelv); \
138 HIP_CHECK(hipGetLastError());
140#define CASE_MFMA(LX, C) \
141 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
142 ax_helm_kernel_mfma<real, LX, NEKO_MFMA_NWF(C)> ), \
143 NEKO_MFMA_NBLCKS(*nelv, LX, C), NEKO_MFMA_NTHRDS(C), 0, \
144 (hipStream_t) glb_cmd_queue, \
145 (real *) w, (real *) u, \
146 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
147 (real *) g11, (real *) g22, (real *) g33, \
148 (real *) g12, (real *) g13, (real *) g23, *nelv); \
149 HIP_CHECK(hipGetLastError());
152#define CASE_MFMA_SEL(LX, SEL) \
154 case 0: CASE_MFMA(LX, 0); break; \
155 case 1: CASE_MFMA(LX, 1); break; \
156 case 2: CASE_MFMA(LX, 2); break; \
157 default: CASE_MFMA(LX, 3); break; \
161#define CASE_KSTEP_SEL(LX, SEL) \
163 case 0: CASE_KSTEP(LX, 0); break; \
164 case 1: CASE_KSTEP(LX, 1); break; \
165 default: CASE_KSTEP(LX, 2); break; \
168#define CASE_KSTEP_PADDED_SEL(LX, SEL) \
170 case 0: CASE_KSTEP_PADDED(LX, 0); break; \
171 case 1: CASE_KSTEP_PADDED(LX, 1); break; \
172 default: CASE_KSTEP_PADDED(LX, 2); break; \
177 if(autotune[LX] == 0 ) { \
178 autotune[LX]=tune<LX>( w, u, \
182 g12, g13, g23, nelv, lx, \
183 &autotune_eb[LX], &autotune_ch[LX], \
184 &autotune_nwf[LX]); \
185 } else if (autotune[LX] == 1 ) { \
186 CASE_1D_SEL(LX, autotune_ch[LX]); \
187 } else if (autotune[LX] == 2 ) { \
188 CASE_KSTEP_SEL(LX, autotune_eb[LX]); \
189 } else if (autotune[LX] == 3 ) { \
190 CASE_MFMA_SEL(LX, autotune_nwf[LX]); \
194#define CASE_PADDED(LX) \
196 if(autotune[LX] == 0 ) { \
197 autotune[LX]=tune_padded<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_PADDED_SEL(LX, autotune_eb[LX]); \
208 } else if (autotune[LX] == 3 ) { \
209 CASE_MFMA_SEL(LX, autotune_nwf[LX]); \
218#define CASE_LARGE(LX) \
223#define CASE_LARGE_PADDED(LX) \
225 CASE_KSTEP_PADDED(LX, 0); \
266 void *
u,
void *
v,
void *
w,
267 void *
dx,
void *
dy,
void *
dz,
271 void *
g23,
int *
nelv,
int *lx) {
278#define CASE_VECTOR_KSTEP(LX, C) \
279 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
280 ax_helm_kernel_vector_kstep<real, LX, \
282 NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, \
283 (hipStream_t) glb_cmd_queue, \
284 (real *) au, (real *) av, (real *) aw, \
285 (real *) u, (real *) v, (real *) w, \
286 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
287 (real *) g11, (real *) g22, (real *) g33, \
288 (real *) g12, (real *) g13, (real *) g23, *nelv); \
289 HIP_CHECK(hipGetLastError());
291#define CASE_VECTOR_KSTEP_PADDED(LX, C) \
292 hipLaunchKernelGGL( HIP_KERNEL_NAME( \
293 ax_helm_kernel_vector_kstep_padded<real, LX, \
295 NEKO_EB_NBLCKS(*nelv, LX, C), NEKO_EB_NTHRDS(LX, C), 0, \
296 (hipStream_t) glb_cmd_queue, \
297 (real *) au, (real *) av, (real *) aw, \
298 (real *) u, (real *) v, (real *) w, \
299 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
300 (real *) g11, (real *) g22, (real *) g33, \
301 (real *) g12, (real *) g13, (real *) g23, *nelv); \
302 HIP_CHECK(hipGetLastError());
304#define CASE_VECTOR_SEL(LX, SEL) \
306 case 0: CASE_VECTOR_KSTEP(LX, 0); break; \
307 case 1: CASE_VECTOR_KSTEP(LX, 1); break; \
308 default: CASE_VECTOR_KSTEP(LX, 2); break; \
311#define CASE_VECTOR_PADDED_SEL(LX, SEL) \
313 case 0: CASE_VECTOR_KSTEP_PADDED(LX, 0); break; \
314 case 1: CASE_VECTOR_KSTEP_PADDED(LX, 1); break; \
315 default: CASE_VECTOR_KSTEP_PADDED(LX, 2); break; \
318#define CASE_VECTOR(LX) \
320 if (autotune_v[LX] == 0) { \
321 autotune_v[LX] = 1 + tune_vector<LX>(au, av, aw, u, v, w, \
324 g12, g13, g23, nelv, lx); \
326 CASE_VECTOR_SEL(LX, autotune_v[LX] - 1); \
330#define CASE_VECTOR_PADDED(LX) \
332 if (autotune_v[LX] == 0) { \
333 autotune_v[LX] = 1 + tune_vector_padded<LX>(au, av, aw, u, v, w, \
336 g12, g13, g23, nelv, lx); \
338 CASE_VECTOR_PADDED_SEL(LX, autotune_v[LX] - 1); \
370 void *
u,
void *
v,
void *
w,
371 void *h2,
void *B,
int *n) {
374 const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
386template < const
int LX >
497 for (
int r = 0; r <
rounds; r++) {
565template < const
int LX >
676 for (
int r = 0; r <
rounds; r++) {
753template < const
int LX >
755 void *
dx,
void *
dy,
void *
dz,
void *
h1,
782 if (
getenv(
"NEKO_AUTOTUNE") ||
802 for (
int r = 0; r <
rounds; r++) {
828template < const
int LX >
830 void *
u,
void *
v,
void *
w,
831 void *
dx,
void *
dy,
void *
dz,
void *
h1,
858 if (
getenv(
"NEKO_AUTOTUNE") ||
878 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_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_VECTOR_PADDED_SEL(LX, SEL)
#define CASE_MFMA_SEL(LX, SEL)
#define CASE_KSTEP(LX, C)
#define CASE_KSTEP_PADDED_SEL(LX, SEL)
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)
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)
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)
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)
#define CASE_VECTOR_KSTEP_PADDED(LX, C)
#define CASE_VECTOR_PADDED(LX)
#define CASE_VECTOR_SEL(LX, SEL)
#define CASE_KSTEP_PADDED(LX, C)
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)
__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)
#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()
static int neko_chunks_env()
static int neko_eb_sweep()
#define NEKO_TUNE_LOG_MFMA(LX, T3)
#define NEKO_MFMA_CANDIDATES
static bool hip_have_mfma()
static int neko_mfma_env()
#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)