OpenMP pragma with a meaning: don't vectorize

Viewed 77

I have a loop with a really low trip count where vectorization doesn't pay off, but the compiler vectorizes it nevertheless. Is there a portable way to tell a compiler not to vectorize a loop, an opposite of #pragma omp simd

1 Answers

If you have a compiler that supports the OpenMP API version 5.1, then it should accept this:

#pragma omp simd if(simd:0)
for (...) { ... }

That should then disable vectorization for the loop associated with the simd construct.

See simd Construct in the OpenMP specification.

Related