On Mon, Sep 10, 2018 at 10:22:15PM +0100, Jason Merrill wrote: > > As noted in a previous email, PGI seems to treat pointers to > > aggregates specially, mapping them as ptr[0:1], but it's unclear if the > > same is true for pointers to scalars with their compiler. Neither > > behaviour seems to be standard-mandated, but this patch extends the > > idea to references to scalars nonetheless. > > That certainly seems like the most sensible way of handling references > to non-arrays. And the 'this' pointer, incidentally. Should we not > do the same for OpenMP? Jakub?
OpenMP specifies what to do, though for 4.0, 4.5 and 5.0 it is all different (and also depends on defaultmap clause), I believe currently we implement what 4.5 says and when I'll try to implement the 5.0 version, I'll certainly try to follow the standard. With defaultmap, one can specify what will happen with various kinds of implicit mappings (map them as bits, firstprivatize them, for pointers handle them as zero length array sections, refuse to do any implicit mapping). E.g. part of what OpenMP 5.0 says is: ... - If a defaultmap clause is present for the category of the variable and specifies an implicit behavior other than default, the data-mapping attribute is determined by that clause. - If the target construct is within a class non-static member function, and a variable is an accessible data member of the object for which the non-static data member function is invoked, the variable is treated as if the this[:1] expression had appeared in a map clause with a map-type of tofrom. Additionally, if the variable is of a type pointer or reference to pointer, it is also treated as if it has appeared in a map clause as a zero-length array section. - If the this keyword is referenced inside a target construct within a class non-static member function, it is treated as if the this[:1] expression had appeared in a map clause with a map-type of tofrom. - A variable that is of type pointer is treated as if it is the base pointer of a zero-length array section that appeared as a list item in a map clause. - A variable that is of type reference to pointer is treated as if it had appeared in a map clause as a zero-length array section. ... - If the type of a list item is a reference to a type T then the reference in the device data environment is initialized to refer to the object in the device data environment that corresponds to the object referenced by the list item. If mapping occurs, it occurs as though the object were mapped through a pointer with an array section of type T and length one. - No type mapped through a reference can contain a reference to its own type, or any cycle of references to types that could produce a cycle of references. ... Jakub