Skip to content

Commit 4c190c4

Browse files
Merge branch 'dev' of https://github.com/cpp-taskflow/cpp-taskflow into dev
2 parents c413a36 + bc1d2fd commit 4c190c4

353 files changed

Lines changed: 1981 additions & 49464 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ add_executable(
276276
${TF_BENCHMARK_DIR}/wavefront/seq.cpp
277277
${TF_BENCHMARK_DIR}/wavefront/taskflow.cpp
278278
)
279+
target_include_directories(wavefront PRIVATE ${PROJECT_SOURCE_DIR}/3rd-party/CLI11)
279280
target_link_libraries(
280281
wavefront
281282
${PROJECT_NAME} Threads::Threads ${TBB_IMPORTED_TARGETS} ${OpenMP_CXX_LIBRARIES}
@@ -293,6 +294,7 @@ add_executable(
293294
${TF_BENCHMARK_DIR}/graph_traversal/seq.cpp
294295
${TF_BENCHMARK_DIR}/graph_traversal/taskflow.cpp
295296
)
297+
target_include_directories(graph_traversal PRIVATE ${PROJECT_SOURCE_DIR}/3rd-party/CLI11)
296298
target_link_libraries(
297299
graph_traversal
298300
${PROJECT_NAME} Threads::Threads ${TBB_IMPORTED_TARGETS} ${OpenMP_CXX_LIBRARIES}
@@ -336,6 +338,7 @@ add_executable(
336338
${TF_BENCHMARK_DIR}/framework/seq.cpp
337339
${TF_BENCHMARK_DIR}/framework/taskflow.cpp
338340
)
341+
target_include_directories(framework_benchmarking PRIVATE ${PROJECT_SOURCE_DIR}/3rd-party/CLI11)
339342
target_link_libraries(
340343
framework_benchmarking
341344
${PROJECT_NAME} Threads::Threads ${TBB_IMPORTED_TARGETS} ${OpenMP_CXX_LIBRARIES}

benchmark/framework/levelgraph.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ class LevelGraph {
9595

9696
std::mt19937 g(0); // fixed the seed for graph generator
9797

98-
std::srand(std::time(nullptr));
98+
//std::srand(std::time(nullptr));
99+
std::srand(1);
99100

100101
for(size_t l=0; l<level; ++l){
101102

benchmark/framework/main.cpp

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,73 @@
11
#include "levelgraph.hpp"
2+
#include <CLI11.hpp>
23

34
int main(int argc, char* argv[]) {
45

5-
unsigned num_threads = std::thread::hardware_concurrency();
6+
CLI::App app{"Wavefront"};
7+
8+
unsigned num_threads {1};
9+
app.add_option("-t,--num_threads", num_threads, "number of threads (default=1)");
10+
11+
unsigned num_rounds {1};
12+
app.add_option("-r,--num_rounds", num_rounds, "number of rounds (default=1)");
13+
14+
std::string model = "tf";
15+
app.add_option("-m,--model", model, "model name tbb|omp|tf (default=tf)")
16+
->check([] (const std::string& m) {
17+
if(m != "tbb" && m != "omp" && m != "tf") {
18+
return "model name should be \"tbb\", \"omp\", or \"tf\"";
19+
}
20+
return "";
21+
});
22+
23+
CLI11_PARSE(app, argc, argv);
24+
25+
std::cout << "model=" << model << ' '
26+
<< "num_threads=" << num_threads << ' '
27+
<< "num_rounds=" << num_rounds << ' '
28+
<< std::endl;
629

7-
if(argc > 1) {
8-
num_threads = std::atoi(argv[1]);
9-
}
1030

1131
const int width {12};
12-
const int rounds {5};
1332
const int repeat [] = {1, 5, 10, 100};
1433

1534
std::cout << std::setw(width) << "|V|+|E|"
16-
<< std::setw(width) << "Repeat"
17-
<< std::setw(width) << "OMP"
18-
<< std::setw(width) << "TBB"
19-
<< std::setw(width) << "TF"
20-
<< std::setw(width) << "speedup1"
21-
<< std::setw(width) << "speedup2"
35+
<< std::setw(width) << repeat[0]
36+
<< std::setw(width) << repeat[1]
37+
<< std::setw(width) << repeat[2]
38+
<< std::setw(width) << repeat[3]
2239
<< '\n';
23-
std::cout << std::string(100, '=') << std::endl;
2440

2541
std::cout.precision(3);
2642

27-
const std::string line (100, '-');
28-
2943
for(int i=1; i<=451; i += 15) {
30-
3144
for(int k=0; k<4; k++) {
32-
double omp_time {0.0};
33-
double tbb_time {0.0};
34-
double tf_time {0.0};
45+
double runtime {0.0};
3546

3647
LevelGraph graph(i, i);
3748

3849
if(k == 0) {
3950
std::cout << std::setw(width) << graph.graph_size();
4051
}
41-
else {
42-
std::cout << std::setw(width) << " ";
43-
}
4452

45-
for(int j=0; j<rounds; ++j) {
46-
omp_time += measure_time_omp(graph, num_threads, repeat[k]).count();
47-
48-
tbb_time += measure_time_tbb(graph, num_threads, repeat[k]).count();
49-
50-
tf_time += measure_time_taskflow(graph, num_threads, repeat[k]).count();
53+
for(unsigned j=0; j<num_rounds; ++j) {
54+
if(model == "tf") {
55+
runtime += measure_time_taskflow(graph, num_threads, repeat[k]).count();
56+
}
57+
else if(model == "tbb") {
58+
runtime += measure_time_tbb(graph, num_threads, repeat[k]).count();
59+
}
60+
else if(model == "omp") {
61+
runtime += measure_time_omp(graph, num_threads, repeat[k]).count();
62+
}
63+
else assert(false);
5164
}
5265

53-
std::cout << std::setw(width) << repeat[k] << std::fixed
54-
<< std::setw(width) << omp_time / rounds / 1e3 << std::fixed
55-
<< std::setw(width) << tbb_time / rounds / 1e3 << std::fixed
56-
<< std::setw(width) << tf_time / rounds / 1e3 << std::fixed
57-
<< std::setw(width) << omp_time / tf_time << std::fixed
58-
<< std::setw(width) << tbb_time / tf_time << std::fixed
59-
<< std::endl;
66+
std::cout << std::setw(width) << runtime / num_rounds / 1e3 << std::fixed;
6067
}
61-
std::cout << line << std::endl;
68+
std::cout << std::endl;
6269
}
70+
6371
}
6472

6573

benchmark/graph_traversal/levelgraph.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ class LevelGraph {
9595

9696
std::mt19937 g(0); // fixed the seed for graph generator
9797

98-
std::srand(std::time(nullptr));
98+
//std::srand(std::time(nullptr));
99+
std::srand(1);
99100

100101
for(size_t l=0; l<level; ++l){
101102

benchmark/graph_traversal/main.cpp

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,58 @@
11
#include "levelgraph.hpp"
2+
#include <CLI11.hpp>
23

34
int main(int argc, char* argv[]) {
45

5-
unsigned num_threads = std::thread::hardware_concurrency();
6+
CLI::App app{"Graph Traversal"};
67

7-
if(argc > 1) {
8-
num_threads = std::atoi(argv[1]);
9-
}
8+
unsigned num_threads {1};
9+
app.add_option("-t,--num_threads", num_threads, "number of threads (default=1)");
10+
11+
unsigned num_rounds {1};
12+
app.add_option("-r,--num_rounds", num_rounds, "number of rounds (default=1)");
13+
14+
std::string model = "tf";
15+
app.add_option("-m,--model", model, "model name tbb|omp|tf (default=tf)")
16+
->check([] (const std::string& m) {
17+
if(m != "tbb" && m != "omp" && m != "tf") {
18+
return "model name should be \"tbb\", \"omp\", or \"tf\"";
19+
}
20+
return "";
21+
});
22+
23+
CLI11_PARSE(app, argc, argv);
24+
25+
std::cout << "model=" << model << ' '
26+
<< "num_threads=" << num_threads << ' '
27+
<< "num_rounds=" << num_rounds << ' '
28+
<< std::endl;
1029

11-
int rounds {5};
12-
1330
std::cout << std::setw(12) << "|V|+|E|"
14-
<< std::setw(12) << "OpenMP"
15-
<< std::setw(12) << "TBB"
16-
<< std::setw(12) << "Taskflow"
17-
<< std::setw(12) << "speedup1"
18-
<< std::setw(12) << "speedup2"
19-
<< '\n';
31+
<< std::setw(12) << "Runtime"
32+
<< '\n';
2033

2134
for(int i=1; i<=451; i += 15) {
2235

23-
double omp_time {0.0};
24-
double tbb_time {0.0};
25-
double tf_time {0.0};
36+
double runtime {0.0};
2637

2738
LevelGraph graph(i, i);
2839

29-
for(int j=0; j<rounds; ++j) {
30-
omp_time += measure_time_omp(graph, num_threads).count();
31-
graph.clear_graph();
32-
33-
tbb_time += measure_time_tbb(graph, num_threads).count();
34-
graph.clear_graph();
35-
36-
tf_time += measure_time_taskflow(graph, num_threads).count();
40+
for(unsigned j=0; j<num_rounds; ++j) {
41+
if(model == "tf") {
42+
runtime += measure_time_taskflow(graph, num_threads).count();
43+
}
44+
else if(model == "tbb") {
45+
runtime += measure_time_tbb(graph, num_threads).count();
46+
}
47+
else if(model == "omp") {
48+
runtime += measure_time_omp(graph, num_threads).count();
49+
}
3750
graph.clear_graph();
3851
}
3952

4053
std::cout << std::setw(12) << graph.graph_size()
41-
<< std::setw(12) << omp_time / rounds / 1e3
42-
<< std::setw(12) << tbb_time / rounds / 1e3
43-
<< std::setw(12) << tf_time / rounds / 1e3
44-
<< std::setw(12) << omp_time / tf_time
45-
<< std::setw(12) << tbb_time / tf_time
54+
<< std::setw(12) << runtime / num_rounds / 1e3
4655
<< std::endl;
56+
4757
}
4858
}
49-
50-

benchmark/parallel_dnn/dnn.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,6 @@ struct MNIST_DNN {
284284
size_t batch_size {1};
285285
};
286286

287-
288-
289-
290-
291-
292287
inline Eigen::MatrixXf IMAGES;
293288
inline Eigen::VectorXi LABELS;
294289
inline Eigen::MatrixXf TEST_IMAGES;

0 commit comments

Comments
 (0)