This is about OpenMP's "deep mapping" of allocatable components of derived types. The basic feature is on OG12 (and OG11) but yet in GCC mainline. The old submissions are at https://gcc.gnu.org/pipermail/gcc-patches/2022-April/593704.html My plan is to get the whole feature into GCC 14 once trunk has opened (and after some simpler pending patches have been merged). It requires some re-diffing to be more digestible. * * * OG12: This patch as been committed to the devel/omp/gcc-12 branch as https://gcc.gnu.org/g:a63735b8034db65a33c359633462accd9d71d3b5 * * * This patch fixes an issue with 'map(alloc:' and 'map(from:' with deep mapping of allocatable components - namely: * For unmapping/coping to the host, the state of unallocated allocatables needs to be preservered. * For mapping to the device ('alloc' and 'from'), we still need to copy data to the device to have the array bounds correctly set. The data pointer (of allocated allocatables) is set as part of allocating memory on the device ('attach'); thus, this part works. As described in the patch (cf. comment above the checking function), we could either copy only the descriptor data (and the NULL for pointers) or we copy everything (shallowly) which includes this data. As there is no means to do the former (without changing the refcount), we do the latter. NOTE: The actual data to which the scalar/array allocatable points to is not 'to' mapped but only 'alloc'. As that is supposed to be the large data, copying everything should™ not cause a large performance penalty with real-world code; it could be even faster than, let's say, copying 5 descriptors separately. OpenMP spec side: It is not completely clear how the OpenMP spec expects the copy out to work. Hence, I filed OpenMP Spec Issue #3545. ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955