Skip to content

Commit

Permalink
interchange ordering of coarse solver tolerance and coarse solver max…
Browse files Browse the repository at this point in the history
… iterations, prevent parameters going negative when tuning with negative delta
  • Loading branch information
kostrzewa committed Jul 18, 2024
1 parent 7d30f29 commit 66fa8e8
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions quda_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2715,7 +2715,9 @@ void update_tunable_params(tm_QudaMGTunableParams_t * tunable_params,
}
case TM_MG_TUNE_COARSE_SOLVER_MAXITER:
{
tunable_params->mg_coarse_solver_maxiter[lvl] += tuning_plan->mg_coarse_solver_maxiter_delta[lvl];
if( tunable_params->mg_coarse_solver_maxiter[lvl] + tuning_plan->mg_coarse_solver_maxiter_delta[lvl] >= 0 ){
tunable_params->mg_coarse_solver_maxiter[lvl] += tuning_plan->mg_coarse_solver_maxiter_delta[lvl];
}
break;
}
case TM_MG_TUNE_COARSE_SOLVER_TOL:
Expand All @@ -2725,12 +2727,16 @@ void update_tunable_params(tm_QudaMGTunableParams_t * tunable_params,
}
case TM_MG_TUNE_NU_PRE:
{
tunable_params->mg_nu_pre[lvl] += tuning_plan->mg_nu_pre_delta[lvl];
if( tunable_params->mg_nu_pre[lvl] + tuning_plan->mg_nu_pre_delta[lvl] >= 0 ){
tunable_params->mg_nu_pre[lvl] += tuning_plan->mg_nu_pre_delta[lvl];
}
break;
}
case TM_MG_TUNE_NU_POST:
{
tunable_params->mg_nu_post[lvl] += tuning_plan->mg_nu_post_delta[lvl];
{
if( tunable_params->mg_nu_post[lvl] + tuning_plan->mg_nu_post_delta[lvl] >= 0 ){
tunable_params->mg_nu_post[lvl] += tuning_plan->mg_nu_post_delta[lvl];
}
break;
}
case TM_MG_TUNE_SMOOTHER_TOL:
Expand Down Expand Up @@ -2894,20 +2900,20 @@ tm_QudaMGTuningDirection_t update_tuning_dir(const tm_QudaMGTuningPlan_t * const
tuning_plan->mg_mu_factor_steps[lvl] > 0 ) )
return TM_MG_TUNE_MU_FACTOR;
break;
case TM_MG_TUNE_COARSE_SOLVER_MAXITER:
if( (i == (int)tuning_dir &&
tuning_plan->mg_coarse_solver_maxiter_steps[lvl] > cur_dir_steps_done ) ||
(i != (int)tuning_dir &&
tuning_plan->mg_coarse_solver_maxiter_steps[lvl] > 0 ) )
return TM_MG_TUNE_COARSE_SOLVER_MAXITER;
break;
case TM_MG_TUNE_COARSE_SOLVER_TOL:
if( (i == (int)tuning_dir &&
tuning_plan->mg_coarse_solver_tol_steps[lvl] > cur_dir_steps_done ) ||
(i != (int)tuning_dir &&
tuning_plan->mg_coarse_solver_tol_steps[lvl] > 0 ) )
return TM_MG_TUNE_COARSE_SOLVER_TOL;
break;
case TM_MG_TUNE_COARSE_SOLVER_MAXITER:
if( (i == (int)tuning_dir &&
tuning_plan->mg_coarse_solver_maxiter_steps[lvl] > cur_dir_steps_done ) ||
(i != (int)tuning_dir &&
tuning_plan->mg_coarse_solver_maxiter_steps[lvl] > 0 ) )
return TM_MG_TUNE_COARSE_SOLVER_MAXITER;
break;
case TM_MG_TUNE_NU_POST:
if( (i == (int)tuning_dir &&
tuning_plan->mg_nu_post_steps[lvl] > cur_dir_steps_done ) ||
Expand Down Expand Up @@ -2952,12 +2958,12 @@ void adjust_tuning_plan(tm_QudaMGTuningPlan_t * tuning_plan,
case TM_MG_TUNE_MU_FACTOR:
tuning_plan->mg_mu_factor_steps[lvl] = 0;
break;
case TM_MG_TUNE_COARSE_SOLVER_MAXITER:
tuning_plan->mg_coarse_solver_maxiter_steps[lvl] = 0;
break;
case TM_MG_TUNE_COARSE_SOLVER_TOL:
tuning_plan->mg_coarse_solver_tol_steps[lvl] = 0;
break;
case TM_MG_TUNE_COARSE_SOLVER_MAXITER:
tuning_plan->mg_coarse_solver_maxiter_steps[lvl] = 0;
break;
case TM_MG_TUNE_NU_PRE:
tuning_plan->mg_nu_pre_steps[lvl] = 0;
break;
Expand All @@ -2972,7 +2978,6 @@ void adjust_tuning_plan(tm_QudaMGTuningPlan_t * tuning_plan,
break;
case TM_MG_TUNE_INVALID:
default:
return TM_MG_TUNE_INVALID;
break;
}
}
Expand Down

0 comments on commit 66fa8e8

Please sign in to comment.