Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
C++ High Performance

You're reading from  C++ High Performance

Product type Book
Published in Jan 2018
Publisher Packt
ISBN-13 9781787120952
Pages 374 pages
Edition 1st Edition
Languages
Authors (2):
Björn Andrist Björn Andrist
Profile icon Björn Andrist
Viktor Sehr Viktor Sehr
Profile icon Viktor Sehr
View More author details

Table of Contents (13) Chapters

Preface A Brief Introduction to C++ Modern C++ Concepts Measuring Performance Data Structures A Deeper Look at Iterators STL Algorithms and Beyond Memory Management Metaprogramming and Compile-Time Evaluation Proxy Objects and Lazy Evaluation Concurrency Parallel STL Other Books You May Enjoy

Parallel algorithms

As mentioned in Chapter 10, Concurrency, with parallelism we refer to programming that takes advantage of hardware with multiple cores. It makes no sense to parallelize algorithms if the hardware does not provide any of the benefits of it.

Therefore, a parallel algorithm equivalent of a sequential algorithm is algorithmically slower than the sequential. Its benefits come from the ability to spread the algorithms onto several processing units.

With that in mind, it's also notable that not all algorithms gain the same performance increase when run in parallel. As a simple measurement of how well an algorithm scales, we can measure:

  • A: The time it takes to execute sequentially at one CPU core
  • B: The time it takes to execute in parallel, multiplied by the number of cores

If A and B are equal, the algorithm parallelizes perfectly, and the larger B is compared...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}