Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #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/algorithms/sort.hpp>
- #include <hpx/parallel/executors/static_chunk_size.hpp>
- #include <hpx/parallel/executors/dynamic_chunk_size.hpp>
- #include <boost/range/irange.hpp>
- #include <blaze/Math.h>
- double get_time() {
- return hpx::util::high_resolution_clock::now() * 1e-9;
- }
- int hpx_main(int argc, char *argv[]) {
- int N = std::stoi(argv[1], NULL);
- blaze::DynamicMatrix<int> A(N, N), B(N, N), C(N, N);
- for(size_t i(0); i < A.rows(); i++) {
- for(size_t j(0); j < A.columns(); j++) {
- A(i, j) = blaze::rand<int>(0, 1000);
- B(i, j) = blaze::rand<int>(0, 1000);
- }
- }
- std::cout << " matrices divided into " << blaze::getNumThreads() << std::endl;
- double t1 = get_time();
- C = A * B;
- double t2 = get_time();
- double delta = t2 - t1;
- std::cout << "Time spent with " << hpx::get_os_thread_count() << " is " << delta << " (s) \n";
- return hpx::finalize();
- }
- int main(int argc, char *argv[]) {
- return hpx::init(argc, argv);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement