Does "host_data" need to be in a "data presen

In my MPI+OpenACC code I do the following:

!$acc host_data use_device(a(:,:,:))
  call MPI_ROUTINE(a(:,:,:))
!$acc end host_data

where “a” is on the device from a previous “acc enter data copyin”.

In the new OpenACC book (pg. 283) an example similar to mine is shown but with the above block within an “acc data present(a)” clause, i.e.

!$acc data present(a(:,:,:))
!$acc host_data use_device(a(:,:,:))
  call MPI_ROUTINE(a(:,:,:))
!$acc end host_data
!$acc end data

Is it required to explicitly say “acc data present()” before using “acc host_data use_device(a)”?

I would think that the host_data clause would assume the array was on the device.

My code seems to work on my local machine both ways.
Which is “correct”?

  • Ron



Hi Ron,

Is it required to explicitly say “acc data present()” before using “acc host_data use_device(a)”?

No, it’s not required but doesn’t hurt.

I would think that the host_data clause would assume the array was on the device.

It doesn’t assume, it requires that “a” have mirrored device variable. Hence, the host_data directive should give a run time error if the variable doesn’t exist. The exception being in the case of a shared memory system where there’s only a single variable.

  • Mat