Hi Jakub, On 19.05.22 15:59, Jakub Jelinek wrote:
I guess ok like this for now, but handling the further deep copy cases (allocatable members of derived types) wouldn't be very nice, I think generally we need a target hook to handle the stuff that is target specific and express it say in further clauses or their modified copies (perhaps some flags on them, or new clause types) which will allow the pointer attachments to be done.
I concur – although, the question is how to to it best – i.e. what is statically known vs. only known at run time. The current patch requires some in-depth knowledge both of the internal structure (array size) and also the handling of what is passed to libgomp. But it can be done statically. Thus, I think it is okay to handle this case of firstprivate differently from: For the Fortran patch regarding deep-copying of derived types, it is different: it is a complicated deeply nested structure and with polymorphic types or recursive types – or array derived types with allocatable derived components. In this case, omp-low.cc only calls a three lang hooks and defers most to the language hooks. Namely: Has deep copying, how many (run-time determined) - do a malloc - and last hook: fill the three arrays (data, sizes, kinds). I think that patch can be extended to handle deep firstprivate as well. As the FE lang hook code controls the data/sizes/kinds array handling, it can also handle the firstprivate bits. (I need at some point to cleanup the patch and submit it piecewise, starting with some generic Fortran patches.) (Cross ref: See omp-low.cc changes at https://gcc.gnu.org/pipermail/gcc-patches/2022-April/593562.html)
But eventually it would be nice to have a target hook that emulates the cross-device copy construction. And we probably need also something to emulate destruction...
Yes – we also need something for map as OpenMP 5.x (x=1 or 2, I forgot; to be extended in 6.0) permits more with regards to dynamic types and calling virtual functions. (Likewise, but not relevant to mapping: Also dereferencing function pointers.) The submitted patch was now committed as https://gcc.gnu.org/r13-706-g49d1a2f91325fa8cc011149e27e5093a988b3a49. Thanks for the comments! Tobias ----------------- 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