[Patch] Fortran: Support OpenMP's 'allocate' directive for stack vars

Tobias Burnus tobias@codesourcery.com
Tue Oct 10 16:46:35 GMT 2023


The attached patch adds 'omp allocate' support for stack/automatic variables
variables for Fortran.

I had originally a pure FE version for Fortran, which failed with 'defaultmap'/'default';
I then thought I could simply piggyback on the existing C/C++ support.

But it turns out that Fortran is completely different, e.g. there is often no BIND_EXPR
but just some (scoped / try-final-expr) code inside of it, i.e. the scope of the BIND_EXPR
has no relation to where GOMP_alloc has to be added. (GOMP_free is less critical, except
that a longer lifetime might cause memory constraints.)

Thus, RFC:
- Is the current scheme okay or should me move moved to the FE
   there is not that much happening at the ME?
- Should for the one 'if (lang_GNU_Fortran () ...' condition a lang hook
   be introduced?

Any other suggestions?

ALSO: I decided that the wording permits 'type(c_ptr)', 'type(c_funptr)' as they are
rather normal variables (of opaque type) in the Fortran sense. I decided that we do
not want to support EQUIVALENCE, Cray pointers, COMMON blocks ever (even though the
first to surely could be made to work, the latter - maybe.)
I also reject coarrays as it is really incompatible for allocate/allocators; for
the 'allocate' clause, that's different and permitted (just used for privatization).

Thoughts, suggestions?

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: omp-allocate-fortran.diff
Type: text/x-patch
Size: 79184 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/fortran/attachments/20231010/7ced6dd0/attachment-0001.bin>


More information about the Fortran mailing list