parallelizing array assignments

parallelizing array assignments

Hi,

If I have a DO loop where the values of array B are assigned to array A in the form:

DO N=N1,N2

   A(:,N)=B(:,N)

ENDDO

Will parallelizing it in OpenMP like below work, or do i need to explicitly loop through the first index:

!$OMP PARALLEL DO

!$OMP& PRIVATE(N)

DO N=N1,N2

   A(:,N)=B(:,N)

ENDDO

What if, instead of an array B on the right-hand side, it is a scalar?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Your code will work in parallel, even with scalar.

For small arrays you might want to avoid the parallel code. For large arrays, you might want to limit the number of threads to 2-4 as you will soon hit a memory bandwidth situation.

Jim Dempsey

Jim Dempsey

www.quickthreadprogramming.com

Thank you, Jim.

Leave a Comment

Please sign in to add a comment. Not a member? Join today