Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <hpx/hpx_init.hpp>
- #include <hpx/util/high_resolution_timer.hpp>
- #include <hpx/runtime/get_worker_thread_num.hpp>
- #include <hpx/runtime/get_os_thread_count.hpp>
- #include <hpx/parallel/algorithms/for_each.hpp>
- #include <hpx/parallel/executors/static_chunk_size.hpp>
- #include <hpx/parallel/executors/dynamic_chunk_size.hpp>
- #include <boost/range/irange.hpp>
- int get_time() {
- return hpx::util::high_resolution_clock::now() * 1e-9;
- }
- int hpx_main(int argc, char *argv[]) {
- std::vector<std::vector<int>> Threads(hpx::get_os_thread_count(), std::vector<int>());
- std::cout << "Working on " << hpx::get_os_thread_count() << " threads " <<std::endl;
- auto range = boost::irange(0, 10);
- hpx::parallel::for_each(hpx::parallel::execution::par.with(hpx::parallel::execution::static_chunk_size(3)), range.begin(), range.end(), [&](int i){
- Threads[hpx::get_worker_thread_num()].push_back(i);});
- std::cout << " Iterations " << std::endl;
- for (int i(0); i < hpx::get_os_thread_count(); i++) {
- std::cout << "Thread " << i << " : ";
- for(int j(0); j < Threads[i].size(); j++) {
- std::cout << Threads[i][j] << " ";
- }
- std::cout << "\n";
- }
- return hpx::finalize();
- }
- int main(int argc, char *argv[]){
- return hpx::init(argc, argv);
- }
Advertisement
Add Comment
Please, Sign In to add comment