OpenMP: Enable 'omp groupprivate' for nvptx offload
OpenMP's `groupprivate` clause is now supported for nvptx offload targets.
The OpenMP groupprivate clause, which provides a copy of a variable per thread team, is now enabled for offloading to NVIDIA’s nvptx devices. This feature aligns with Nvidia’s ‘shared’ variable concept. The commit adds support in the NVPTX backend and Fortran frontend, while issuing a ‘sorry’ message for other devices like GCN or when accessing from the host unless specific conditions are met. This enables more flexible data scoping for parallel regions executed on GPUs.
In Details
Support for the OpenMP groupprivate clause has been extended to the nvptx offload target. groupprivate variables are implemented as static variables with a copy per team, analogous to Nvidia's 'shared' variables. The changes involve modifications to nvptx.cc for encoding section information, varpool.cc to manage variable pooling and issue warnings for unsupported targets, and Fortran-specific files (f95-lang.cc, trans-common.cc, trans-decl.cc) to recognize and handle the attribute. The implementation currently targets only nvptx offload, with a warning for other targets. Host-si…
- OpenMP
- Open Multi-Processing. An API for parallel programming that supports shared-memory multiprocessing programming in C, C++, and Fortran.
- groupprivate
- An OpenMP clause that declares variables which have a distinct copy for each team in a parallel region. This is useful for maintaining team-specific state.
- nvptx
- NVIDIA Parallel Thread Execution. A virtual instruction set architecture used by NVIDIA GPUs, targeted by CUDA and OpenACC/OpenMP offloading.
- offload
- The process of executing code or computations on a specific hardware device, such as a GPU, rather than on the main CPU.
- team
- In OpenMP, a team is a group of threads that can execute work cooperatively. Threading models like the nested team model allow for hierarchical parallelism.