OpenMP: Correct Fortran memspace use and multiple uses_allocators clauses
Fixes OpenMP's handling of Fortran `uses_allocators` memspace modifier and multiple clauses by improving data handling and alignment.
This commit addresses two issues with OpenMP’s uses_allocators clause. First, it corrects how the memspace modifier is handled in Fortran, preventing it from being misinterpreted as an external variable and causing link-time errors. Second, it resolves an issue where multiple uses_allocator clauses were not properly supported, with later clauses overriding earlier ones. The fix involves adjusting data offsets in the runtime library to accommodate multiple clauses correctly. Additional test cases are included to cover these fixes.
In Details
The Fortran frontend's translation of the uses_allocators clause's memspace modifier is fixed to directly use an integer constant rather than an external variable, aligning with C/C++ behavior and avoiding linker issues. For multiple uses_allocators clauses, libgomp's copy_firstprivate_data now correctly accounts for the size of the omp_allocator_data_t structure, shifting offsets to prevent overwrites. This ensures proper handling of user-defined allocators and consistent behavior across clauses.
- uses_allocators
- An OpenMP clause that specifies custom memory allocators to be used for private variables within a construct. It allows fine-grained control over memory management for performance or specific allocation strategies.
- memspace
- A modifier for the
uses_allocatorsclause in OpenMP that specifies the memory space or attribute for the allocator (e.g., 'host', 'device'). - Fortran Frontend (FE)
- The part of the GCC compiler responsible for parsing and semantically analyzing Fortran source code, typically translating it into an intermediate representation (IR) for subsequent optimization and code generation passes.