Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
告知
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 ディスカッション

Copy A to B on device with !$OMP TARGET

cu238
初心者
1,643件の閲覧回数

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.

 

ラベル(1)
0 件の賞賛
1 解決策
Lorri_M_Intel
従業員
1,578件の閲覧回数

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.  

元の投稿で解決策を見る

3 返答(返信)
Lorri_M_Intel
従業員
1,579件の閲覧回数

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
名誉コントリビューター III
1,520件の閲覧回数

>>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

Frankcombe__Kim
ビギナー
1,165件の閲覧回数

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

返信