Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenMP 4 simd vectorization for c=c+a*b

Tags:

c++

simd

openmp

I do not know if OpenMP 4 support this for loop or not. The speed with and without the pragma is the same.

#pragma omp  for simd
for (size_t i = 0; i < col; i++)
{
    C[i] += A[i]* B[i];
}
like image 251
user1436187 Avatar asked Aug 12 '26 04:08

user1436187


1 Answers

The reason (I guess) for the pragma do be of no effect is double:

  • The code vectorises already without the simd directive; and
  • The code is memory bound anyway, so adding more threads to compute it won't make much differences unless it gives you access to more memory bandwidth. See this excellent answer for more details.
like image 75
Gilles Avatar answered Aug 14 '26 20:08

Gilles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!