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

Copy A to B on device with !$OMP TARGET

cu238
Novice
548 Views

Considering

real A(10000), B(10000)

 

If A and B are on host (CPU), copying A to B is easy:

B=A

 

What if A and B are on device (GPU) ? Code below is not neat enough:

!$OMP TARGET DEFAULTMAP(present: aggregate)

!$OMP TEAMS DISTRIBUTE PARALLEL DO

do i=1,10000

   B(i)=A(i)

enddo

!$OMP END TARGET

 

Is there any neat expression?

 

Thanks.

 

Labels (1)
0 Kudos
1 Solution
Lorri_M_Intel
Employee
483 Views

OpenMP doesn't recognize Fortran array expressions as loopnests, to allow them under OMP DO directives.

What you have here is about the "neatest" idiom you can use.  

View solution in original post

3 Replies
Lorri_M_Intel
Employee
484 Views

OpenMP doesn't recognize Fortran array expressions as loopnests, to allow them under OMP DO directives.

What you have here is about the "neatest" idiom you can use.  

jimdempseyatthecove
Honored Contributor III
425 Views

>>OpenMP doesn't recognize Fortran array expressions as loopnests,

 

This should be fixable. IOW the language features supported on the host should be available on the target.

 

Jim Dempsey

0 Kudos
Frankcombe__Kim
Beginner
70 Views

I'm no expert on OpenMP but

!#OMP PARALLEL WORKSHARE

B=A

!$OMP END PARALLEL WORKSHARE

works on my tests and runs faster than

!$OMP PARALLEL DO

DO I=1,N

  B(I)=A(I)

END DO

!OMP END PARALLEL DO.

If you have a whole bunch of them with no serial bits between then wrapping the whole lot in a !$OMP PARALLEL/END PARALLEL and then just using !$OMP WORKSHARE/END WORKSHARE or !$OMP DO/END DO gives a nano second or two of speed up, presumably because of the OMP setup overhead.

Please tell me if it is unsafe as I've just spent half a day adding a few hundred of them to implied do  array assignments in my code.

Cheers

Kim

0 Kudos
Reply