Libgomp: Improve GOMP_RUNTIME_USM handling for shared memory.
Optimizes OpenMP runtime for devices with shared memory by reducing unnecessary data structure updates.
This commit enhances OpenMP runtime handling for devices with shared memory capabilities. For such devices, it avoids adding ‘link’ variables to the splay tree when they are initialized to point to host variables, as these will not be modified. It also refines error handling for specific USM scenarios and map types.
In Details
This change refines libgomp's handling of GOMP_RUNTIME_USM for devices supporting OFFLOAD_CAP_SHARED_MEM. It optimizes by not adding 'link' variables to the splay tree if they point to host variables and won't be modified. For 'requires self_maps'/'unified_shared_memory', it correctly handles data mapping. Error diagnostics are improved for certain 'always' map-type modifiers when unified memory is involved, though a loophole exists for 'target map(to: A)'.
- libgomp
- The OpenMP runtime library for GCC, responsible for managing parallel execution and OpenMP directives.
- OpenMP
- A standardized API for shared-memory parallel programming, allowing developers to use compiler directives to parallelize their code.
- GOMP_RUNTIME_USM
- An environment variable controlling Unified Shared Memory (USM) behavior in the libgomp runtime. USM allows a single memory address space for host and device memory.
- USM
- Unified Shared Memory. A feature in OpenMP that provides a single memory address space accessible by both the host CPU and the accelerator devices.
- OFFLOAD_CAP_SHARED_MEM
- A capability flag indicating that a target device supports shared memory, allowing direct access to memory from both host and device.
- splay tree
- A self-balancing binary search tree that restructures itself to optimize access to frequently used elements. Used here for managing device memory mappings.
- link variables
- In the context of OpenMP offloading, these are variables that link host and device memory regions, often used for shared memory access.
- requires self_maps
- An OpenMP clause or property that mandates the compiler and runtime to handle self-mapping of memory, essential for USM.