Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <hpx/hpx_main.hpp>
- #include <hpx/include/lcos.hpp>
- #include <hpx/include/actions.hpp>
- #include <hpx/include/components.hpp>
- #include <hpx/include/iostreams.hpp>
- #include <cstddef>
- #include <list>
- #include <mutex>
- #include <set>
- #include <vector>
- std::size_t total_tasks = 100000;
- std::size_t n = 1000;
- void ep_worker()
- {
- std::vector<double> a(n);
- std::vector<double> b(n);
- std::vector<double> c(n);
- /* fill it with random */
- for(int i = 0; i < n; i++ ) {
- a[i] = rand() % 10;
- b[i] = rand() % 10;
- }
- for(int i = 0; i < n; i++ ) {
- c[i] = a[i] * b[i];
- }
- }
- hpx::future<void> ep_foreman()
- {
- std::vector<hpx::future<std::size_t> > futures;
- futures.reserve(total_tasks);
- for(std::size_t i = 0; i != total_tasks; ++i)
- futures.push_back(hpx::async(&ep_worker));
- return hpx::when_all(futures);
- }
- HPX_PLAIN_ACTION(ep_foreman, ep_foreman_action);
- int main(int argc, char **argv)
- {
- cores = 1;
- n = 1000;
- total_tasks = 1000;
- process_input(&argc, &argv, 3);
- std::vector<hpx::id_type> localities = hpx::find_all_localities();
- std::vector<hpx::future<void> > futures;
- futures.reserve(localities.size());
- for (hpx::id_type const& node : localities)
- {
- typedef ep_foreman_action action_type;
- futures.push_back(hpx::async<action_type>(node));
- }
- START_TIMER;
- hpx::wait_all(futures);
- /* stop timer */
- STOP_TIMER_AND_PRINT(("Cores: %d Tasks: %d\tn: %d\n", cores, total_tasks, n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement