Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Multiple code paths and intrinsics

$
0
0

I have some code where I'm using a combination of automatically vectorized code (with many different possible CPU paths, including SSE2, SSE4.2, AVX and AVX2) and some hand-written intrinsics.

One function may contain both types of loops. So, what I would like is to be able to tell the compiler which of the hand-written types of code to use (they are written using SSE2 and AVX2). But I really don't want to have to write separate dispatcher functions for each loop - including having to make all the variables that are needed available in the dispatched function.

Is there an easier way to do this? At this moment I have made some #define's and I can compile 2 different versions of my code, and right now this means that - unless I know that for a specific version it will definitely run on an AVX2 CPU - I'm just using the SSE2 version.

To make things worse though, I now need to compile my code also for an ARM chip, and - since there is no Intel compiler for ARM - I need to use GCC, which unfortunately doesn't vectorize most of the code that the Intel compiler does. And the performance is not good enough. So I'm kinda forced to manually vectorize this code - the problem is that this means vectorizing dozens, potentially hundreds of loops, and if I do that, I still want the Intel compiled version to support both SSE2 and AVX2. The difference in performance between the SSE2 and AVX2 compiled versions is about 7% for the whole program, and I really cannot afford loosing that extra performance. The easiest way to vectorize those loops would be using some simple class to encapsulate SSE/AVX intrinsics so I hardly need to change the code at all, but I would still need to get both SSE2 and AVX2 code out of it without having to write all the code twice. (Copying it is also not really an option, and in the future I also want to be able to add AVX512 support).

 


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>