static int qopqdp_force_random(lua_State *L) { #define NC QDP_get_nc(g->links[0]) BEGIN_ARGS; GET_GAUGE(g); END_ARGS; QDP_RandomState *rs = g->lat->rs; qassert(rs!=NULL); if(QLA_Nc==3) { // use MILC conventions QLA_RandomState *s = QDP_expose_S(rs); for(int i=0; i<g->nd; i++) { QDP_M_eq_funcia(g->links[i], randforce, s, QDP_all_L(g->qlat)); } QDP_reset_S(rs); } else { QDP_ColorMatrix *m = QDP_create_M_L(g->qlat); for(int i=0; i<g->nd; i++) { QDP_M_eq_gaussian_S(m, rs, QDP_all_L(g->qlat)); QDP_M_eq_antiherm_M(g->links[i], m, QDP_all_L(g->qlat)); } QDP_destroy_M(m); } return 0; #undef NC }
void packM(Layout *l, real *y, QDP_ColorMatrix *m) { QDP_Lattice *lat = QDP_get_lattice_M(m); QDP_ColorMatrix *xx = QDP_create_M_L(lat); //QDP_M_eq_M(xx, m, QDP_all_L(lat)); QDP_M_eq_transpose_M(xx, m, QDP_all_L(lat)); real *x = QDP_expose_M(xx); int nelem = 2*QDP_Nc*QDP_Nc; fromQDP_F(y, l, x, lat, nelem, 1); QDP_reset_M(xx); QDP_destroy_M(xx); }
void unpackM(Layout *l, QDP_ColorMatrix *m, real *y) { QDP_Lattice *lat = QDP_get_lattice_M(m); QDP_ColorMatrix *xx = QDP_create_M_L(lat); real *x = QDP_expose_M(xx); int nelem = 2*QDP_Nc*QDP_Nc; toQDP_F(x, lat, y, l, nelem, 1); QDP_reset_M(xx); //QDP_M_eq_M(m, xx, QDP_all_L(lat)); QDP_M_eq_transpose_M(m, xx, QDP_all_L(lat)); QDP_destroy_M(xx); }
void QOP_symanzik_1loop_gauge_heatbath_qdp(QOP_info_t *info, QDP_ColorMatrix *links[], QLA_Real beta, QOP_gauge_coeffs_t *coeffs, QDP_RandomState *rs0, int nup, int nhb, int nover) { #define NC QDP_get_nc(links[0]) double dtime = QOP_time(); double nflops = 0; if(coeffs->adjoint_plaquette) { QOP_error("%s: adj plaq not supported\n", __func__); } fac = beta/QLA_Nc; int imp = (coeffs->rectangle!=0)||(coeffs->parallelogram!=0); QDP_Lattice *lat = QDP_get_lattice_M(links[0]); int nd = QDP_ndim_L(lat); QDP_Subset *cbs=QDP_even_and_odd_L(lat); int ncb = 2; if(imp) { ncb = 32; cbs = QOP_get_sub32(lat); } QDP_ColorMatrix *staple = QDP_create_M_L(lat); QDP_ColorMatrix *v = QDP_create_M_L(lat); QDP_ColorMatrix *tmp = QDP_create_M_L(lat); rs = QDP_expose_S(rs0); for(int up=0; up<nup; up++) { for(int hb=0; hb<nhb; hb++) { for(int cb=0; cb<ncb; cb++) { QDP_Subset subset = cbs[cb]; for(int mu=0; mu<nd; mu++) { QDP_M_eq_zero(staple, subset); QOP_symanzik_1loop_gauge_staple_qdp(info, links, staple, mu, coeffs, cbs, cb); QDP_M_eq_M_times_Ma(v, links[mu], staple, subset); QDP_M_eq_funcit(v, hb_func, subset); QDP_M_eq_M_times_M(tmp, v, links[mu], subset); QDP_M_eq_M(links[mu], tmp, subset); } } } for(int over=0; over<nover; over++) { for(int cb=0; cb<ncb; cb++) { QDP_Subset subset = cbs[cb]; for(int mu=0; mu<nd; mu++) { QDP_M_eq_zero(staple, subset); QOP_symanzik_1loop_gauge_staple_qdp(info, links, staple, mu, coeffs, cbs, cb); QDP_M_eq_M_times_Ma(v, links[mu], staple, subset); QDP_M_eq_funcit(v, over_func, subset); QDP_M_eq_M_times_M(tmp, v, links[mu], subset); QDP_M_eq_M(links[mu], tmp, subset); } } } } QDP_reset_S(rs0); QDP_destroy_M(tmp); QDP_destroy_M(v); QDP_destroy_M(staple); info->final_sec = QOP_time() - dtime; info->final_flop = nflops*QDP_sites_on_node; info->status = QOP_SUCCESS; #undef NC }
static void get_staple_plaq(QDP_ColorMatrix *staple, int mu, QDP_ColorMatrix *u[], QOP_gauge_coeffs_t *coeffs, QDP_Subset subset, QDP_Subset osubset) { #define NC QDP_get_nc(staple) QDP_Lattice *lat = QDP_get_lattice_M(staple); int nd = QDP_ndim_L(lat); QDP_Shift *neighbor = QDP_neighbor_L(lat); QLA_Real plaq = coeffs->plaquette; QLA_Real adpl = coeffs->adjoint_plaquette; #if 1 QDP_ColorMatrix *temp1, *temp2, *temp3, *temp4, *temp5, *temp6; //temp1 = QDP_create_M(); temp2 = QDP_create_M_L(lat); //temp3 = QDP_create_M(); temp4 = QDP_create_M_L(lat); //temp5 = QDP_create_M(); temp6 = QDP_create_M_L(lat); QDP_Complex *tc = NULL; if(adpl!=0) tc = QDP_create_C_L(lat); /* staple += u[nu](x) u[mu](x+nu) u*[nu](x+mu) * + u*[nu](x-nu) u[mu](x-nu) u[nu](x-nu+mu) */ for(int nu=0; nu<nd; nu++) { if (nu == mu) continue; temp1 = QDP_create_M_L(lat); temp3 = QDP_create_M_L(lat); temp5 = QDP_create_M_L(lat); QDP_M_eq_sM(temp1, u[nu], neighbor[mu], QDP_forward, QDP_all_L(lat)); QDP_M_eq_Ma_times_M(temp2, u[nu], u[mu], osubset); QDP_M_eq_sM(temp3, u[mu], neighbor[nu], QDP_forward, subset); QDP_M_eq_M_times_M(temp4, temp2, temp1, osubset); QDP_M_eq_sM(temp5, temp4, neighbor[nu], QDP_backward, subset); QDP_M_eq_M_times_M(temp6, u[nu], temp3, subset); //QDP_M_peq_M_times_Ma(staple, temp6, temp1, subset); //QDP_M_peq_M(staple, temp5, subset); if(adpl==0) { QDP_M_peq_M_times_Ma(temp5, temp6, temp1, subset); QDP_M_peq_r_times_M(staple, &plaq, temp5, subset); } else { QLA_Complex z; QLA_c_eq_r(z, plaq/adpl); QDP_C_eq_c(tc, &z, subset); QDP_M_eq_M_times_Ma(temp2, temp6, temp1, subset); QDP_C_peq_M_dot_M(tc, temp2, u[mu], subset); QDP_C_eq_r_times_C(tc, &adpl, tc, subset); QDP_M_peq_C_times_M(staple, tc, temp2, subset); QDP_C_eq_c(tc, &z, subset); QDP_C_peq_M_dot_M(tc, temp5, u[mu], subset); QDP_C_eq_r_times_C(tc, &adpl, tc, subset); QDP_M_peq_C_times_M(staple, tc, temp5, subset); } //QDP_discard_M(temp1); //QDP_discard_M(temp3); //QDP_discard_M(temp5); QDP_destroy_M(temp1); QDP_destroy_M(temp3); QDP_destroy_M(temp5); } /* closes nu loop */ if(adpl!=0) QDP_destroy_C(tc); //QDP_destroy_M(temp1); QDP_destroy_M(temp2); //QDP_destroy_M(temp3); QDP_destroy_M(temp4); //QDP_destroy_M(temp5); QDP_destroy_M(temp6); #else QDP_ColorMatrix *t = QDP_create_M_L(lat); int nu, path[3]; QDP_Subset subs[2]; subs[0] = subset; subs[1] = osubset; for(nu=0; nu<nd; nu++) { if (nu == mu) continue; path[0] = 1+nu; path[1] = -(1+mu); path[2] = -(1+nu); path_prod(u, t, path, 3, 1, subs, neighsubeo); QDP_M_peq_M(staple, t, subset); path[0] = -(1+nu); path[1] = -(1+mu); path[2] = 1+nu; path_prod(u, t, path, 3, 1, subs, neighsubeo); QDP_M_peq_M(staple, t, subset); } QDP_destroy_M(t); #endif }
static void get_staple_imp(QDP_ColorMatrix *staple, int mu, QDP_ColorMatrix **u, QOP_gauge_coeffs_t *coeffs, int subl, QDP_Subset subs[], int (*neighsub)(int subl, int dir)) { #define NC QDP_get_nc(staple) QDP_Lattice *lat = QDP_get_lattice_M(staple); int nd = QDP_ndim_L(lat); int nd2 = 2*nd; QLA_Real plaq = coeffs->plaquette; QLA_Real rect = coeffs->rectangle; QLA_Real pgm = coeffs->parallelogram; QLA_Real adpl = coeffs->adjoint_plaquette; QDP_ColorMatrix *sm0[2][nd2]; QDP_ColorMatrix *t = QDP_create_M_L(lat); for(int i=0; i<2; i++) { tm[i] = QDP_create_M_L(lat); sm[i] = sm0[i]; for(int nu=0; nu<nd2; nu++) { sm[i][nu] = QDP_create_M_L(lat); } } QDP_Complex *tc = NULL; if(adpl!=0) tc = QDP_create_C_L(lat); int mup = 1 + mu; int bsubl = neighsub(subl, mup); int path[5]; QDP_Subset subset = subs[subl]; if(plaq!=0 || adpl!=0) { for(int nu=-nd; nu<=nd; nu++) { if ( nu==-mup || nu==0 || nu==mup ) continue; path[0] = nu; path[1] = -mup; path[2] = -nu; path_prod(u, t, path, 3, bsubl, subs, neighsub); if(adpl==0) { QDP_M_peq_r_times_M(staple, &plaq, t, subset); } else { QLA_Complex z; QLA_c_eq_r(z, plaq/adpl); QDP_C_eq_c(tc, &z, subset); QDP_C_peq_M_dot_M(tc, t, u[mu], subset); QDP_C_eq_r_times_C(tc, &adpl, tc, subset); QDP_M_peq_C_times_M(staple, tc, t, subset); } } } if(rect) { for(int nu=-nd; nu<=nd; nu++) { if ( nu==-mup || nu==0 || nu==mup ) continue; //s = QDP_create_M(); path[0] = nu; path[1] = nu; path[2] = -mup; path[3] = -nu; path[4] = -nu; path_prod(u, t, path, 5, bsubl, subs, neighsub); QDP_M_peq_r_times_M(staple, &rect, t, subset); //QDP_destroy_M(s); //s = QDP_create_M(); path[0] = nu; path[1] = -mup; path[2] = -mup; path[3] = -nu; path[4] = mup; path_prod(u, t, path, 5, bsubl, subs, neighsub); QDP_M_peq_r_times_M(staple, &rect, t, subset); //QDP_destroy_M(s); //s = QDP_create_M(); path[0] = mup; path[1] = nu; path[2] = -mup; path[3] = -mup; path[4] = -nu; path_prod(u, t, path, 5, bsubl, subs, neighsub); QDP_M_peq_r_times_M(staple, &rect, t, subset); //QDP_destroy_M(s); } } if(pgm) { for(int nu=-nd; nu<=nd; nu++) { if ( nu==-mup || nu==0 || nu==mup ) continue; for(int rho=-nd; rho<=nd; rho++) { if ( rho==-mup || rho==0 || rho==mup || rho==-nu || rho==nu ) continue; path[0] = nu; path[1] = rho; path[2] = -mup; path[3] = -nu; path[4] = -rho; path_prod(u, t, path, 5, bsubl, subs, neighsub); QDP_M_peq_r_times_M(staple, &pgm, t, subset); } } } if(adpl!=0) QDP_destroy_C(tc); QDP_destroy_M(t); for(int i=0; i<2; i++) { for(int nu=0; nu<nd2; nu++) { QDP_destroy_M(sm[i][nu]); } QDP_destroy_M(tm[i]); } }