Skip to content

Commit eedb242

Browse files
author
Carleton Detar
committedApr 18, 2018
Upgrade to Version 7 standards. Revise input parameter lines. Remove unnecessary calculations.
1 parent e3aea48 commit eedb242

11 files changed

+423
-573
lines changed
 

‎ks_eigen/Make_template

+29-35
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,24 @@ MY_HEADERS = \
3131
ks_eig_includes.h \
3232
quark_action.h
3333

34-
HEADERS = ${GLOBAL_HEADERS} ${MY_HEADERS} ${INLINE_HEADERS} ${SCIDAC_HEADERS}
34+
HEADERS = ${GLOBAL_HEADERS} ${MY_HEADERS} ${INLINE_HEADERS} \
35+
${QUDA_HEADERS} ${QPHIX_HEADERS} ${GRID_HEADERS} ${SCIDAC_HEADERS}
3536

37+
# All required object files
38+
# Basic set from current directory
3639
MY_OBJECTS = \
3740
control.o \
3841
gauge_info.o \
3942
setup.o
4043

44+
G_U1_OBJECTS = \
45+
io_u1lat.o \
46+
u1link.o \
47+
u1plaq.o
4148

42-
LAYOUT = layout_hyper_prime.o
49+
# Selection of layout
50+
51+
LAYOUT = layout_hyper_prime.o # Choices possible here
4352

4453
ADD_OBJECTS = ${MACHINE_DEP_IO} ${COMMPKG} jacobi.o spin_taste_ops.o gammas.o
4554

@@ -56,11 +65,6 @@ else
5665
ADDDEFINES += -DKalkreuter_Ritz
5766
endif
5867

59-
# # Generic QOP objects
60-
# ifeq ($(strip ${HAVEQOP}),true)
61-
# ADD_OBJECTS += ${GENERICQOP}
62-
# endif
63-
6468
OBJECTS = \
6569
${MY_OBJECTS} \
6670
${FFT_OBJECTS} \
@@ -77,7 +81,8 @@ QCDLIB = ${LIBDIR}/su3.${P}.a ${LIBDIR}/complex.${P}.a
7781
LIBRARIES = ${QCDLIB} ${SCIDAC_LIBRARIES} ${QUDA_LIBRARIES}
7882

7983
# Default rule for C compilation
80-
.c.o: ; ${CC} -c ${CFLAGS} $*.c
84+
.c.o: ; ${CC} -c ${CFLAGS} $<
85+
.cc.o: ; ${CXX} -c ${CXXFLAGS} $<
8186

8287
# To force a full remake when changing targets
8388
LASTMAKE = .lastmake.${MAKEFILE}.${P}.${MYTARGET}
@@ -89,13 +94,13 @@ ${LASTMAKE}: ${ALL_MAKES}
8994

9095
# All make files used in this compilation
9196
ALL_MAKES = \
92-
Make_template \
93-
${MAKEFILE} \
94-
../Make_template_combos \
95-
../Make_template_scidac \
96-
../generic/Make_template \
97-
../generic_ks/Make_template \
98-
../generic_wilson/Make_template
97+
Make_template \
98+
${MAKEFILE} \
99+
../Make_template_combos \
100+
../Make_template_scidac \
101+
../generic/Make_template \
102+
../generic_ks/Make_template \
103+
../generic_u1/Make_template
99104

100105
# To force a remake when changing any make file, header, or target
101106
${OBJECTS} : ${LASTMAKE} ${HEADERS} ${ALL_MAKES}
@@ -107,32 +112,13 @@ quark_action.h: ${QUARKIMP}/${QUARK}
107112
@echo Copying quark_action.h from ${QUARKIMP}/${QUARK}
108113
/bin/cp ${QUARKIMP}/${QUARK} quark_action.h
109114

110-
ifeq ($(strip ${HAVEQMP}),true)
111-
DHAVE_QMP = -DHAVE_QMP
112-
endif
113-
114-
ifeq ($(strip ${HAVEQIO}),true)
115-
DHAVE_QIO = -DHAVE_QIO
116-
endif
117-
118-
ifeq ($(strip ${HAVEQDP}),true)
119-
DHAVE_QDP = -DHAVE_QDP
120-
endif
121-
122-
ifeq ($(strip ${HAVEQOP}),true)
123-
DHAVE_QOP = -DHAVE_QOP
124-
endif
125-
126-
DARCH = ${DQCDOC} ${DHAVE_QMP} ${DHAVE_QIO} ${DHAVE_QDP} ${DHAVE_QOP}
115+
##### Targets:
127116

128-
########################################################
129117
# Optional DEFINES for targets
130118

131119
# -DFN identifies fat-Naik-like actions with only next and 3rd
132120
# next neighbor linkage
133121

134-
##### Targets:
135-
136122
su3_eigen_asqtad::
137123
${MAKE} -f ${MAKEFILE} target "MYTARGET = $@" \
138124
"DEFINES = -DFN -DEIGEN_QIO" \
@@ -145,6 +131,14 @@ su3_eigen_hisq::
145131
"QUARK = hisq/hisq_u3_action.h" \
146132
"EXTRA_OBJECTS = ${HISQ_OBJECTS}"
147133

134+
# HISQ + U(1) targets WARNING: Naive implementation
135+
136+
su3_u1_eigen_hisq::
137+
${MAKE} -f ${MAKEFILE} target "MYTARGET = $@" \
138+
"DEFINES = -DFN -DEIGEN_QIO -DU1_FIELD" \
139+
"QUARK = hisq/hisq_u3_action.h" \
140+
"EXTRA_OBJECTS = ${HISQ_OBJECTS} ${G_U1_OBJECTS}"
141+
148142
# No QOP support for p4, so we use pure MILC routines only and
149143
# undefine the macros HAVE_QOP and HAVE_QDP
150144
# Currently not supported. Needs fixing.

‎ks_eigen/control.c

+105-89
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
#define CONTROL
66
#include "ks_eig_includes.h" /* definitions files and prototypes */
77

8-
EXTERN gauge_header start_lat_hdr; /* Input gauge field header */
8+
#ifdef HAVE_QUDA
9+
#include <quda_milc_interface.h>
10+
#endif
11+
#ifdef U1_FIELD
12+
#include "../include/io_u1lat.h"
13+
#endif
914

