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

Skip to content

Commit b4fab70

Browse files
author
twhuang
committed
Merge branch 'dev'
2 parents 1707c56 + 18f4e69 commit b4fab70

Some content is hidden

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

51 files changed

+11260
-159
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

.vscode/c_cpp_properties.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"/home/xiongzc/taskflow/3rd-party/tbb/include",
7+
"${workspaceFolder}/**"
8+
],
9+
"defines": [],
10+
"compilerPath": "/usr/local/bin/gcc",
11+
"cStandard": "gnu11",
12+
"cppStandard": "gnu++17",
13+
"intelliSenseMode": "linux-gcc-x64"
14+
}
15+
],
16+
"version": 4
17+
}

.vscode/settings.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"cmake.configureOnOpen": false,
3+
"files.associations": {
4+
"array": "cpp",
5+
"cmath": "cpp",
6+
"cstdarg": "cpp",
7+
"cstddef": "cpp",
8+
"cstdio": "cpp",
9+
"cstdlib": "cpp",
10+
"cstring": "cpp",
11+
"ctime": "cpp",
12+
"cwchar": "cpp",
13+
"atomic": "cpp",
14+
"*.tcc": "cpp",
15+
"bitset": "cpp",
16+
"cstdint": "cpp",
17+
"deque": "cpp",
18+
"unordered_map": "cpp",
19+
"vector": "cpp",
20+
"exception": "cpp",
21+
"fstream": "cpp",
22+
"functional": "cpp",
23+
"initializer_list": "cpp",
24+
"iomanip": "cpp",
25+
"iosfwd": "cpp",
26+
"iostream": "cpp",
27+
"istream": "cpp",
28+
"limits": "cpp",
29+
"new": "cpp",
30+
"ostream": "cpp",
31+
"numeric": "cpp",
32+
"sstream": "cpp",
33+
"stdexcept": "cpp",
34+
"streambuf": "cpp",
35+
"tuple": "cpp",
36+
"type_traits": "cpp",
37+
"utility": "cpp",
38+
"typeinfo": "cpp",
39+
"optional": "cpp",
40+
"string_view": "cpp",
41+
"algorithm": "cpp",
42+
"filesystem": "cpp",
43+
"memory": "cpp",
44+
"iterator": "cpp",
45+
"map": "cpp",
46+
"memory_resource": "cpp",
47+
"random": "cpp",
48+
"set": "cpp",
49+
"string": "cpp",
50+
"chrono": "cpp",
51+
"condition_variable": "cpp",
52+
"forward_list": "cpp",
53+
"list": "cpp",
54+
"unordered_set": "cpp",
55+
"future": "cpp",
56+
"mutex": "cpp",
57+
"ratio": "cpp",
58+
"system_error": "cpp",
59+
"thread": "cpp",
60+
"variant": "cpp",
61+
"any": "cpp",
62+
"cctype": "cpp",
63+
"clocale": "cpp",
64+
"cwctype": "cpp",
65+
"hash_map": "cpp",
66+
"complex": "cpp"
67+
}
68+
}

benchmarks/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,40 @@ 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+
299+
## benchmark 15: data_pipeline_dev (temporary)
300+
add_executable(
301+
data_pipeline_dev
302+
${TF_BENCHMARK_DIR}/data_pipeline_dev/main.cpp
303+
${TF_BENCHMARK_DIR}/data_pipeline_dev/normal.cpp
304+
${TF_BENCHMARK_DIR}/data_pipeline_dev/efficient.cpp
305+
)
306+
target_include_directories(data_pipeline_dev PRIVATE ${PROJECT_SOURCE_DIR}/3rd-party/CLI11)
307+
target_link_libraries(
308+
data_pipeline_dev
309+
${PROJECT_NAME}
310+
${TBB_IMPORTED_TARGETS}
311+
${OpenMP_CXX_LIBRARIES}
312+
tf::default_settings
313+
)
314+
set_target_properties(data_pipeline_dev PROPERTIES COMPILE_FLAGS ${OpenMP_CXX_FLAGS})
315+
282316
###############################################################################
283317
# CUDA benchmarks
284318
###############################################################################
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)