Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

parallelizing array assignments

john-l-ditter
Beginner
261 Views

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?

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
261 Views

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

0 Kudos
john-l-ditter
Beginner
261 Views

Thank you, Jim.

0 Kudos
Reply