Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hb solver #546

Merged
merged 38 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9640a58
I am adding a functionality to the HMC. For the CLOVERDETRATIO monomi…
simone-romiti Jul 6, 2022
7cdddf5
In `read_input.l`, I added the block
simone-romiti Jul 6, 2022
40482d0
In `monomial/detratio_monomial.c` I changed the function `detratio_he…
simone-romiti Jul 8, 2022
c39d63e
Reply to https://github.com/etmc/tmLQCD/pull/546#discussion_r91773270…
simone-romiti Jul 12, 2022
327f2d8
Reply to https://github.com/etmc/tmLQCD/pull/546#discussion_r91773408…
simone-romiti Jul 12, 2022
860e5ad
Reply to https://github.com/etmc/tmLQCD/pull/546#discussion_r91773854…
simone-romiti Jul 12, 2022
2534c6c
modified: read_input.l
simone-romiti Jul 12, 2022
141c9a6
- declaration of DETRATIO
Jul 12, 2022
3cf0922
add HB_maxiter
simone-romiti Jul 13, 2022
7438daa
fix reading of HB_solver and HB_MaxSolverIterations
Marcogarofalo Jul 13, 2022
d0d772d
always init HB_solver_params
Marcogarofalo Jul 13, 2022
5bccf10
deleting not necessary files
Marcogarofalo Jul 13, 2022
0d14fc4
default and initialization of HB_solver
Marcogarofalo Jul 13, 2022
cc5292a
DDalphaAMG as HB solver
Marcogarofalo Jul 14, 2022
4f02cc5
Merge remote-tracking branch 'origin/quda_work' into HB_solver
kostrzewa Nov 2, 2022
23f7f54
added documentation for the `HB_solver` parameter
simone-romiti Dec 16, 2022
ff57999
added doc for HB_solver options in a dedicated subsection.
simone-romiti Dec 16, 2022
0cc0336
see https://github.com/etmc/tmLQCD/commit/ff57999735061187e7a64d21bcc…
simone-romiti Dec 16, 2022
c330493
output mpicc version in basic build workflow
kostrzewa Jan 11, 2023
7786c3e
typo in basic-build.yaml
kostrzewa Jan 11, 2023
ee1c4e1
test github action artifact upload (lime config.log)
kostrzewa Jan 11, 2023
8854044
figure out how this artifact stuff works
kostrzewa Jan 11, 2023
41a9916
with: is required
kostrzewa Jan 11, 2023
81a9c80
update basic-build.yaml to use checkout@v3 action
kostrzewa Jan 11, 2023
704b891
add more artifacts for basic-build.yaml
kostrzewa Jan 11, 2023
b855787
always attempt to upload artifacts
kostrzewa Jan 11, 2023
bcf6cfb
test if using LD=mpicc fixes things for now
kostrzewa Jan 11, 2023
1d05e28
apparently the OpenMPI package does not ship with libmpi any more, th…
kostrzewa Jan 11, 2023
ad2738b
hopefully fix all three github actions
kostrzewa Jan 11, 2023
fe1d38b
remove LD=mpicc from basic build
kostrzewa Jan 11, 2023
bd9e369
Merge remote-tracking branch 'origin/quda_work' into HB_solver
kostrzewa Jan 27, 2023
5c25216
switch qphix branch, maybe this will help
kostrzewa Feb 2, 2023
7f65fe9
prevent the qphix workflow from crashing the CI node ...
kostrzewa Feb 2, 2023
10989e0
let's see if modifying qphix has fixed the qphix workflow
kostrzewa Feb 3, 2023
fadcbc1
see if ed165e0065c422743a60d65ec325ce3c9ee791aa for DDalphaAMG fixes …
kostrzewa Feb 4, 2023
d8a7d38
correctly initialize HB_maxiter when no HB solver has been defined
kostrzewa Mar 1, 2023
d24e5ce
set reorder = 0 by default to work correctly on LUMI
kostrzewa Mar 2, 2023
ac9349e
change reference location for the HB_solver details
kostrzewa Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ doc/*.txt
doc/*.gpl
doc/wrapper*
history_hmc_tm
.vscode/*
1 change: 1 addition & 0 deletions default_input_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#define _default_rlxd_level 1
#define _default_solver_flag 1 // this is CG (see solver/solver_types.h)
#define _default_nd_solver_flag 15 // this is CGMMSND (see solver/solver_types.h)
#define _default_HB_solver_flag 26 // this is INVALID_SOLVER (see solver/solver_types.h)
#define _default_startoption 0
#define _default_Ntherm 0
#define _default_Nmeas 1
Expand Down
17 changes: 13 additions & 4 deletions doc/input.tex
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,25 @@ \subsection{Input parameter for main program}
\item {\ttfamily Name}: a name to be assigned to the monomial. The
default is {\ttfamily DET}
\end{itemize}
%
\item {\ttfamily DETRATIO}: the same as for {\ttfamily DET}, but in
addition:
\begin{itemize}
\item {\ttfamily 2KappaMu2}
\item {\ttfamily Kappa2}
\item {\ttfamily Name}: a name to be assigned to the monomial. The
default is {\ttfamily DETRATIO}
\item {\ttfamily Name}:
a name to be assigned to the monomial.
The default is {\ttfamily DETRATIO}
\item {\ttfamily HB\_solver}:
Optional parameter. It's the solver to be used in the heatbath.
If not specified, the MD solver is used.
Supported values: MG, BICGSTAB.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this supports many more values, not sure if it makes so much sense to list them here or whether we should introduce a new section into the documentation describing which solvers can be used in the HMC under which circumstances and with which kinds of fermions

Copy link
Contributor

@simone-romiti simone-romiti Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. I listed them here because at the moment the code foresees only these options. For these few lines of documentation I thought it was unnecessary to create a dedicated section, which may be done when the number of tested cases increases. I don't have strong preference though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because at the moment the code foresees only these options

This is not true. We use CG here ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that we have

if( mnl->HB_solver == MG || mnl->HB_solver == BICGSTAB ){

there is because when these solvers are used, a different kind of solve is performed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both MG and BICGSTAB can directly invert Q_{+}, rather than having to invert the normal operator Q_{+} Q_{-} and subsequently multiplying the result by Q_{-}. For BICGSTAB, this statement does not really apply for twisted mass fermions (because the solver does not perform very well in this case), but it certainly works for Wilson (clover) fermions without a twisted mass term. MG instead can deal with any of Wilson (clover) (twisted mass).

\end{itemize}


%
\item {\ttfamily CLOVERDETRATIO}:
the same as for {\ttfamily CLOVERDET} and {\ttfamily DETRATIO}.
Supported values for {\ttfamily HB\_solver}: MG.
%
\item {\ttfamily GAUGE}:
\begin{itemize}
\item {\ttfamily Timescale}: the timescale on which to integrate
Expand Down
10 changes: 5 additions & 5 deletions monomial/cloverdetratio_monomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ void cloverdetratio_heatbath(const int id, hamiltonian_field_t * const hf) {
zero_spinor_field(mnl->pf,VOLUME/2);
tm_stopwatch_pop(&g_timers, 0, 1, "");

if( mnl->solver == MG ){
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->solver_params, mnl->maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME/2, mnl->Qp, mnl->solver);
if( mnl->HB_solver == MG ){
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->HB_solver_params, mnl->HB_maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME/2, mnl->Qp, mnl->HB_solver);

chrono_add_solution(mnl->pf, mnl->csg_field, mnl->csg_index_array,
mnl->csg_N, &mnl->csg_n, VOLUME/2);
} else {
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->solver_params, mnl->maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME/2, mnl->Qsq, mnl->solver);
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->HB_solver_params, mnl->HB_maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME/2, mnl->Qsq, mnl->HB_solver);

chrono_add_solution(mnl->pf, mnl->csg_field, mnl->csg_index_array,
mnl->csg_N, &mnl->csg_n, VOLUME/2);
Expand Down
26 changes: 13 additions & 13 deletions monomial/detratio_monomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ void detratio_heatbath(const int id, hamiltonian_field_t * const hf) {
boundary(g_kappa);

zero_spinor_field(mnl->w_fields[0], VOLUME/2);
if( mnl->solver == MG || mnl->solver == BICGSTAB ){
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->solver_params, mnl->maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME/2, mnl->Qp, mnl->solver);
if( mnl->HB_solver == MG || mnl->HB_solver == BICGSTAB ){
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->HB_solver_params, mnl->HB_maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME/2, mnl->Qp, mnl->HB_solver);
chrono_add_solution(mnl->pf, mnl->csg_field, mnl->csg_index_array,
mnl->csg_N, &mnl->csg_n, VOLUME/2);
} else {
mnl->iter0 = solve_degenerate(mnl->w_fields[0], mnl->w_fields[1], mnl->solver_params, mnl->maxiter,
mnl->accprec, g_relative_precision_flag, VOLUME/2, mnl->Qsq, mnl->solver);
mnl->iter0 = solve_degenerate(mnl->w_fields[0], mnl->w_fields[1], mnl->HB_solver_params, mnl->HB_maxiter,
mnl->accprec, g_relative_precision_flag, VOLUME/2, mnl->Qsq, mnl->HB_solver);
tm_stopwatch_push(&g_timers, "Qm", "");
mnl->Qm(mnl->pf, mnl->w_fields[0]);
tm_stopwatch_pop(&g_timers, 0, 1, "");
Expand All @@ -271,23 +271,23 @@ void detratio_heatbath(const int id, hamiltonian_field_t * const hf) {
boundary(g_kappa);

zero_spinor_field(mnl->pf,VOLUME);
if((mnl->solver == CG) || (mnl->solver == MIXEDCG) || (mnl->solver == RGMIXEDCG)){
mnl->iter0 = solve_degenerate(mnl->w_fields[0], mnl->w_fields[1], mnl->solver_params,
mnl->maxiter, mnl->accprec, g_relative_precision_flag, VOLUME, Q_pm_psi, mnl->solver);
if((mnl->HB_solver == CG) || (mnl->HB_solver == MIXEDCG) || (mnl->HB_solver == RGMIXEDCG)){
mnl->iter0 = solve_degenerate(mnl->w_fields[0], mnl->w_fields[1], mnl->HB_solver_params,
mnl->HB_maxiter, mnl->accprec, g_relative_precision_flag, VOLUME, Q_pm_psi, mnl->HB_solver);
tm_stopwatch_push(&g_timers, "Q_minus_psi", "");
Q_minus_psi(mnl->pf, mnl->w_fields[0]);
tm_stopwatch_pop(&g_timers, 0, 1, "");
chrono_add_solution(mnl->pf, mnl->csg_field, mnl->csg_index_array,
mnl->csg_N, &mnl->csg_n, VOLUME/2);
// FIXME why only MG here?
} else if( mnl->solver == MG ){
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->solver_params, mnl->maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME, Q_plus_psi, mnl->solver);
} else if( mnl->HB_solver == MG ){
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->HB_solver_params, mnl->HB_maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME, Q_plus_psi, mnl->HB_solver);
chrono_add_solution(mnl->pf, mnl->csg_field, mnl->csg_index_array,
mnl->csg_N, &mnl->csg_n, VOLUME/2);
} else {
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->solver_params, mnl->maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME, Q_plus_psi, mnl->solver);
mnl->iter0 = solve_degenerate(mnl->pf, mnl->w_fields[1], mnl->HB_solver_params, mnl->HB_maxiter, mnl->accprec,
g_relative_precision_flag, VOLUME, Q_plus_psi, mnl->HB_solver);
chrono_add_solution(mnl->pf, mnl->csg_field, mnl->csg_index_array,
mnl->csg_N, &mnl->csg_n, VOLUME/2);
chrono_add_solution(mnl->pf, mnl->csg_field2, mnl->csg_index_array2,
Expand Down
15 changes: 15 additions & 0 deletions monomial/monomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ int add_monomial(const int type) {
monomial_list[no_monomials].accprec = _default_g_eps_sq_acc;
monomial_list[no_monomials].forceprec = _default_g_eps_sq_force;
monomial_list[no_monomials].maxiter = _default_max_solver_iterations;
monomial_list[no_monomials].HB_maxiter = _default_max_solver_iterations;
if((monomial_list[no_monomials].type == NDRAT) ||
(monomial_list[no_monomials].type == NDRATCOR) ||
(monomial_list[no_monomials].type == NDCLOVERRAT) ||
Expand All @@ -103,6 +104,7 @@ int add_monomial(const int type) {
}
else{
monomial_list[no_monomials].solver = _default_solver_flag;
monomial_list[no_monomials].HB_solver = _default_HB_solver_flag;
}
monomial_list[no_monomials].solver_params.mcg_delta = _default_mixcg_innereps;
monomial_list[no_monomials].solver_params.solution_type = TM_SOLUTION_M_MDAG;
Expand All @@ -115,6 +117,7 @@ int add_monomial(const int type) {
monomial_list[no_monomials].solver_params.sloppy_precision = _default_operator_sloppy_precision_flag;
monomial_list[no_monomials].external_library = _default_external_library;
monomial_list[no_monomials].solver_params.refinement_precision = _default_operator_sloppy_precision_flag;
monomial_list[no_monomials].HB_solver_params = monomial_list[no_monomials].solver_params;
monomial_list[no_monomials].even_odd_flag = _default_even_odd_flag;
monomial_list[no_monomials].forcefactor = 1.;
monomial_list[no_monomials].use_rectangles = 0;
Expand Down Expand Up @@ -248,6 +251,12 @@ int init_monomials(const int V, const int even_odd_flag) {
}
}
else if(monomial_list[i].type == CLOVERDETRATIO) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need the same thing for DETRATIO

if (monomial_list[i].HB_solver == _default_HB_solver_flag) {
monomial_list[i].HB_solver = monomial_list[i].solver;
monomial_list[i].HB_solver_params = monomial_list[i].solver_params;
monomial_list[no_monomials].HB_maxiter = monomial_list[no_monomials].maxiter;
}

monomial_list[i].hbfunction = &cloverdetratio_heatbath;
monomial_list[i].accfunction = &cloverdetratio_acc;
monomial_list[i].derivativefunction = &cloverdetratio_derivative;
Expand Down Expand Up @@ -277,6 +286,12 @@ int init_monomials(const int V, const int even_odd_flag) {
}
}
else if(monomial_list[i].type == DETRATIO) {
if (monomial_list[i].HB_solver == _default_HB_solver_flag) {
monomial_list[i].HB_solver = monomial_list[i].solver;
monomial_list[i].HB_solver_params = monomial_list[i].solver_params;
monomial_list[no_monomials].HB_maxiter =monomial_list[no_monomials].maxiter;
}

monomial_list[i].hbfunction = &detratio_heatbath;
monomial_list[i].accfunction = &detratio_acc;
monomial_list[i].derivativefunction = &detratio_derivative;
Expand Down
3 changes: 3 additions & 0 deletions monomial/monomial.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ typedef struct {
int initialised;
int timescale;
int maxiter;
int HB_maxiter; // as maxiter, but for the HB solver
int id;
int even_odd_flag;
int rngrepro;
int solver;
int HB_solver; // solver for the HB only (optional)

int iter0, iter1, iter2;
int csg_N, csg_N2;
Expand All @@ -90,6 +92,7 @@ typedef struct {
double forceprec;
double accprec;
solver_params_t solver_params;
solver_params_t HB_solver_params; // parameters of the HB solver
/* force normalisation */
double forcefactor;
/* some book-keeping */
Expand Down
111 changes: 109 additions & 2 deletions read_input.l
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ static inline double fltlist_next_token(int * const list_end){
%x INITMONOMIAL
%x DETMONOMIAL
%x CLDETMONOMIAL
%x DETRATMONOMIAL
%x CLDETRATMONOMIAL
%x CLDETRATRWMONOMIAL
%x GAUGEMONOMIAL
Expand All @@ -600,6 +601,7 @@ static inline double fltlist_next_token(int * const list_end){
%x MNAME
%x MCSTR
%x MSOLVER
%x HB_MSOLVER
%x RATMSOLVER
%x NDMSOLVER
%x GTYPE
Expand Down Expand Up @@ -2170,13 +2172,13 @@ static inline double fltlist_next_token(int * const list_end){
}
else if(mnl->type == CLOVERDET) BEGIN(CLDETMONOMIAL);
else if(mnl->type == CLOVERDETRATIO) BEGIN(CLDETRATMONOMIAL);
else if(mnl->type == DETRATIO) BEGIN(DETRATMONOMIAL);
else if(mnl->type == CLOVERDETRATIORW) BEGIN(CLDETRATRWMONOMIAL);
else BEGIN(DETMONOMIAL);
}



<DETMONOMIAL,GAUGEMONOMIAL,NDPOLYMONOMIAL,POLYMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,CLDETRATRWMONOMIAL,CLPOLYMONOMIAL,NDRATMONOMIAL,NDRATCORMONOMIAL,NDCLRATMONOMIAL,NDCLRATCORMONOMIAL,RATMONOMIAL,CLRATMONOMIAL,RATCORMONOMIAL,CLRATCORMONOMIAL,NDDETRATMONOMIAL,NDCLDETRATMONOMIAL>{
<DETMONOMIAL,GAUGEMONOMIAL,NDPOLYMONOMIAL,POLYMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,CLDETRATRWMONOMIAL,CLPOLYMONOMIAL,NDRATMONOMIAL,NDRATCORMONOMIAL,NDCLRATMONOMIAL,NDCLRATCORMONOMIAL,RATMONOMIAL,CLRATMONOMIAL,RATCORMONOMIAL,CLRATCORMONOMIAL,NDDETRATMONOMIAL,NDCLDETRATMONOMIAL,DETRATMONOMIAL>{
{SPC}*Timescale{EQL}{DIGIT}+ {
if(mnl->type == NDDETRATIO || mnl->type == NDCLOVERDETRATIO) {
mnl->timescale = -5;
Expand Down Expand Up @@ -2338,6 +2340,66 @@ static inline double fltlist_next_token(int * const list_end){
}
}

<CLDETRATMONOMIAL,DETRATMONOMIAL>{
{SPC}*HB_Solver{EQL} {
solver_caller=YY_START;
BEGIN(HB_MSOLVER);
}
{SPC}*HB_MaxSolverIterations{EQL}{DIGIT}+ {
sscanf(yytext, " %[a-zA-Z_] = %d", name, &a);
mnl->HB_maxiter = a;
if(myverbose) printf(" HB_MaxSolverIterations set to %d line %d monomial %d\n", a, line_of_file, current_monomial);
}
{SPC}*HB_UseExternalInverter{EQL}quda {
if(myverbose) printf(" HB Use Quda inverter line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.external_inverter = QUDA_INVERTER;
}
{SPC}*HB_UseExternalInverter{EQL}qphix {
if(myverbose) printf(" HB Use QPhiX inverter line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.external_inverter = QPHIX_INVERTER;
}
{SPC}*HB_UseExternalInverter{EQL}no {
if(myverbose) printf(" HB Use QPhiX inverter line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.external_inverter = NO_EXT_INV;
}
{SPC}*HB_UseSloppyPrecision{EQL}yes {
if(myverbose) printf(" HB Use sloppy precision (single) in the inverter (if supported) line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.sloppy_precision = SLOPPY_SINGLE;
}
{SPC}*HB_UseSloppyPrecision{EQL}float {
if(myverbose) printf(" HB Use sloppy precision (single) in the inverter (if supported) line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.sloppy_precision = SLOPPY_SINGLE;
}
{SPC}*HB_UseSloppyPrecision{EQL}single {
if(myverbose) printf(" HB Use sloppy precision (single) in the inverter (if supported) line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.sloppy_precision = SLOPPY_SINGLE;
}
{SPC}*HB_UseSloppyPrecision{EQL}no {
if(myverbose) printf(" HB Use sloppy precision (double) in the inverter line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.sloppy_precision = SLOPPY_DOUBLE;
}
{SPC}*HB_UseSloppyPrecision{EQL}double {
if(myverbose) printf(" HB Use sloppy precision (double) in the inverter line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.sloppy_precision = SLOPPY_DOUBLE;
}
{SPC}*HB_UseSloppyPrecision{EQL}half {
if(myverbose) printf(" HB Use sloppy precision (half) in the inverter (if supported) line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.sloppy_precision = SLOPPY_HALF;
}
{SPC}*HB_UseCompression{EQL}12 {
if(myverbose) printf(" HB Use 12 compression in the inverter (if supported) line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.compression_type = COMPRESSION_12;
}
{SPC}*HB_UseCompression{EQL}8 {
if(myverbose) printf(" HB Use 8 compression in the inverter (if supported) line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.compression_type = COMPRESSION_8;
}
{SPC}*HB_UseCompression{EQL}18 {
if(myverbose) printf(" HB Not using compression in the inverter line %d monomial %d\n", line_of_file, current_monomial);
mnl->HB_solver_params.compression_type = NO_COMPRESSION;
}
}

<DETMONOMIAL,POLYMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,CLDETRATRWMONOMIAL,NDRATMONOMIAL,NDRATCORMONOMIAL,NDCLRATMONOMIAL,NDCLRATCORMONOMIAL,RATMONOMIAL,RATCORMONOMIAL,CLRATMONOMIAL,CLRATCORMONOMIAL,NDDETRATMONOMIAL,NDCLDETRATMONOMIAL>{
{SPC}*ForcePrecision{EQL}{FLT} {
sscanf(yytext, " %[a-zA-Z] = %lf",name , &c);
Expand Down Expand Up @@ -2637,6 +2699,51 @@ static inline double fltlist_next_token(int * const list_end){
}
}

<HB_MSOLVER>{
CG {
if(myverbose) printf(" HB Solver set to \"%s\" line %d monomial %d\n", yytext, line_of_file, current_monomial);
mnl->HB_solver = CG;
BEGIN(solver_caller);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check this line. We found that BEGIN(solver_caller) is necessary to continue reading the input file correctly but I do not understand the logic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. This allows the parser to return to the point it came from (after having parsed the solver string). To be precise, this is what happens in flex:

<CLDETRATMONOMIAL,DETRATMONOMIAL>{
  {SPC}*HB_Solver{EQL} {
   solver_caller=YY_START;
   BEGIN(HB_MSOLVER);  -> jump to HB_MSOLVER parser
  }
  [...] -->
  <HB_MSOLVER>{
  CG {
    if(myverbose) printf("  HB Solver set to \"%s\" line %d monomial %d\n", yytext, line_of_file, current_monomial);
    mnl->HB_solver = CG;
    BEGIN(solver_caller);  --> jump back
  }  
  [...]
  } <-- return to this point
    {SPC}*HB_MaxSolverIterations{EQL}{DIGIT}+ {
    sscanf(yytext, " %[a-zA-Z_] = %d", name, &a);
    mnl->HB_maxiter = a;
    if(myverbose) printf("  HB_MaxSolverIterations set to %d line %d monomial %d\n", a, line_of_file, current_monomial);
  }
  [...]

While looking at this I realised that there are actually a few bugs in the parser. There are instances of name_caller where instead there should be instances of solver_caller...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually surprised that the parsing of the monomials works correctly when the MG (or mixedbicgstab) is used as a solver... :)

}
mixedCG {
if(myverbose) printf(" HB Solver set to \"%s\" line %d monomial %d\n", yytext, line_of_file, current_monomial);
mnl->HB_solver = MIXEDCG;
BEGIN(solver_caller);
}
rgmixedCG {
if(myverbose) printf(" HB Solver set to \"%s\" line %d monomial %d\n", yytext, line_of_file, current_monomial);
mnl->HB_solver = RGMIXEDCG;
BEGIN(solver_caller);
}
BICGSTAB {
if(myverbose) printf(" HB Solver set to \"%s\" line %d monomial %d\n", yytext, line_of_file, current_monomial);
mnl->HB_solver = BICGSTAB;
BEGIN(solver_caller);
}
mixedbicgstab {
if(myverbose) printf(" HB Solver set to \"%s\" line %d monomial %d\n", yytext, line_of_file, current_monomial);
mnl->HB_solver=MIXEDBICGSTAB;
BEGIN(solver_caller);
}
MG {
if(myverbose) printf(" HB Solver set to \"%s\" line %d monomial %d\n", yytext, line_of_file, current_monomial);
mnl->HB_solver = MG;
BEGIN(solver_caller);
}
DDalphaAMG {
#ifdef DDalphaAMG
if(myverbose) printf(" HB Solver set to DDalphaAMG line %d operator %d\n", line_of_file, current_operator);
mnl->HB_solver = MG;
BEGIN(solver_caller);
#else
printf("ERROR line %d operator %d: DDalphaAMG library not included\n", line_of_file, current_operator);
exit(1);
#endif
}
}



<RATMSOLVER>{
rgmixedCG {
if(myverbose) printf(" Solver set to \"%s\" line %d monomial %d\n", yytext, line_of_file, current_monomial);
Expand Down
3 changes: 2 additions & 1 deletion solver/solver_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ typedef enum SOLVER_TYPE {
MG,
MIXEDBICGSTAB,
DUMMYHERMTEST,
CA_GCR
CA_GCR,
INVALID_SOLVER
} SOLVER_TYPE;

int solver_is_mixed( const int solver_type );
Expand Down