<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-console"><spanclass="gp"># </span>under<spanclass="w"></span>/taskflow/build
<spanclass="go">~$ make</span></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-console"><spanclass="go">~$ cd benchmarks & ls</span>
<spanclass="go"> 711200 83.957</span></pre><p>You can display the help message by giving the option <code>--help</code>.</p><preclass="m-console"><spanclass="go">~$ ./bench_graph_traversal --help</span>
<spanclass="go"> -h,--help Print this help message and exit</span>
<spanclass="go"> -t,--num_threads UINT number of threads (default=1)</span>
<spanclass="go"> -r,--num_rounds UINT number of rounds (default=1)</span>
<spanclass="go"> -m,--model TEXT model name tbb|omp|tf (default=tf)</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>pipeline scheduling on a linear chain of pipes</td></tr><tr><td>bench_graph_pipeline</td><td>pipeline scheduling on a graph of pipes</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>display the help message</td></tr><tr><td><code>-t</code></td><td>integer</td><td>configure the number of threads to run</td></tr><tr><td><code>-r</code></td><td>integer</td><td>configure the number of rounds to run</td></tr><tr><td><code>-m</code></td><td>string</td><td>configure 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-console"><spanclass="go">~$ ./bench_graph_traversal -m tf # run the Taskflow implementation (default)</span>
<spanclass="go">~$ ./bench_graph_traversal -m tbb # run the TBB implementation</span>
<spanclass="go">~$ ./bench_graph_traversal -m omp # 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-console"><spanclass="gp"># </span>run<spanclass="w"></span>the<spanclass="w"></span>Taskflow<spanclass="w"></span>implementation<spanclass="w"></span>using<spanclass="w"></span><spanclass="m">4</span><spanclass="w"></span>threads
<spanclass="go">~$ ./bench_graph_traversal -m tf -t 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-console"><spanclass="gp"># </span>affine<spanclass="w"></span>the<spanclass="w"></span>process<spanclass="w"></span>to<spanclass="w"></span><spanclass="m">4</span><spanclass="w"></span>CPUs,<spanclass="w"></span>CPU<spanclass="w"></span><spanclass="m">0</span>,<spanclass="w"></span>CPU<spanclass="w"></span><spanclass="m">1</span>,<spanclass="w"></span>CPU<spanclass="w"></span><spanclass="m">2</span>,<spanclass="w"></span>and<spanclass="w"></span>CPU<spanclass="w"></span><spanclass="m">3</span>
<spanclass="go">~$ taskset -c 0-3 bench_graph_traversal -t 4 </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-console"><spanclass="gp"># </span>measure<spanclass="w"></span>the<spanclass="w"></span>runtime<spanclass="w"></span><spanclass="k">in</span><spanclass="w"></span>an<spanclass="w"></span>average<spanclass="w"></span>of<spanclass="w"></span><spanclass="m">10</span><spanclass="w"></span>runs