Community
cancel
Showing results for 
Search instead for 
Did you mean: 
high_end_c_
Beginner
144 Views

correct syntax for pragma simd with icc v17

hi, just wanting to check whether anything changed v15 to v17 of icc compiler with regards to use of 

#pragma simd // above an inner loop

within an 

#pragma omp parallel for  // at the outer loop

construct, since I now seem to be getting "Segmentation Faults" unless I remove the innermost "#pragma simd" (which I believe I need to force vectorisation of the inner loop)

 

Yours, M

Tags (1)
0 Kudos
9 Replies
gaston-hillar
Black Belt
144 Views

Hi High end c.,

Intel C++ Compiler 17 added support for more new features for OpenMP 4.0 or later, and other new features related to #pragma. You can check all of them in the release notes

However, the are no changes in the way #pragma simd works.

Can you share the code in which you are using the two #pragma?

gaston-hillar
Black Belt
144 Views

Hi High end c.,

The following is the link to the documentation of the usage of #pragma simd to enforce vectorisation of loops in Intel C++ Compiler 17: https://software.intel.com/en-us/node/684214#64C8708E-FCD9-4C88-A440-C82158283A79

If you can share the code, it will be easier to understand what is going on.

high_end_c_
Beginner
144 Views

Hi, I'll narrow this down and post code shortly. Meanwhile, I have tested with v15.0.2.164 which worked find but version 17.0.0.098 gives the Seg fault. BRB, M

 

gaston-hillar
Black Belt
144 Views

high end c. wrote:

Hi, I'll narrow this down and post code shortly. Meanwhile, I have tested with v15.0.2.164 which worked find but version 17.0.0.098 gives the Seg fault. BRB, M

 

Hi High end c.,

Cool. The code will be extremely helpful to have a better idea of what's going on.

jimdempseyatthecove
Black Belt
144 Views

>> I now seem to be getting "Segmentation Faults" unless I remove the innermost "#pragma simd" (which I believe I need to force vectorisation of the inner loop)

When forcing vectorization, you have entered a contract with the compiler that the arrays within the loop are properly aligned (as referenced within the loop). The (programmer's) expectation is that the compiler shouldn't do something stupid (e.g. use aligned loads or stores on unaligned data), however, the #pragma simd instructs the compiler that when alignment is uncertain, to assume the programmer knew better.

Jim Dempsey

McCalpinJohn
Black Belt
144 Views

Following up on Jim Dempsey's comment....

The need for alignment depends on both the instruction set generation and the specific instruction used.   For SSE1/2/3/4, most memory accesses needed to be aligned (except for the explicitly unaligned MOVE instructions), while for AVX/AVX2/AVX512, most memory accesses are not required to be aligned (except for the explicitly aligned MOVE instructions and the non-temporal MOVE instructions).  

Alignment violations are only one possible cause of seg faults, so getting a bit more clarity on exactly what the error is should help limit the scope of the search for causes.

 

gaston-hillar
Black Belt
144 Views

Hi High end c.,

Are you using exactly the same code with the different compiler versions? I think there is a need for clarification on this. Jim and John provided extremely helpful info regarding potential causes of seg faults. However, it is not clear whether you are running the same code with both compiler versions. Just trying to understand a bit more. I do believe, without the code, it is very difficult to try to *guess* what might happen. 

TimP
Black Belt
144 Views

#pragma simd alone (without an explicit alignment specification) doesn't require alignment.

Several SSE instructions which required alignment on the original SSE CPUs don't require alignment on a CPU which supports AVX.  I doubt there is much continued testing of SSE intrinsics code on non- AVX CPUs.

Some of the rules for use of #pragma simd (such as properly specifying reduction and firstprivate/lastprivate) are easily missed and associated with latent bugs which don't show up until something changes (including compiler version).

I'd suspect that combinations of OpenMP with the legacy non-omp simd pragmas may not get as much testing as the current pragma omp simd syntax.

 

gaston-hillar
Black Belt
144 Views

Tim P. wrote:

#pragma simd alone (without an explicit alignment specification) doesn't require alignment.

Several SSE instructions which required alignment on the original SSE CPUs don't require alignment on a CPU which supports AVX.  I doubt there is much continued testing of SSE intrinsics code on non- AVX CPUs.

Some of the rules for use of #pragma simd (such as properly specifying reduction and firstprivate/lastprivate) are easily missed and associated with latent bugs which don't show up until something changes (including compiler version).

I'd suspect that combinations of OpenMP with the legacy non-omp simd pragmas may not get as much testing as the current pragma omp simd syntax.

 

@Tim,

I never had issues when I upgraded to newer compiler versions. However, I always got rid of legacy non-imp simd pragmas... So, I guess I followed *best-practices*. I'm still curious about this case.

Reply