Skip to content

Commit

Permalink
Obtained a working (on my laptopt) version of invert using lemon.
Browse files Browse the repository at this point in the history
Ironed out additional annoyances in the code while debugging with
-pedantic -Werror; this should not be directly relevant
(removing unused variables, etc), but be aware of this.
  • Loading branch information
Siebren committed Nov 27, 2009
1 parent f697395 commit 080e120
Show file tree
Hide file tree
Showing 37 changed files with 713 additions and 806 deletions.
6 changes: 3 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ MODULES = read_input gamma hybrid_update observables start \
test/check_geometry test/check_xchange \
invert_eo invert_doublet_eo \
polyakov_loop getopt sighandler reweighting_factor \
source_generation boundary io update_tm ranlxd \
source_generation boundary update_tm ranlxd \
mpi_init linsolve deriv_Sb deriv_Sb_D_psi ranlxs \
xchange_deri geometry_eo \
init_moment_field init_gauge_tmp propagator_io \
init_moment_field init_gauge_tmp \
xchange_field xchange_gauge \
init_gauge_field init_geometry_indices init_spinor_field \
init_dirac_halfspinor xchange_halffield stout_smear \
Expand All @@ -58,7 +58,7 @@ MODULES = read_input gamma hybrid_update observables start \
integrator gauge_monomial ndpoly_monomial phmc \
little_D block sf_gauge_monomial sf_utils sf_calc_action \
sf_get_staples sf_get_rectangle_staples sf_observables \
Dov_psi
Dov_psi io propagator_io

NOOPTMOD = test/check_xchange test/check_geometry

