OpenMP/Fortran clauses target-consistent and dyn_groupprivate now evaluated on host
Evaluates num_teams, thread_limit, and dyn_groupprivate clauses on the host for OpenMP/Fortran target regions, aligning with recent specification changes.
This commit ensures that OpenMP clauses like num_teams and thread_limit within target regions, and dyn_groupprivate, are evaluated on the host. This aligns with OpenMP 5.0 and 6.0 specifications which mandate host evaluation for consistency, especially when launching GPU kernels. Previously, these evaluations sometimes occurred too late or on the device, potentially leading to incorrect behavior. The change enhances correctness and adheres to evolving OpenMP standards.
In Details
This change affects the OpenMP runtime and Fortran frontend, specifically within the gimplify.cc and openmp.cc files. It modifies how num_teams, thread_limit, and dyn_groupprivate clauses are processed for target and teams constructs. The core issue addressed is the timing of expression evaluation: ensuring these clauses are evaluated on the host prior to kernel launch to maintain target consistency, as dictated by OpenMP 5.0/6.0 specifications. This impacts the interaction between host and device execution contexts for parallel regions.
- target region
- An OpenMP construct that specifies a region of code to be executed on a target device, such as a GPU. It allows for offloading computation.
- teams construct
- An OpenMP construct that creates a set of teams of threads, allowing for nested parallelism and flexible thread management.
- num_teams clause
- An OpenMP clause that specifies the number of teams to be created for a
teamsconstruct. - thread_limit clause
- An OpenMP clause that specifies the maximum number of threads per team.
- dyn_groupprivate
- An OpenMP clause that provides private variables for each thread within a dynamic group, typically used with
teamsconstructs. - target consistent
- Refers to clauses whose values must be the same whether evaluated on the host or the device. This ensures predictable behavior across different execution environments.
- gimplify.cc
- A GCC source file containing the gimplification pass, which converts the compiler's intermediate representation (tree) into GENERIC and GIMPLE forms for further optimization.