On Tue, 9 Feb 2021 13:45:36 +0100 Tobias Burnus <tob...@codesourcery.com> wrote:
> On 09.02.21 12:58, Thomas Schwinge wrote: > >> Granted. The array(:)%re access might update too much, but that's > >> not different to array with strides or with contiguous arrays > >> sections which contain component reference (and more than one > >> component). > > (Is that indeed allowed to "update too much"?) > > Yes - that's the general problem with strides or bit sets; > copying only a subset – and doing so atomically – is not > always possible or feasible. > > *OpenACC* 3.1 has for "2.14.4 Update Directive" the restriction: > > "Noncontiguous subarrays may appear. It is implementation-specific > whether noncontiguous regions are updated by using one transfer > for each contiguous subregion, or whether the noncontiguous data > is packed, transferred once, and unpacked, or whether one or more > larger subarrays (no larger than the smallest contiguous region > that contains the specified subarray) are updated." > > For map, I saw that that's the case – but I think Julian's > patch does not handle this correctly for: > > type t > integer :: i, j, k > end type t > type(t) :: A(100) > ... host(A(:)%j) > > I think instead of transferring A(1)%j to A(100)%j, it transfers > all of A(:), i.e. also A(1)%i and A(100)%k :-( > > ^– Julian? Yes it will -- but given that A(2)%i and A(99)%k (and all the in-between values) can legitimately be transferred according to the spec, how much of a problem is that? In particular, are there situations where this "over-updating" can lead to incorrect results in a conforming program? Perhaps the question is, can a user legitimately expect the host and offloaded versions of some given memory block to hold different data, like maintaining different data in a cache than the storage backing that cache? One use-case for that might be double buffering a "single array" (i.e. the host and device versions of that array). I don't think that's something we'd want to encourage, though. I think, rather, that partial updates are an optimisation the user can use when they know that only part of an array has been updated, so slight over-copying is harmless. Thanks, Julian