Doubts about subarray copy to and from device

Hello.

I have the following Fortran code:

(...)
!$acc region copy(sh_c(:,iw0)),copyin(con_c(:,iw0)),copyout(cat_cx,cat_rx)

cat_rx%cat1 = 0.
cat_rx%cat2 = 0.
cat_rx%cat3 = 0.
cat_rx%cat4 = 0.
cat_rx%cat5 = 0.
cat_rx%cat6 = 0.
cat_rx%cat7 = 0.
cat_cx%cat1 = 0.
cat_cx%cat2 = 0.
cat_cx%cat3 = 0.
cat_cx%cat4 = 0.
cat_cx%cat5 = 0.
cat_cx%cat6 = 0.
cat_cx%cat7 = 0.

if (jnmb(1) >= 1) then
   do k = lpw0,mza0
      if (sh_c(k,iw0) >= rxmin(1)) then

         cat_rx(k)%cat1 = sh_c(k,iw0) * rhoa(k)

         if (jnmb(1) >= 5) cat_cx(k)%cat1 = con_c(k,iw0) * rhoa(k)

      elseif (sh_c(k,iw0) < 0.) then

         sh_c(k,iw0) = 0.

      endif
   enddo
endif
!$acc end region
(...)

This produce right results. Changing:

!$acc region copy(sh_c(:,iw0)),copyin(con_c(:,iw0)),copyout(cat_cx,cat_rx)

to:

!$acc region copy(sh_c(lpw0:mza0,iw0)),copyin(con_c(lpw0:mza0,iw0)),copyout(cat_cx,cat_rx)

produces wrong results, or even a segmentation fault.

The compiler shows a similar construction when the statement is:


!$acc region copyout(cat_cx,cat_rx)

Producing the following message:

mic_copy:
    937, Generating copyout(cat_rx(:))
         Generating copyout(cat_cx(:))
    938, Generating copyin(rhoa(lpw0:mza0))
         Generating copy(sh_c(lpw0:mza0,iw0))
         Generating copyin(rxmin(1))
         Generating copyin(con_c(lpw0:mza0,iw0))
         Generating copyin(jnmb(1))
         Generating compute capability 1.3 binary

The sh_c and con_c variables are coming from modules.

Is the accelerator copy task misaligned? How can I produce correct results copying just a part of the matrix?

Thanks a lot!

Hi pedropaislopes,

Can you please post a reproducing example or send one to PGI Customer Service (trs@pgroup.com) and ask them to forward it to me?

Thanks,
Mat

Mat, I will do that ASAP.

Thank you!