void common_wrapper(UArg arg0, UArg arg1) { taskArgs* t = (taskArgs*)arg0 ; int tid = (int)arg1 ; int i, j, k ; for(i=0 ; i<NUM_ITER ; i++) { if(tid == 0) { callBarrier(0, /*lock_id=*/4) ; } callLocalBarrier() ; compute_histo(t->buffer1, t->buffer2, t->start_indx, t->end_indx) ; Cache_wbInv (t->buffer2, HISTO_SIZE*4, Cache_Type_ALL, FALSE) ; callLocalBarrier() ; if(tid == 0) { callBarrier(1, /*lock_id=*/4) ; compute_gray_level_mapping() ; } callLocalBarrier() ; compute_image(t->buffer1, m3_gray_level_mapping, t->start_indx, t->end_indx) ; if(tid == 0) Cache_wbInv (t->buffer1, IMG_SIZE*IMG_SIZE*4, Cache_Type_ALL, FALSE); } if(tid == 0) Event_post(edgeDetectEvent, Event_Id_00) ; else Event_post(edgeDetectEvent, Event_Id_01) ; }
//------------------------------------------------------------ // MAIN //------------------------------------------------------------ int main(int argc, char* argv[]) { // initialize mpi boost::mpi::environment env(argc, argv); boost::mpi::communicator world; // greeting if (world.rank() == 0) std::cout << "Random walk calculation" << std::endl; // prepare the MC parameters int N_Cycles = 100000; int Length_Cycle = 100; int N_Warmup_Cycles = 0; std::string Random_Name = ""; int Random_Seed = 374982 + world.rank() * 273894; int Verbosity = (world.rank() == 0 ? 3 : 0); int xmax=floor(4*sqrt(Length_Cycle) ); //max of the position registered in the histogram double pl=1.5, pr=1; //non normalized probabilities for proposing a left or right move h5::file file("params.h5",H5F_ACC_TRUNC); h5_write(file,"pr",make_array(pr)); h5_write(file,"pl",make_array(pl)); h5_write(file,"xmax",make_array(xmax)); h5_write(file,"N_Cycles",make_array(N_Cycles)); h5_write(file,"Length_Cycle",make_array(Length_Cycle)); // construct a Monte Carlo loop triqs::mc_tools::mc_generic<double> IntMC(N_Cycles, Length_Cycle, N_Warmup_Cycles, Random_Name, Random_Seed, Verbosity); // construct configuration configuration config; triqs::arrays::array<double,1> H(2*xmax); H()=0; // add moves and measures IntMC.add_move(move_left (config, pl, pr, IntMC.rng() ), "left move", pl); IntMC.add_move(move_right(config, pl, pr, IntMC.rng() ), "right move", pr); IntMC.add_measure(compute_histo(config, H, xmax), "histogramn measure"); // Run and collect results IntMC.start(1.0, triqs::utility::clock_callback(600)); IntMC.collect_results(world); return 0; }