Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 607ae79

Browse files
author
“phrygiangates”
committed
add data_pipeline benchmarks
1 parent a109b74 commit 607ae79

File tree

10 files changed

+1426
-19
lines changed

10 files changed

+1426
-19
lines changed

.vscode/c_cpp_properties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
"name": "Linux",
55
"includePath": [
6+
"/home/xiongzc/taskflow/3rd-party/tbb/include",
67
"${workspaceFolder}/**"
78
],
89
"defines": [],

3rd-party/tbb/cmake/TBBConfig.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ get_filename_component(_tbb_root "${_tbb_root}" PATH)
4848
foreach (_tbb_component ${TBB_FIND_COMPONENTS})
4949
set(TBB_${_tbb_component}_FOUND 0)
5050

51-
set(_tbb_release_lib "/home/twhuang/Code/taskflow/build/benchmarks/tbb_cmake_build/tbb_cmake_build_subdir_release/lib${_tbb_component}.so.2")
51+
set(_tbb_release_lib "/home/xiongzc/taskflow/build/benchmarks/tbb_cmake_build/tbb_cmake_build_subdir_release/lib${_tbb_component}.so.2")
5252

5353
if (NOT TBB_FIND_RELEASE_ONLY)
54-
set(_tbb_debug_lib "/home/twhuang/Code/taskflow/build/benchmarks/tbb_cmake_build/tbb_cmake_build_subdir_debug/lib${_tbb_component}_debug.so.2")
54+
set(_tbb_debug_lib "/home/xiongzc/taskflow/build/benchmarks/tbb_cmake_build/tbb_cmake_build_subdir_debug/lib${_tbb_component}_debug.so.2")
5555
endif()
5656

5757
if (EXISTS "${_tbb_release_lib}" OR EXISTS "${_tbb_debug_lib}")

benchmarks/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,23 @@ target_link_libraries(
279279
)
280280
set_target_properties(thread_pool PROPERTIES COMPILE_FLAGS ${OpenMP_CXX_FLAGS})
281281

282+
## benchmark 14: data_pipeline
283+
add_executable(
284+
data_pipeline
285+
${TF_BENCHMARK_DIR}/data_pipeline/main.cpp
286+
${TF_BENCHMARK_DIR}/data_pipeline/tbb.cpp
287+
${TF_BENCHMARK_DIR}/data_pipeline/taskflow.cpp
288+
)
289+
target_include_directories(data_pipeline PRIVATE ${PROJECT_SOURCE_DIR}/3rd-party/CLI11)
290+
target_link_libraries(
291+
data_pipeline
292+
${PROJECT_NAME}
293+
${TBB_IMPORTED_TARGETS}
294+
${OpenMP_CXX_LIBRARIES}
295+
tf::default_settings
296+
)
297+
set_target_properties(data_pipeline PROPERTIES COMPILE_FLAGS ${OpenMP_CXX_FLAGS})
298+
282299
###############################################################################
283300
# CUDA benchmarks
284301
###############################################################################
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <chrono>
2+
#include <string>
3+
#include <cassert>
4+
#include <thread>
5+
6+
inline void work() {
7+
std::this_thread::sleep_for(std::chrono::microseconds(10));
8+
}
9+
10+
std::chrono::microseconds measure_time_taskflow(std::string, unsigned, unsigned, size_t);
11+
std::chrono::microseconds measure_time_tbb(std::string, unsigned, unsigned, size_t);
12+

benchmarks/data_pipeline/main.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#include "data_pipeline.hpp"
2+
#include <CLI11.hpp>
3+
4+
int main(int argc, char* argv[]) {
5+
6+
CLI::App app{"Parallel DataPipeline"};
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|tf (default=tf)")
16+
->check([] (const std::string& m) {
17+
if(m != "tbb" && m != "tf") {
18+
return "model name should be \"tbb\" or \"tf\"";
19+
}
20+
return "";
21+
});
22+
23+
unsigned num_lines {8};
24+
app.add_option("-l,--num_lines", num_lines, "num of lines (default=8)");
25+
26+
std::string pipes = "ssssssss";
27+
app.add_option("-p,--pipes", pipes, "the chain of pipes (default=ssssssss)")
28+
->check([pipes] (const std::string& p) {
29+
if (p[0] == 'p') {
30+
return "the first pipe should be \"s\" (serial)";
31+
}
32+
else if (p.size() > 16) {
33+
return "no more than 16 pipes";
34+
}
35+
else if (p.size() == 0) {
36+
return "at least one pipe is required";
37+
}
38+
return "";
39+
});
40+
41+
CLI11_PARSE(app, argc, argv);
42+
43+
std::cout << "model=" << model << ' '
44+
<< "num_threads=" << num_threads << ' '
45+
<< "num_rounds=" << num_rounds << ' '
46+
<< "num_lines=" << num_lines << ' '
47+
<< "pipes=" << pipes << ' '
48+
<< std::endl;
49+
50+
std::cout << std::setw(12) << "size"
51+
<< std::setw(12) << "Runtime"
52+
<< '\n';
53+
54+
size_t log_length = 23;
55+
56+
for(size_t i = 1; i <= log_length; ++i) {
57+
58+
size_t L = 1 << i;
59+
60+
double runtime {0.0};
61+
62+
for(unsigned j = 0; j < num_rounds; ++j) {
63+
if(model == "tf") {
64+
runtime += measure_time_taskflow(pipes, num_lines, num_threads, L).count();
65+
}
66+
else if(model == "tbb") {
67+
runtime += measure_time_tbb(pipes, num_lines, num_threads, L).count();
68+
}
69+
}
70+
71+
std::cout << std::setw(12) << L
72+
<< std::setw(12) << runtime / num_rounds / 1e3
73+
<< std::endl;
74+
75+
/*if (model == "tf") {
76+
std::ofstream outputfile;
77+
outputfile.open("./tf_time.csv", std::ofstream::app);
78+
outputfile << num_threads << ','
79+
<< num_lines << ','
80+
<< pipes << ','
81+
<< L << ','
82+
<< runtime / num_rounds / 1e3 << '\n';
83+
84+
outputfile.close();
85+
}
86+
else if (model == "tbb") {
87+
std::ofstream outputfile;
88+
outputfile.open("./tbb_time.csv", std::ofstream::app);
89+
outputfile << num_threads << ','
90+
<< num_lines << ','
91+
<< pipes << ','
92+
<< L << ','
93+
<< runtime / num_rounds / 1e3 << '\n';
94+
95+
outputfile.close();
96+
}*/
97+
}
98+
}

0 commit comments

Comments
 (0)