How I Calculate An x86 CPU FLOPs

submited by
Style Pass
2024-12-12 18:00:03

My friend and I have been taking some performance engineering courses. One thing we’ve come to realize is how important calculating the maximum Floating-point Operations per second (FLOPs) of a CPU is. It turns out this is a little trickier than it looks.

This is a formula I use to calculate this value. The formula is number of cores * peak cpu speed * (max SIMD register size/32) * (fma throughput * 2). Let me break it down.

Max SIMD register size: Single Instruction Multiple Data (SIMD) allows a program to carry out vectorized operations using special registers. Some of the extensions are SSE, AVX, AVX2, and AVX-512. There are other extensions on Wikipedia. You can find a CPU’s supported extension on its web page. CPUs that only support SSE have a max SIMD register size of 128 bits. Those that support AVX or AVX2 have a max SIMD register size of 256 bits. Those that support AVX-512 have a max SIMD register size of 512 bits.

The size of a single-precision float type is 4 bytes. To check the maximum number of floats a SIMD register can support, the formula is register size / 4 bytes * 8 bits in a byte.

Leave a Comment