<spanclass="m-breadcrumb"><ahref="install.html">Building and Installing</a> »</span>
Benchmark Taskflow
</h1>
<navclass="m-block m-default">
<h3>Contents</h3>
<ul>
<li><ahref="#CompileAndRunBenchmarks">Compile and Run Benchmarks</a></li>
<li>
<ahref="#ConfigureRunOptions">Configure Run Options</a>
<ul>
<li><ahref="#SpecifyTheRunModel">Specify the Run Model</a></li>
<li><ahref="#SpecifyTheNumberOfThreads">Specify the Number of Threads</a></li>
<li><ahref="#SpecifyTheNumberOfRounds">Specify the Number of Rounds</a></li>
</ul>
</li>
</ul>
</nav>
<sectionid="CompileAndRunBenchmarks"><h2><ahref="#CompileAndRunBenchmarks">Compile and Run Benchmarks</a></h2><p>To build the benchmark code, enable the CMake option <code>TF_BUILD_BENCHMARKS</code> to <code>ON</code> as follows:</p><preclass="m-code"><spanclass="c1"># under /taskflow/build</span>
~$<spanclass="w"></span>make</pre><p>After you successfully build the benchmark code, you can find all benchmark instances in the <code>benchmarks/</code> folder. You can run the executable of each instance in the corresponding folder.</p><preclass="m-code">~$<spanclass="w"></span><spanclass="nb">cd</span><spanclass="w"></span>benchmarks<spanclass="w"></span><spanclass="p">&</span><spanclass="w"></span>ls
<spanclass="w"></span><spanclass="m">711200</span><spanclass="w"></span><spanclass="m">83</span>.957</pre><p>You can display the help message by giving the option <code>--help</code>.</p><preclass="m-code">~$<spanclass="w"></span>./bench_graph_traversal<spanclass="w"></span>--help
<spanclass="w"></span>-m,--model<spanclass="w"></span>TEXT<spanclass="w"></span>model<spanclass="w"></span>name<spanclass="w"></span>tbb<spanclass="p">|</span>omp<spanclass="p">|</span>tf<spanclass="w"></span><spanclass="o">(</span><spanclass="nv">default</span><spanclass="o">=</span>tf<spanclass="o">)</span></pre><p>We currently implement the following instances that are commonly used by the parallel computing community to evaluate the system performance.</p><tableclass="m-table"><thead><tr><th>Instance</th><th>Description</th></tr></thead><tbody><tr><td>bench_binary_tree</td><td>traverses a complete binary tree</td></tr><tr><td>bench_black_scholes</td><td>computes option pricing with Black-Shcoles Models</td></tr><tr><td>bench_graph_traversal</td><td>traverses a randomly generated direct acyclic graph</td></tr><tr><td>bench_linear_chain</td><td>traverses a linear chain of tasks</td></tr><tr><td>bench_mandelbrot</td><td>exploits imbalanced workloads in a Mandelbrot set</td></tr><tr><td>bench_matrix_multiplication</td><td>multiplies two 2D matrices</td></tr><tr><td>bench_mnist</td><td>trains a neural network-based image classifier on the MNIST dataset</td></tr><tr><td>bench_parallel_sort</td><td>sorts a range of items</td></tr><tr><td>bench_reduce_sum</td><td>sums a range of items using reduction</td></tr><tr><td>bench_wavefront</td><td>propagates computations in a 2D grid</td></tr><tr><td>bench_linear_pipeline</td><td>performs pipeline parallelism on a linear chain of pipes</td></tr><tr><td>bench_graph_pipeline</td><td>performs pipeline parallelism on a graph of pipes</td></tr><tr><td>bench_deferred_pipeline</td><td>performs pipeline parallelism with dependencies from future pipes</td></tr><tr><td>bench_data_pipeline</td><td>performs pipeline parallelisms on a cache-friendly data wrapper</td></tr><tr><td>bench_thread_pool</td><td>uses our executor as a simple thread pool</td></tr><tr><td>bench_for_each</td><td>performs parallel-iteration algorithms</td></tr><tr><td>bench_scan</td><td>performs parallel-scan algorithms</td></tr><tr><td>bench_async_task</td><td>creates asynchronous tasks</td></tr><tr><td>bench_fibonacci</td><td>finds Fibonacci numbers using recursive asynchronous tasking</td></tr><tr><td>bench_nqueens</td><td>parallelizes n-queen search using recursive asynchronous tasking</td></tr><tr><td>bench_integrate</td><td>parallelizes integration using recursive asynchronous tasking</td></tr><tr><td>bench_primes</td><td>finds a range of prime numbers using parallel-reduction algorithms</td></tr><tr><td>bench_skynet</td><td>traverses a 10-ray tree using recursive asynchronous tasking</td></tr></tbody></table></section><sectionid="ConfigureRunOptions"><h2><ahref="#ConfigureRunOptions">Configure Run Options</a></h2><p>We implement consistent options for each benchmark instance. Common options are:</p><tableclass="m-table"><thead><tr><th>option</th><th>value</th><th>function</th></tr></thead><tbody><tr><td><code>-h</code></td><td>none</td><td>displays the help message</td></tr><tr><td><code>-t</code></td><td>integer</td><td>configures the number of threads to run</td></tr><tr><td><code>-r</code></td><td>integer</td><td>configures the number of rounds to run</td></tr><tr><td><code>-m</code></td><td>string</td><td>configures the baseline models to run, tbb, omp, or tf</td></tr></tbody></table><p>You can configure the benchmarking environment by giving different options.</p><sectionid="SpecifyTheRunModel"><h3><ahref="#SpecifyTheRunModel">Specify the Run Model</a></h3><p>In addition to a Taskflow-based implementation for each benchmark instance, we have implemented two baseline models using the state-of-the-art parallel programming libraries, <ahref="https://www.openmp.org/">OpenMP</a> and <ahref="https://github.com/oneapi-src/oneTBB">Intel TBB</a>, to measure and evaluate the performance of Taskflow. You can select different implementations by passing the option <code>-m</code>.</p><preclass="m-code">~$<spanclass="w"></span>./bench_graph_traversal<spanclass="w"></span>-m<spanclass="w"></span>tf<spanclass="w"></span><spanclass="c1"># run the Taskflow implementation (default)</span>
~$<spanclass="w"></span>./bench_graph_traversal<spanclass="w"></span>-m<spanclass="w"></span>tbb<spanclass="w"></span><spanclass="c1"># run the TBB implementation</span>
~$<spanclass="w"></span>./bench_graph_traversal<spanclass="w"></span>-m<spanclass="w"></span>omp<spanclass="w"></span><spanclass="c1"># run the OpenMP implementation</span></pre></section><sectionid="SpecifyTheNumberOfThreads"><h3><ahref="#SpecifyTheNumberOfThreads">Specify the Number of Threads</a></h3><p>You can configure the number of threads to run a benchmark instance by passing the option <code>-t</code>. The default value is one.</p><preclass="m-code"><spanclass="c1"># run the Taskflow implementation using 4 threads</span>
~$<spanclass="w"></span>./bench_graph_traversal<spanclass="w"></span>-m<spanclass="w"></span>tf<spanclass="w"></span>-t<spanclass="w"></span><spanclass="m">4</span></pre><p>Depending on your environment, you may need to use <code>taskset</code> to set the CPU affinity of the running process. This allows the OS scheduler to keep process on the same CPU(s) as long as practical for performance reason.</p><preclass="m-code"><spanclass="c1"># affine the process to 4 CPUs, CPU 0, CPU 1, CPU 2, and CPU 3</span>
~$<spanclass="w"></span>taskset<spanclass="w"></span>-c<spanclass="w"></span><spanclass="m">0</span>-3<spanclass="w"></span>bench_graph_traversal<spanclass="w"></span>-t<spanclass="w"></span><spanclass="m">4</span><spanclass="w"></span></pre></section><sectionid="SpecifyTheNumberOfRounds"><h3><ahref="#SpecifyTheNumberOfRounds">Specify the Number of Rounds</a></h3><p>Each benchmark instance evaluates the runtime of the implementation at different problem sizes. Each problem size corresponds to one iteration. You can configure the number of rounds per iteration to average the runtime.</p><preclass="m-code"><spanclass="c1"># measure the %Taskflow runtime by averaging the results over 10 runs</span>
<spanclass="w"></span><spanclass="m">2</span><spanclass="w"></span><spanclass="m">0</span>.109<spanclass="w"></span><spanclass="c1"># the runtime value 0.109 is an average of 10 runs</span>