pragma simd vectorlength does not take compile time constants?

pragma simd vectorlength does not take compile time constants?

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!
template <int m>
void foo(float *v, int n) {
#pragma simd vectorlength(m)
   for (int i = 0; i < n; ++i) {
   v[i] = v[i - m] + 1;
void bar(float *v, int n) {
  foo(v, n);

3 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

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.

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 

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen