Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Wei_Pan
Beginner
70 Views

pragma simd vectorlength does not take compile time constants?

Hello,
The following code vectorlength.cpp does not compile with icc version 12.1.4
vectorlength.cpp(4): error: expression must have a constant value
#pragma simd vectorlength(m)
                                 ^
This is odd to me and is it difficult to enable this? Any workaround? Thanks!
Wei
===============================================
template <int m>
void foo(float *v, int n) {
#pragma simd vectorlength(m)
   for (int i = 0; i < n; ++i) {
   v = v[i - m] + 1;
  }
 }
void bar(float *v, int n) {
  foo(v, n);
}

0 Kudos
2 Replies
TimP
Black Belt
70 Views

A variable parameter doesn't make sense to me; you're asserting conditions the compiler must heed in order to vectorize, and it's not going to change the code at run time.  If the compiler requires vectorlength(64), and you will sometimes violate that at run time, you can make 2 versions of the loop yourself, with and without the assertion, with if(m>=64), so as to choose between them at run time.
JenniferJ
Moderator
70 Views

our compiler does support it on Windows. It is a bug on Linux and will be sent to the compiler team. 
Well, so far there is no work-around. 
So maybe try not use templated code here. 
Jennifer 
Reply