Skip to content

Commit

Permalink
refurbished the ReproduceRandomNumbers input parameter
Browse files Browse the repository at this point in the history
Setting

ReproduceRandomNumbers = yes

in the input file should now produce really identical random numbers
not depending on MPI or scalar.

Between scalar and MPI I do see a difference in the 11th digit of
deltaH, which is rouding.
  • Loading branch information
urbach committed Nov 25, 2012
1 parent 35846e5 commit d9d22ff
Show file tree
Hide file tree
Showing 31 changed files with 326 additions and 327 deletions.
2 changes: 1 addition & 1 deletion P_M_eta.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ void Check_Approximation(double const mstar) {
Sin =calloc(VOLUMEPLUSRAND, sizeof(spinor));
#endif

random_spinor_field(Sin, VOLUME, 1);
random_spinor_field_lexic(Sin, 0);

s_ = calloc(4*VOLUMEPLUSRAND+1, sizeof(spinor));
s = calloc(4, sizeof(spinor*));
Expand Down
6 changes: 3 additions & 3 deletions Ptilde_nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ double chebtilde_eval(int M, double *dd, double s){
void degree_of_Ptilde(int * _degree, double ** coefs,
const double EVMin, const double EVMax,
const int sloppy_degree, const double acc,
matrix_mult_nd Qsq) {
matrix_mult_nd Qsq, const int repro) {
int i, j;
double temp, temp2;
int degree;
Expand Down Expand Up @@ -307,8 +307,8 @@ void degree_of_Ptilde(int * _degree, double ** coefs,
if(g_debug_level > 0) {
/* Ptilde P S P Ptilde X - X */
/* for random spinor X */
random_spinor_field(ss,VOLUME/2, 1);
random_spinor_field(sc,VOLUME/2, 1);
random_spinor_field_eo(ss, repro);
random_spinor_field_eo(sc, repro);

Ptilde_ndpsi(&auxs[0], &auxc[0], *coefs, degree, &ss[0], &sc[0], Qsq);
Ptilde_ndpsi(&aux2s[0], &aux2c[0], phmc_dop_cheby_coef, phmc_dop_n_cheby, &auxs[0], &auxc[0], Qsq);
Expand Down
2 changes: 1 addition & 1 deletion Ptilde_nd.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ double chebtilde_eval(int M, double *dd, double s);
void degree_of_Ptilde(int * _degree, double ** coefs,
const double EVMin, const double EVMax,
const int sloppy_degree, const double acc,
matrix_mult_nd Qsw);
matrix_mult_nd Qsw, const int repro);

#endif
4 changes: 2 additions & 2 deletions benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ int main(int argc,char *argv[])
j_max=2048;
sdt=0.;
for (k = 0; k < k_max; k++) {
random_spinor_field(g_spinor_field[k], VOLUME/2, 0);
random_spinor_field_eo(g_spinor_field[k], reproduce_randomnumber_flag);
}

while(sdt < 30.) {
Expand Down Expand Up @@ -366,7 +366,7 @@ int main(int argc,char *argv[])
j_max=1;
sdt=0.;
for (k=0;k<k_max;k++) {
random_spinor_field(g_spinor_field[k], VOLUME, 0);
random_spinor_field_lexic(g_spinor_field[k], reproduce_randomnumber_flag);
}

while(sdt < 3.) {
Expand Down
8 changes: 4 additions & 4 deletions chebyshev_polynomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ double stopeps=5.0e-16;
int dop_n_cheby=0;
double * dop_cheby_coef;

void degree_of_polynomial(){
void degree_of_polynomial(const int repro){
int i;
double temp;
static int ini=0;
Expand Down Expand Up @@ -289,11 +289,11 @@ void degree_of_polynomial(){
aux3c=calloc(VOLUMEPLUSRAND/2, sizeof(spinor));
#endif

chebyshev_polynomial(cheb_evmin, cheb_evmax, dop_cheby_coef, N_CHEBYMAX, 0.25);
chebyshev_polynomial(cheb_evmin, cheb_evmax, dop_cheby_coef, N_CHEBYMAX, 0.25);

temp=1.0;
random_spinor_field(ss,VOLUME/2);
random_spinor_field(sc,VOLUME/2);
random_spinor_field_eo(ss, repro);
random_spinor_field_eo(sc, repro);
/* assign(&sc[0], &ss[0],VOLUME/2);
Qtm_pm_psi(&auxs[0], &ss[0]);
Expand Down
2 changes: 1 addition & 1 deletion chebyshev_polynomial.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ void chebyshev_polynomial(double a, double b, double c[], int n, double exponent

void QdaggerQ_power(spinor *R_s, spinor *R_c, double *c, int n, spinor *S_s, spinor *S_c);

void degree_of_polynomial();
void degree_of_polynomial(const int repro);

#endif
6 changes: 3 additions & 3 deletions chebyshev_polynomial_nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ double cheb_eval(int M, double *c, double s){

void degree_of_polynomial_nd(int * _degree_of_p, double ** coefs,
const double EVMin, const double EVMax,
matrix_mult_nd Qsq) {
matrix_mult_nd Qsq, const int repro) {
double temp, temp2;
int degree_of_p = *_degree_of_p + 1;

Expand All @@ -130,8 +130,8 @@ void degree_of_polynomial_nd(int * _degree_of_p, double ** coefs,

chebyshev_coefs(EVMin, EVMax, *coefs, degree_of_p, -0.5);

random_spinor_field(ss,VOLUME/2, 1);
random_spinor_field(sc,VOLUME/2, 1);
random_spinor_field_eo(ss, repro);
random_spinor_field_eo(sc, repro);

if((g_proc_id == g_stdio_proc) && (g_debug_level > 0)){
printf("# NDPOLY MD Polynomial: EVmin = %e EVmax = %e \n", EVMin, EVMax);
Expand Down
2 changes: 1 addition & 1 deletion chebyshev_polynomial_nd.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ double cheb_eval(int M, double *c, double s);

void degree_of_polynomial_nd(int * _degree_of_p, double ** coefs,
const double EVMin, const double EVMax,
matrix_mult_nd Qsq);
matrix_mult_nd Qsq, const int repro);

#endif
2 changes: 1 addition & 1 deletion hopping_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ int main(int argc,char *argv[])
/*initialize the pseudo-fermion fields*/
j_max=1;
for (k = 0; k < k_max; k++) {
random_spinor_field(g_spinor_field[k], VOLUME/2, 0);
random_spinor_field_eo(g_spinor_field[k], reproduce_randomnumber_flag);
}

if (read_source_flag == 2) { /* save */
Expand Down
154 changes: 60 additions & 94 deletions hybrid_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,120 +105,88 @@ double moment_energy(su3adj ** const momenta) {
double init_momenta(const int repro, su3adj ** const momenta) {

su3adj *xm;
int i, mu;
int i, mu, t0, x, y, z, X, Y, Z, t, id = 0;
int coords[4];
#ifdef MPI
int k;
int rlxd_state[105];
#endif
static double y[8];
static double tt,tr,ts,kc,ks,sum;
double ALIGN yy[8];
double ALIGN tt, tr, ts, kc = 0., ks = 0., sum;

if(repro == 1) {
if(g_proc_id==0){
kc=0.;
ks=0.;
for(i=0;i<VOLUME;i++){
for(mu=0;mu<4;mu++){
sum=0.;
xm=&momenta[i][mu];
gauss_vector(y,8);
/* from the previous line we get exp(-y^2) distribution */
/* this means that <y^2> = sigma^2 = 1/2 */
/* in order to get <y^2> = 1 distribution ==> *sqrt(2) */
(*xm).d1=1.4142135623731*y[0];
(*xm).d2=1.4142135623731*y[1];
sum+=(*xm).d1*(*xm).d1+(*xm).d2*(*xm).d2;
(*xm).d3=1.4142135623731*y[2];
(*xm).d4=1.4142135623731*y[3];
sum+=(*xm).d3*(*xm).d3+(*xm).d4*(*xm).d4;
(*xm).d5=1.4142135623731*y[4];
(*xm).d6=1.4142135623731*y[5];
sum+=(*xm).d5*(*xm).d5+(*xm).d6*(*xm).d6;
(*xm).d7=1.4142135623731*y[6];
(*xm).d8=1.4142135623731*y[7];
sum+=(*xm).d7*(*xm).d7+(*xm).d8*(*xm).d8;
tr=sum+kc;
ts=tr+ks;
tt=ts-ks;
ks=ts;
kc=tr-tt;
}
}
if(repro) {
#ifdef MPI
/* send the state for the random-number generator to 1 */
if(g_proc_id == 0) {
rlxd_get(rlxd_state);
MPI_Send(&rlxd_state[0], 105, MPI_INT, 1, 101, MPI_COMM_WORLD);
#endif
}

MPI_Bcast(rlxd_state, 105, MPI_INT, 0, MPI_COMM_WORLD);
rlxd_reset(rlxd_state);
#endif
for(t0 = 0; t0 < g_nproc_t*T; t0++) {
t = t0 - T*g_proc_coords[0];
coords[0] = t0 / T;
for(x = 0; x < g_nproc_x*LX; x++) {
X = x - g_proc_coords[1]*LX;
coords[1] = x / LX;
for(y = 0; y < g_nproc_y*LY; y++) {
Y = y - g_proc_coords[2]*LY;
coords[2] = y / LY;
for(z = 0; z < g_nproc_z*LZ; z++) {
Z = z - g_proc_coords[3]*LZ;
coords[3] = z / LZ;
#ifdef MPI
if(g_proc_id != 0){
MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_proc_id-1, 101, MPI_COMM_WORLD, &status);
rlxd_reset(rlxd_state);
kc=0.; ks=0.;
for(i=0;i<VOLUME;i++){
for(mu=0;mu<4;mu++){
sum=0.;
xm=&momenta[i][mu];
gauss_vector(y,8);
(*xm).d1=1.4142135623731*y[0];
(*xm).d2=1.4142135623731*y[1];
sum+=(*xm).d1*(*xm).d1+(*xm).d2*(*xm).d2;
(*xm).d3=1.4142135623731*y[2];
(*xm).d4=1.4142135623731*y[3];
sum+=(*xm).d3*(*xm).d3+(*xm).d4*(*xm).d4;
(*xm).d5=1.4142135623731*y[4];
(*xm).d6=1.4142135623731*y[5];
sum+=(*xm).d5*(*xm).d5+(*xm).d6*(*xm).d6;
(*xm).d7=1.4142135623731*y[6];
(*xm).d8=1.4142135623731*y[7];
sum+=(*xm).d7*(*xm).d7+(*xm).d8*(*xm).d8;
tr=sum+kc;
ts=tr+ks;
tt=ts-ks;
ks=ts;
kc=tr-tt;
MPI_Cart_rank(g_cart_grid, coords, &id);
#endif
if(g_cart_id == id) i = g_ipt[t][X][Y][Z];
for(mu = 0; mu < 4; mu++) {
gauss_vector(yy,8);
if(g_cart_id == id) {
sum = 0.;
xm = &momenta[i][mu];
(*xm).d1 = 1.4142135623731*yy[0];
(*xm).d2 = 1.4142135623731*yy[1];
sum += (*xm).d1*(*xm).d1+(*xm).d2*(*xm).d2;
(*xm).d3 = 1.4142135623731*yy[2];
(*xm).d4 = 1.4142135623731*yy[3];
sum += (*xm).d3*(*xm).d3+(*xm).d4*(*xm).d4;
(*xm).d5 = 1.4142135623731*yy[4];
(*xm).d6 = 1.4142135623731*yy[5];
sum += (*xm).d5*(*xm).d5+(*xm).d6*(*xm).d6;
(*xm).d7 = 1.4142135623731*yy[6];
(*xm).d8 = 1.4142135623731*yy[7];
sum += (*xm).d7*(*xm).d7+(*xm).d8*(*xm).d8;
tr = sum+kc;
ts = tr+ks;
tt = ts-ks;
ks = ts;
kc = tr-tt;
}
}
}
}
}
/* send the state fo the random-number
generator to next processor */

k=g_proc_id+1;
if(k==g_nproc){
k=0;
}
rlxd_get(rlxd_state);
MPI_Send(&rlxd_state[0], 105, MPI_INT, k, 101, MPI_COMM_WORLD);
}
#endif
kc=0.5*(ks+kc);

#ifdef MPI
if(g_proc_id == 0){
MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_nproc-1, 101, MPI_COMM_WORLD, &status);
rlxd_reset(rlxd_state);
}
#endif
}
else {
kc=0.;
ks=0.;
for(i=0;i<VOLUME;i++){
for(mu=0;mu<4;mu++){
for(i = 0; i < VOLUME; i++) {
for(mu = 0; mu < 4; mu++) {
sum=0.;
xm=&momenta[i][mu];
gauss_vector(y,8);
(*xm).d1=1.4142135623731*y[0];
(*xm).d2=1.4142135623731*y[1];
gauss_vector(yy,8);
(*xm).d1=1.4142135623731*yy[0];
(*xm).d2=1.4142135623731*yy[1];
sum+=(*xm).d1*(*xm).d1+(*xm).d2*(*xm).d2;
(*xm).d3=1.4142135623731*y[2];
(*xm).d4=1.4142135623731*y[3];
(*xm).d3=1.4142135623731*yy[2];
(*xm).d4=1.4142135623731*yy[3];
sum+=(*xm).d3*(*xm).d3+(*xm).d4*(*xm).d4;
(*xm).d5=1.4142135623731*y[4];
(*xm).d6=1.4142135623731*y[5];
(*xm).d5=1.4142135623731*yy[4];
(*xm).d6=1.4142135623731*yy[5];
sum+=(*xm).d5*(*xm).d5+(*xm).d6*(*xm).d6;
(*xm).d7=1.4142135623731*y[6];
(*xm).d8=1.4142135623731*y[7];
(*xm).d7=1.4142135623731*yy[6];
(*xm).d8=1.4142135623731*yy[7];
sum+=(*xm).d7*(*xm).d7+(*xm).d8*(*xm).d8;
tr=sum+kc;
ts=tr+ks;
Expand All @@ -228,8 +196,6 @@ double init_momenta(const int repro, su3adj ** const momenta) {
}
}
kc=0.5*(ks+kc);


}
#ifdef MPI
MPI_Allreduce(&kc, &ks, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
Expand Down
6 changes: 3 additions & 3 deletions invert.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,11 @@ int main(int argc, char *argv[])
/* Compute little Dirac operators */
/* alt_block_compute_little_D(); */
if (g_debug_level > 0) {
check_projectors();
check_local_D();
check_projectors(reproduce_randomnumber_flag);
check_local_D(reproduce_randomnumber_flag);
}
if (g_debug_level > 1) {
check_little_D_inversion();
check_little_D_inversion(reproduce_randomnumber_flag);
}

}
Expand Down
2 changes: 1 addition & 1 deletion monomial/clover_trlog_monomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ double clover_trlog_acc(const int id, hamiltonian_field_t * const hf) {
/*compute the contribution from the clover trlog term */
mnl->energy1 = -sw_trace(EO, mnl->mu);
if(g_proc_id == 0 && g_debug_level > 3) {
printf("called clover_trlog_acc for id %d dH = %1.4e\n",
printf("called clover_trlog_acc for id %d dH = %1.10e\n",
id, mnl->energy1 - mnl->energy0);
}
return(mnl->energy1 - mnl->energy0);
Expand Down
4 changes: 2 additions & 2 deletions monomial/cloverdet_monomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void cloverdet_heatbath(const int id, hamiltonian_field_t * const hf) {
sw_term( (const su3**) hf->gaugefield, mnl->kappa, mnl->c_sw);
sw_invert(EE, mnl->mu);

random_spinor_field(mnl->w_fields[0], VOLUME/2, mnl->rngrepro);
random_spinor_field_eo(mnl->w_fields[0], mnl->rngrepro);
mnl->energy0 = square_norm(mnl->w_fields[0], VOLUME/2, 1);

mnl->Qp(mnl->pf, mnl->w_fields[0]);
Expand Down Expand Up @@ -193,7 +193,7 @@ double cloverdet_acc(const int id, hamiltonian_field_t * const hf) {
g_mu3 = 0.;
boundary(g_kappa);
if(g_proc_id == 0 && g_debug_level > 3) {
printf("called cloverdet_acc for id %d %d dH = %1.4e\n",
printf("called cloverdet_acc for id %d %d dH = %1.10e\n",
id, mnl->even_odd_flag, mnl->energy1 - mnl->energy0);
}
return(mnl->energy1 - mnl->energy0);
Expand Down
4 changes: 2 additions & 2 deletions monomial/cloverdetratio_monomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void cloverdetratio_heatbath(const int id, hamiltonian_field_t * const hf) {
sw_term( (const su3**) hf->gaugefield, mnl->kappa, mnl->c_sw);
sw_invert(EE, mnl->mu);

random_spinor_field(mnl->w_fields[0], VOLUME/2, mnl->rngrepro);
random_spinor_field_eo(mnl->w_fields[0], mnl->rngrepro);
mnl->energy0 = square_norm(mnl->w_fields[0], VOLUME/2, 1);

g_mu3 = mnl->rho;
Expand Down Expand Up @@ -291,7 +291,7 @@ double cloverdetratio_acc(const int id, hamiltonian_field_t * const hf) {
g_mu3 = 0.;
boundary(g_kappa);
if(g_proc_id == 0 && g_debug_level > 3) {
printf("called cloverdetratio_acc for id %d dH = %1.4e\n",
printf("called cloverdetratio_acc for id %d dH = %1.10e\n",
id, mnl->energy1 - mnl->energy0);
}
return(mnl->energy1 - mnl->energy0);
Expand Down
2 changes: 1 addition & 1 deletion monomial/clovernd_trlog_monomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ double clovernd_trlog_acc(const int id, hamiltonian_field_t * const hf) {
/*compute the contribution from the clover trlog term */
mnl->energy1 = -sw_trace_nd(EE, mnl->mubar, mnl->epsbar);
if(g_proc_id == 0 && g_debug_level > 3) {
printf("called clovernd_trlog_acc for id %d dH = %1.4e\n",
printf("called clovernd_trlog_acc for id %d dH = %1.10e\n",
id, mnl->energy1 - mnl->energy0);
}
return(mnl->energy1 - mnl->energy0);
Expand Down
Loading

0 comments on commit d9d22ff

Please sign in to comment.