Algorithms for Modern HardwareSergey Slotin
Algorithms for Modern Hardware
by Sergey Slotin · first published 2022
22mentions
15recommended by
17HN commenters
2022–2026first – last mentioned
88% recommend12% neutral
Algorithmica's book on performance engineering and high-performance computing (free online).
Affiliate links. As an Amazon Associate I earn from qualifying purchases.



:) How about Chapter 12 of Agner's awesome manual (https://agner.org/optimize/optimizing_cpp.pdf), http://const.me/articles/simd/simd.pdf, https://en.algorithmica.org/hpc/simd/ ? Does anyone have others to share?
on “Vectorized and performance-portable Quicksort” ↗There's a great explanation on algorithmica as well: https://en.algorithmica.org/hpc/complexity/languages/
on “Dive into deep learning compilers” ↗Thank you, that is a nice positive and in-depth review. It is good to discuss technical details of 'Algorithms for Modern Hardware' but it also helps to show how real-world projects struggle or succeed in applying various optimizations: Amdahl's law will move you focus from one serial bottleneck to the other (in large programs).…
on “Algorithms for Modern Hardware” ↗Sounds good. This might be an interesting read in preparation for those: https://en.algorithmica.org/hpc/algorithms/argmin/
on “Ask HN: Does someone know a good SIMD programming tutorial?” ↗See also "Algorithms for Modern Hardware" by Sergey Slotin https://en.algorithmica.org/hpc/ > Its intended audience is everyone from performance engineers and practical algorithm researchers to undergraduate computer science students who have just finished an advanced algorithms course and want to learn more practical ways to speed up a program ...
on “Algorithms for competitive programming” ↗The web site containing the article has a collection of other articles about this sort of thing. You can also read about this in some parts of Algorithms for Modern Hardware[0]. highload.fun includes some other links about this stuff[1]. In general there isn't a great guide and it's best to get your hands dirty. highload.fun happens to be a good place to do that :) [0]: https://en.algorithmica.or
on “SWAR find any byte from set” ↗Thank you for your incredible work! I have been reading Algorithms for Modern Hardware as part of my after-work study and I have found it invaluable—I reference it daily. I can’t wait for Part II :)
on “Eytzinger Binary Search – Algorithmica” ↗Read https://en.algorithmica.org/hpc/pipelining/branching/ and the following chapter. TL;DR: you can generate different, and more efficient code if you know how much it is going to be mispredicted.
on “Fastest Branchless Binary Search” ↗https://en.algorithmica.org/hpc/ and http://0x80.pl/ have some stuff about this, but the latter can be dense. I've had fun getting my hands dirty with some problems at https://highload.fun/ but there's not much direction unless you go to the telegram chat and ask people questions.
on “SIMD Everywhere Optimization from ARM Neon to RISC-V Vector Extensions” ↗It seems like for the 1d case you should be able to compute the double-prefix sum (the prefix sum of the prefix sum of the input row) and then add 2 elements of that array and subtract 2 other elements to get the output pixel. Here are notes about how to compute the prefix sum, which can be adapted to compute the double-prefix sum: https://en.algorithmica.org/hpc/algorithms/prefix/ Since you acc
on “Implementing Mario's Stack Blur 15 times in C++ (with tests and benchmarks)” ↗Hello, recently I've enjoyed Casey Muratori's Performance-Aware Programming course[0]. You could read Algorithms for Modern Hardware[1] to learn similar set of stuff though. Casey's course is aimed at bringing beginners all the way to a nearly-industry-leading understanding of performance issues while the book assumes a bit more knowledge, but I think a lot of people have trouble getting into this
on “Ask HN: Programming Courses for Experienced Coders?” ↗https://en.algorithmica.org/hpc/ This is a good book. It covers most common concepts and techniques in a fairly accessible way. At they end it also shows builds up a highly optimized version of some algorithms and data structures and does explains every optimization.
on “Ask HN: How can I learn about performance optimization?” ↗I admire Daniel Lemire’s work on SIMD implementations. [Lemire] [Lemire] https://lemire.me/en/#publications I learn a lot by reading my compiler’s and profiler’s documentation. For Rust, the Rust Performance Book by Nicholas Nethercote et al. [Nethercote] seems like a nice place to start after reading the Cargo and rustc books. [Nethercote] https://nnethercote.github.io/perf-book/ Algorithms
on “Ask HN: How can I learn about performance optimization?” ↗I'd be curious to see how performance would change from storing b-tree entries in a semi-sorted array, and applying various other optimizations from here: https://en.algorithmica.org/hpc/data-structures/b-tree/ The aggregate performance improvements Sergey Slotin gets from applying various "tricks" is insane.
on “Fast B-Trees” ↗I agree that it may not be the most readable format. So far, the best-structured piece on similar topics I’ve seen is Algorithmica: <https://en.algorithmica.org/hpc>. I am sure it overlaps in terms of topics, maybe even some examples, but the homepage suggests that the book is about 500 pages long. I generally don’t have a time budget to read that much, and in most cases, I want to play with the
on “Less Slow C++” ↗