49 void *
dx,
void *
dy,
void *
dz,
53 void *
jacinv,
int *nel,
int *lx,
int *eb_sel,
int *ch_sel);
61 void *
dx,
void *
dy,
void *
dz,
65 void *
jacinv,
int *nel,
int *lx) {
67 static int autotune[17] = { 0 };
69 static int autotune_eb[17] = { 0 };
71 static int autotune_ch[17] = { 0 };
73 const dim3 nthrds_1d(1024, 1, 1);
74 const dim3 nthrds_kstep((*lx), (*lx), 1);
75 const dim3 nblcks((*nel), 1, 1);
78#define CASE_1D(LX, C) \
79 lambda2_kernel_1d<real, LX, NEKO_CHUNKS(LX, C)> \
80 <<<nblcks, NEKO_CHUNKS_NTHRDS(LX, C), 0, stream>>> \
81 ((real *) lambda2, (real *) u, (real *) v, (real *) w, \
82 (real *) dx, (real *) dy, (real *) dz, \
83 (real *) drdx, (real *) dsdx, (real *) dtdx, \
84 (real *) drdy, (real *) dsdy, (real *) dtdy, \
85 (real *) drdz, (real *) dsdz, (real *) dtdz, \
87 CUDA_CHECK(cudaGetLastError());
90#define CASE_1D_SEL(LX, SEL) \
92 case 0: CASE_1D(LX, 0); break; \
93 case 1: CASE_1D(LX, 1); break; \
94 case 2: CASE_1D(LX, 2); break; \
95 default: CASE_1D(LX, 3); break; \
99#define CASE_KSTEP(LX, C) \
100 lambda2_kernel_kstep<real, LX, NEKO_EB(LX, C)> \
101 <<<NEKO_EB_NBLCKS(*nel, LX, C), NEKO_EB_NTHRDS(LX, C), 0, stream>>> \
102 ((real *) lambda2, (real *) u, (real *) v, (real *) w, \
103 (real *) dx, (real *) dy, (real *) dz, \
104 (real *) drdx, (real *) dsdx, (real *) dtdx, \
105 (real *) drdy, (real *) dsdy, (real *) dtdy, \
106 (real *) drdz, (real *) dsdz, (real *) dtdz, \
107 (real *) jacinv, *nel); \
108 CUDA_CHECK(cudaGetLastError());
111#define CASE_KSTEP_SEL(LX, SEL) \
113 case 0: CASE_KSTEP(LX, 0); break; \
114 case 1: CASE_KSTEP(LX, 1); break; \
115 default: CASE_KSTEP(LX, 2); break; \
120 if(autotune[LX] == 0 ) { \
121 autotune[LX]=tune_lambda2<LX>(lambda2, u, v, w, \
126 jacinv, nel, lx, &autotune_eb[LX], \
128 } else if (autotune[LX] == 1 ) { \
129 CASE_1D_SEL(LX, autotune_ch[LX]); \
130 } else if (autotune[LX] == 2 ) { \
131 CASE_KSTEP_SEL(LX, autotune_eb[LX]); \
149 fprintf(stderr, __FILE__
": size not supported: %d\n", *lx);
156template < const
int LX >
158 void *
dx,
void *
dy,
void *
dz,
162 void *
jacinv,
int *nel,
int *lx,
int *eb_sel,
int *ch_sel) {
163 cudaEvent_t start,stop;
187 const dim3 nthrds_1d(1024, 1, 1);
188 const dim3 nthrds_kstep((*lx), (*lx), 1);
189 const dim3 nblcks((*nel), 1, 1);
192 char *env_value = NULL;
193 char neko_log_buf[80];
195 env_value=getenv(
"NEKO_AUTOTUNE");
197 sprintf(neko_log_buf,
"Autotune lambda2 (lx: %d)", *lx);
207 if( !strcmp(env_value,
"1D") ) {
209 }
else if( !strcmp(env_value,
"KSTEP") ) {
212 sprintf(neko_log_buf,
"Invalid value set for NEKO_AUTOTUNE");
220 const int pin = (strat == 1) ? ch_pin : (strat == 2) ? eb_pin : -1;
227 sprintf(neko_log_buf,
"Set by env : 1 (1D, %d chunk)",
233 sprintf(neko_log_buf,
"Set by env : 2 (KSTEP, %d elem/block)",
243 sprintf(neko_log_buf,
"Set by env : %d (%s)", strat, env_value);
248 const bool try_1d = (strat == 0 || strat == 1);
249 const bool try_kstep = (strat == 0 || strat == 2);
251 cudaEventCreate(&start);
252 cudaEventCreate(&stop);
266 for (
int r = 0; r < rounds; r++) {
281 if (time1[best1] < time2[best]) {
296 sprintf(neko_log_buf,
"Chose : 1 (1D, %d chunk)",
299 sprintf(neko_log_buf,
"Chose : 2 (KSTEP, %d elem/block)",
#define CASE_KSTEP_SEL(LX, SEL)
#define CASE_1D_SEL(LX, SEL)
__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__ dz
__global__ void const T *__restrict__ const T *__restrict__ dx
__global__ void const T *__restrict__ u
__global__ void 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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdy
__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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdx
__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__ 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__ dtdz
__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__ 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__ jacinv
__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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdz
__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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdz
__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__ const T *__restrict__ drdx
__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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdx
__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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdy
__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__ const T *__restrict__ const T *__restrict__ drdy
#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()
__global__ void T *__restrict__ uy
__global__ void T *__restrict__ T *__restrict__ uz
A simulation component that computes lambda2 The values are stored in the field registry under the na...
void log_error(char *msg)
void log_message(char *msg)
void log_section(char *msg)
#define CASE_KSTEP_SEL(LX, SEL)
#define CASE_1D_SEL(LX, SEL)
int tune_lambda2(void *ux, void *uy, void *uz, void *u, void *dx, void *dy, void *dz, void *drdx, void *dsdx, void *dtdx, void *drdy, void *dsdy, void *dtdy, void *drdz, void *dsdz, void *dtdz, void *jacinv, int *nel, int *lx, int *eb_sel, int *ch_sel)
void cuda_lambda2(void *lambda2, void *u, void *v, void *w, void *dx, void *dy, void *dz, void *drdx, void *dsdx, void *dtdx, void *drdy, void *dsdy, void *dtdy, void *drdz, void *dsdz, void *dtdz, void *jacinv, int *nel, int *lx)