int mat_invert_uml(field_offset src, field_offset dest, field_offset temp, double mass ){ int cgn; double finalrsq; register int i; register site *s; if( src==temp ){ printf("BOTCH\n"); exit(0); } /* multiply by U - even sites only */ dslash( src, F_OFFSET(ttt), EVEN); scalar_mult_add_latvec( F_OFFSET(ttt), src, -2.0*mass, temp, EVEN); scalar_mult_latvec( temp, -1.0, temp, EVEN); /* invert with M_adj M even */ cgn = ks_congrad( temp, dest, mass, niter, rsqprop, EVEN, &finalrsq ); /* multiply by (1/2m)L, does nothing to even sites */ /* fix up odd sites , 1/2m (Dslash_oe*dest_e + phi_odd) */ dslash( dest, F_OFFSET(ttt), ODD ); FORODDSITES(i,s){ sub_su3_vector( (su3_vector *)F_PT(s,src), &(s->ttt), (su3_vector *)F_PT(s,dest) ); scalar_mult_su3_vector( (su3_vector *)F_PT(s,dest), 1.0/(2.0*mass), (su3_vector *)F_PT(s,dest) ); }
void Matrix_Vec_mult(su3_vector *src, su3_vector *res, int parity, imp_ferm_links_t *fn ) { register site *s; register int i; int otherparity = EVENANDODD; if(temp == NULL ){ temp = (su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); } switch(parity){ case EVEN: otherparity = ODD ; break ; case ODD: otherparity = EVEN ; break ; case EVENANDODD: otherparity = EVENANDODD ; break ; default: node0_printf("ERROR: wrong parity in eigen_stuff::Matrix_Vec_mult\n") ; terminate(1) ; } dslash_field(src , temp, otherparity, fn) ; dslash_field(temp, res , parity , fn) ; FORSOMEPARITY(i,s,parity){ scalar_mult_su3_vector( &(res[i]), -1.0, &(res[i])) ; }
static void qop_to_milc_normalization_field(su3_vector *sol, MASSREAL mass, int parity) { site *s; int i; Real x = 1/(NORMFACT(mass)); FORSOMEPARITY(i,s,parity){ scalar_mult_su3_vector(sol+i, x, sol+i); }
void scalar_mult_wvec( wilson_vector *src, Real s, wilson_vector *dest){ #ifndef NATIVEDOUBLE register int i; for(i=0;i<4;i++)scalar_mult_su3_vector( &(src->d[i]), s, &(dest->d[i])); #else /* RS6000 version */ register double ss; ss = s; dest->d[0].c[0].real = ss*src->d[0].c[0].real; dest->d[0].c[0].imag = ss*src->d[0].c[0].imag; dest->d[0].c[1].real = ss*src->d[0].c[1].real; dest->d[0].c[1].imag = ss*src->d[0].c[1].imag; dest->d[0].c[2].real = ss*src->d[0].c[2].real; dest->d[0].c[2].imag = ss*src->d[0].c[2].imag; dest->d[1].c[0].real = ss*src->d[1].c[0].real; dest->d[1].c[0].imag = ss*src->d[1].c[0].imag; dest->d[1].c[1].real = ss*src->d[1].c[1].real; dest->d[1].c[1].imag = ss*src->d[1].c[1].imag; dest->d[1].c[2].real = ss*src->d[1].c[2].real; dest->d[1].c[2].imag = ss*src->d[1].c[2].imag; dest->d[2].c[0].real = ss*src->d[2].c[0].real; dest->d[2].c[0].imag = ss*src->d[2].c[0].imag; dest->d[2].c[1].real = ss*src->d[2].c[1].real; dest->d[2].c[1].imag = ss*src->d[2].c[1].imag; dest->d[2].c[2].real = ss*src->d[2].c[2].real; dest->d[2].c[2].imag = ss*src->d[2].c[2].imag; dest->d[3].c[0].real = ss*src->d[3].c[0].real; dest->d[3].c[0].imag = ss*src->d[3].c[0].imag; dest->d[3].c[1].real = ss*src->d[3].c[1].real; dest->d[3].c[1].imag = ss*src->d[3].c[1].imag; dest->d[3].c[2].real = ss*src->d[3].c[2].real; dest->d[3].c[2].imag = ss*src->d[3].c[2].imag; #endif }
int quark_renorm( void ) { register int i, dir; register site *s; int j, cgn; Real mass_x2, finalrsq; Real pix, piy, piz, pit; Real sin_pmu, q_mu, prop_a, prop_b, z_fac, m_func, ftmp = 0; Real r1, r2, r3; int pmu, px, py, pz, pt; int pxn, pyn, pzn, ptn; int currentnode; int j1, jm2, k, dirs[4]; msg_tag *mtag[2]; int j_mass; su3_vector **psim = NULL; int xi, j2, j3, j4, parity; int multiflag; FILE *fp_mom_ks[MAX_NUM_MASS]; /* for writing mom propagator files */ char filename[50]; int prec = PRECISION; /* Make internal precision for CG the same as the prevailing precision */ pix = 2.*PI / (Real)nx; piy = 2.*PI / (Real)ny; piz = 2.*PI / (Real)nz; pit = 2.*PI / (Real)nt; cgn = 0; if( num_mass == 1){ multiflag = 0; } else{ multiflag = 1; psim = (su3_vector **)malloc(num_mass*sizeof(su3_vector *)); for(j=0; j<num_mass; j++){ psim[j] = (su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); } } /* Open the momentum propagator files */ if(this_node == 0){ for(j=0; j<num_mass; j++){ sprintf(filename,"mom_pt_prop.m_%d",j); fp_mom_ks[j] = fopen(filename, "ab"); if(fp_mom_ks[j] == NULL){ printf("quark_renorm: Node %d can't open file %s, error %d\n", this_node,filename,errno);fflush(stdout); terminate(1); } } } rephase( ON ); /* Turn staggered phases on */ /* Create fat and long links */ load_ferm_links(&fn_links, &ks_act_paths); /* Loop over the 16 source points */ for(xi=0; xi<16; xi++){ /* Initialize color trace of the propagator */ FORALLSITES(i,s){ for(j=0; j<num_mass; j++){ s->trace_prop[j].real = 0.0; s->trace_prop[j].imag = 0.0; } } j1 = xi%2; k = xi/2; j2 = k%2; k /= 2; j3 = k%2; k /= 2; j4 = k%2; parity = (j1+j2+j3+j4)%2; /* dirs[XUP] = j1; dirs[YUP] = j2; dirs[ZUP] = j3; dirs[TUP] = j4; */ /* Loop over colors of source vector */ for(j=0; j<3; j++){ /* initialize the source in phi */ FORALLSITES(i,s){ clearvec( &(s->phi)); } /* Point source at site xi in the hypercube at origin */ if( node_number(j1,j2,j3,j4) == this_node ){ i=node_index(j1,j2,j3,j4); lattice[i].phi.c[j].real = -1.0; } if( multiflag == 0){ for(j_mass=0; j_mass<num_mass; j_mass++){ FORALLSITES(i,s){ clearvec( &(s->xxx1)); } if(parity == 0){ /* do a C.G. (source in phi, result in xxx1) */ cgn += ks_congrad( F_OFFSET(phi), F_OFFSET(xxx1), mass[j_mass], niter, nrestart, rsqprop, PRECISION, EVEN, &finalrsq, &fn_links); /* Multiply by -Madjoint */ dslash_site( F_OFFSET(xxx1), F_OFFSET(ttt), ODD, &fn_links); mass_x2 = 2.*mass[j_mass]; FOREVENSITES(i,s){ scalar_mult_su3_vector( &(s->xxx1), -mass_x2, &(s->ttt)); } } else{
FORODDSITES(i,s){ scalar_mult_su3_vector( &(s->xxx1), -mass_x2, &(s->ttt)); }
Until we have EO versions of dslash_field, we require FN #endif #include "generic_ks_includes.h" /* definitions files and prototypes */ #include "../include/dslash_ks_redefine.h" /* Actually not used, yet */ #include "../include/loopend.h" /*#define CGTIME*/ int ks_congrad_two_src( /* Return value is number of iterations taken */ field_offset src1, /* source vector (type su3_vector) */ field_offset src2, field_offset dest1, /* solution vectors */ field_offset dest2, Real mass1, Real mass2, int niter, /* maximal number of CG interations */ int nrestart, /* maximal number of CG restarts */ Real rsqmin, /* desired residue squared */ int prec, /* internal precision for the inversion (ignored) */ int parity, /* parity to be worked on */ Real *final_rsq_ptr, /* final residue squared */ ferm_links_t *fn /* Storage for fermion links */ ) { /* Site su3_vector's resid, cg_p and ttt are used as temporaries */ register int i; register site *s; int iteration; /* counter for iterations */ double c1, c2, rsq, oldrsq, pkp; /* pkp = cg_p.K.cg_p */ double source_norm,source_norm1; /* squared magnitude of source vector */ double rsqstop; /* stopping residual normalized by source norm */ int l_parity; /* parity we are currently doing */ int l_otherparity; /* the other parity */ msg_tag *tags1[16], *tags2[16]; /* tags for gathers to parity and opposite */ int special_started; /* 1 if dslash_special has been called */ int j, jud, jstrange; double shift, msq_xm4; double zeta_i[2], zeta_im1[2], zeta_ip1[2]; double beta_i[2], beta_im1[2], alpha[2]; int first; su3_vector *temp; su3_vector *destvec1; su3_vector *destvec2; su3_vector *pm_strange; su3_vector *init_guess; su3_vector *common_source; su3_vector *ttt; su3_vector *cg_p; su3_vector *resid; /* Timing */ #ifdef CGTIME double dtimed,dtimec; #endif double nflop; /* debug */ #ifdef CGTIME dtimec = -dclock(); #endif first = 0; nflop = 1187; /* THIS LOOKS WRONG - DT */ if(parity==EVENANDODD)nflop *=2; special_started = 0; /* if we want both parities, we will do even first. */ switch(parity){ case(EVEN): l_parity=EVEN; l_otherparity=ODD; break; case(ODD): l_parity=ODD; l_otherparity=EVEN; break; case(EVENANDODD): l_parity=EVEN; l_otherparity=ODD; break; } jud = 0; jstrange = 1; temp=(su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); destvec1=(su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); destvec2=(su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); ttt=(su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); cg_p=(su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); resid=(su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); pm_strange = (su3_vector *)malloc(sites_on_node*sizeof(su3_vector)); init_guess = (su3_vector *)malloc(sites_on_node*sizeof(su3_vector) ); common_source = (su3_vector *)malloc(sites_on_node*sizeof(su3_vector) ); shift = 4.0*( mass2*mass2 - mass1*mass1); msq_xm4 = -4.0*mass1*mass1; iteration = 0; #ifdef CGTIME dtimec = -dclock(); #endif /* initialization process */ start: #ifdef FN if(special_started==1) { /* clean up gathers */ cleanup_gathers(tags1, tags2); special_started = 0; } #endif /*This loop calculates init_guess = (phi2 - phi1)/shift = X0 , which * is used to equalize the two sources*/ FORSOMEPARITY(i,s,l_parity){ sub_su3_vector( (su3_vector *)F_PT(s,src2),(su3_vector *)F_PT(s,src1),&temp[i] ); scalar_mult_su3_vector(&temp[i],1.0/shift,&init_guess[i] ); }END_LOOP
int main( int argc, char **argv ){ register site *s; int i,si; int prompt; double dtime; su3_vector **eigVec ; su3_vector *tmp ; double *eigVal ; int total_R_iters ; double chirality ; initialize_machine(&argc,&argv); #ifdef HAVE_QDP QDP_initialize(&argc, &argv); #ifndef QDP_PROFILE QDP_profcontrol(0); #endif #endif /* Remap standard I/O */ if(remap_stdio_from_args(argc, argv) == 1)terminate(1); g_sync(); /* set up */ prompt = setup(); /* loop over input sets */ while( readin(prompt) == 0){ dtime = -dclock(); invalidate_all_ferm_links(&fn_links); make_path_table(&ks_act_paths, &ks_act_paths_dmdu0); /* Load fat and long links for fermion measurements if needed */ load_ferm_links(&fn_links, &ks_act_paths); /* call fermion_variable measuring routines */ /* results are printed in output file */ f_meas_imp( F_OFFSET(phi), F_OFFSET(xxx), mass, &fn_links, &fn_links_dmdu0); eigVal = (double *)malloc(Nvecs*sizeof(double)); eigVec = (su3_vector **)malloc(Nvecs*sizeof(su3_vector*)); for(i=0;i<Nvecs;i++) eigVec[i]= (su3_vector*)malloc(sites_on_node*sizeof(su3_vector)); total_R_iters=Kalkreuter(eigVec, eigVal, eigenval_tol, error_decr, Nvecs, MaxIter, Restart, Kiters, EVEN, &fn_links) ; tmp = (su3_vector*)malloc(sites_on_node*sizeof(su3_vector)); for(i=0;i<Nvecs;i++) { /* Construct to odd part of the vector. * * Note that the true odd part of the eigenvector is * * i/sqrt(eigVal) Dslash Psi. But since I only compute * * the chirality the i factor is irrelevant (-i)*i=1!! */ dslash_fn_field(eigVec[i], tmp, ODD, &fn_links) ; FORSOMEPARITY(si,s,ODD){ scalar_mult_su3_vector( &(tmp[si]), 1.0/sqrt(eigVal[i]), &(eigVec[i][si]) ) ; } measure_chirality(eigVec[i], &chirality, EVENANDODD); /* Here I divide by 2 since the EVEN vector is normalized to * 1. The EVENANDODD vector is normalized to 2. I could have * normalized the EVENANDODD vector to 1 and then not devide * by to. The measure_chirality routine assumes vectors * normalized to 1. */ node0_printf("Chirality(%i): %g\n",i,chirality/2) ; } free(tmp); /** for(i=0;i<Nvecs;i++) { sprintf(label,"DENSITY(%i)",i) ; print_densities(eigVec[i], label, ny/2,nz/2,nt/2, EVEN) ; } **/ for(i=0;i<Nvecs;i++) free(eigVec[i]) ; free(eigVec) ; free(eigVal) ; #ifdef FN invalidate_all_ferm_links(&fn_links); #endif fflush(stdout); node0_printf("RUNNING COMPLETED\n"); fflush(stdout); dtime += dclock(); if(this_node==0){ printf("Time = %e seconds\n",dtime); printf("total_iters = %d\n",total_iters); printf("total Rayleigh iters = %d\n",total_R_iters); } fflush(stdout); }
int main( int argc, char **argv ){ register site *s; int i,si; int prompt; double dtime; su3_vector **eigVec ; su3_vector *tmp ; double *eigVal ; int total_R_iters ; double chirality, chir_ev, chir_od ; imp_ferm_links_t **fn; initialize_machine(&argc,&argv); /* Remap standard I/O */ if(remap_stdio_from_args(argc, argv) == 1)terminate(1); g_sync(); /* set up */ prompt = setup(); /* loop over input sets */ while( readin(prompt) == 0){ dtime = -dclock(); #ifdef HISQ_SVD_COUNTER hisq_svd_counter = 0; #endif restore_fermion_links_from_site(fn_links, PRECISION); /* call fermion_variable measuring routines */ /* results are printed in output file */ f_meas_imp( 1, PRECISION, F_OFFSET(phi), F_OFFSET(xxx), mass, 0, fn_links); eigVal = (double *)malloc(Nvecs*sizeof(double)); eigVec = (su3_vector **)malloc(Nvecs*sizeof(su3_vector*)); for(i=0;i<Nvecs;i++) eigVec[i]= (su3_vector*)malloc(sites_on_node*sizeof(su3_vector)); fn = get_fm_links(fn_links); active_parity = EVEN; total_R_iters=Kalkreuter(eigVec, eigVal, eigenval_tol, error_decr, Nvecs, MaxIter, Restart, Kiters); node0_printf("The above where eigenvalues of -Dslash^2 in MILC normalization\n"); node0_printf("Here we also list eigenvalues of iDslash in continuum normalization\n"); for(i=0;i<Nvecs;i++) { if ( eigVal[i] > 0.0 ){ chirality = sqrt(eigVal[i]) / 2.0; } else { chirality = 0.0; } node0_printf("eigenval(%i): %10g\n",i,chirality) ; } tmp = (su3_vector*)malloc(sites_on_node*sizeof(su3_vector)); for(i=0;i<Nvecs;i++) { // if ( eigVal[i] > 10.0*eigenval_tol ) // { /* Construct to odd part of the vector. * * Note that the true odd part of the eigenvector is * * i/sqrt(eigVal) Dslash Psi. But since I only compute * * the chirality the i factor is irrelevant (-i)*i=1!! */ dslash_field(eigVec[i], tmp, ODD, fn[0]) ; FORSOMEPARITY(si,s,ODD){ scalar_mult_su3_vector( &(tmp[si]), 1.0/sqrt(eigVal[i]), &(eigVec[i][si]) ) ; } // measure_chirality(eigVec[i], &chirality, EVENANDODD); /* Here I divide by 2 since the EVEN vector is normalized to * 1. The EVENANDODD vector is normalized to 2. I could have * normalized the EVENANDODD vector to 1 and then not devide * by to. The measure_chirality routine assumes vectors * normalized to 1. */ // node0_printf("Chirality(%i): %g\n",i,chirality/2) ; measure_chirality(eigVec[i], &chir_ev, EVEN); measure_chirality(eigVec[i], &chir_od, ODD); chirality = (chir_ev + chir_od) / 2.0; node0_printf("Chirality(%i) -- even, odd, total: %10g, %10g, %10g\n", i,chir_ev,chir_od,chirality) ; // } // else // { /* This is considered a "zero mode", and treated as such */ // measure_chirality(eigVec[i], &chirality, EVEN); // node0_printf("Chirality(%i): %g\n",i,chirality) ; // } } #ifdef EO cleanup_dslash_temps(); #endif free(tmp); /** for(i=0;i<Nvecs;i++) { sprintf(label,"DENSITY(%i)",i) ; print_densities(eigVec[i], label, ny/2,nz/2,nt/2, EVEN) ; } **/ for(i=0;i<Nvecs;i++) free(eigVec[i]) ; free(eigVec) ; free(eigVal) ; invalidate_fermion_links(fn_links); fflush(stdout); node0_printf("RUNNING COMPLETED\n"); fflush(stdout); dtime += dclock(); if(this_node==0){ printf("Time = %e seconds\n",dtime); printf("total_iters = %d\n",total_iters); printf("total Rayleigh iters = %d\n",total_R_iters); #ifdef HISQ_SVD_COUNTER printf("hisq_svd_counter = %d\n",hisq_svd_counter); #endif } fflush(stdout); }
/* Now devide by 2 eq. (4.2b) of Golderman's Meson paper*/ FORALLSITES(i,s) { scalar_mult_su3_vector( (su3_vector *)F_PT(s,dest), .5, (su3_vector *)F_PT(s,dest) ); }
/* Now divide by 2 eq. (4.2b) of Golterman's Meson paper*/ FORALLSITES(i,s) { scalar_mult_su3_vector( dest+i, .5, dest+i ); }