Advertisement
Guest User

Untitled

a guest
Nov 6th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <hpx/hpx_init.hpp>
  5. #include <hpx/util/high_resolution_timer.hpp>
  6. #include <hpx/runtime/get_worker_thread_num.hpp>
  7. #include <hpx/runtime/get_os_thread_count.hpp>
  8. #include <hpx/parallel/algorithms/for_each.hpp>
  9. #include <hpx/parallel/algorithms/sort.hpp>
  10. #include <hpx/parallel/executors/static_chunk_size.hpp>
  11. #include <hpx/parallel/executors/dynamic_chunk_size.hpp>
  12. #include <boost/range/irange.hpp>
  13. #include <blaze/Math.h>
  14.  
  15. double get_time() {
  16.     return hpx::util::high_resolution_clock::now() * 1e-9;
  17. }
  18.  
  19. int hpx_main(int argc, char *argv[]) {
  20.    
  21.     int N = std::stoi(argv[1], NULL);
  22.    
  23.     blaze::DynamicMatrix<int> A(N, N), B(N, N), C(N, N);
  24.    
  25.    for(size_t i(0); i < A.rows(); i++) {
  26.         for(size_t j(0); j < A.columns(); j++) {
  27.             A(i, j) = blaze::rand<int>(0, 1000);
  28.             B(i, j) = blaze::rand<int>(0, 1000);
  29.         }
  30.     }
  31.    
  32.     std::cout << " matrices divided into " << blaze::getNumThreads() << std::endl;
  33.    
  34.     double t1 = get_time();
  35.     C = A * B;
  36.     double t2 = get_time();
  37.     double delta = t2 - t1;
  38.     std::cout << "Time spent with " << hpx::get_os_thread_count() << " is " << delta << " (s) \n";
  39.     return hpx::finalize();
  40.  
  41. }
  42.  
  43. int main(int argc, char *argv[]) {
  44.     return hpx::init(argc, argv);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement