-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskflowPar.cpp
39 lines (28 loc) · 959 Bytes
/
taskflowPar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <algorithm/sort.hpp>
#include <commons.hpp>
#include <taskflow.hpp>
int main(int argc, char **argv) {
long long length;
char *a = argv[1];
length = atoll(a);
int num_threads;
char *b = argv[2];
num_threads = atoi(b);
std::cout << "running experiment with size of " + std::to_string(length)
<< "\n";
std::cout << "running with number of threads: " << num_threads << "\n";
tf::Executor executor(num_threads);
std::vector<double> workVec(length);
for (size_t i = 0; i < length; ++i) {
workVec[i] = uni(rng);
}
tf::Taskflow t1;
t1.for_each(workVec.begin(), workVec.end(),
[](double &arg) { arg = std::tan(arg); });
getExecutionTime("taskflow transform",
[&]() mutable { executor.run(t1).wait(); });
tf::Taskflow t2;
t2.sort(workVec.begin(), workVec.end());
getExecutionTime("taskflow sort", [&]() mutable { executor.run(t2).wait(); });
std::cout << '\n';
}