1 #include "matrix.hpp"
2 #include <taskflow/taskflow.hpp>
3 
4 // wavefront computing
wavefront_taskflow(unsigned num_threads)5 void wavefront_taskflow(unsigned num_threads) {
6 
7   tf::Executor executor(num_threads);
8   tf::Taskflow taskflow;
9 
10   std::vector<std::vector<tf::Task>> node(MB);
11 
12   for(auto &n : node){
13     for(int i=0; i<NB; i++){
14       n.emplace_back(taskflow.placeholder());
15     }
16   }
17 
18   matrix[M-1][N-1] = 0;
19   for( int i=MB; --i>=0; ) {
20     for( int j=NB; --j>=0; ) {
21       node[i][j].work(
22         [=]() {
23           block_computation(i, j);
24         }
25       );
26 
27       if(j+1 < NB) node[i][j].precede(node[i][j+1]);
28       if(i+1 < MB) node[i][j].precede(node[i+1][j]);
29     }
30   }
31 
32   executor.run(taskflow).get();
33 }
34 
measure_time_taskflow(unsigned num_threads)35 std::chrono::microseconds measure_time_taskflow(unsigned num_threads) {
36   auto beg = std::chrono::high_resolution_clock::now();
37   wavefront_taskflow(num_threads);
38   auto end = std::chrono::high_resolution_clock::now();
39   return std::chrono::duration_cast<std::chrono::microseconds>(end - beg);
40 }
41 
42 
43