Page 1 of 1
Optimization manuals
Posted: 2019-12-30, 8:02:50
by agner
I have written a series of five manuals describing everything you need to know about optimizing code for x86 and x86-64 family microprocessors, including optimization advice for C++ and assembly language, details about the microarchitecture and instruction timings of Intel, AMD and VIA processors, and details about different compilers and calling conventions.
- Optimizing software in C++: An optimization guide for Windows, Linux and Mac platforms
- Optimizing subroutines in assembly language: An optimization guide for x86 platforms
- The microarchitecture of Intel, AMD and VIA CPUs: An optimization guide for assembly programmers and compiler makers
- Instruction tables: Lists of instruction latencies, throughputs and micro-operation breakdowns for Intel, AMD and VIA CPUs
- Calling conventions for different C++ compilers and operating systems
These five manuals are continuously maintained and updated whenever I have new information to provide. You can always find the latest version at
https://www.agner.org/optimize/#manuals
Re: Optimization manuals
Posted: 2020-02-06, 6:22:03
by KonradK
Could you provide EPUB, MOBI, or AZW3 versions of the manuals?
Re: Optimization manuals
Posted: 2020-02-10, 7:37:13
by agner
Sorry, no. It is too much work to maintain multiple versions of the manuals. I think that almost all E-book readers support the pdf format.
Re: Optimization manuals
Posted: 2020-05-14, 6:32:30
by dyaitskov
Hi Agner,
I was reading your book, Optimization C++, many years ago.
Today I wanted to find arithmetic hacks and I wasn't able to do that.
I checked random older versions on internet archive.
I remember hacks such as:
- An int value is treated as a vector of bytes (simulation SIMD in plain C)
- Add number if it is bigger than other number without if.
Please, cloud you hint a version of the book having such stuff?
Re: Optimization manuals
Posted: 2020-05-14, 7:57:56
by dyaitskov
Sorry,
I found what I was looking for
https://graphics.stanford.edu/~seander/bithacks.html
Over the years these papers got mixed in my head.
Re: Optimization manuals
Posted: 2020-05-14, 8:55:55
by agner
Doing vector operations in general purpose registers is explained in my assembly manual chapter 13.9.
The book: Hacker's Delight by Henry S. Warren (2003) also has a lot of useful tricks.
Re: Optimization manuals
Posted: 2020-05-22, 14:56:58
by b_jonas
In the 5. Calling conventions volume, chapter 7, could you perhaps make it more clear how C++ empty objects are passed as a function argument? I know there's a "has now data" row in the table, but even with that it's not clear. I did some experiments. It seems that on x86_64 Linux, the empty object is just ignored, it doesn't take space on either the stack or registers. In x86_64 Windows, it seems one of the argument registers is reserved for the empty object (though I haven't checked whether the register is zeroed or what happens for arguments after the four registers are exhausted).
Re: Optimization manuals
Posted: 2020-05-24, 16:25:12
by polar
Maybe you already know, maybe not ... in manual no. 3 "The microarchitecture of Intel, AMD and VIA CPUsAn optimization guide for assembly programmers and compiler makers" Last updated 2020-03-08 there are two times chapters 3.1 - 3.6
Re: Optimization manuals
Posted: 2020-08-05, 19:35:57
by logus
Is there a correct place for suggestions/comments on the optimization manuals?
Found a small typo on optimizing_assembly.pdf page 113:
"AVX512IFMA. Fused multiply-and-add on 52-bit integers."
That was meant to be 32-bit integers, I suppose.
Re: Optimization manuals
Posted: 2020-08-06, 16:27:13
by agner
AVX512IFMA is indeed multiplying 52 bit integers.