Skip to content

Commit ab50052

Browse files
committedMar 15, 2024··
basics for eigenvalues online / offline measurement wired up
1 parent 0809bc0 commit ab50052

6 files changed

+130
-9
lines changed
 

‎meas/Makefile.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ libmeas_TARGETS = measurements \
3737
pion_norm \
3838
polyakov_loop \
3939
measure_clover_field_strength_observables \
40-
gradient_flow
40+
gradient_flow \
41+
eigenvalues
4142

4243
libmeas_OBJECTS = $(addsuffix .o, ${libmeas_TARGETS})
4344

‎meas/eigenvalues.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void eigenvalues_measurement(const int traj, const int id, const int ieo) {
4949
if(no_operators < 1){
5050
tm_debug_printf(0, 0, "Error: no operators defined in input file, cannot perform eigenvalues online measurement!\n");
5151
#ifdef TM_USE_MPI
52-
MPI_Finallize();
52+
MPI_Finalize();
5353
#endif
5454
exit(1);
5555
}
@@ -61,9 +61,9 @@ void eigenvalues_measurement(const int traj, const int id, const int ieo) {
6161
for( int op_id = 0; op_id < no_operators; op_id++ ){
6262
operator * optr = &operator_list[op_id];
6363

64-
if( optr->type != TMWILSON || optr->type != WILSON ||
65-
optr->type != CLOVER || optr->type != DBTMWILSON ||
66-
optr->type != DBCLOVER ){
64+
if( !(optr->type == TMWILSON || optr->type == WILSON ||
65+
optr->type == CLOVER || optr->type == DBTMWILSON ||
66+
optr->type == DBCLOVER) ){
6767
tm_debug_printf(0, 0, "Error: only operator types WILSON, TMWILSON, CLOVER, DBTMWILSON and DBCLOVER are supported.\n");
6868
#ifdef TM_USE_MPI
6969
MPI_Finalize();
@@ -76,7 +76,7 @@ void eigenvalues_measurement(const int traj, const int id, const int ieo) {
7676

7777
if( measurement_list[id].external_library == QUDA_LIB ){
7878
#ifdef TM_USE_QUDA
79-
eigsolveQuda(evals, eig.n_evals, eig.tol, 1, 0, eig.max_iterations, eig.maxmin,
79+
eigsolveQuda(evals, eig.n_evals, eig.tol, 1, 0, eig.max_iter, eig.maxmin,
8080
optr->eps_sq, optr->maxiter, eig.polydeg, eig.amin, eig.amax, eig.n_kr,
8181
optr->solver, optr->solver, optr->rel_prec, ieo,
8282
optr->sloppy_precision, optr->sloppy_precision, optr->compression_type,

‎meas/measurements.c

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "default_input_values.h"
3131
#include "read_input.h"
3232

33+
#include "eigenvalues.h"
3334
#include "pion_norm.h"
3435
#include "correlators.h"
3536
#include "polyakov_loop.h"
@@ -80,6 +81,10 @@ int init_measurements(){
8081
measurement_list[i].measurefunc = &gradient_flow_measurement;
8182
}
8283

84+
if(measurement_list[i].type == EIGENVALUES) {
85+
measurement_list[i].measurefunc = &eigenvalues_measurement;
86+
}
87+
8388
measurement_list[i].id = i;
8489
}
8590
return(0);

‎meas/measurements.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef struct {
4040
int n_evals;
4141
int blksize;
4242
int blkwise;
43-
int max_iterations;
43+
int max_iter;
4444
double tol;
4545
int maxmin;
4646
int polydeg;

‎read_input.l

+67-2
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ static inline double fltlist_next_token(int * const list_end){
553553
%x PLOOP
554554
%x ORIENTEDPLAQUETTESMEAS
555555
%x GRADIENTFLOWMEAS
556+
%x EIGENVALUESMEAS
556557

557558
%x REWEIGH
558559
%x REWSAMPLES
@@ -3058,6 +3059,10 @@ static inline double fltlist_next_token(int * const list_end){
30583059
meas->type = GRADIENT_FLOW;
30593060
strcpy(meas->name, "GRADIENTFLOW");
30603061
}
3062+
else if(strcmp(yytext, "EIGENVALUES")==0) {
3063+
meas->type = EIGENVALUES;
3064+
strcpy(meas->name, "EIGENVALUES");
3065+
}
30613066
else {
30623067
fprintf(stderr, "Unknown measurement type %s in line %d\n", yytext, line_of_file);
30633068
exit(1);
@@ -3086,9 +3091,10 @@ static inline double fltlist_next_token(int * const list_end){
30863091
else if(meas->type == POLYAKOV) BEGIN(PLOOP);
30873092
else if(meas->type == ORIENTED_PLAQUETTES) BEGIN(ORIENTEDPLAQUETTESMEAS);
30883093
else if(meas->type == GRADIENT_FLOW) BEGIN(GRADIENTFLOWMEAS);
3094+
else if(meas->type == EIGENVALUES) BEGIN(EIGENVALUESMEAS);
30893095
}
30903096

3091-
<ONLINEMEAS,PIONNORMMEAS,PLOOP,ORIENTEDPLAQUETTESMEAS,GRADIENTFLOWMEAS>{
3097+
<ONLINEMEAS,PIONNORMMEAS,PLOOP,ORIENTEDPLAQUETTESMEAS,GRADIENTFLOWMEAS,EIGENVALUESMEAS>{
30923098
^EndMeasurement{SPC}* {
30933099
if(myverbose) printf("Measurement with id %d parsed in line %d\n\n", meas->id, line_of_file);
30943100
BEGIN(0);
@@ -3142,6 +3148,65 @@ static inline double fltlist_next_token(int * const list_end){
31423148
}
31433149
}
31443150

3151+
<EIGENVALUESMEAS>{
3152+
{SPC}*Tolerance{EQL}{FLT} {
3153+
sscanf(yytext, " %[2a-zA-Z] = %lf", name, &c);
3154+
meas->eig.tol = c;
3155+
if(myverbose) printf(" Eigenvalue measurement tolerance set to %lf line %d, measurement id=%d\n", meas->eig.tol, line_of_file, meas->id);
3156+
}
3157+
{SPC}*NoEigenvalues{EQL}{DIGIT}+ {
3158+
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
3159+
meas->eig.n_evals = a;
3160+
if(myverbose) printf(" Number of eigenvalues to be determined set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
3161+
}
3162+
{SPC}*BlockSize{EQL}{DIGIT}+ {
3163+
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
3164+
meas->eig.blksize = a;
3165+
if(myverbose) printf(" Block size for eigensolver set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
3166+
}
3167+
{SPC}*Blockwise{EQL}yes {
3168+
meas->eig.blkwise = 1;
3169+
if(myverbose) printf(" Blockwise eigenvalue determination, line %d, measurement id=%d\n", line_of_file, meas->id);
3170+
}
3171+
{SPC}*Blockwise{EQL}no {
3172+
meas->eig.blkwise = 0;
3173+
if(myverbose) printf(" NO blockwise eigenvalue deterination, line %d, measurement id=%d\n", line_of_file, meas->id);
3174+
}
3175+
{SPC}*LargestEigenvalues{EQL}yes {
3176+
meas->eig.maxmin = 1;
3177+
if(myverbose) printf(" Largest eigenvalues to be determined, line %d, measurement id=%d\n", line_of_file, meas->id);
3178+
}
3179+
{SPC}*LargestEigenvalues{EQL}no {
3180+
meas->eig.maxmin = 0;
3181+
if(myverbose) printf(" Smallest eigenvalues to be determined, line %d, measurement id=%d\n", line_of_file, meas->id);
3182+
}
3183+
{SPC}*MaxIterations{EQL}{DIGIT}+ {
3184+
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
3185+
meas->eig.max_iter = a;
3186+
if(myverbose) printf(" Maximum number of iterations for eigensolver set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
3187+
}
3188+
{SPC}*PolynomialDegree{EQL}{DIGIT}+ {
3189+
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
3190+
meas->eig.polydeg = a;
3191+
if(myverbose) printf(" Degree of polynomial for eigensolver set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
3192+
}
3193+
{SPC}*PolyMin{EQL}{FLT} {
3194+
sscanf(yytext, " %[2a-zA-Z] = %lf", name, &c);
3195+
meas->eig.amin = c;
3196+
if(myverbose) printf(" Minimum eigenvalue to exclude using polynomial acceleration in eigensolver set to %e line %d, measurement id=%d\n", c, line_of_file, meas->id);
3197+
}
3198+
{SPC}*PolyMax{EQL}{FLT} {
3199+
sscanf(yytext, " %[2a-zA-Z] = %lf", name, &c);
3200+
meas->eig.amax = c;
3201+
if(myverbose) printf(" Maximum eigenvalue to exclude using polynomial acceleration in eigensolver set to %e line %d, measurement id=%d\n", c, line_of_file, meas->id);
3202+
}
3203+
{SPC}*KrylovSubspaceSize{EQL}{DIGIT}+ {
3204+
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
3205+
meas->eig.n_kr = a;
3206+
if(myverbose) printf(" Krylov subspace size for polynomial acceleration in eigensolver set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
3207+
}
3208+
}
3209+
31453210
<PLOOP>{
31463211
{SPC}*Direction{EQL}[03] {
31473212
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
@@ -3691,7 +3756,7 @@ static inline double fltlist_next_token(int * const list_end){
36913756
BEGIN(comment_caller);
36923757
}
36933758

3694-
<INITMONOMIAL,DETMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,CLDETRATRWMONOMIAL,NDPOLYMONOMIAL,NDRATMONOMIAL,NDRATCORMONOMIAL,NDCLRATMONOMIAL,NDCLRATCORMONOMIAL,CLPOLYMONOMIAL,GAUGEMONOMIAL,INTEGRATOR,INITINTEGRATOR,INITMEASUREMENT,PIONNORMMEAS,ONLINEMEAS,ORIENTEDPLAQUETTESMEAS,GRADIENTFLOWMEAS,INITOPERATOR,TMOP,DBTMOP,OVERLAPOP,WILSONOP,CLOVEROP,DBCLOVEROP,POLYMONOMIAL,PLOOP,RATMONOMIAL,RATCORMONOMIAL,CLRATMONOMIAL,CLRATCORMONOMIAL,INITDEFLATION,DEFLATION,INITMULTIGRID,MULTIGRID,INITEXTERNALINVERTER,QUDAINVERTER,QPHIXINVERTER,NDDETRATMONOMIAL,NDCLDETRATMONOMIAL>{SPC}*\n {
3759+
<INITMONOMIAL,DETMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,CLDETRATRWMONOMIAL,NDPOLYMONOMIAL,NDRATMONOMIAL,NDRATCORMONOMIAL,NDCLRATMONOMIAL,NDCLRATCORMONOMIAL,CLPOLYMONOMIAL,GAUGEMONOMIAL,INTEGRATOR,INITINTEGRATOR,INITMEASUREMENT,PIONNORMMEAS,ONLINEMEAS,ORIENTEDPLAQUETTESMEAS,GRADIENTFLOWMEAS,EIGENVALUESMEAS,INITOPERATOR,TMOP,DBTMOP,OVERLAPOP,WILSONOP,CLOVEROP,DBCLOVEROP,POLYMONOMIAL,PLOOP,RATMONOMIAL,RATCORMONOMIAL,CLRATMONOMIAL,CLRATCORMONOMIAL,INITDEFLATION,DEFLATION,INITMULTIGRID,MULTIGRID,INITEXTERNALINVERTER,QUDAINVERTER,QPHIXINVERTER,NDDETRATMONOMIAL,NDCLDETRATMONOMIAL>{SPC}*\n {
36953760
line_of_file++;
36963761
}
36973762
<*>{SPC}*\n {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# example input file for eigenvalue measurements using "offline_measurement"
2+
# requires 2 8^4 gauge configuration conf.0000 and conf.0002
3+
4+
L=8
5+
T=8
6+
7+
DebugLevel = 5
8+
ompnumthreads=4
9+
10+
InitialStoreCounter = 0
11+
Measurements = 2
12+
# measurements will be carried out in nsave steps
13+
# e.g. for conf.0000 and conf.0002 in this case
14+
nsave=2
15+
2kappamu = 0.05
16+
kappa = 0.177
17+
BCAngleT = 1
18+
GaugeConfigInputFile = conf
19+
UseEvenOdd = yes
20+
21+
# the eigenvalues measurement requires at least ONE operator to be defined
22+
# if multiple operators are defined, the measurement will loop over them
23+
# and produce numbered output files
24+
BeginMeasurement EIGENVALUES
25+
Frequency = 1
26+
NoEigenvalues = 10
27+
LargestEigenvalues = yes
28+
BlockSize = 1
29+
Blockwise = no
30+
MaxIterations = 10000
31+
Tolerance = 1e-14
32+
PolynomialDegree = 0
33+
PolyMin = 0.0002
34+
PolyMax = 0.003
35+
KrylovSubspaceSize = 100
36+
UseExternalLibrary = quda
37+
EndMeasurement
38+
39+
# note: setting the solver to CGMMS will result in the CGMMS inversion taking place
40+
# because the solver is not properly decoupled form the rest of the code
41+
BeginOperator TMWILSON
42+
2kappaMu = 0.05
43+
kappa = 0.177
44+
UseEvenOdd = yes
45+
Solver = CG
46+
SolverPrecision = 1e-14
47+
MaxSolverIterations = 1000
48+
AddDownPropagator = no
49+
EndOperator
50+

0 commit comments

Comments
 (0)
Please sign in to comment.