Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7954 Discussions

Vectorization unsing pragma simd with Compiler Version 12.1 and 13.x

Sebastian_R_1
Beginner
373 Views

I have a code (part) that I vectorized using pragma simd. This worked fine with the Compiler 12.1.

However, compiling the same code with 13.0 or 13.1 breaks it.

Regarding pragma simd, are there any code constructs that work with 12.1 but are no longer supported by 13.x??

You can finde the code here (loops starting at line 137 and 177):

https://github.com/TUM-I5/SWE/blob/SSE_performance_measure/src/blocks/SWE_WavePropagationBlock.cpp

The solver that is called is here:

https://github.com/TUM-I5/swe_solvers/blob/master/src/solver/FWaveVec.hpp

0 Kudos
2 Replies
TimP
Honored Contributor III
373 Views

The more likely situation is that there are usages of #pragma simd that happened accidentally to work (or at least not to break) with the older compiler but don't work with the newer one.  One of the more common cases is with a reduction not being designated properly.

In the case you pose, the for loop looks far too complicated to attempt vectorization safely, so I suppose the compiler didn't try too hard even with the pragma.

#pragma simd is an assertion that you want the compiler to attempt all kinds of risky optimizations, even some which normally violate language syntax.  It does more than take away the default no-ansi-alias and treat all pointers as if declared restrict (but without necessarily checking for syntax which violates the rules).  It invites the compiler to try things in a new version which it might not have tried in an earlier version.

0 Kudos
Sebastian_R_1
Beginner
373 Views

Yes, the loops are complicated but loop iterations are completely independent (except for the max reduction at the end). Besides, speedups show that 12.1 did vectorize the code.

I had some small local arrays in the  solver (e.g.):

float fWaves[2];

Looks like 12.1 placed those arrays in registers while 13.x puts them on the stack.
Replacing those arrays with variables seems to fix my problem:

float fWaves0, fWaves1;

0 Kudos
Reply