C Programming Optimization and Processor Expansion

I have a C programming programming that involves optimizing the code as much as possible. I've already read a little about this on the internet and found things like using case

over if

, following pointers instead of value, etc.

What I would like to ask is why I know what CPU extensions are available, can help me optimize my code? I know SSE and AVX are available on the machine, but what does that mean to me as a programmer?

In connection with my above question, I found the Intel Intrinsic Guide which I think is related to processor extensions. Are there any performance advantages of using these functions over other C functions for example would use _mm_sqrt_ps

from xmmintrin.h

faster than sqrt

from math.h



source to share

1 answer

The idea is to have based on CPU optimized libraries (SSE, AVX, etc.) and call something like _may_i_use_cpu_feature () to dynamically determine which feature is available at runtime and load the "best" implementation for CPU.

For portable code, you want to use sqrt () - and some runtime libraries have optimized implementations that are good enough. If you want complete control and maximize performance on a specific platform and don't care about portability, you can write a hand-optimized build (or use built-in functions).

In any case, better performance is achieved by better algorithms ...



All Articles