void qopWilsonDslashInit(int *argc, char ***argv) { QDP_initialize(argc, argv); QDP_verbose(0); QDP_profcontrol(0); }
int main(int argc, char *argv[]) { int i, j; QDP_initialize(&argc, &argv); QDP_profcontrol(0); seed = time(NULL); j = 0; for(i=1; i<argc; i++) { switch(argv[i][0]) { case 'c' : cgtype=atoi(&argv[i][1]); break; case 'k' : kappa=atof(&argv[i][1]); break; case 'n' : nit=atoi(&argv[i][1]); break; case 's' : seed=atoi(&argv[i][1]); break; case 'S' : style=atoi(&argv[i][1]); break; case 'x' : j=i; while((i+1<argc)&&(isdigit(argv[i+1][0]))) ++i; break; default : usage(argv[0]); } } lattice_size = (int *) malloc(ndim*sizeof(int)); if(j==0) { for(i=0; i<ndim; ++i) lattice_size[i] = 8; } else { if(!isdigit(argv[j][1])) usage(argv[0]); lattice_size[0] = atoi(&argv[j][1]); for(i=1; i<ndim; ++i) { if((++j<argc)&&(isdigit(argv[j][0]))) { lattice_size[i] = atoi(&argv[j][0]); } else { lattice_size[i] = lattice_size[i-1]; } } } if(QDP_this_node==0) { printf("size = %i", lattice_size[0]); for(i=1; i<ndim; i++) { printf(" %i", lattice_size[i]); } printf("\n"); printf("kappa = %g\n", kappa); printf("seed = %i\n", seed); } QDP_set_latsize(ndim, lattice_size); QDP_create_layout(); rs = QDP_create_S(); seed_rand(rs, seed); start(); QDP_finalize(); return 0; }
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); }
void start(void) { double mf, best_mf; QLA_Real plaq; QDP_ColorMatrix **u; QDP_DiracFermion *out, *in; int i, st, ns, nm, bs, sti, nsi, nmi, bsi, best_st, best_ns, best_nm, best_bs; u = (QDP_ColorMatrix **) malloc(ndim*sizeof(QDP_ColorMatrix *)); for(i=0; i<ndim; i++) u[i] = QDP_create_M(); get_random_links(u, ndim, 0.2); plaq = get_plaq(u); if(QDP_this_node==0) printf("plaquette = %g\n", plaq); out = QDP_create_D(); in = QDP_create_D(); QDP_D_eq_gaussian_S(in, rs, QDP_all); QOP_layout_t qoplayout = QOP_LAYOUT_ZERO; qoplayout.latdim = ndim; qoplayout.latsize = (int *) malloc(ndim*sizeof(int)); for(i=0; i<ndim; i++) { qoplayout.latsize[i] = lattice_size[i]; } qoplayout.machdim = -1; QOP_info_t info = QOP_INFO_ZERO; QOP_invert_arg_t inv_arg = QOP_INVERT_ARG_DEFAULT; QOP_resid_arg_t res_arg = QOP_RESID_ARG_DEFAULT; res_arg.rsqmin = rsqmin; inv_arg.max_iter = 600; inv_arg.restart = 200; inv_arg.evenodd = QOP_EVEN; if(QDP_this_node==0) { printf("begin init\n"); fflush(stdout); } QOP_init(&qoplayout); if(QDP_this_node==0) { printf("begin load links\n"); fflush(stdout); } //flw = QOP_wilson_create_L_from_qdp(u, NULL); if(QDP_this_node==0) { printf("begin invert\n"); fflush(stdout); } if(cgtype>=0) { QOP_opt_t optcg; optcg.tag = "cg"; optcg.value = cgtype; QOP_wilson_invert_set_opts(&optcg, 1); } best_mf = 0; best_st = sta[0]; best_ns = nsa[0]; best_nm = nma[0]; best_bs = bsa[0]; QOP_opt_t optst; optst.tag = "st"; QOP_opt_t optns; optns.tag = "ns"; QOP_opt_t optnm; optnm.tag = "nm"; for(sti=0; sti<stn; sti++) { if((style>=0)&&(sti!=style)) continue; st = sta[sti]; optst.value = st; if(QOP_wilson_invert_set_opts(&optst, 1)==QOP_FAIL) continue; for(nsi=0; nsi<nsn; nsi++) { ns = nsa[nsi]; optns.value = ns; if(QOP_wilson_invert_set_opts(&optns, 1)==QOP_FAIL) continue; for(nmi=0; nmi<nmn; nmi++) { nm = nma[nmi]; if(nm==0) nm = ns; optnm.value = nm; if(QOP_wilson_invert_set_opts(&optnm, 1)==QOP_FAIL) continue; for(bsi=0; bsi<bsn; bsi++) { bs = bsa[bsi]; QDP_set_block_size(bs); flw = QOP_wilson_create_L_from_qdp(u, NULL); mf = bench_inv(&info, &inv_arg, &res_arg, out, in); QOP_wilson_destroy_L(flw); printf0("CONGRAD: st%2i ns%2i nm%2i bs%5i iter%5i sec%7.4f mflops = %g\n", st, ns, nm, bs, res_arg.final_iter, info.final_sec, mf); if(mf>best_mf) { best_mf = mf; best_st = st; best_ns = ns; best_nm = nm; best_bs = bs; } } } } } flw = QOP_wilson_create_L_from_qdp(u, NULL); optst.value = best_st; optns.value = best_ns; optnm.value = best_nm; QOP_wilson_invert_set_opts(&optst, 1); QOP_wilson_invert_set_opts(&optns, 1); QOP_wilson_invert_set_opts(&optnm, 1); QDP_set_block_size(best_bs); QDP_profcontrol(1); mf = bench_inv(&info, &inv_arg, &res_arg, out, in); QDP_profcontrol(0); printf0("prof: CONGRAD: st%2i ns%2i nm%2i bs%5i iter%5i sec%7.4f mflops = %g\n", best_st, best_ns, best_nm, best_bs, res_arg.final_iter, info.final_sec, mf); printf0("best: CONGRAD: st%2i ns%2i nm%2i bs%5i mflops = %g\n", best_st, best_ns, best_nm, best_bs, best_mf); if(QDP_this_node==0) { printf("begin unload links\n"); fflush(stdout); } //QOP_wilson_invert_unload_links(); if(QDP_this_node==0) { printf("begin finalize\n"); fflush(stdout); } QOP_finalize(); }
int main( int argc, char **argv ) { int meascount,traj_done,i; int prompt; int s_iters, avs_iters, avspect_iters, avbcorr_iters; double dtime, dclock(); 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) { /* perform warmup trajectories */ #ifdef MILC_GLOBAL_DEBUG global_current_time_step = 0; #endif /* MILC_GLOBAL_DEBUG */ dtime = -dclock(); for( traj_done=0; traj_done < warms; traj_done++ ){ update(); } node0_printf("WARMUPS COMPLETED\n"); fflush(stdout); /* perform measuring trajectories, reunitarizing and measuring */ meascount=0; /* number of measurements */ avspect_iters = avs_iters = avbcorr_iters = 0; for( traj_done=0; traj_done < trajecs; traj_done++ ){ #ifdef MILC_GLOBAL_DEBUG #ifdef HISQ_REUNITARIZATION_DEBUG { int isite, idir; site *s; FORALLSITES(isite,s) { for( idir=XUP;idir<=TUP;idir++ ) { lattice[isite].on_step_Y[idir] = 0; lattice[isite].on_step_W[idir] = 0; lattice[isite].on_step_V[idir] = 0; } } } #endif /* HISQ_REUNITARIZATION_DEBUG */ #endif /* MILC_GLOBAL_DEBUG */ /* do the trajectories */ s_iters=update(); /* measure every "propinterval" trajectories */ if( (traj_done%propinterval)==(propinterval-1) ){ /* call gauge_variable fermion_variable measuring routines */ /* results are printed in output file */ rephase(OFF); g_measure( ); rephase(ON); #ifdef MILC_GLOBAL_DEBUG #ifdef HISQ g_measure_plaq( ); #endif #ifdef MEASURE_AND_TUNE_HISQ g_measure_tune( ); #endif /* MEASURE_AND_TUNE_HISQ */ #endif /* MILC_GLOBAL_DEBUG */ /************************************************************/ /* WARNING: The spectrum code below is under revision */ /* It works only in special cases */ /* For the asqtad spectrum, please create the lattice first */ /* and then run the appropriate executable in ks_imp_dyn. */ /************************************************************/ /* Do some fermion measurements */ #ifdef SPECTRUM /* Fix TUP Coulomb gauge - gauge links only*/ rephase( OFF ); gaugefix(TUP,(Real)1.8,500,(Real)GAUGE_FIX_TOL); rephase( ON ); invalidate_all_ferm_links(&fn_links); #ifdef DM_DU0 invalidate_all_ferm_links(&fn_links_dmdu0); #endif #endif for(i=0;i<n_dyn_masses;i++){ // Remake the path table if the fermion coeffs change for this mass // DT IT CAN"T BE RIGHT TO CALL IT WITH dyn_mass //if(make_path_table(&ks_act_paths, &ks_act_paths_dmdu0,dyn_mass[i])) //AB: NOT SURE IF WE ARE DOING THIS RIGHT HERE // HAVE TO THINK THROUGH HOW LINKS ARE LOADED FOR MEASUREMENTS // AND WHERE NAIK CORRECTION CAN EVER POSSIBLY ENTER // if(make_path_table(&ks_act_paths, &ks_act_paths_dmdu0, 0.0/*TEMP*/ )) { // If they change, invalidate only fat and long links //node0_printf("INVALIDATE\n"); invalidate_all_ferm_links(&fn_links); #ifdef DM_DU0 invalidate_all_ferm_links(&fn_links_dmdu0); #endif } /* Load fat and long links for fermion measurements if needed */ #ifdef HISQ //AB: QUICK FIX TO USE NAIK EPSILON FOR SPECTRUM MEASUREMENTS, // WORKS ONLY IF IN THE RATIONAL FUNCTION FILE naik_term_epsilon IS NON-ZERO // FOR LAST PSEUDO-FIELD // IT IS ASSUMED THAT THIS CORRECTION CORRESPONDS TO LAST DYNAMICAL MASS //AB: OLD WAY OF INITIALIZING THE LINKS: fn_links.hl.current_X_set = 0; // INSTEAD WE DO: //// if(n_dyn_masses-1==i) { // last dynamical mass, assumed to be c-quark //// fn_links.hl.current_X_set = n_naiks-1; //DT CHARM QUARK NEEDS SMALLER RESIDUAL //// node0_printf("TEMP: reset rsqprop from %e to %e\n",rsqprop,1e-8*rsqprop); //// rsqprop *= 1e-8; //// } //// else { // light quarks fn_links.hl.current_X_set = 0; //// } #endif load_ferm_links(&fn_links, &ks_act_paths); #ifdef DM_DU0 #ifdef HISQ fn_links_dmdu0.hl.current_X_set = 0; #endif load_ferm_links(&fn_links_dmdu0, &ks_act_paths_dmdu0); #endif f_meas_imp( F_OFFSET(phi1), F_OFFSET(xxx1), dyn_mass[i], &fn_links, &fn_links_dmdu0); /* Measure derivatives wrto chemical potential */ #ifdef D_CHEM_POT Deriv_O6( F_OFFSET(phi1), F_OFFSET(xxx1), F_OFFSET(xxx2), dyn_mass[i], &fn_links, &fn_links_dmdu0); #endif #ifdef SPECTRUM // DT: At the moment spectrum_nd does only the first two masses // this only makes sense to get the kaon, and only works if // eps_naik is the same for both the first two quarks if( strstr(spectrum_request,",spectrum_nd,") != NULL && i==0 ) avspect_iters += spectrum_nd( dyn_mass[0], dyn_mass[1], 1e-2, &fn_links); // AB: spectrum() is used only for the charm quark, // i.e., last dynamical mass if(strstr(spectrum_request,",spectrum,") != NULL && n_dyn_masses-1==i) avspect_iters += spectrum2( dyn_mass[i], F_OFFSET(phi1), F_OFFSET(xxx1), &fn_links); if(strstr(spectrum_request,",spectrum_point,") != NULL) avspect_iters += spectrum_fzw( dyn_mass[i], F_OFFSET(phi1), F_OFFSET(xxx1), &fn_links); // AB: nl_spectrum is used only for strange, // i.e., second mass if(strstr(spectrum_request,",nl_spectrum,") != NULL && 1==i) avspect_iters += nl_spectrum( dyn_mass[i], F_OFFSET(phi1), F_OFFSET(xxx1), F_OFFSET(tempmat1), F_OFFSET(staple), &fn_links); // AB: spectrum_mom is used only for charm, // i.e., last mass if(strstr(spectrum_request,",spectrum_mom,") != NULL && n_dyn_masses-1==i) avspect_iters += spectrum_mom( dyn_mass[i], dyn_mass[i], F_OFFSET(phi1), 1e-1, &fn_links); // For now we can't do the off-diagonal spectrum if Dirac operators // depend on masses. We need two propagators // if(strstr(spectrum_request,",spectrum_multimom,") != NULL) // avspect_iters += spectrum_multimom(dyn_mass[i], // spectrum_multimom_low_mass, // spectrum_multimom_mass_step, // spectrum_multimom_nmasses, // 5e-3, &fn_links); // For now we can't do the off-diagonal spectrum if Dirac operators // depend on masses. We need two propagators // if(strstr(spectrum_request,",spectrum_nd,") != NULL){ // avspect_iters += spectrum_nd( mass1, mass2, 1e-1, // &fn_links); // AB: spectrum_nlpi2 is used only for up/down, // i.e., first mass if(strstr(spectrum_request,",spectrum_nlpi2,") != NULL && 0==i) avspect_iters += spectrum_nlpi2( dyn_mass[i], dyn_mass[i], F_OFFSET(phi1),1e-1, &fn_links ); if(strstr(spectrum_request,",spectrum_singlets,") != NULL) avspect_iters += spectrum_singlets(dyn_mass[i], 5e-3, F_OFFSET(phi1), &fn_links ); // For now we can't do the off-diagonal spectrum if Dirac operators // depend on masses. We need two propagators // if(strstr(spectrum_request,",fpi,") != NULL) // avspect_iters += fpi_2( fpi_mass, fpi_nmasses, 2e-3, // &fn_links ); #ifdef HYBRIDS if(strstr(spectrum_request,",spectrum_hybrids,") != NULL) avspect_iters += spectrum_hybrids( dyn_mass[i], F_OFFSET(phi1), 5e-3, &fn_links); #endif if(strstr(spectrum_request,",hvy_pot,") != NULL){ rephase( OFF ); hvy_pot( F_OFFSET(link[XUP]) ); rephase( ON ); } #endif // if(n_dyn_masses-1==i) { // last dynamical mass, assumed to be c-quark //DT CHARM QUARK NEEDS SMALLER RESIDUAL //AB NEED TO RETURN RESIDUAL TO THE ORIGINAL VALUE // node0_printf("TEMP: reset rsqprop from %e to %e\n",rsqprop,1e+8*rsqprop); // rsqprop *= 1e+8; // } } avs_iters += s_iters; ++meascount; fflush(stdout); } } /* end loop over trajectories */ node0_printf("RUNNING COMPLETED\n"); fflush(stdout); if(meascount>0) { node0_printf("average cg iters for step= %e\n", (double)avs_iters/meascount); } dtime += dclock(); if(this_node==0){ printf("Time = %e seconds\n",dtime); printf("total_iters = %d\n",total_iters); } fflush(stdout); /* save lattice if requested */ if( saveflag != FORGET ){ rephase( OFF ); save_lattice( saveflag, savefile, stringLFN ); rephase( ON ); } } #ifdef HAVE_QDP QDP_finalize(); #endif normal_exit(0); return 0; }
void start(void) { double mf, best_mf; QLA_Real plaq; QDP_ColorMatrix **u; int i, bs, bsi, best_bs; u = (QDP_ColorMatrix **) malloc(ndim*sizeof(QDP_ColorMatrix *)); for(i=0; i<ndim; i++) u[i] = QDP_create_M(); get_random_links(u, ndim, 0.3); plaq = get_plaq(u); if(QDP_this_node==0) printf("plaquette = %g\n", plaq); QOP_layout_t qoplayout = QOP_LAYOUT_ZERO; qoplayout.latdim = ndim; qoplayout.latsize = (int *) malloc(ndim*sizeof(int)); for(i=0; i<ndim; i++) { qoplayout.latsize[i] = lattice_size[i]; } qoplayout.machdim = -1; if(QDP_this_node==0) { printf("begin init\n"); fflush(stdout); } QOP_init(&qoplayout); gauge = QOP_create_G_from_qdp(u); QOP_Force *force; QDP_ColorMatrix *cm[4]; for(i=0; i<4; i++) { cm[i] = QDP_create_M(); QDP_M_eq_zero(cm[i], QDP_all); } QOP_gauge_coeffs_t gcoeffs = QOP_GAUGE_COEFFS_ZERO; gcoeffs.plaquette = 0.2; gcoeffs.rectangle = 0.2; gcoeffs.parallelogram = 0.2; gcoeffs.adjoint_plaquette = 0.2; force = QOP_create_F_from_qdp(cm); mf = bench_action(&gcoeffs, force); QOP_destroy_F(force); printf0("action: sec%7.4f mflops = %g\n", secs, mf); if(QDP_this_node==0) { printf("begin force\n"); fflush(stdout); } best_mf = 0; best_bs = bsa[0]; for(bsi=0; bsi<bsn; bsi++) { bs = bsa[bsi]; QDP_set_block_size(bs); force = QOP_create_F_from_qdp(cm); mf = bench_force(&gcoeffs, force); QOP_destroy_F(force); printf0("GF: bs%5i sec%7.4f mflops = %g\n", bs, secs, mf); if(mf>best_mf) { best_mf = mf; best_bs = bs; } } QDP_set_block_size(best_bs); QDP_profcontrol(1); force = QOP_create_F_from_qdp(cm); mf = bench_force(&gcoeffs, force); QDP_profcontrol(0); printf0("prof: GF: bs%5i sec%7.4f mflops = %g\n", best_bs, secs, mf); printf0("best: GF: bs%5i mflops = %g\n", best_bs, best_mf); if(QDP_this_node==0) { printf("begin unload links\n"); fflush(stdout); } //QOP_asqtad_invert_unload_links(); if(QDP_this_node==0) { printf("begin finalize\n"); fflush(stdout); } QOP_finalize(); }
void qhmc_init_qopqdp(int *argc, char ***argv) { QDP_initialize(argc, argv); QDP_profcontrol(0); }
/* the driver */ int main(int argc, char *argv[]) { int status = 1; int i; lua_State *L = NULL; if (QDP_initialize(&argc, &argv)) { fprintf(stderr, "QDP initialization failed\n"); return 1; } QDP_profcontrol(0); double node = QDP_this_node; QMP_min_double(&node); qlua_master_node = node; L = lua_open(); if (L == NULL) { message("can not create Lua state"); goto end; } qlua_init(L, argc, argv); /* open libraries */ if (argc < 2) { message("QLUA component versions:\n"); for (i = 0; versions[i].name; i++) message(" %10s: %s\n", versions[i].name, versions[i].value); } else { for (i = 1; i < argc; i++) { char *source; if(strcmp(argv[i],"-e")==0) { // process command const char *chunk = argv[i] + 2; if (*chunk == '\0') { if (++i >= argc) { message("missing argument to -e"); goto end; } chunk = argv[i]; } QLUA_ASSERT(chunk != NULL); status = dostring(L, chunk); source = "=(command line)"; } else { status = dofile(L, argv[i]); source = argv[i]; } report(L, source, status); if (status) { fflush(stdout); fflush(stderr); QDP_abort(1); break; } } } qlua_fini(L); lua_close(L); end: QDP_finalize(); return status; }