8 #ifndef LIB_ACTIONS_FERM_INVERT_QUDA_SOLVERS_QUDA_MG_UTILS_H_
9 #define LIB_ACTIONS_FERM_INVERT_QUDA_SOLVERS_QUDA_MG_UTILS_H_
17 #include <cuda_runtime_api.h>
21 namespace QUDAMGUtils {
43 QudaMultigridParam& mg_param = ret_val->
mg_param;
45 QudaPrecision_s cpu_prec;
46 QudaPrecision_s gpu_prec;
47 QudaPrecision_s gpu_half_prec;
48 int s =
sizeof(
typename WordType<T>::Type_t );
50 cpu_prec = QUDA_SINGLE_PRECISION;
53 cpu_prec = QUDA_DOUBLE_PRECISION;
60 gpu_prec = found->second;
72 gpu_prec = QUDA_HALF_PRECISION;
75 gpu_prec = QUDA_SINGLE_PRECISION;
78 gpu_prec = QUDA_DOUBLE_PRECISION;
90 gpu_half_prec = found->second;
94 gpu_half_prec = gpu_prec;
103 gpu_half_prec = QUDA_HALF_PRECISION;
106 gpu_half_prec = QUDA_SINGLE_PRECISION;
109 gpu_half_prec = QUDA_DOUBLE_PRECISION;
112 gpu_half_prec = gpu_prec;
117 QDPIO::cout<<
"Creating MG subspace."<<std::endl;
120 mg_inv_param.dslash_type = QUDA_CLOVER_WILSON_DSLASH;
121 mg_inv_param.inv_type = QUDA_GCR_INVERTER;
122 mg_inv_param.tol = 1e-10;
123 mg_inv_param.maxiter = 10000;
124 mg_inv_param.reliable_delta = 1e-10;
125 mg_inv_param.cpu_prec = cpu_prec;
126 mg_inv_param.cuda_prec = gpu_prec;
127 mg_inv_param.cuda_prec_sloppy = gpu_half_prec;
128 mg_inv_param.cuda_prec_precondition = gpu_half_prec;
130 mg_inv_param.clover_cpu_prec = cpu_prec;
131 mg_inv_param.clover_cuda_prec = gpu_prec;
132 mg_inv_param.clover_cuda_prec_sloppy = gpu_half_prec;
133 mg_inv_param.clover_cuda_prec_precondition = gpu_half_prec;
134 mg_inv_param.clover_order = QUDA_PACKED_CLOVER_ORDER;
139 QDPIO::cout <<
"Enabling MG Dslash Autotuning" << std::endl;
140 mg_inv_param.tune = QUDA_TUNE_YES;
143 QDPIO::cout <<
"Disabling MG Dslash Autotuning" << std::endl;
144 mg_inv_param.tune = QUDA_TUNE_NO;
147 QDPIO::cout <<
"Setting MULTIGRID solver params" << std::endl;
155 mg_inv_param.cuda_prec_precondition = found->second;
156 mg_inv_param.clover_cuda_prec_precondition = found->second;
160 mg_inv_param.cuda_prec_precondition = QUDA_HALF_PRECISION;
161 mg_inv_param.clover_cuda_prec_precondition = QUDA_HALF_PRECISION;
169 mg_inv_param.cuda_prec_precondition = QUDA_HALF_PRECISION;
170 mg_inv_param.clover_cuda_prec_precondition = QUDA_HALF_PRECISION;
173 mg_inv_param.cuda_prec_precondition = QUDA_SINGLE_PRECISION;
174 mg_inv_param.clover_cuda_prec_precondition = QUDA_SINGLE_PRECISION;
177 mg_inv_param.cuda_prec_precondition = QUDA_DOUBLE_PRECISION;
178 mg_inv_param.clover_cuda_prec_precondition = QUDA_DOUBLE_PRECISION;
181 mg_inv_param.cuda_prec_precondition = QUDA_HALF_PRECISION;
182 mg_inv_param.clover_cuda_prec_precondition = QUDA_HALF_PRECISION;
188 mg_inv_param.verbosity = QUDA_VERBOSE;
191 mg_inv_param.verbosity = QUDA_SUMMARIZE;
197 mg_inv_param.verbosity_precondition = QUDA_SILENT;
201 mg_inv_param.sp_pad = 0;
202 mg_inv_param.cl_pad = 0;
203 mg_inv_param.preserve_source = QUDA_PRESERVE_SOURCE_NO;
204 mg_inv_param.gamma_basis = QUDA_DEGRAND_ROSSI_GAMMA_BASIS;
205 mg_inv_param.dirac_order = QUDA_DIRAC_ORDER;
206 mg_inv_param.input_location = QUDA_CPU_FIELD_LOCATION;
207 mg_inv_param.output_location = QUDA_CPU_FIELD_LOCATION;
209 mg_inv_param.dagger = QUDA_DAG_NO;
210 mg_inv_param.kappa = 0.5;
211 mg_inv_param.mass_normalization = QUDA_KAPPA_NORMALIZATION;
212 mg_inv_param.clover_coeff = 1.0;
213 mg_inv_param.matpc_type = QUDA_MATPC_ODD_ODD;
214 mg_inv_param.solution_type = QUDA_MAT_SOLUTION;
215 mg_inv_param.solve_type = QUDA_DIRECT_SOLVE;
216 mg_param.invert_param = &mg_inv_param;
221 mg_param.run_verify = QUDA_BOOLEAN_YES;
224 mg_param.run_verify = QUDA_BOOLEAN_NO;
227 for (
int i=0;
i<mg_param.n_level-1; ++
i) {
229 mg_param.setup_location[
i] = QUDA_CUDA_FIELD_LOCATION;
232 mg_param.setup_location[
i] = QUDA_CPU_FIELD_LOCATION;
237 for (
int i=0;
i<mg_param.n_level;
i++) {
238 for (
int j=0;
j<
Nd;
j++) {
239 if(
i < mg_param.n_level-1 ) {
243 mg_param.geo_block_size[
i][
j] = 4;
247 QDPIO::cout <<
"Set Level " <<
i <<
" blocking as: ";
248 for(
int j=0;
j < 4; ++
j) {
249 QDPIO::cout <<
" " << mg_param.geo_block_size[
i][
j];
251 QDPIO::cout << std::endl;
254 mg_param.spin_block_size[
i] = 1;
256 if (
i < mg_param.n_level-1) {
257 mg_param.n_vec[
i] = ip.
nvec[
i];
262 mg_param.mu_factor[
i] = 1.0;
265 if (
i < mg_param.n_level-1) {
270 mg_param.num_setup_iter[
i] =1;
271 mg_param.precision_null[
i] = mg_inv_param.cuda_prec_precondition;
281 mg_param.coarse_solver[
i] = QUDA_GCR_INVERTER;
284 mg_param.coarse_solver[
i] = QUDA_CA_GCR_INVERTER;
285 if (
i != mg_param.n_level-1 ) {
286 QDPIO::cout <<
"ERROR: Right now CA_GCR is only allowed on the bottom level as a coarse solver"
293 QDPIO::cout <<
"Invalid coarse solver. Right now only GCR and CA_GCR solvers are allowed" << std::endl;
299 mg_param.coarse_solver[0] = QUDA_GCR_INVERTER;
304 mg_param.coarse_solver_tol[
i] = toDouble(ip.
tol[
i]);
312 mg_param.smoother[
i] = QUDA_MR_INVERTER;
314 mg_param.smoother_solve_type[
i] = QUDA_DIRECT_PC_SOLVE;
320 mg_param.smoother[
i] = QUDA_CA_GCR_INVERTER;
322 mg_param.smoother_solve_type[
i] = QUDA_DIRECT_PC_SOLVE;
328 QDPIO::cout <<
"Unknown or no smother type specified, no smoothing inverter will be used." << std::endl;
329 mg_param.smoother[
i] = QUDA_INVALID_INVERTER;
343 mg_param.smoother_halo_precision[
i] = QUDA_QUARTER_PRECISION;
346 mg_param.smoother_halo_precision[
i] = QUDA_HALF_PRECISION;
349 mg_param.smoother_halo_precision[
i] = QUDA_SINGLE_PRECISION;
352 mg_param.smoother_halo_precision[
i] = QUDA_DOUBLE_PRECISION;
359 QDPIO::cout <<
"CKheckopoint 2" << std::endl << std::flush;
361 mg_param.global_reduction[
i] = (mg_param.smoother_schwarz_type[
i] == QUDA_INVALID_SCHWARZ) ? QUDA_BOOLEAN_YES : QUDA_BOOLEAN_NO;
362 mg_param.location[
i] = QUDA_CUDA_FIELD_LOCATION;
365 mg_param.cycle_type[
i] = QUDA_MG_CYCLE_VCYCLE;
366 }
else if (ip.
cycle_type ==
"MG_RECURSIVE" ) {
367 mg_param.cycle_type[
i] = QUDA_MG_CYCLE_RECURSIVE;
369 QDPIO::cout <<
"Unknown Cycle Type" << ip.
cycle_type << std::endl;
374 switch( mg_param.cycle_type[
i] ) {
375 case QUDA_MG_CYCLE_RECURSIVE :
376 mg_param.coarse_grid_solution_type[
i] = QUDA_MATPC_SOLUTION;
378 case QUDA_MG_CYCLE_VCYCLE :
379 mg_param.coarse_grid_solution_type[
i] = QUDA_MAT_SOLUTION;
382 QDPIO::cerr <<
"Should never get here" << std::endl;
387 mg_param.setup_type = QUDA_NULL_VECTOR_SETUP;
388 mg_param.pre_orthonormalize = QUDA_BOOLEAN_NO;
389 mg_param.post_orthonormalize = QUDA_BOOLEAN_YES;
392 mg_param.coarse_grid_solution_type[0] = QUDA_MATPC_SOLUTION;
394 mg_param.spin_block_size[0] = 2;
396 mg_param.smoother[ip.
mg_levels-1] = QUDA_GCR_INVERTER;
398 : QUDA_COMPUTE_NULL_VECTOR_NO;
402 mg_param.vec_infile[
l][0] =
'\0';
403 mg_param.vec_outfile[
l][0] =
'\0';
405 QDPIO::cout<<
"Basic MULTIGRID params copied."<<std::endl;
409 QDPIO::cout <<
"About to Call newMultigridQuda" << std::endl;
412 QDPIO::cout<<
"NewMultigridQuda state initialized."<<std::endl;
413 QDPIO::cout<<
"MULTIGRID preconditioner set."<<std::endl;
414 QDPIO::cout <<
"After call to newMultigridQuda" <<std::endl;
416 for(
int i=0;
i < mg_param.n_level; ++
i) {
417 QDPIO::cout <<
"Set Level " <<
i <<
" blocking as: ";
419 for(
int j=0;
j < 4; ++
j) {
420 QDPIO::cout <<
" " << mg_param.geo_block_size[
i][
j];
422 QDPIO::cout << std::endl;
426 QDPIO::cout <<
"MULTIGrid Param Dump" << std::endl;
427 printQudaMultigridParam(&mg_param);
444 delete subspace_pointers;
456 ret = cudaMemGetInfo( &free, &total );
457 if ( ret != cudaSuccess ) {
458 QDPIO::cout <<
"cudaMemGetInfo() returned unsuccesful status: " << ret << std::endl;
Primary include file for CHROMA library code.
Named object function std::map.
MGSubspacePointers * create_subspace(const SysSolverQUDAMULTIGRIDCloverParams &invParam)
void delete_subspace(const std::string SubspaceID)
size_t getCUDAFreeMem(void)
Asqtad Staggered-Dirac operator.
multi1d< LatticeFermion > s(Ncb)
multi1d< Real > relaxationOmegaMG
multi1d< QudaSchwarzMethod > smootherSchwarzType
multi1d< Real > rsdTargetSubspaceCreate
multi1d< int > maxIterations
multi1d< int > smootherSchwarzCycle
multi1d< QudaSolverType > subspaceSolver
multi1d< Real > smootherTol
multi1d< QudaPrecisionType > smootherHaloPrecision
bool check_multigrid_setup
multi1d< QudaSolverType > coarseSolverType
multi1d< QudaSolverType > smootherType
multi1d< multi1d< int > > blocking
multi1d< bool > setup_on_gpu
multi1d< int > maxIterSubspaceCreate
multi1d< int > maxIterSubspaceRefresh
QudaMultigridParam mg_param
QudaInvertParam mg_inv_param
QudaPrecisionType cudaSloppyPrecision
QudaPrecisionType cudaPrecision
Handle< MULTIGRIDSolverParams > MULTIGRIDParams