46 template < const
int >
48 void *
dx,
void *
dy,
void *
dz,
52 void *
w3,
int *nel,
int *lx);
60 void *
dx,
void *
dy,
void *
dz,
64 void *
w3,
int *nel,
int *lx) {
66 static int autotune[17] = { 0 };
68 const dim3 nthrds_1d(1024, 1, 1);
69 const dim3 nthrds_kstep((*lx), (*lx), 1);
70 const dim3 nblcks((*nel), 1, 1);
74 opgrad_kernel_1d<real, LX, 1024> \
75 <<<nblcks, nthrds_1d, 0, stream>>> \
76 ((real *) ux, (real *) uy, (real *) uz, (real *) u, \
77 (real *) dx, (real *) dy, (real *) dz, \
78 (real *) drdx, (real *) dsdx, (real *) dtdx, \
79 (real *) drdy, (real *) dsdy, (real *) dtdy, \
80 (real *) drdz, (real *) dsdz, (real *) dtdz, \
82 CUDA_CHECK(cudaGetLastError());
85 #define CASE_KSTEP(LX) \
86 opgrad_kernel_kstep<real, LX> <<<nblcks, nthrds_kstep, 0, stream>>> \
87 ((real *) ux, (real *) uy, (real *) uz, (real *) u, \
88 (real *) dx, (real *) dy, (real *) dz, \
89 (real *) drdx, (real *) dsdx, (real *) dtdx, \
90 (real *) drdy, (real *) dsdy, (real *) dtdy, \
91 (real *) drdz, (real *) dsdz, (real *) dtdz, \
93 CUDA_CHECK(cudaGetLastError());
97 if(autotune[LX] == 0 ) { \
98 autotune[LX]=tune_opgrad<LX>(ux, uy, uz, u, \
104 } else if (autotune[LX] == 1 ) { \
106 } else if (autotune[LX] == 2 ) { \
129 fprintf(stderr, __FILE__
": size not supported: %d\n", *lx);
136 template < const
int LX >
138 void *
dx,
void *
dy,
void *
dz,
142 void *
w3,
int *nel,
int *lx) {
143 cudaEvent_t start,stop;
147 const dim3 nthrds_1d(1024, 1, 1);
148 const dim3 nthrds_kstep((*lx), (*lx), 1);
149 const dim3 nblcks((*nel), 1, 1);
152 char *env_value = NULL;
153 char neko_log_buf[80];
155 env_value=getenv(
"NEKO_AUTOTUNE");
157 sprintf(neko_log_buf,
"Autotune opgrad (lx: %d)", *lx);
161 if( !strcmp(env_value,
"1D") ) {
163 sprintf(neko_log_buf,
"Set by env : 1 (1D)");
167 }
else if( !strcmp(env_value,
"KSTEP") ) {
169 sprintf(neko_log_buf,
"Set by env : 2 (KSTEP)");
174 sprintf(neko_log_buf,
"Invalid value set for NEKO_AUTOTUNE");
179 cudaEventCreate(&start);
180 cudaEventCreate(&stop);
182 cudaEventRecord(start,0);
184 for(
int i = 0;
i < 100;
i++) {
188 cudaEventRecord(stop,0);
189 cudaEventSynchronize(stop);
190 cudaEventElapsedTime(&time1, start, stop);
192 cudaEventRecord(start,0);
194 for(
int i = 0;
i < 100;
i++) {
198 cudaEventRecord(stop,0);
199 cudaEventSynchronize(stop);
200 cudaEventElapsedTime(&time2, start, stop);
208 sprintf(neko_log_buf,
"Chose : %d (%s)", retval,
209 (retval > 1 ?
"KSTEP" :
"1D"));
__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
__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__ 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__ 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__ 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__ u
__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__ 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__ 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__ 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__ 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__ dz
__global__ void T *__restrict__ 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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w3
__global__ void T *__restrict__ uy
__global__ void T *__restrict__ T *__restrict__ uz
void log_error(char *msg)
void log_message(char *msg)
void log_section(char *msg)
int tune_opgrad(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 *w3, int *nel, int *lx)
void cuda_opgrad(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 *w3, int *nel, int *lx)