38 #include <hip/hip_runtime.h>
51 void *
g13,
void *
g23,
int *nelv,
int *lx);
57 void *
g13,
void *
g23,
int *nelv,
int *lx);
67 void *
g13,
void *
g23,
int *nelv,
int *lx) {
69 static int autotune[13] = { 0 };
71 const dim3 nthrds_1d(1024, 1, 1);
72 const dim3 nblcks_1d((*nelv), 1, 1);
73 const dim3 nthrds_kstep((*lx), (*lx), 1);
74 const dim3 nblcks_kstep((*nelv), 1, 1);
77 hipLaunchKernelGGL(HIP_KERNEL_NAME( ax_helm_kernel_1d<real, LX, 1024> ), \
78 nblcks_1d, nthrds_1d, 0, \
79 (hipStream_t) glb_cmd_queue, \
80 (real *) w, (real *) u, \
81 (real *) dx, (real *) dy, (real *) dz, \
82 (real *) dxt, (real *) dyt, (real *) dzt, (real *) h1, \
83 (real *) g11, (real *) g22, (real *) g33, \
84 (real *) g12, (real *) g13, (real *) g23); \
85 HIP_CHECK(hipGetLastError());
87 #define CASE_KSTEP(LX) \
88 hipLaunchKernelGGL( HIP_KERNEL_NAME( ax_helm_kernel_kstep<real, LX> ), \
89 nblcks_kstep, nthrds_kstep, 0, \
90 (hipStream_t) glb_cmd_queue, \
91 (real *) w, (real *) u, \
92 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
93 (real *) g11, (real *) g22, (real *) g33, \
94 (real *) g12, (real *) g13, (real *) g23); \
95 HIP_CHECK(hipGetLastError());
99 #define CASE_KSTEP_PADDED(LX) \
100 hipLaunchKernelGGL( HIP_KERNEL_NAME(ax_helm_kernel_kstep_padded<real, LX> ),\
101 nblcks_kstep, nthrds_kstep, 0, \
102 (hipStream_t) glb_cmd_queue, \
103 (real *) w, (real *) u, \
104 (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
105 (real *) g11, (real *) g22, (real *) g33, \
106 (real *) g12, (real *) g13, (real *) g23); \
107 HIP_CHECK(hipGetLastError());
111 if(autotune[LX] == 0 ) { \
112 autotune[LX]=tune<LX>( w, u, \
116 g12, g13, g23, nelv, lx); \
117 } else if (autotune[LX] == 1 ) { \
119 } else if (autotune[LX] == 2 ) { \
125 #define CASE_PADDED(LX) \
127 if(autotune[LX] == 0 ) { \
128 autotune[LX]=tune_padded<LX>(w, u, \
132 g12, g13, g23,nelv,lx); \
133 } else if (autotune[LX] == 1 ) { \
135 } else if (autotune[LX] == 2 ) { \
136 CASE_KSTEP_PADDED(LX); \
155 fprintf(stderr, __FILE__
": size not supported: %d\n", *lx);
163 template < const
int LX >
167 void *
g13,
void *
g23,
int *nelv,
int *lx) {
168 hipEvent_t start,stop;
172 const dim3 nthrds_1d(1024, 1, 1);
173 const dim3 nblcks_1d((*nelv), 1, 1);
174 const dim3 nthrds_kstep((*lx), (*lx), 1);
175 const dim3 nblcks_kstep((*nelv), 1, 1);
177 char *env_value = NULL;
178 char neko_log_buf[80];
180 env_value=getenv(
"NEKO_AUTOTUNE");
182 sprintf(neko_log_buf,
"Autotune Ax helm (lx: %d)", *lx);
186 if( !strcmp(env_value,
"1D") ) {
188 sprintf(neko_log_buf,
"Set by env : 1 (1D)");
192 }
else if( !strcmp(env_value,
"KSTEP") ) {
194 sprintf(neko_log_buf,
"Set by env : 2 (KSTEP)");
199 sprintf(neko_log_buf,
"Invalid value set for NEKO_AUTOTUNE");
204 hipEventCreate(&start);
205 hipEventCreate(&stop);
207 hipEventRecord(start,0);
209 for(
int i = 0;
i < 100;
i++) {
213 hipEventRecord(stop,0);
214 hipEventSynchronize(stop);
215 hipEventElapsedTime(&time1, start, stop);
217 hipEventRecord(start,0);
219 for(
int i = 0;
i < 100;
i++) {
223 hipEventRecord(stop,0);
224 hipEventSynchronize(stop);
225 hipEventElapsedTime(&time2, start, stop);
233 sprintf(neko_log_buf,
"Chose : %d (%s)", retval,
234 (retval > 1 ?
"KSTEP" :
"1D"));
240 template < const
int LX >
244 void *
g13,
void *
g23,
int *nelv,
int *lx) {
245 hipEvent_t start, stop;
249 const dim3 nthrds_1d(1024, 1, 1);
250 const dim3 nblcks_1d((*nelv), 1, 1);
251 const dim3 nthrds_kstep((*lx), (*lx), 1);
252 const dim3 nblcks_kstep((*nelv), 1, 1);
254 char *env_value = NULL;
255 char neko_log_buf[80];
257 env_value=getenv(
"NEKO_AUTOTUNE");
259 sprintf(neko_log_buf,
"Autotune Ax helm (lx: %d)", *lx);
263 if( !strcmp(env_value,
"1D") ) {
265 sprintf(neko_log_buf,
"Set by env : 1 (1D)");
269 }
else if( !strcmp(env_value,
"KSTEP") ) {
271 sprintf(neko_log_buf,
"Set by env : 2 (KSTEP)");
276 sprintf(neko_log_buf,
"Invalid value set for NEKO_AUTOTUNE");
281 hipEventCreate(&start);
282 hipEventCreate(&stop);
284 hipEventRecord(start,0);
286 for(
int i = 0;
i < 100;
i++) {
290 hipEventRecord(stop, 0);
291 hipEventSynchronize(stop);
292 hipEventElapsedTime(&time1, start, stop);
294 hipEventRecord(start, 0);
296 for(
int i = 0;
i < 100;
i++) {
300 hipEventRecord(stop, 0);
301 hipEventSynchronize(stop);
302 hipEventElapsedTime(&time2, start, stop);
310 sprintf(neko_log_buf,
"Chose : %d (%s)", retval,
311 (retval > 1 ?
"KSTEP" :
"1D"));
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)
#define CASE_KSTEP_PADDED(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)
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)
__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__ const T *__restrict__ dyt
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dxt
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dz
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dx
__global__ void const T *__restrict__ u
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dy
__global__ void 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__ 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__ g12
__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__ 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__ g33
__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__ g11
void log_error(char *msg)
void log_message(char *msg)
void log_section(char *msg)