#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #undef USE_SCU_CHECKSUMS #ifdef USE_SCU_CHECKSUMS #include #endif #include #include #include #include #include //-------------------------------------------------------------- USING_NAMESPACE_CPS using namespace std; DoArg do_arg; void setupDoArg(DoArg &do_arg, const int size[], const int ngp){ do_arg.x_sites = size[0]; do_arg.y_sites = size[1]; do_arg.z_sites = size[2]; do_arg.t_sites = size[3]; do_arg.s_sites = size[4]; do_arg.x_node_sites = 0; do_arg.y_node_sites = 0; do_arg.z_node_sites = 0; do_arg.t_node_sites = 0; do_arg.s_node_sites = 0; do_arg.x_nodes = 0; do_arg.y_nodes = 0; do_arg.z_nodes = 0; do_arg.t_nodes = 0; do_arg.s_nodes = 0; do_arg.updates = 0; do_arg.measurements = 0; do_arg.measurefreq = 0; do_arg.cg_reprod_freq = 10; do_arg.x_bc = BND_CND_PRD; do_arg.y_bc = BND_CND_PRD; do_arg.z_bc = BND_CND_PRD; do_arg.t_bc = BND_CND_APRD; do_arg.start_conf_kind = START_CONF_ORD; do_arg.start_conf_load_addr = 0x0; do_arg.start_seed_kind = START_SEED_FIXED; do_arg.start_seed_filename = "../rngs/ckpoint_rng.0"; do_arg.start_conf_filename = "../configurations/ckpoint_lat.0"; do_arg.start_conf_alloc_flag = 6; do_arg.wfm_alloc_flag = 2; do_arg.wfm_send_alloc_flag = 2; do_arg.start_seed_value = 83209; do_arg.beta = 2.25; do_arg.c_1 = -3.3100000000000002e-01; do_arg.u0 = 1.0000000000000000e+00; do_arg.dwf_height = 1.8000000000000000e+00; do_arg.dwf_a5_inv = 1.0000000000000000e+00; do_arg.power_plaq_cutoff = 0.0000000000000000e+00; do_arg.power_plaq_exponent = 0; do_arg.power_rect_cutoff = 0.0000000000000000e+00; do_arg.power_rect_exponent = 0; do_arg.verbose_level = -1202;//VERBOSE_DEBUG_LEVEL; //-1202; do_arg.checksum_level = 0; do_arg.exec_task_list = 0; do_arg.xi_bare = 1.0000000000000000e+00; do_arg.xi_dir = 3; do_arg.xi_v = 1.0000000000000000e+00; do_arg.xi_v_xi = 1.0000000000000000e+00; do_arg.clover_coeff = 0.0000000000000000e+00; do_arg.clover_coeff_xi = 0.0000000000000000e+00; do_arg.xi_gfix = 1.0000000000000000e+00; do_arg.gfix_chkb = 1; do_arg.asqtad_KS = 0.0000000000000000e+00; do_arg.asqtad_naik = 0.0000000000000000e+00; do_arg.asqtad_3staple = 0.0000000000000000e+00; do_arg.asqtad_5staple = 0.0000000000000000e+00; do_arg.asqtad_7staple = 0.0000000000000000e+00; do_arg.asqtad_lepage = 0.0000000000000000e+00; do_arg.p4_KS = 0.0000000000000000e+00; do_arg.p4_knight = 0.0000000000000000e+00; do_arg.p4_3staple = 0.0000000000000000e+00; do_arg.p4_5staple = 0.0000000000000000e+00; do_arg.p4_7staple = 0.0000000000000000e+00; do_arg.p4_lepage = 0.0000000000000000e+00; BndCndType* bcs[3] = { &do_arg.x_bc , &do_arg.y_bc, &do_arg.z_bc }; if(ngp > 3 || ngp < 0){ ERR.General("","","Number of GPBC must be between 0 and 3\n"); } for(int i=0;i> 8 ) ^ kCrc32Table[(_crc ^ *pCur) & 0xff]; } const uint32_t GetCrc32() { return ~_crc; } private: uint32_t _crc; }; bool RNG_equal(UGrandomGenerator &a, UGrandomGenerator &b){ // int aa[57], bb[57]; // a.store(aa); b.store(bb); int const *aa = a.getState(); int const *bb = b.getState(); for(int i=0;i<55;i++) if(aa[i] != bb[i]) return false; return true; } int main(int argc, char *argv[]) { Start(&argc,&argv); const char *cname=argv[0]; const char *fname="main()"; int ngp; { std::stringstream ss; ss << argv[1]; ss >> ngp; } if(!UniqueID()) printf("Number of GPBC: %d\n",ngp); int size[] = {4,4,4,4,4}; bool save_lrg(false); char *save_lrg_file; bool load_lrg(false); char *load_lrg_file; int nthreads = 1; int i=2; while(iargc-6){ printf("Did not specify enough arguments for 'latt' (require 5 dimensions)\n"); exit(-1); } for(int xx=0;xx<5;xx++){ std::stringstream ss; ss << argv[i+1+xx]; ss >> size[xx]; } i+=6; }else if( strncmp(cmd,"-save_lrg",15) == 0){ if(i==argc-1){ printf("-save_lrg requires an argument\n"); exit(-1); } save_lrg=true; save_lrg_file = argv[i+1]; i+=2; }else if( strncmp(cmd,"-load_lrg",15) == 0){ if(i==argc-1){ printf("-load_lrg requires an argument\n"); exit(-1); } load_lrg=true; load_lrg_file = argv[i+1]; i+=2; }else if( strncmp(cmd,"-nthread",8) == 0){ std::stringstream ss; ss << argv[i+1]; ss >> nthreads; if(!UniqueID()){ printf("Setting number of threads to %d\n",nthreads); } i+=2; }else{ if(UniqueID()==0) printf("Unrecognised argument: %s\n",cmd); exit(-1); } } if(!UniqueID()) printf("Lattice size is %d %d %d %d %d\n",size[0],size[1],size[2],size[3],size[4]); DoArg do_arg; setupDoArg(do_arg,size,ngp); GJP.Initialize(do_arg); LRG.Initialize(); omp_set_num_threads(nthreads); int nodes = 1; for(int i=0;i<5;i++) nodes *= GJP.Nodes(i); if(nodes > 1) ERR.General("","","This test code is designed to be run on a local machine!\n"); if(load_lrg){ if(UniqueID()==0) printf("Loading RNG state from %s\n",load_lrg_file); LRG.Read(load_lrg_file,32); } if(save_lrg){ if(UniqueID()==0) printf("Writing RNG state to %s\n",save_lrg_file); LRG.Write(save_lrg_file,32); } int rngs_dir[5]; for(int i=0;i<5;i++) rngs_dir[i] = GJP.NodeSites(i)/2; int vol5d = GJP.VolNodeSites()*GJP.SnodeSites()/32; int vol4d = GJP.VolNodeSites()/16; int max_threads = omp_get_max_threads(); std::vector< std::vector > > thread_matches(max_threads); //Check 5d generators printf("Starting comparison with %d threads\n",max_threads); fflush(stdout); Crc32 crc; std::map > test_matches; //compile by checksum assert( sizeof(int) % sizeof(uint32_t) == 0 ); for(int i=0;i > all_matches; for(std::map >::const_iterator it = test_matches.begin(); it != test_matches.end(); it++){ for(int ii=0;iisecond.size();ii++){ for(int jj=ii+1;jjsecond.size();jj++){ int i= it->second[ii]; int j= it->second[jj]; UGrandomGenerator & rng_i = LRG.UGrandGen(i); UGrandomGenerator & rng_j = LRG.UGrandGen(j); if(RNG_equal(rng_i,rng_j)) all_matches.push_back(std::pair(i,j)); } } } // void AddData(const uint8_t* pData, const uint32_t length) // #pragma omp parallel for // for(int i=0;i(i,j)); // } // } // printf("Combining\n"); printf("Sorting\n"); std::sort(all_matches.begin(), all_matches.end()); #if 0 printf("Printing\n"); for(int m=0;m (%d,%d,%d,%d,%d; %d)\n", xi[0],xi[1],xi[2],xi[3],xi[4],fi, xj[0],xj[1],xj[2],xj[3],xj[4],fj); } #else //Instead of printing all of them (there are a lot!), find compile just the unique deltas std::map unique_deltas; for(int m=0;m::const_iterator it = unique_deltas.begin(); it != unique_deltas.end(); it++){ std::cout << it->first << " count " << it->second << "\n"; } #endif // int size_5d_lcl = GJP.Gparity() ? 2:1; // int size_5d_glb = size_5d_lcl; // int sizes_glb[5]; // int sizes_lcl[5]; // int node_rng_offset[5]; // for(int i=0;i<5;i++){ // sizes_lcl[i] = GJP.NodeSites(i)/2; // size_5d_lcl *= sizes_lcl[i]; // sizes_glb[i] = GJP.NodeSites(i)*GJP.Nodes(i)/2; // size_5d_glb *= sizes_glb[i]; // node_rng_offset[i] = GJP.NodeCoor(i)*sizes_lcl[i]; // } // int f_off = size_5d_glb/2; //offset to second flavor // if(!UniqueID()){ printf("Generating random field\n"); fflush(stdout); } // //Store a global 5D field and just populate this node's segment // Float* field = (Float*)malloc(size_5d_glb*sizeof(Float)); // memset(field,0, size_5d_glb*sizeof(Float)); //zero it! // //Generate a 5D random field on each 2^4 hypercube of local volume // for(int s=0;s=0;i--){ // xoff_5d *= sizes_glb[i]; // xoff_5d += x_glb_rng[i]; // } // LRG.AssignGenerator(x,y,z,t,s,0); // field[xoff_5d] = LRG.Urand(FIVE_D); // if(GJP.Gparity()){ // LRG.AssignGenerator(x,y,z,t,s,1); // field[xoff_5d+f_off] = LRG.Urand(FIVE_D); // } // } // } // } // } // } // if(!UniqueID()){ printf("Running check\n"); fflush(stdout); } // std::map rand_map; //map of random number to RNG global coordinate // for(int i=0;i::const_iterator it = rand_map.find(val); // if(it != rand_map.end()){ // rem = it->second; // int x_other[5]; // for(int xx=0;xx<5;xx++){ // x_other[xx] = rem % sizes_glb[xx]; rem /= sizes_glb[xx]; // } // int f_other = rem; // if(!UniqueID()){ // printf("Found match in random numbers (%g) between global RNG sites (%d,%d,%d,%d,%d; %d) and (%d,%d,%d,%d,%d; %d)\n", // field[i], // x[0],x[1],x[2],x[3],x[4],f, // x_other[0],x_other[1],x_other[2],x_other[3],x_other[4],f_other // ); // } // }else rand_map[val] = i; // } // free(field); End(); if(!UniqueID()) printf("End of program\n"); return(0); }