https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116977

--- Comment #4 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
David, thanks for the pointers; Vedant is looking into this.

Question:

(In reply to David Malcolm from comment #2)
> Note that the analyzer assumes that pointers in different memory spaces can't 
> alias.

Are you saying that, given two pointers with different values, the analyzer
currently assumes that these don't "alias" (don't point to the same underlying
region of memory)?  That is correct for OpenACC host vs. device pointers.  For
example:

    char *a_h = malloc(N);
    char *a_d = acc_create(a_h, N);

The 'acc_create' call creates a device memory object "corresponding" to the
host memory object (as specified by 'a_h, N'), but 'a_h' and 'a_d' don't
"alias": OpenACC calls the memory object pointed to by 'a_d' a "visible device
copy", and this means that the memory objects pointed to by 'a_h' and 'a_d' may
diverge.

And/or are you saying that, considering the example above, the analyzer
currently assumes that even if 'a_h' is known to be in the "host" memory space
and 'a_d' is known to be in the "device" memory space (to be implemented),
still 'a_d' must not "alias" 'a_h' in the meaning that the value of 'a_d' must
be different from 'a_h'?

(Is this the same underlying issue that the analyzer currently doesn't (seem
to?) handle address spaces, 'TYPE_ADDR_SPACE'?  There's no GCC PR for that yet,
as far as I can tell, right?)

There is, indeed, per my quick review, no provision in OpenACC from that would
follow that a pointer to a "visible device copy" may not have the same value as
the corresponding host pointer.  (..., or the host/device pointer value spaces
be disjoint, generally.)  I'll bring that up with the OpenACC Technical
Committee.

However, for all practical purposes, we shall assume that host vs. device
pointer values will always be disjoint (other than 'NULL'), for the reason that
the device shares a virtual address space with the host.  Nvidia/CUDA, for
example, calls this 'CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING', and "Unified
addressing is automatically enabled in 64-bit processes",
<https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html>.  (In
the libgomp nvptx plugin, we 'assert' this to be true.)

> So that might be worth modeling, if I'm understanding OpenACC's pointer model 
> correctly.

Reply via email to