Implementing parallel std::transform()

Although algorithmically std::transform() is easy to implement, in practice implementing even a rudimentary parallel version is more complex than it might appear at first sight.

A naive parallel implementation of std::transform() would probably look something like this:

  • Divide the elements into chunks corresponding to the number of cores in the computer
  • Execute each chunk in a separate task in parallel
  • Wait for all tasks to finish

Get C++ High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.