Skip to content

Commit

Permalink
basics for eigenvalues online / offline measurement wired up
Browse files Browse the repository at this point in the history
  • Loading branch information
kostrzewa committed Mar 15, 2024
1 parent 0809bc0 commit ab50052
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 9 deletions.
3 changes: 2 additions & 1 deletion meas/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ libmeas_TARGETS = measurements \
pion_norm \
polyakov_loop \
measure_clover_field_strength_observables \
gradient_flow
gradient_flow \
eigenvalues

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

Expand Down
10 changes: 5 additions & 5 deletions meas/eigenvalues.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void eigenvalues_measurement(const int traj, const int id, const int ieo) {
if(no_operators < 1){
tm_debug_printf(0, 0, "Error: no operators defined in input file, cannot perform eigenvalues online measurement!\n");
#ifdef TM_USE_MPI
MPI_Finallize();
MPI_Finalize();
#endif
exit(1);
}
Expand All @@ -61,9 +61,9 @@ void eigenvalues_measurement(const int traj, const int id, const int ieo) {
for( int op_id = 0; op_id < no_operators; op_id++ ){
operator * optr = &operator_list[op_id];

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

if( measurement_list[id].external_library == QUDA_LIB ){
#ifdef TM_USE_QUDA
eigsolveQuda(evals, eig.n_evals, eig.tol, 1, 0, eig.max_iterations, eig.maxmin,
eigsolveQuda(evals, eig.n_evals, eig.tol, 1, 0, eig.max_iter, eig.maxmin,
optr->eps_sq, optr->maxiter, eig.polydeg, eig.amin, eig.amax, eig.n_kr,
optr->solver, optr->solver, optr->rel_prec, ieo,
optr->sloppy_precision, optr->sloppy_precision, optr->compression_type,
Expand Down
5 changes: 5 additions & 0 deletions meas/measurements.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "default_input_values.h"
#include "read_input.h"

#include "eigenvalues.h"
#include "pion_norm.h"
#include "correlators.h"
#include "polyakov_loop.h"
Expand Down Expand Up @@ -80,6 +81,10 @@ int init_measurements(){
measurement_list[i].measurefunc = &gradient_flow_measurement;
}

if(measurement_list[i].type == EIGENVALUES) {
measurement_list[i].measurefunc = &eigenvalues_measurement;
}

measurement_list[i].id = i;
}
return(0);
Expand Down
2 changes: 1 addition & 1 deletion meas/measurements.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef struct {
int n_evals;
int blksize;
int blkwise;
int max_iterations;
int max_iter;
double tol;
int maxmin;
int polydeg;
Expand Down
69 changes: 67 additions & 2 deletions read_input.l
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ static inline double fltlist_next_token(int * const list_end){
%x PLOOP
%x ORIENTEDPLAQUETTESMEAS
%x GRADIENTFLOWMEAS
%x EIGENVALUESMEAS

%x REWEIGH
%x REWSAMPLES
Expand Down Expand Up @@ -3058,6 +3059,10 @@ static inline double fltlist_next_token(int * const list_end){
meas->type = GRADIENT_FLOW;
strcpy(meas->name, "GRADIENTFLOW");
}
else if(strcmp(yytext, "EIGENVALUES")==0) {
meas->type = EIGENVALUES;
strcpy(meas->name, "EIGENVALUES");
}
else {
fprintf(stderr, "Unknown measurement type %s in line %d\n", yytext, line_of_file);
exit(1);
Expand Down Expand Up @@ -3086,9 +3091,10 @@ static inline double fltlist_next_token(int * const list_end){
else if(meas->type == POLYAKOV) BEGIN(PLOOP);
else if(meas->type == ORIENTED_PLAQUETTES) BEGIN(ORIENTEDPLAQUETTESMEAS);
else if(meas->type == GRADIENT_FLOW) BEGIN(GRADIENTFLOWMEAS);
else if(meas->type == EIGENVALUES) BEGIN(EIGENVALUESMEAS);
}

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

<EIGENVALUESMEAS>{
{SPC}*Tolerance{EQL}{FLT} {
sscanf(yytext, " %[2a-zA-Z] = %lf", name, &c);
meas->eig.tol = c;
if(myverbose) printf(" Eigenvalue measurement tolerance set to %lf line %d, measurement id=%d\n", meas->eig.tol, line_of_file, meas->id);
}
{SPC}*NoEigenvalues{EQL}{DIGIT}+ {
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
meas->eig.n_evals = a;
if(myverbose) printf(" Number of eigenvalues to be determined set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
}
{SPC}*BlockSize{EQL}{DIGIT}+ {
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
meas->eig.blksize = a;
if(myverbose) printf(" Block size for eigensolver set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
}
{SPC}*Blockwise{EQL}yes {
meas->eig.blkwise = 1;
if(myverbose) printf(" Blockwise eigenvalue determination, line %d, measurement id=%d\n", line_of_file, meas->id);
}
{SPC}*Blockwise{EQL}no {
meas->eig.blkwise = 0;
if(myverbose) printf(" NO blockwise eigenvalue deterination, line %d, measurement id=%d\n", line_of_file, meas->id);
}
{SPC}*LargestEigenvalues{EQL}yes {
meas->eig.maxmin = 1;
if(myverbose) printf(" Largest eigenvalues to be determined, line %d, measurement id=%d\n", line_of_file, meas->id);
}
{SPC}*LargestEigenvalues{EQL}no {
meas->eig.maxmin = 0;
if(myverbose) printf(" Smallest eigenvalues to be determined, line %d, measurement id=%d\n", line_of_file, meas->id);
}
{SPC}*MaxIterations{EQL}{DIGIT}+ {
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
meas->eig.max_iter = a;
if(myverbose) printf(" Maximum number of iterations for eigensolver set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
}
{SPC}*PolynomialDegree{EQL}{DIGIT}+ {
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
meas->eig.polydeg = a;
if(myverbose) printf(" Degree of polynomial for eigensolver set to %d, line %d measurement id=%d\n", a, line_of_file, meas->id);
}
{SPC}*PolyMin{EQL}{FLT} {
sscanf(yytext, " %[2a-zA-Z] = %lf", name, &c);
meas->eig.amin = c;
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);
}
{SPC}*PolyMax{EQL}{FLT} {
sscanf(yytext, " %[2a-zA-Z] = %lf", name, &c);
meas->eig.amax = c;
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);
}
{SPC}*KrylovSubspaceSize{EQL}{DIGIT}+ {
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
meas->eig.n_kr = a;
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);
}
}

<PLOOP>{
{SPC}*Direction{EQL}[03] {
sscanf(yytext, " %[a-zA-Z] = %d", name, &a);
Expand Down Expand Up @@ -3691,7 +3756,7 @@ static inline double fltlist_next_token(int * const list_end){
BEGIN(comment_caller);
}

<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 {
<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 {
line_of_file++;
}
<*>{SPC}*\n {
Expand Down
50 changes: 50 additions & 0 deletions sample-input/sample-eigenvalues-measurement.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# example input file for eigenvalue measurements using "offline_measurement"
# requires 2 8^4 gauge configuration conf.0000 and conf.0002

L=8
T=8

DebugLevel = 5
ompnumthreads=4

InitialStoreCounter = 0
Measurements = 2
# measurements will be carried out in nsave steps
# e.g. for conf.0000 and conf.0002 in this case
nsave=2
2kappamu = 0.05
kappa = 0.177
BCAngleT = 1
GaugeConfigInputFile = conf
UseEvenOdd = yes

# the eigenvalues measurement requires at least ONE operator to be defined
# if multiple operators are defined, the measurement will loop over them
# and produce numbered output files
BeginMeasurement EIGENVALUES
Frequency = 1
NoEigenvalues = 10
LargestEigenvalues = yes
BlockSize = 1
Blockwise = no
MaxIterations = 10000
Tolerance = 1e-14
PolynomialDegree = 0
PolyMin = 0.0002
PolyMax = 0.003
KrylovSubspaceSize = 100
UseExternalLibrary = quda
EndMeasurement

# note: setting the solver to CGMMS will result in the CGMMS inversion taking place
# because the solver is not properly decoupled form the rest of the code
BeginOperator TMWILSON
2kappaMu = 0.05
kappa = 0.177
UseEvenOdd = yes
Solver = CG
SolverPrecision = 1e-14
MaxSolverIterations = 1000
AddDownPropagator = no
EndOperator

0 comments on commit ab50052

Please sign in to comment.