Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add taskflow simple for benchmark #38

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions benchmarks/simple_for_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "tbb/task_scheduler_init.h"
#endif // !BENCHMARK_WITHOUT_TBB

#include <taskflow/taskflow.hpp>

#include "thread_benchmark_common.h"

static uint32_t kSeed(8);
Expand Down Expand Up @@ -91,6 +93,25 @@ void BM_dispenso(benchmark::State& state) {
checkResults(input, output);
}

void BM_taskflow(benchmark::State& state) {
const int num_threads = state.range(0);
const int num_elements = state.range(1);

std::vector<int> output(num_elements, 0);
auto& input = getInputs(num_elements);

tf::Executor executor(num_threads);
tf::Taskflow taskflow;

for (auto UNUSED_VAR : state) {
taskflow.for_each_index(0, num_elements, 1, [&input, &output](int i) {
output[i] = input[i] * input[i] - 3 * input[i];
});
executor.run(taskflow).wait();
}
checkResults(input, output);
}

void BM_dispenso_static_chunk(benchmark::State& state) {
const int num_threads = state.range(0) - 1;
const int num_elements = state.range(1);
Expand Down Expand Up @@ -205,6 +226,7 @@ BENCHMARK(BM_omp)->Apply(CustomArguments)->UseRealTime();
BENCHMARK(BM_tbb)->Apply(CustomArguments)->UseRealTime();
#endif // !BENCHMARK_WITHOUT_TBB

BENCHMARK(BM_taskflow)->Apply(CustomArguments)->UseRealTime();
BENCHMARK(BM_dispenso)->Apply(CustomArguments)->UseRealTime();
BENCHMARK(BM_dispenso_static_chunk)->Apply(CustomArguments)->UseRealTime();
BENCHMARK(BM_dispenso_auto_chunk)->Apply(CustomArguments)->UseRealTime();
Expand Down
Loading