OpenMP TR8 sec. 2.15.6 "target update Construct", p. 183, L3-4 states:
If the corresponding list item is not present in the device data
environment and there is no present modifier in the clause, then no
assignment occurs to or from the original list item.
If a present modifier appears in the clause and the corresponding
list item is not present in the device data environment then an
error occurs and the program termintates.
(OpenMP 5.0 also has the first passage but without mention of the
present modifier of course.)
In both passages, I assume "is not present" includes the case of
partially but not entirely present. However, without this patch, the
target update directive misbehaves in this case both with and without
the present modifier. For example:
#pragma omp target enter data map(to:arr[0:3]) #pragma omp target update to(arr[0:5]) // might fail on data transfer #pragma omp target update to(present:arr[0:5]) // might fail on data transfer
The problem is that DeviceTy::getTgtPtrBegin does not return a null
pointer in that case, so target_data_update sees the data as fully
present, and the data transfer then might fail depending on the target
device. However, without the present modifier, there should never be
a failure. Moreover, with the present modifier, there should always
be a failure, and the diagnostic should mention the present modifier.
This patch fixes DeviceTy::getTgtPtrBegin to return null when
target_data_update is the caller. I'm wondering if it should do the
same for more callers.