On Wed, May 11, 2022 at 07:33:00PM +0200, Tobias Burnus wrote: > gcc/fortran/ChangeLog: > > PR fortran/104949 > * f95-lang.cc (LANG_HOOKS_OMP_ARRAY_SIZE): Redefine. > * trans-openmp.cc (gfc_omp_array_size): New. > (gfc_trans_omp_variable_list): Never turn has_device_addr > to firstprivate. > * trans.h (gfc_omp_array_size): New. > > gcc/ChangeLog: > > PR fortran/104949 > * langhooks-def.h (lhd_omp_array_size): New. > (LANG_HOOKS_OMP_ARRAY_SIZE): Define
Missing full stop above. > (LANG_HOOKS_DECLS): Add it. > * langhooks.cc (lhd_omp_array_size): New. > * langhooks.h (struct lang_hooks_for_decls): Add hook. > * omp-low.cc (scan_sharing_clauses, lower_omp_target): > Handle GOMP_MAP_FIRSTPRIVATE for array descriptors. > > libgomp/ChangeLog: > > PR fortran/104949 > * target.c (gomp_map_vars_internal, copy_firstprivate_data): > Support attach for GOMP_MAP_FIRSTPRIVATE. > * testsuite/libgomp.fortran/target-firstprivate-1.f90: New test. > * testsuite/libgomp.fortran/target-firstprivate-2.f90: New test. > * testsuite/libgomp.fortran/target-firstprivate-3.f90: New test. 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. Generally, for firstprivate on constructs other than target we invoke a copy constructor or its language equivalent (memcpy for C, perhaps some deep copying for Fortran), which takes care of stuff like in C++ embedded reference type members etc. But for target we don't have such a luxury, we don't have copy ctors between different devices and so we need to do something different, for now it has been mainly just bitwise copying the aggregate between devices. 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... Jakub