Skip to content

Commit

Permalink
WIP: eigenvalue online measurement
Browse files Browse the repository at this point in the history
  • Loading branch information
kostrzewa committed Mar 15, 2024
1 parent d24f12a commit 0809bc0
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 1 deletion.
101 changes: 101 additions & 0 deletions meas/eigenvalues.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/***********************************************************************
*
* Copyright (C) 2024 Bartosz Kostrzewa
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
*
************************************************************************/

#ifdef HAVE_CONFIG_H
# include <tmlqcd_config.h>
#endif
#ifdef TM_USE_OMP
# include <omp.h>
#endif

#include <string.h>
#include <stdio.h>

#include "global.h"
#include "geometry_eo.h"
#include "fatal_error.h"
#include "measurements.h"
#include "operator.h"
#include "gettime.h"
#include "tm_debug_printf.h"
#include "misc_types.h"

#ifdef TM_USE_QUDA
#include "quda_interface.h"
#endif

void eigenvalues_measurement(const int traj, const int id, const int ieo) {
tm_stopwatch_push(&g_timers, __func__, "");
init_operators();

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();
#endif
exit(1);
}

eig_param_t eig = measurement_list[id].eig;

double * evals = calloc(eig.n_evals, sizeof(double));

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 ){
tm_debug_printf(0, 0, "Error: only operator types WILSON, TMWILSON, CLOVER, DBTMWILSON and DBCLOVER are supported.\n");
#ifdef TM_USE_MPI
MPI_Finalize();
#endif
exit(1);
}

op_backup_restore_globals(TM_BACKUP_GLOBALS);
op_set_globals(op_id);

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,
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,
optr->type == CLOVER || optr->type == TMWILSON || optr->type == WILSON);
#else
tm_debug_printf(0, 0, "Error: Attempted to use QUDA eigensolver but this build was not configured for QUDA usage.\n");
#ifdef TM_USE_MPI
MPI_Finalize();
#endif
exit(1);
#endif
}

op_backup_restore_globals(TM_RESTORE_GLOBALS);

} // loop over operators

free(evals);
tm_stopwatch_pop(&g_timers, 0, 1, "");
return;
}

32 changes: 32 additions & 0 deletions meas/eigenvalues.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/***********************************************************************
*
* Copyright (C) 2024 Bartosz Kostrzewa
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#ifndef _MEASURE_EIGENVALUES_H
#define _MEASURE_EIGENVALUES_H

#include "su3.h"

/* implements the eigenvalue online measurement
* writes into eigenvalues.mXY.IJKLMN
* where XY corresponds to the operator index and IJKLMN refers to the trajectory counter */

void eigenvalues_measurement(const int traj, const int id, const int ieo);

#endif
20 changes: 19 additions & 1 deletion meas/measurements.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef _MEASUREMENTS_H
#define _MEASUREMENTS_H

#include "misc_types.h"

#define max_no_measurements 20

/* Give the measurement types an unambiguous ID*/
Expand All @@ -30,9 +32,23 @@ enum MEAS_TYPE {
PIONNORM,
POLYAKOV,
ORIENTED_PLAQUETTES,
GRADIENT_FLOW
GRADIENT_FLOW,
EIGENVALUES
};

typedef struct {
int n_evals;
int blksize;
int blkwise;
int max_iterations;
double tol;
int maxmin;
int polydeg;
double amin;
double amax;
int n_kr;
} eig_param_t;

typedef struct {
enum MEAS_TYPE type;
int initialised;
Expand Down Expand Up @@ -70,6 +86,8 @@ typedef struct {
void (*measurefunc) (const int traj, const int id, const int ieo);

ExternalLibrary external_library;

eig_param_t eig;
} measurement;


Expand Down

0 comments on commit 0809bc0

Please sign in to comment.