- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);
}
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page