-
Notifications
You must be signed in to change notification settings - Fork 47
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
Hb solver #546
Changes from 16 commits
9640a58
7cdddf5
40482d0
c39d63e
327f2d8
860e5ad
2534c6c
141c9a6
3cf0922
7438daa
d0d772d
5bccf10
0d14fc4
cc5292a
4f02cc5
23f7f54
ff57999
0cc0336
c330493
7786c3e
ee1c4e1
8854044
41a9916
81a9c80
704b891
b855787
bcf6cfb
1d05e28
ad2738b
fe1d38b
bd9e369
5c25216
7f65fe9
10989e0
fadcbc1
d8a7d38
d24e5ce
ac9349e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,4 @@ doc/*.txt | |
doc/*.gpl | ||
doc/wrapper* | ||
history_hmc_tm | ||
.vscode/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) || | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -248,6 +251,12 @@ int init_monomials(const int V, const int even_odd_flag) { | |
} | ||
} | ||
else if(monomial_list[i].type == CLOVERDETRATIO) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need the same thing for |
||
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; | ||
|
@@ -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; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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; | ||
|
@@ -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); | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check this line. We found that There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
While looking at this I realised that there are actually a few bugs in the parser. There are instances of There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not true. We use CG here ...
There was a problem hiding this comment.
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
there is because when these solvers are used, a different kind of solve is performed.
There was a problem hiding this comment.
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).