Search⌘ K
AI Features

Benchmark II

Explore the performance differences between parallel and serial execution of sum calculations on vectors using C++17 STL algorithms. Learn how hardware and compiler optimizations influence benchmarks and understand when to use parallel versus sequential policies for efficient multithreading.

Sum of All Elements in a Vector

Below there’s a benchmark of computing the sum of all elements in a vector:

When comparing the parallel and serial execution time for the reduce function using Benchmark II, the results sometimes indicate that parallel execution takes more time than serial execution. The examples in this course use a machine with single hardware Hyper-thread with 3.75 GB of memory. You can disregard this unexpected result; on a traditional CPU, that usually has ...