int hpx_main(boost::program_options::variables_map& vm) { mini_ghost::profiling::data().time_init(hpx::util::high_resolution_timer::now() - init_start); hpx::util::high_resolution_timer timer_all; hpx::id_type here = hpx::find_here(); std::string name = hpx::get_locality_name(); p.rank = hpx::naming::get_locality_id_from_id(here); if(p.rank == 0) { std::cout << "mini ghost started up in " << hpx::util::high_resolution_timer::now() - init_start << " seconds.\n"; } p.nranks = hpx::get_num_localities().get(); profiling_data_sem.reset(new hpx::lcos::local::counting_semaphore(p.nranks)); p.setup(vm); hpx::id_type stepper_id = hpx::components::new_<stepper_type>(hpx::find_here()).get(); boost::shared_ptr<stepper_type> stepper(hpx::get_ptr<stepper_type>(stepper_id).get()); stepper->init(p); mini_ghost::barrier_wait(); stepper->run(p.num_spikes, p.num_tsteps); mini_ghost::barrier_wait(); if (p.rank==0) { add_profile(mini_ghost::profiling::data()); if(p.report_perf) mini_ghost::profiling::report(std::cout, profiling_data, p); else std::cout << "Total runtime: " << timer_all.elapsed() << "\n"; std::ofstream fs("results.yaml"); mini_ghost::profiling::report(fs, profiling_data, p); std::cout << "finalizing ...\n"; return hpx::finalize(); } else { hpx::apply(add_profile_action(), hpx::find_root_locality(), mini_ghost::profiling::data()); return 0; } }
int hpx_main(boost::program_options::variables_map& vm) { mini_ghost::profiling::data().time_init( hpx::util::high_resolution_timer::now() - init_start); hpx::util::high_resolution_timer timer_all; hpx::id_type here = hpx::find_here(); std::string name = hpx::get_locality_name(); p.rank = hpx::naming::get_locality_id_from_id(here); if(p.rank == 0) { std::cout << "mini ghost started up in " << hpx::util::high_resolution_timer::now() - init_start << " seconds.\n"; } p.nranks = hpx::get_num_localities_sync(); profiling_data_sem.reset(new hpx::lcos::local::counting_semaphore(p.nranks)); p.setup(vm); // Create the local stepper object, retrieve the local pointer to it hpx::id_type stepper_id = hpx::components::new_<stepper_type>(here).get(); boost::shared_ptr<stepper_type> stepper( hpx::get_ptr<stepper_type>(stepper_id).get()); // Initialize stepper stepper->init(p).get(); mini_ghost::barrier_wait(); // Perform the actual simulation work stepper->run(p.num_spikes, p.num_tsteps); mini_ghost::barrier_wait(); // Output various pieces of information about the run if (stepper->get_rank() == 0) { // Output various pieces of information about the run add_profile(mini_ghost::profiling::data()); if (p.report_perf) mini_ghost::profiling::report(std::cout, profiling_data, p); else std::cout << "Total runtime: " << timer_all.elapsed() << "\n"; std::ofstream fs("results.yaml"); mini_ghost::profiling::report(fs, profiling_data, p); std::cout << "finalizing ...\n"; return hpx::finalize(); } else { // Send performance data from this locality to root hpx::apply(add_profile_action(), hpx::find_root_locality(), mini_ghost::profiling::data()); return 0; } }