Expand Down
2 changes: 1 addition & 1 deletion Ptilde_nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Poly_tilde_ND(spinor *R_s, spinor *R_c, double *dd, int n,
spinor *S_s, spinor *S_c){

int j;
double fact1, fact2, temp, temp1, temp2, temp3, temp4;
double fact1, fact2, temp1, temp2, temp3, temp4;

spinor *svs_=NULL, *svs=NULL, *ds_=NULL, *ds=NULL, *dds_=NULL, *dds=NULL,
*auxs_=NULL, *auxs=NULL, *aux2s_=NULL, *aux2s=NULL, *aux3s_=NULL,
Expand Down
4 changes: 2 additions & 2 deletions chebyshev_polynomial_nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void QdaggerQ_poly(spinor *R_s, spinor *R_c, double *c, int n,
spinor *S_s, spinor *S_c){

int j;
double fact1, fact2, temp, temp1, temp2, temp3, temp4;
double fact1, fact2, temp1, temp2, temp3, temp4;

spinor *svs_=NULL, *svs=NULL, *ds_=NULL, *ds=NULL, *dds_=NULL, *dds=NULL,
*auxs_=NULL, *auxs=NULL, *aux2s_=NULL, *aux2s=NULL, *aux3s_=NULL,
Expand Down Expand Up @@ -267,7 +267,7 @@ double cheb_eval(int M, double *c, double s){


void degree_of_polynomial_nd(const int degree_of_p){
int i, j;
int j;
double temp, temp2;
static int ini=0;

Expand Down
1 change: 0 additions & 1 deletion gwc2ildg.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "global.h"
#include "getopt.h"
#include "io.h"
#include "gauge_io.h"
#include "read_input.h"
#include "mpi_init.h"
#ifdef MPI
Expand Down
1 change: 0 additions & 1 deletion init_stout_smear_vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ int init_stout_smear_vars(const int V, const int stout_no_iter)

int i, k, x, mu;

su3* tmp_su3_pointer;
i = 0;
k = 0;
mu = 0;
Expand Down
104 changes: 33 additions & 71 deletions invert.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ int check_geometry();

int main(int argc, char *argv[])
{
FILE *parameterfile = NULL, *ifs = NULL;
FILE *parameterfile = NULL;
FILE *ifs = NULL;
int c, iter, j, ix = 0, is = 0, ic = 0, err = 0;
char * filename = NULL;
char datafilename[50];
char parameterfilename[50];
char conf_filename[50];
char tmp_filename[50];
char * input_filename = NULL;
char * xlfmessage = NULL;
char * gaugelfn = NULL;
Expand All @@ -122,19 +122,13 @@ int main(int argc, char *argv[])
#pragma pomp inst init
#pragma pomp inst begin(main)
#endif

#ifdef HAVE_LIBLEMON
MPI_File fh;
LemonWriter *Writer;
#else
FILE * fh;
LimeWriter *Writer;
#endif

paramsXlfInfo *xlfInfo;
paramsSourceFormat *sourceFormat;
paramsPropagatorFormat *propagatorFormat;
paramsInverterInfo *inverterInfo;
WRITER *writer = NULL;

paramsXlfInfo *xlfInfo = NULL;
paramsSourceFormat *sourceFormat = NULL;
paramsPropagatorFormat *propagatorFormat = NULL;
paramsInverterInfo *inverterInfo = NULL;

#if (defined SSE || defined SSE2 || SSE3)
signal(SIGILL, &catch_ill_inst);
Expand Down Expand Up @@ -302,7 +296,14 @@ int main(int argc, char *argv[])
{
for (j = 0; j < g_no_extra_masses; j++)
{
fscanf(parameterfile, "%lf", &g_extra_masses[j]);
/* Code added below mainly to stop the compiler from whining! */
if (fscanf(parameterfile, "%lf", &g_extra_masses[j]) == EOF)
{
g_no_extra_masses = j + 1;
if (g_proc_id == 0 )
fprintf(stderr, "Reduced the number of extra masses to %d for lack of input values.\n", g_no_extra_masses);
break;
}
if (g_proc_id == 0 && g_debug_level > 0)
{
printf("# g_extra_masses[%d] = %lf\n", j, g_extra_masses[j]);
Expand Down Expand Up @@ -356,7 +357,8 @@ int main(int argc, char *argv[])
printf("Reading Gauge field from file %s\n", conf_filename);
fflush(stdout);
}
read_lime_gauge_field(conf_filename, &gaugecksum, &xlfmessage, &gaugelfn);
read_gauge_field(conf_filename, &gaugecksum, &xlfmessage, &gaugelfn);

if (g_proc_id == 0)
{
printf("done!\n");
Expand Down Expand Up @@ -586,44 +588,28 @@ int main(int argc, char *argv[])
mul_r(g_spinor_field[3], (2*g_kappa), g_spinor_field[3], VOLUME / 2);
}

#ifdef HAVE_LIBLEMON
MPI_File_open(g_cart_grid, conf_filename, MPI_MODE_WRONLY | MPI_MODE_CREATE | MPI_MODE_APPEND, MPI_INFO_NULL, &fh);
Writer = lemonCreateWriter(&fh, g_cart_grid);
#else
if(propagator_splitted || ix == 0) {
fh = fopen(conf_filename, "w");
}
else {
fh = fopen(conf_filename, "a");
}
Writer = limeCreateWriter(fh);
#endif
construct_writer(&writer, conf_filename);

if (write_prop_format_flag < 10)
{
if (propagator_splitted || ix == index_start)
{
xlfInfo = construct_paramsXlfInfo(plaquette_energy / (6.*VOLUME*g_nproc), nstore);
inverterInfo = construct_paramsInverterInfo(solver_precision, iter, solver_flag, 1);
#ifdef HAVE_LIBLEMON
write_spinor_info_parallel(Writer, xlfInfo, write_prop_format_flag, inverterInfo, gaugelfn, &gaugecksum);
#else /* HAVE_LIBLEMON */
write_spinor_info(Writer, xlfInfo, write_prop_format_flag, inverterInfo, gaugelfn, &gaugecksum);
#endif /* HAVE_LIBLEMON */

write_spinor_info(writer, xlfInfo, write_prop_format_flag, inverterInfo, gaugelfn, &gaugecksum);

free(xlfInfo);
free(inverterInfo);
}

/* write the source depending on format */
if (write_prop_format_flag == 1) {
sourceFormat = construct_paramsSourceFormat(32, 1, 4, 3);
#ifdef HAVE_LIBLEMON
write_source_format_parallel(Writer, sourceFormat);
write_spinor_parallel(Writer, &g_spinor_field[0], &g_spinor_field[1], 1, 32);
#else /* HAVE_LIBLEMON */
write_source_format(Writer, sourceFormat);
write_spinor(Writer, &g_spinor_field[0], &g_spinor_field[1], 1, 32);
#endif /* HAVE_LIBLEMON */

write_source_format(writer, sourceFormat);
write_spinor(writer, &g_spinor_field[0], &g_spinor_field[1], 1, 32);

free(sourceFormat);
}
}
Expand All @@ -633,13 +619,11 @@ int main(int argc, char *argv[])
ratime = (double)clock() / (double)(CLOCKS_PER_SEC);
#endif
propagatorFormat = construct_paramsPropagatorFormat(prop_precision_flag, 1);
#ifdef HAVE_LIBLEMON
write_propagator_format_parallel(Writer, propagatorFormat);
write_spinor_parallel(Writer, &g_spinor_field[2], &g_spinor_field[3], 1, prop_precision_flag);
#else /* HAVE_LIBLEMON */
write_propagator_format(Writer, propagatorFormat);
write_spinor(Writer, &g_spinor_field[2], &g_spinor_field[3], 1, prop_precision_flag);
#endif /* HAVE_LIBLEMON */

write_propagator_format(writer, propagatorFormat);
write_spinor(writer, &g_spinor_field[2], &g_spinor_field[3], 1, prop_precision_flag);

free(propagatorFormat);

#ifdef MPI
retime = MPI_Wtime();
Expand Down Expand Up @@ -670,30 +654,8 @@ int main(int argc, char *argv[])
printf("Inversion for source %d done in %d iterations, squared residue = %e!\n", ix, iter, nrm1 + nrm2);
printf("Inversion done in %1.2e sec. \n", etime - atime);
}

#ifdef HAVE_LIBLEMON /* Need to clear up the file to allow LIME routines access again - to be moved down eventually */
lemonDestroyWriter(Writer);
MPI_File_close(&fh);
#else /* HAVE_LIBLEMON */
limeDestroyWriter(Writer);
fclose(fh);
#endif /* HAVE_LIBLEMON */

#ifndef HAVE_LIBLEMON
if (solver_flag == 12 && g_no_extra_masses > 0)
{
for (j = 0; j < g_no_extra_masses + 1; j++)
{
sprintf(conf_filename, "%s.%.2d.Qsq.mass%.2d.inverted", source_input_filename, ix, j);
sprintf(tmp_filename, ".cgmms.%.2d.inverted", j);
rename(tmp_filename, conf_filename);
/* write_inverter_info(nrm1 + nrm2, iter, 0, 1, conf_filename, j); */
/* write_xlf_info(plaquette_energy / (6.*VOLUME*g_nproc), nstore, conf_filename, 1, xlfmessage); */
/* write_message(conf_filename, gaugelfn, "gauge-ildg-data-lfn-copy", 1); */
/* write_message(conf_filename, gaugecksum, "gauge-scidac-checksum-copy", 1); */
}
}
#endif /* !HAVE_LIBLEMON */

destruct_writer(writer);
}
nstore += Nsave;
}
Expand Down
5 changes: 5 additions & 0 deletions io/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ libio_TARGETS = utils_engineering \
utils_write_checksum \
utils_write_inverter_info \
utils_kill_with_error \
utils_construct_reader \
utils_destruct_reader \
utils_construct_writer \
utils_destruct_writer \
params_construct_ildgFormat \
params_construct_propagatorFormat \
params_construct_sourceFormat \
Expand All @@ -55,6 +59,7 @@ libio_TARGETS = utils_engineering \
spinor_read \
spinor_write_binary \
spinor_read_binary \
spinor_write_info \
spinor_write_source_format \
spinor_write_propagator_format \
spinor_write_propagator_type \
Expand Down
10 changes: 6 additions & 4 deletions io/gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
#include <io/selector.h>
#include <io/utils.h>

void read_gauge_field(char *filename, DML_Checksum *scidac_checksum, char **xlf_info, char **ildg_data_lfn);
void read_binary_gauge_data(READER *reader, DML_Checksum *checksum);
int read_gauge_field(char *filename, DML_Checksum *scidac_checksum, char **xlf_info, char **ildg_data_lfn);
int read_binary_gauge_data(READER *reader, DML_Checksum *checksum);

void write_gauge_field(char * filename, int prec, paramsXlfInfo const *xlfInfo);
void write_binary_gauge_data(WRITER *writer, const int prec, DML_Checksum * checksum);
int write_gauge_field(char * filename, int prec, paramsXlfInfo const *xlfInfo);
int write_binary_gauge_data(WRITER * writer, const int prec, DML_Checksum * checksum);

void write_ildg_format(WRITER *writer, paramsIldgFormat const *format);

#endif
4 changes: 2 additions & 2 deletions io/gauge_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int read_gauge_field(char * filename, DML_Checksum *scidac_checksum,
int gauge_read_flag = 0;
char *checksum_string = NULL;

construct_reader(reader, filename);
construct_reader(&reader, filename);

while ((status = ReaderNextRecord(reader)) != LIME_EOF)
{
Expand Down Expand Up @@ -70,7 +70,7 @@ int read_gauge_field(char * filename, DML_Checksum *scidac_checksum,
}

if (!gauge_read_flag)
kill_with_error(&ifs, g_cart_id, "Did not find gauge record. Aborting...\n");
kill_with_error(reader->fp, g_cart_id, "Did not find gauge record. Aborting...\n");


if (g_debug_level > 0 && g_cart_id == 0)
Expand Down
Loading

0 comments on commit 080e120

Please sign in to comment.