diff --git a/P_M_eta.c b/P_M_eta.c index 5c2263089..14e8454b9 100644 --- a/P_M_eta.c +++ b/P_M_eta.c @@ -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*)); diff --git a/Ptilde_nd.c b/Ptilde_nd.c index f20c70350..3a003063f 100644 --- a/Ptilde_nd.c +++ b/Ptilde_nd.c @@ -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; @@ -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); diff --git a/Ptilde_nd.h b/Ptilde_nd.h index 438777220..dc1cb7200 100644 --- a/Ptilde_nd.h +++ b/Ptilde_nd.h @@ -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 diff --git a/benchmark.c b/benchmark.c index 8bef32b6d..041019cbe 100644 --- a/benchmark.c +++ b/benchmark.c @@ -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.) { @@ -366,7 +366,7 @@ int main(int argc,char *argv[]) j_max=1; sdt=0.; for (k=0;k 0)){ printf("# NDPOLY MD Polynomial: EVmin = %e EVmax = %e \n", EVMin, EVMax); diff --git a/chebyshev_polynomial_nd.h b/chebyshev_polynomial_nd.h index 438ca1898..7eb091663 100644 --- a/chebyshev_polynomial_nd.h +++ b/chebyshev_polynomial_nd.h @@ -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 diff --git a/hopping_test.c b/hopping_test.c index bedb82b52..c86694dc2 100644 --- a/hopping_test.c +++ b/hopping_test.c @@ -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 */ diff --git a/hybrid_update.c b/hybrid_update.c index 1dce0f4c4..ac4eb5c3a 100644 --- a/hybrid_update.c +++ b/hybrid_update.c @@ -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 = sigma^2 = 1/2 */ - /* in order to get = 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 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); } } diff --git a/monomial/clover_trlog_monomial.c b/monomial/clover_trlog_monomial.c index 16b3aa540..e393cee61 100644 --- a/monomial/clover_trlog_monomial.c +++ b/monomial/clover_trlog_monomial.c @@ -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); diff --git a/monomial/cloverdet_monomial.c b/monomial/cloverdet_monomial.c index e303e31d0..5281aa19b 100644 --- a/monomial/cloverdet_monomial.c +++ b/monomial/cloverdet_monomial.c @@ -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]); @@ -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); diff --git a/monomial/cloverdetratio_monomial.c b/monomial/cloverdetratio_monomial.c index 77c3e8edb..95904c9fa 100644 --- a/monomial/cloverdetratio_monomial.c +++ b/monomial/cloverdetratio_monomial.c @@ -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; @@ -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); diff --git a/monomial/clovernd_trlog_monomial.c b/monomial/clovernd_trlog_monomial.c index 8d4c4c12d..bde805781 100644 --- a/monomial/clovernd_trlog_monomial.c +++ b/monomial/clovernd_trlog_monomial.c @@ -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); diff --git a/monomial/cloverndpoly_monomial.c b/monomial/cloverndpoly_monomial.c index 918a5232d..0b7fecf45 100644 --- a/monomial/cloverndpoly_monomial.c +++ b/monomial/cloverndpoly_monomial.c @@ -150,10 +150,10 @@ void cloverndpoly_heatbath(const int id, hamiltonian_field_t * const hf) { } mnl->energy0 = 0.; - random_spinor_field(g_chi_up_spinor_field[0], VOLUME/2, mnl->rngrepro); + random_spinor_field_eo(g_chi_up_spinor_field[0], mnl->rngrepro); mnl->energy0 = square_norm(g_chi_up_spinor_field[0], VOLUME/2, 1); - random_spinor_field(g_chi_dn_spinor_field[0], VOLUME/2, mnl->rngrepro); + random_spinor_field_eo(g_chi_dn_spinor_field[0], mnl->rngrepro); mnl->energy0 += square_norm(g_chi_dn_spinor_field[0], VOLUME/2, 1); Qsw_ndpsi(g_chi_up_spinor_field[1], g_chi_dn_spinor_field[1], @@ -216,7 +216,7 @@ double cloverndpoly_acc(const int id, hamiltonian_field_t * const hf) { mnl->energy1 += square_norm(dn0, VOLUME/2, 1); if(g_proc_id == 0 && g_debug_level > 3) { - printf("called cloverndpoly_acc for id %d %d dH = %1.4e\n", id, g_running_phmc, mnl->energy1 - mnl->energy0); + printf("called cloverndpoly_acc for id %d %d dH = %1.10e\n", id, g_running_phmc, mnl->energy1 - mnl->energy0); } return(mnl->energy1 - mnl->energy0); } diff --git a/monomial/det_monomial.c b/monomial/det_monomial.c index 0e17a8528..e68738ea3 100644 --- a/monomial/det_monomial.c +++ b/monomial/det_monomial.c @@ -156,7 +156,7 @@ void det_heatbath(const int id, hamiltonian_field_t * const hf) { mnl->iter1 = 0; if(mnl->even_odd_flag) { - 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]); @@ -168,7 +168,7 @@ void det_heatbath(const int id, hamiltonian_field_t * const hf) { } } else { - random_spinor_field(mnl->w_fields[0], VOLUME, mnl->rngrepro); + random_spinor_field_lexic(mnl->w_fields[0], mnl->rngrepro); mnl->energy0 = square_norm(mnl->w_fields[0], VOLUME, 1); Q_plus_psi(mnl->pf, mnl->w_fields[0]); @@ -232,7 +232,7 @@ double det_acc(const int id, hamiltonian_field_t * const hf) { g_mu = g_mu1; boundary(g_kappa); if(g_proc_id == 0 && g_debug_level > 3) { - printf("called det_acc for id %d %d dH = %1.4e\n", + printf("called det_acc for id %d %d dH = %1.10e\n", id, mnl->even_odd_flag, mnl->energy1 - mnl->energy0); } return(mnl->energy1 - mnl->energy0); diff --git a/monomial/detratio_monomial.c b/monomial/detratio_monomial.c index bd3536790..f95095688 100644 --- a/monomial/detratio_monomial.c +++ b/monomial/detratio_monomial.c @@ -198,7 +198,7 @@ void detratio_heatbath(const int id, hamiltonian_field_t * const hf) { mnl->iter0 = 0; mnl->iter1 = 0; if(mnl->even_odd_flag) { - 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->w_fields[1], mnl->w_fields[0]); @@ -212,7 +212,7 @@ void detratio_heatbath(const int id, hamiltonian_field_t * const hf) { mnl->csg_N, &mnl->csg_n, VOLUME/2); } else { - random_spinor_field(mnl->w_fields[0], VOLUME, mnl->rngrepro); + random_spinor_field_lexic(mnl->w_fields[0], mnl->rngrepro); mnl->energy0 = square_norm(mnl->w_fields[0], VOLUME, 1); Q_plus_psi(mnl->w_fields[1], mnl->w_fields[0]); @@ -271,7 +271,7 @@ double detratio_acc(const int id, hamiltonian_field_t * const hf) { g_mu = g_mu1; boundary(g_kappa); if(g_proc_id == 0 && g_debug_level > 3) { - printf("called detratio_acc for id %d %d dH = %1.4e\n", + printf("called detratio_acc for id %d %d dH = %1.10e\n", id, mnl->even_odd_flag, mnl->energy1 - mnl->energy0); } return(mnl->energy1 - mnl->energy0); diff --git a/monomial/gauge_monomial.c b/monomial/gauge_monomial.c index e39dbf0b5..862cf8ba9 100644 --- a/monomial/gauge_monomial.c +++ b/monomial/gauge_monomial.c @@ -110,7 +110,7 @@ double gauge_acc(const int id, hamiltonian_field_t * const hf) { mnl->energy1 += g_beta*(mnl->c1 * measure_rectangles( (const su3**) hf->gaugefield)); } if(g_proc_id == 0 && g_debug_level > 3) { - printf("called gauge_acc for id %d %d dH = %1.4e\n", + printf("called gauge_acc for id %d %d dH = %1.10e\n", id, mnl->even_odd_flag, mnl->energy0 - mnl->energy1); } return(mnl->energy0 - mnl->energy1); diff --git a/monomial/ndpoly_monomial.c b/monomial/ndpoly_monomial.c index 6aa45af33..b5d98f1cd 100644 --- a/monomial/ndpoly_monomial.c +++ b/monomial/ndpoly_monomial.c @@ -170,11 +170,11 @@ void ndpoly_heatbath(const int id, hamiltonian_field_t * const hf) { } mnl->energy0 = 0.; - random_spinor_field(g_chi_up_spinor_field[0], VOLUME/2, mnl->rngrepro); + random_spinor_field_eo(g_chi_up_spinor_field[0], mnl->rngrepro); mnl->energy0 = square_norm(g_chi_up_spinor_field[0], VOLUME/2, 1); if(g_epsbar!=0.0 || phmc_exact_poly == 0) { - random_spinor_field(g_chi_dn_spinor_field[0], VOLUME/2, mnl->rngrepro); + random_spinor_field_eo(g_chi_dn_spinor_field[0], mnl->rngrepro); mnl->energy0 += square_norm(g_chi_dn_spinor_field[0], VOLUME/2, 1); } else { @@ -407,7 +407,7 @@ double ndpoly_acc(const int id, hamiltonian_field_t * const hf) { } if(g_proc_id == 0 && g_debug_level > 3) { - printf("called ndpoly_acc for id %d %d dH = %1.4e\n", id, g_running_phmc, mnl->energy1 - mnl->energy0); + printf("called ndpoly_acc for id %d %d dH = %1.10e\n", id, g_running_phmc, mnl->energy1 - mnl->energy0); } /* END IF PHMC */ return(mnl->energy1 - mnl->energy0); @@ -458,7 +458,7 @@ int init_ndpoly_monomial(const int id) { /* Here we prepare the less precise MD polynomial first */ degree_of_polynomial_nd(&mnl->MDPolyDegree, &mnl->MDPolyCoefs, mnl->EVMin, mnl->EVMax, - Qsq); + Qsq, mnl->rngrepro); phmc_dop_n_cheby = mnl->MDPolyDegree; phmc_dop_cheby_coef = mnl->MDPolyCoefs; if((g_proc_id == 0) && (g_debug_level > 1)) { @@ -479,7 +479,7 @@ int init_ndpoly_monomial(const int id) { /* Here we prepare the precise polynomial Ptilde */ degree_of_Ptilde(&mnl->PtildeDegree, &mnl->PtildeCoefs, mnl->EVMin, mnl->EVMax, mnl->MDPolyDegree, - mnl->PrecisionPtilde, Qsq); + mnl->PrecisionPtilde, Qsq, mnl->rngrepro); phmc_ptilde_cheby_coef = mnl->PtildeCoefs; phmc_ptilde_n_cheby = mnl->PtildeDegree; diff --git a/monomial/poly_monomial.c b/monomial/poly_monomial.c index 22aaa7b4c..a0b4a5c8a 100644 --- a/monomial/poly_monomial.c +++ b/monomial/poly_monomial.c @@ -279,7 +279,7 @@ void poly_heatbath(const int id, hamiltonian_field_t * const hf){ if(mnl->even_odd_flag) { - 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); if(g_proc_id == 0 && g_debug_level > 3) { diff --git a/monomial/sf_gauge_monomial.c b/monomial/sf_gauge_monomial.c index 719c59eaf..075f62c49 100644 --- a/monomial/sf_gauge_monomial.c +++ b/monomial/sf_gauge_monomial.c @@ -154,7 +154,7 @@ double sf_gauge_acc( const int id, hamiltonian_field_t * const hf) if( ( g_proc_id == 0 ) & ( g_debug_level > 3 ) ) { - printf( "called sf_gauge_acc for id %d %d dH = %1.4e\n", + printf( "called sf_gauge_acc for id %d %d dH = %1.10e\n", id, mnl->even_odd_flag, mnl->energy0 - mnl->energy1 ); } diff --git a/reweighting_factor.c b/reweighting_factor.c index cc3738904..c1c1b777b 100644 --- a/reweighting_factor.c +++ b/reweighting_factor.c @@ -55,12 +55,15 @@ void reweighting_factor(const int N, const int nstore) { mnl = &monomial_list[j]; if(mnl->type != GAUGE) { if(mnl->even_odd_flag) { - n = VOLUME/2; + random_spinor_field_eo(mnl->pf, mnl->rngrepro); } - random_spinor_field(mnl->pf, n, mnl->rngrepro); + else random_spinor_field_lexic(mnl->pf, mnl->rngrepro); mnl->energy0 = square_norm(mnl->pf, n, 1); if(mnl->type == NDDETRATIO) { - random_spinor_field(mnl->pf2, n, mnl->rngrepro); + if(mnl->even_odd_flag) { + random_spinor_field_eo(mnl->pf2, mnl->rngrepro); + } + else random_spinor_field_lexic(mnl->pf, mnl->rngrepro); mnl->energy0 += square_norm(mnl->pf2, n, 1); } } diff --git a/reweighting_factor_nd.c b/reweighting_factor_nd.c index 48ffc699c..d852efd9a 100644 --- a/reweighting_factor_nd.c +++ b/reweighting_factor_nd.c @@ -32,7 +32,7 @@ #include "phmc.h" #include "reweighting_factor_nd.h" -double reweighting_factor_nd(const int N) +double reweighting_factor_nd(const int N, const int repro) { int i, n_iter; double sq_norm, corr, sum=0., sq_sum = 0., temp1; @@ -48,8 +48,8 @@ double reweighting_factor_nd(const int N) for(i = 0; i < N; ++i) { - random_spinor_field(g_chi_up_spinor_field[2], VOLUME/2, 1); - random_spinor_field(g_chi_dn_spinor_field[2], VOLUME/2, 1); + random_spinor_field_eo(g_chi_up_spinor_field[2], repro); + random_spinor_field_eo(g_chi_dn_spinor_field[2], repro); zero_spinor_field(g_chi_up_spinor_field[3], VOLUME/2); zero_spinor_field(g_chi_dn_spinor_field[3], VOLUME/2); diff --git a/reweighting_factor_nd.h b/reweighting_factor_nd.h index b5da162f6..c2b84f487 100644 --- a/reweighting_factor_nd.h +++ b/reweighting_factor_nd.h @@ -20,6 +20,6 @@ #ifndef _REWEIGHTING_FACTOR_ND_H #define _REWEIGHTING_FACTOR_ND_H -double reweighting_factor_nd(const int N); +double reweighting_factor_nd(const int N, const int repro); #endif diff --git a/solver/dfl_projector.c b/solver/dfl_projector.c index cbdad2e32..0a3a66ca0 100644 --- a/solver/dfl_projector.c +++ b/solver/dfl_projector.c @@ -485,7 +485,7 @@ void little_D_P_R(_Complex double * const out, _Complex double * const in) { } -int check_projectors() { +int check_projectors(const int repro) { double nrm = 0.; int i,j; spinor **phi; @@ -498,7 +498,7 @@ int check_projectors() { phi = malloc(nb_blocks*sizeof(spinor *)); wphi = malloc(nb_blocks*sizeof(spinor *)); - random_spinor_field(work_fields[0], VOLUME, 1); + random_spinor_field_lexic(work_fields[0], repro); nrm = square_norm(work_fields[0], VOLUME, 1); if(g_cart_id == 0) { printf("\nNow we check the DFL projection routines!\n\n"); @@ -806,7 +806,7 @@ int check_projectors() { return(0); } -void check_little_D_inversion() { +void check_little_D_inversion(const int repro) { int i,j,ctr_t; int contig_block = LZ / nb_blocks; int vol = block_list[0].volume; @@ -816,7 +816,7 @@ void check_little_D_inversion() { const int nr_wf = 1; init_solver_field(&work_fields, VOLUMEPLUSRAND, nr_wf); - random_spinor_field(work_fields[0], VOLUME, 1); + random_spinor_field_lexic(work_fields[0], repro); if(init_dfl_projector == 0) { alloc_dfl_projector(); } @@ -895,7 +895,7 @@ void check_little_D_inversion() { return; } -void check_local_D() +void check_local_D(const int repro) { spinor * r[8]; int j, vol = block_list[0].volume/2, i; @@ -950,7 +950,7 @@ void check_local_D() } } /* check Msap and Msap_eo on a radom vector */ - random_spinor_field(work_fields[0], VOLUME, 1); + random_spinor_field_lexic(work_fields[0], repro); zero_spinor_field(work_fields[1], VOLUME); Msap(work_fields[1], work_fields[0], 2); D_psi(work_fields[2], work_fields[1]); diff --git a/solver/dfl_projector.h b/solver/dfl_projector.h index 787d4ec42..ae4839a6f 100644 --- a/solver/dfl_projector.h +++ b/solver/dfl_projector.h @@ -26,9 +26,9 @@ void project_left(spinor * const out, spinor * const in); void project_right(spinor * const out, spinor * const in); void project_left_D(spinor * const out, spinor * const in); void D_project_right(spinor * const out, spinor * const in); -int check_projectors(); -void check_little_D_inversion(); -void check_local_D(); +int check_projectors(const int repro); +void check_little_D_inversion(const int repro); +void check_local_D(const int repro); void free_dfl_projector(); void little_project(_Complex double * const out, _Complex double * const in, const int N); diff --git a/solver/mode_number.c b/solver/mode_number.c index 5c40642bc..d5f2a49bf 100644 --- a/solver/mode_number.c +++ b/solver/mode_number.c @@ -266,7 +266,7 @@ void X_over_sqrt_X_sqr(spinor * const R, double * const c, } -void Check_Approximation(double const mstar) { +void Check_Approximation(double const mstar, const int repro) { if(g_proc_id == 0) { printf("Checking the approximation of X/sqrt(X^2) in the mode number: \n"); @@ -305,7 +305,7 @@ void Check_Approximation(double const mstar) { Sin =calloc(VOLUMEPLUSRAND, sizeof(spinor)); #endif - random_spinor_field(Sin, VOLUME, 1); + random_spinor_field_lexic(Sin, repro); s_ = calloc(4*VOLUMEPLUSRAND+1, sizeof(spinor)); s = calloc(4, sizeof(spinor*)); diff --git a/start.c b/start.c index 7ceaf578d..0777da746 100644 --- a/start.c +++ b/start.c @@ -179,21 +179,17 @@ su3_vector unif_su3_vector(void) } -spinor random_spinor(void) -{ - spinor s; - - s.s0=random_su3_vector(); - s.s1=random_su3_vector(); - s.s2=random_su3_vector(); - s.s3=random_su3_vector(); - - _vector_mul(s.s0,0.5,s.s0); - _vector_mul(s.s1,0.5,s.s1); - _vector_mul(s.s2,0.5,s.s2); - _vector_mul(s.s3,0.5,s.s3); - - return(s); +void random_spinor(spinor * const s) { + s->s0 = random_su3_vector(); + s->s1 = random_su3_vector(); + s->s2 = random_su3_vector(); + s->s3 = random_su3_vector(); + + _vector_mul(s->s0, 0.5, s->s0); + _vector_mul(s->s1, 0.5, s->s1); + _vector_mul(s->s2, 0.5, s->s2); + _vector_mul(s->s3, 0.5, s->s3); + return; } spinor unit_spinor() @@ -219,9 +215,9 @@ void unit_spinor_field(const int k) } } -/* Function provides a spinor field of length V with +/* Function provides a spinor field of length VOLUME with Gaussian distribution */ -void random_spinor_field_lexic(spinor * const k) { +void random_spinor_field_lexic(spinor * const k, const int repro) { int x, y, z, t, X, Y, Z, tt, id=0; #ifdef MPI int rlxd_state[105]; @@ -230,47 +226,56 @@ void random_spinor_field_lexic(spinor * const k) { spinor *s; double v[24]; + if(repro) { #ifdef MPI - if(g_proc_id == 0) { - rlxd_get(rlxd_state); - } - MPI_Bcast(rlxd_state, 105, MPI_INT, 0, MPI_COMM_WORLD); - if(g_proc_id != 0) { - rlxd_reset(rlxd_state); - } + if(g_proc_id == 0) { + rlxd_get(rlxd_state); + } + MPI_Bcast(rlxd_state, 105, MPI_INT, 0, MPI_COMM_WORLD); + if(g_proc_id != 0) { + rlxd_reset(rlxd_state); + } #endif - for(t = 0; t < g_nproc_t*T; t++) { - tt = t - g_proc_coords[0]*T; - coords[0] = t / 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; + for(t = 0; t < g_nproc_t*T; t++) { + tt = t - g_proc_coords[0]*T; + coords[0] = t / 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 - MPI_Cart_rank(g_cart_grid, coords, &id); + MPI_Cart_rank(g_cart_grid, coords, &id); #endif - if(g_cart_id == id) { - gauss_vector(v, 24); - s = k + g_ipt[tt][X][Y][Z]; - memcpy(s, v, 24*sizeof(double)); - } - else { - ranlxd(v,24); + if(g_cart_id == id) { + gauss_vector(v, 24); + s = k + g_ipt[tt][X][Y][Z]; + memcpy(s, v, 24*sizeof(double)); + } + else { + ranlxd(v,24); + } } } } } } + else { + for(x = 0; x < VOLUME; x++) { + gauss_vector(v, 24); + s = k + x; + memcpy(s, v, 24*sizeof(double)); + } + } return; } -void random_spinor_field_eo(spinor * const k) { - int x, y, z, t, id = 0; +void random_spinor_field_eo(spinor * const k, const int repro) { + int x, X, y, Y, z, Z, t, t0, id = 0; #ifdef MPI int rlxd_state[105]; #endif @@ -278,117 +283,120 @@ void random_spinor_field_eo(spinor * const k) { spinor *s; double v[24]; + if(repro) { #ifdef MPI - if(g_proc_id == 0) { - rlxd_get(rlxd_state); - } - MPI_Bcast(rlxd_state, 105, MPI_INT, 0, MPI_COMM_WORLD); - if(g_proc_id != 0) { - rlxd_reset(rlxd_state); - } + if(g_proc_id == 0) { + rlxd_get(rlxd_state); + } + MPI_Bcast(rlxd_state, 105, MPI_INT, 0, MPI_COMM_WORLD); + if(g_proc_id != 0) { + rlxd_reset(rlxd_state); + } #endif - for(t = 0; t < g_nproc_t*T; t++) { - coords[0] = t / T; - for(x = 0; x < g_nproc_x*LX; x++) { - coords[1] = x / LX; - for(y = 0; y < g_nproc_y*LY; y++) { - coords[2] = y / LY; - for(z = 0; z < g_nproc_z*LZ; z++) { - coords[3] = z / LZ; + for(t0 = 0; t0 < g_nproc_t*T; t0++) { + coords[0] = t0 / T; + t = t0 - T*g_proc_coords[0]; + for(x = 0; x < g_nproc_x*LX; x++) { + coords[1] = x / LX; + X = x - g_proc_coords[1]*LX; + for(y = 0; y < g_nproc_y*LY; y++) { + coords[2] = y / LY; + Y = y - g_proc_coords[2]*LY; + for(z = 0; z < g_nproc_z*LZ; z++) { + coords[3] = z / LZ; + Z = z - g_proc_coords[3]*LZ; #ifdef MPI - MPI_Cart_rank(g_cart_grid, coords, &id); + MPI_Cart_rank(g_cart_grid, coords, &id); #endif - gauss_vector(v, 24); - if(g_cart_id == id) { - s = k + g_ipt[t][x][y][z]; - memcpy(s, v, 24*sizeof(double)); + if((t0+x+y+z)%2 == 0) { + gauss_vector(v, 24); + if(g_cart_id == id) { + s = k + g_lexic2eosub[ g_ipt[t][X][Y][Z] ]; + memcpy(s, v, 24*sizeof(double)); + } + } } } } } } + else { + for (x = 0; x < VOLUME/2; x++) { + s = k + x; + gauss_vector(v, 24); + memcpy(s, v, 24*sizeof(double)); + } + } return; } void random_spinor_field(spinor * const k, const int V, const int repro) { - int ix; + int ix, t0, t, x, X, y, Y, z, Z, id = 0; + int coords[4]; +#ifdef MPI int rlxd_state[105]; +#endif spinor *s; double v[6]; + if(repro) { #ifdef MPI - int j=0; -#endif - - if(g_proc_id==0 && repro == 1) { - for (ix = 0; ix < V; ix++) { - s = k + ix; - gauss_vector(v,6); - s->s0.c0 = v[0] + v[1] * I; - s->s0.c1 = v[2] + v[3] * I; - s->s0.c2 = v[4] + v[5] * I; - gauss_vector(v,6); - s->s1.c0 = v[0] + v[1] * I; - s->s1.c1 = v[2] + v[3] * I; - s->s1.c2 = v[4] + v[5] * I; - gauss_vector(v,6); - s->s2.c0 = v[0] + v[1] * I; - s->s2.c1 = v[2] + v[3] * I; - s->s2.c2 = v[4] + v[5] * I; - gauss_vector(v,6); - s->s3.c0 = v[0] + v[1] * I; - s->s3.c1 = v[2] + v[3] * I; - s->s3.c2 = v[4] + v[5] * I; - } - /* send the state for the random-number generator to 1 */ - rlxd_get(rlxd_state); -#ifdef MPI - if(g_nproc > 1) { - MPI_Send(&rlxd_state[0], 105, MPI_INT, 1, 102, MPI_COMM_WORLD); + if(g_proc_id == 0) { + rlxd_get(rlxd_state); } + 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 && repro == 1) { - MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_proc_id-1, 102, MPI_COMM_WORLD, &status); - rlxd_reset(rlxd_state); - for (ix=0;ixs0.c0 = v[0] + v[1] * I; - s->s0.c1 = v[2] + v[3] * I; - s->s0.c2 = v[4] + v[5] * I; - gauss_vector(v,6); - s->s1.c0 = v[0] + v[1] * I; - s->s1.c1 = v[2] + v[3] * I; - s->s1.c2 = v[4] + v[5] * I; - gauss_vector(v,6); - s->s2.c0 = v[0] + v[1] * I; - s->s2.c1 = v[2] + v[3] * I; - s->s2.c2 = v[4] + v[5] * I; - gauss_vector(v,6); - s->s3.c0 = v[0] + v[1] * I; - s->s3.c1 = v[2] + v[3] * I; - s->s3.c2 = v[4] + v[5] * I; - } - /* send the state fo the random-number generator to k+1 */ - - j=g_proc_id+1; - if(j==g_nproc){ - j=0; + MPI_Cart_rank(g_cart_grid, coords, &id); +#endif + if(g_cart_id == id) ix = g_lexic2eosub[ g_ipt[t][X][Y][Z] ]; + gauss_vector(v, 6); + if(g_cart_id == id) { + s = k + ix; + s->s0.c0 = v[0] + v[1] * I; + s->s0.c1 = v[2] + v[3] * I; + s->s0.c2 = v[4] + v[5] * I; + } + gauss_vector(v,6); + if(g_cart_id == id) { + s->s1.c0 = v[0] + v[1] * I; + s->s1.c1 = v[2] + v[3] * I; + s->s1.c2 = v[4] + v[5] * I; + } + gauss_vector(v,6); + if(g_cart_id == id) { + s->s2.c0 = v[0] + v[1] * I; + s->s2.c1 = v[2] + v[3] * I; + s->s2.c2 = v[4] + v[5] * I; + } + gauss_vector(v,6); + if(g_cart_id == id) { + s->s3.c0 = v[0] + v[1] * I; + s->s3.c1 = v[2] + v[3] * I; + s->s3.c2 = v[4] + v[5] * I; + } + } + } + } } - rlxd_get(rlxd_state); - MPI_Send(&rlxd_state[0], 105, MPI_INT, j, 102, MPI_COMM_WORLD); - } - if(g_nproc > 1 && g_proc_id==0 && repro == 1) { - MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_nproc-1, 102, MPI_COMM_WORLD, &status); - rlxd_reset(rlxd_state); } -#endif - if(repro != 1) { + else { for (ix = 0; ix < V; ix++) { s = k + ix; - gauss_vector(v,6); + gauss_vector(v, 6); s->s0.c0 = v[0] + v[1] * I; s->s0.c1 = v[2] + v[3] * I; s->s0.c2 = v[4] + v[5] * I; @@ -406,9 +414,10 @@ void random_spinor_field(spinor * const k, const int V, const int repro) { s->s3.c2 = v[4] + v[5] * I; } } + return; } -/* Function provides a zero spinor field of length N with */ +/* Function provides a z2 random spinor field of length N with */ void z2_random_spinor_field(spinor * const k, const int N) { int ix; @@ -469,15 +478,12 @@ void constant_spinor_field(spinor * const k, const int p, const int N) } -su3 random_su3(void) -{ +void random_su3(su3 * const u) { double norm,fact; _Complex double z; su3_vector z1,z2,z3; - su3 u; z1=unif_su3_vector(); - for (;;) { z2=unif_su3_vector(); @@ -499,19 +505,18 @@ su3 random_su3(void) z3.c1 = conj((z1.c2 * z2.c0) - (z1.c0 * z2.c2)); z3.c2 = conj((z1.c0 * z2.c1) - (z1.c1 * z2.c0)); - u.c00=z1.c0; - u.c01=z1.c1; - u.c02=z1.c2; + u->c00 = z1.c0; + u->c01 = z1.c1; + u->c02 = z1.c2; - u.c10=z2.c0; - u.c11=z2.c1; - u.c12=z2.c2; + u->c10 = z2.c0; + u->c11 = z2.c1; + u->c12 = z2.c2; - u.c20=z3.c0; - u.c21=z3.c1; - u.c22=z3.c2; - - return(u); + u->c20 = z3.c0; + u->c21 = z3.c1; + u->c22 = z3.c2; + return; } @@ -533,35 +538,58 @@ void unit_g_gauge_field(void) void random_gauge_field(const int repro) { - int ix,mu; + int ix, mu, t0, t, x, X, y, Y, z, Z, id; + int coords[4]; + su3 ALIGN tmp; #ifdef MPI int rlxd_state[105]; - int j=0; +#endif - if(g_proc_id !=0 && repro == 1) { - MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_proc_id-1, 102, MPI_COMM_WORLD, &status); + if(repro) { +#ifdef MPI + if(g_proc_id == 0) { + rlxd_get(rlxd_state); + } + MPI_Bcast(rlxd_state, 105, MPI_INT, 0, MPI_COMM_WORLD); rlxd_reset(rlxd_state); - } #endif - - for (ix = 0; ix < VOLUME; ix++) { - for (mu = 0; mu < 4; mu++) { - g_gauge_field[ix][mu] = random_su3(); + 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 + MPI_Cart_rank(g_cart_grid, coords, &id); +#endif + for(mu = 0; mu < 4; mu++) { + if(g_cart_id == id) { + ix = g_ipt[t][X][Y][Z]; + random_su3(&g_gauge_field[ix][mu]); + } + else { + random_su3(&tmp); + } + } + } + } + } } } - -#ifdef MPI - if(repro == 1) { - j = (g_proc_id + 1) % g_nproc; - rlxd_get(rlxd_state); - MPI_Send(&rlxd_state[0], 105, MPI_INT, j, 102, MPI_COMM_WORLD); - - if(g_proc_id == 0) { - MPI_Recv(&rlxd_state[0], 105, MPI_INT, g_nproc-1, 102, MPI_COMM_WORLD, &status); - rlxd_reset(rlxd_state); + else { + for (ix = 0; ix < VOLUME; ix++) { + for (mu = 0; mu < 4; mu++) { + random_su3(&g_gauge_field[ix][mu]); + } } } -#endif + g_update_gauge_copy = 1; g_update_gauge_energy = 1; g_update_rectangle_energy = 1; diff --git a/start.h b/start.h index eab92fef3..07b1a8f80 100644 --- a/start.h +++ b/start.h @@ -23,15 +23,16 @@ void gauss_vector(double v[],int n); su3_vector random_su3_vector(void); su3_vector unif_su3_vector(void); -spinor random_spinor(void); +void random_spinor(spinor * const s); void unit_spinor_field(const int k); -void random_spinor_field_lexic(spinor * const k); +void random_spinor_field_lexic(spinor * const k, const int repro); void random_spinor_field(spinor * const k, const int V, const int repro); +void random_spinor_field_eo(spinor * const k, const int repro); void z2_random_spinor_field(spinor * const k, const int N); void zero_spinor_field(spinor * const k, const int N); void constant_spinor_field(spinor * const k, const int p, const int N); -su3 random_su3(void); +void random_su3(su3 * const u); void unit_g_gauge_field(void); void random_gauge_field(const int repro); void set_spinor_field(int k, const double c); diff --git a/update_tm.c b/update_tm.c index f742a9412..0c4b001b8 100644 --- a/update_tm.c +++ b/update_tm.c @@ -162,6 +162,7 @@ int update_tm(double *plaquette_energy, double *rectangle_energy, new_rectangle_energy = measure_rectangles( (const su3**) hf.gaugefield); } } + if(g_proc_id == 0 && g_debug_level > 3) printf("called moment_energy: dh = %1.10e\n", (enepx - enep)); /* Compute the energy difference */ dh = dh + (enepx - enep); if(g_proc_id == 0 && g_debug_level > 3) { @@ -170,8 +171,8 @@ int update_tm(double *plaquette_energy, double *rectangle_energy, expmdh = exp(-dh); /* the random number is only taken at node zero and then distributed to the other sites */ + ranlxd(yy,1); if(g_proc_id==0) { - ranlxd(yy,1); #ifdef MPI for(i = 1; i < g_nproc; i++) { MPI_Send(&yy[0], 1, MPI_DOUBLE, i, 31, MPI_COMM_WORLD);