Skip to content

Commit 747f48a

Browse files
updated README
1 parent 89e6e0c commit 747f48a

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ Alternatively, you can use CMake's testing framework to run the unittest.
233233
## Examples
234234
The folder `example/` contains several examples and is a great place to learn to use Cpp-Taskflow.
235235

236+
| Example | What you will learn |
237+
| ------- | ----------- |
238+
| [simple.cpp](./example/simple.cpp) | create a trivial taskflow graph |
239+
| [matrix.cpp](./example/matrix.cpp) | create two set of matrices and multiply each in parallel |
240+
| [parallel_for.cpp](./example/parallel_for.cpp)| parallelize a for loop with unbalanced workload |
241+
236242
# Get Involved
237243
+ Report bugs/issues by submitting a [Github issue][Github issues].
238244
+ Submit contributions using [pull requests][Github pull requests].

example/matrix.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,21 @@ void openmp(const std::vector<size_t>& D) {
117117

118118
std::cout << "Generating matrix As ...\n";
119119
std::vector<matrix_t> As(D.size());
120-
#pragma omp parallel for num_threads(4)
120+
#pragma omp parallel for
121121
for(size_t j=0; j<D.size(); ++j) {
122122
As[j] = random_matrix(D[j]);
123123
}
124124

125125
std::cout << "Generating matrix Bs ...\n";
126126
std::vector<matrix_t> Bs(D.size());
127-
#pragma omp parallel for num_threads(4)
127+
#pragma omp parallel for
128128
for(size_t j=0; j<D.size(); ++j) {
129129
Bs[j] = random_matrix(D[j]);
130130
}
131131

132132
std::cout << "Computing matrix product values Cs ...\n";
133133
std::vector<matrix_t> Cs(D.size());
134-
#pragma omp parallel for num_threads(4)
134+
#pragma omp parallel for
135135
for(size_t j=0; j<D.size(); ++j) {
136136
Cs[j] = As[j] * Bs[j];
137137
}
@@ -150,7 +150,7 @@ void cppthread(const std::vector<size_t>& D) {
150150

151151
auto tbeg = std::chrono::steady_clock::now();
152152

153-
tf::Threadpool tpl(4);
153+
tf::Threadpool tpl(std::thread::hardware_concurrency());
154154

155155
std::cout << "Generating matrix As ...\n";
156156
std::vector<matrix_t> As(D.size());
@@ -197,7 +197,7 @@ void taskflow(const std::vector<size_t>& D) {
197197

198198
using builder_t = typename tf::Taskflow::Task;
199199

200-
tf::Taskflow tf(4);
200+
tf::Taskflow tf;
201201

202202
std::cout << "Generating task As ...\n";
203203
std::vector<matrix_t> As(D.size());

0 commit comments

Comments
 (0)