1015
int main( int argc, char **argv ){
1116
register site *s;
1217
int i,si;
1318
int prompt;
1419
double dtime;
1520
// su3_vector **eigVec ;
16-
su3_vector *tmp ;
1721
// double *eigVal ;
1822
int total_R_iters ;
1923
double *resid = NULL;
@@ -26,7 +30,9 @@ int main( int argc, char **argv ){
2630

2731
g_sync();
2832
/* set up */
33+
STARTTIME;
2934
prompt = setup();
35+
ENDTIME("setup");
3036

3137
/* loop over input sets */
3238
while( readin(prompt) == 0){
@@ -38,36 +44,74 @@ int main( int argc, char **argv ){
3844
#ifdef HYPISQ_SVD_COUNTER
3945
hypisq_svd_counter = 0;
4046
#endif
41-
restore_fermion_links_from_site(fn_links, MILC_PRECISION);
4247

48+
/* Fix the gauge */
49+
50+
if( param.fixflag == COULOMB_GAUGE_FIX)
51+
{
52+
if(this_node == 0)
53+
printf("Fixing to Coulomb gauge\n");
54+
55+
rephase( OFF );
56+
STARTTIME;
57+
gaugefix(TUP,(Real)1.8,500,GAUGE_FIX_TOL);
58+
ENDTIME("gauge fix");
59+
}
60+
else
61+
if(this_node == 0)printf("COULOMB GAUGE FIXING SKIPPED.\n");
62+
63+
/* save lattice if requested */
64+
if( param.saveflag != FORGET ){
65+
rephase( OFF );
66+
savelat_p = save_lattice( param.saveflag, param.savefile,
67+
param.stringLFN );
68+
rephase( ON );
69+
}
70+
71+
#ifdef U1_FIELD
72+
if( param.save_u1flag != FORGET ){
73+
save_u1_lattice( param.save_u1flag, param.save_u1file );
74+
}
75+
76+
/* Insert U(1) phases into the gauge links in the site structure */
77+
u1phase_on(param.charge, u1_A);
78+
invalidate_fermion_links(fn_links);
79+
#endif
80+
81+
/* Recompute FN links from the links in the site structure */
82+
restore_fermion_links_from_site(fn_links, MILC_PRECISION);
83+
84+
/* Eigenpair calculation */
85+
STARTTIME;
86+
4387
eigVal = (double *)malloc(param.eigen_param.Nvecs*sizeof(double));
4488
eigVec = (su3_vector **)malloc(param.eigen_param.Nvecs*sizeof(su3_vector*));
4589
for(i=0;i<param.eigen_param.Nvecs;i++)
46-
eigVec[i]=
47-
(su3_vector*)malloc(sites_on_node*sizeof(su3_vector));
48-
49-
/* call fermion_variable measuring routines */
50-
/* results are printed in output file */
51-
f_meas_imp( 1, MILC_PRECISION, F_OFFSET(phi), F_OFFSET(xxx), mass,
52-
0, fn_links);
53-
90+
eigVec[i]= (su3_vector*)malloc(sites_on_node*sizeof(su3_vector));
91+
5492
fn = get_fm_links(fn_links);
93+
/* Calculate eigenpairs on even sites */
5594
param.eigen_param.parity = EVEN;
5695
total_R_iters=ks_eigensolve(eigVec, eigVal, &param.eigen_param, 1);
57-
construct_eigen_odd(eigVec, eigVal, &param.eigen_param, fn[0]);
96+
fflush(stdout);
5897

98+
/* Construct eigenpairs on odd sites */
99+
construct_eigen_odd(eigVec, eigVal, &param.eigen_param, fn[0]);
100+
59101
/* Calculate and print the residues and norms of the eigenvectors */
60102
resid = (double *)malloc(param.eigen_param.Nvecs*sizeof(double));
61103
node0_printf("Even site residuals\n");
62104
check_eigres( resid, eigVec, eigVal, param.eigen_param.Nvecs, EVEN, fn[0] );
63105
node0_printf("Odd site residuals\n");
64106
check_eigres( resid, eigVec, eigVal, param.eigen_param.Nvecs, ODD, fn[0] );
65-
107+
fflush(stdout);
108+
66109
/* save eigenvectors if requested */
67110
int status = save_ks_eigen(param.ks_eigen_saveflag, param.ks_eigen_savefile,
68-
param.eigen_param.Nvecs, eigVal, eigVec, resid, 1);
111+
param.eigen_param.Nvecs, eigVal, eigVec, resid, 1);
112+
69113
if(status != 0){
70-
node0_printf("ERROR writing eigenvectors\n");
114+
node0_printf("ERROR writing eigenvectors\n"); fflush(stdout);
71115
}
72116

73117
/* print eigenvalues of iDslash */
@@ -80,92 +124,64 @@ int main( int argc, char **argv ){
80124
node0_printf("eigenval(%i): %10g\n",i,chirality) ;
81125
}
82126

83-
tmp = (su3_vector*)malloc(sites_on_node*sizeof(su3_vector));
84-
for(i=0;i<param.eigen_param.Nvecs;i++)
85-
{
86-
// if ( eigVal[i] > 10.0*eigenval_tol )
87-
// {
88-
/* Construct to odd part of the vector. *
89-
* Note that the true odd part of the eigenvector is *
90-
* i/sqrt(eigVal) Dslash Psi. But since I only compute *
91-
* the chirality the i factor is irrelevant (-i)*i=1!! */
92-
dslash_field(eigVec[i], tmp, ODD, fn[0]) ;
93-
FORSOMEPARITY(si,s,ODD){
94-
scalar_mult_su3_vector( &(tmp[si]),
95-
1.0/sqrt(eigVal[i]),
96-
&(eigVec[i][si]) ) ;
97-
}
98-
99-
// measure_chirality(eigVec[i], &chirality, EVENANDODD);
100-
/* Here I divide by 2 since the EVEN vector is normalized to
101-
* 1. The EVENANDODD vector is normalized to 2. I could have
102-
* normalized the EVENANDODD vector to 1 and then not devide
103-
* by to. The measure_chirality routine assumes vectors
104-
* normalized to 1. */
105-
// node0_printf("Chirality(%i): %g\n",i,chirality/2) ;
106-
measure_chirality(eigVec[i], &chir_ev, EVEN);
107-
measure_chirality(eigVec[i], &chir_od, ODD);
108-
chirality = (chir_ev + chir_od) / 2.0;
109-
node0_printf("Chirality(%i) -- even, odd, total: %10g, %10g, %10g\n",
110-
i,chir_ev,chir_od,chirality) ;
111-
// }
112-
// else
113-
// {
114-
/* This is considered a "zero mode", and treated as such */
115-
// measure_chirality(eigVec[i], &chirality, EVEN);
116-
// node0_printf("Chirality(%i): %g\n",i,chirality) ;
117-
// }
118-
}
119-
#ifdef EO
120-
cleanup_dslash_temps();
121-
#endif
122-
free(tmp);
123-
/**
124-
for(i=0;i<Nvecs;i++)
125-
{
126-
sprintf(label,"DENSITY(%i)",i) ;
127-
print_densities(eigVec[i], label, ny/2,nz/2,nt/2, EVEN) ;
128-
}
129-
**/
130-
for(i=0;i<param.eigen_param.Nvecs;i++)
131-
free(eigVec[i]) ;
132-
free(eigVec) ;
133-
free(eigVal) ;
127+
#ifdef U1_FIELD
128+
/* Unapply the U(1) field phases */
129+
u1phase_off();
134130
invalidate_fermion_links(fn_links);
135-
fflush(stdout);
131+
#endif
132+
ENDTIME("calculate Dirac eigenpairs");
136133

137-
node0_printf("RUNNING COMPLETED\n"); fflush(stdout);
138-
dtime += dclock();
139-
if(this_node==0){
140-
printf("Time = %e seconds\n",dtime);
141-
printf("total_iters = %d\n",total_iters);
142-
printf("total Rayleigh iters = %d\n",total_R_iters);
134+
#ifdef CHIRALITY
135+
measure_chirality(eigVec[i], &chir_ev, EVEN);
136+
measure_chirality(eigVec[i], &chir_od, ODD);
137+
chirality = (chir_ev + chir_od) / 2.0;
138+
node0_printf("Chirality(%i) -- even, odd, total: %10g, %10g, %10g\n",
139+
i,chir_ev,chir_od,chirality) ;
140+
#endif
141+
}
142+
#ifdef EO
143+
cleanup_dslash_temps();
144+
#endif
145+
/**
146+
for(i=0;i<Nvecs;i++)
147+
{
148+
sprintf(label,"DENSITY(%i)",i) ;
149+
print_densities(eigVec[i], label, ny/2,nz/2,nt/2, EVEN) ;
150+
}
151+
**/
152+
153+
/* Clean up eigen storage */
154+
for(i = 0; i < param.eigen_param.Nvecs; i++) free(eigVec[i]);
155+
free(eigVal); free(eigVec); free(resid);
156+
invalidate_fermion_links(fn_links);
157+
158+
node0_printf("RUNNING COMPLETED\n"); fflush(stdout);
159+
dtime += dclock();
160+
if(this_node==0){
161+
printf("Time = %e seconds\n",dtime);
162+
printf("total Rayleigh iters = %d\n",total_R_iters);
143163
#ifdef HISQ_SVD_COUNTER
144-
printf("hisq_svd_counter = %d\n",hisq_svd_counter);
164+
printf("hisq_svd_counter = %d\n",hisq_svd_counter);
145165
#endif
146166
#ifdef HYPISQ_SVD_COUNTER
147-
printf("hypisq_svd_counter = %d\n",hypisq_svd_counter);
167+
printf("hypisq_svd_counter = %d\n",hypisq_svd_counter);
148168
#endif
149-
}
150-
fflush(stdout);
151-
152-
destroy_ape_links_4D(ape_links);
153-
154-
/* Destroy fermion links (created in readin() */
155-
169+
}
170+
fflush(stdout);
171+
172+
/* Destroy fermion links (created in readin() */
173+
156174
#if FERM_ACTION == HISQ
157-
destroy_fermion_links_hisq(fn_links);
175+
destroy_fermion_links_hisq(fn_links);
158176
#else
159-
destroy_fermion_links(fn_links);
177+
destroy_fermion_links(fn_links);
160178
#endif
161-
fn_links = NULL;
162-
163-
} /* readin(prompt) */
164-
179+
fn_links = NULL;
180+
165181
#ifdef HAVE_QUDA
166182
qudaFinalize();
167183
#endif
168-
184+
169185
normal_exit(0);
170186
return 0;
171187
}

‎ks_eigen/ks_eig_includes.h

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
#define dslash_field dslash_eo_field
3131
#endif
3232

33+
#ifdef PRTIME
34+
#define STARTTIME dtime = -dclock();
35+
#define ENDTIME(string) dtime += dclock(); node0_printf("Aggregate time to %s %e\n",(string),dtime);
36+
#else
37+
#define STARTTIME
38+
#define ENDTIME(string)
39+
#endif
40+
3341
/* prototypes for functions in high level code */
3442
int setup();
3543
int readin(int prompt);

0 commit comments

Comments
 (0)