Optimization manuals

News and research about CPU microarchitecture and software optimization
Post Reply
agner
Site Admin
Posts: 75
Joined: 2019-12-27, 18:56:25
Contact:

Optimization manuals

Post by agner » 2019-12-30, 8:02:50

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.
  1. Optimizing software in C++: An optimization guide for Windows, Linux and Mac platforms
  2. Optimizing subroutines in assembly language: An optimization guide for x86 platforms
  3. The microarchitecture of Intel, AMD and VIA CPUs: An optimization guide for assembly programmers and compiler makers
  4. Instruction tables: Lists of instruction latencies, throughputs and micro-operation breakdowns for Intel, AMD and VIA CPUs
  5. 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

KonradK
Posts: 1
Joined: 2020-02-05, 15:39:41

Re: Optimization manuals

Post by KonradK » 2020-02-06, 6:22:03

Could you provide EPUB, MOBI, or AZW3 versions of the manuals?

agner
Site Admin
Posts: 75
Joined: 2019-12-27, 18:56:25
Contact:

Re: Optimization manuals

Post by agner » 2020-02-10, 7:37:13

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.

dyaitskov
Posts: 2
Joined: 2020-05-14, 6:09:51

Re: Optimization manuals

Post by dyaitskov » 2020-05-14, 6:32:30

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?

dyaitskov
Posts: 2
Joined: 2020-05-14, 6:09:51

Re: Optimization manuals

Post by dyaitskov » 2020-05-14, 7:57:56

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.

agner
Site Admin
Posts: 75
Joined: 2019-12-27, 18:56:25
Contact:

Re: Optimization manuals

Post by agner » 2020-05-14, 8:55:55

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.

b_jonas
Posts: 1
Joined: 2020-05-22, 14:06:03

Re: Optimization manuals

Post by b_jonas » 2020-05-22, 14:56:58

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).

polar
Posts: 1
Joined: 2020-05-24, 16:21:04

Re: Optimization manuals

Post by polar » 2020-05-24, 16:25:12

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

logus
Posts: 1
Joined: 2020-08-05, 19:32:00

Re: Optimization manuals

Post by logus » 2020-08-05, 19:35:57

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.

agner
Site Admin
Posts: 75
Joined: 2019-12-27, 18:56:25
Contact:

Re: Optimization manuals

Post by agner » 2020-08-06, 16:27:13

AVX512IFMA is indeed multiplying 52 bit integers.

Post Reply