---
title: "Co-Designing an OpenMP GPU Runtime and Optimizations for"
description: "How LLVM and OpenMP redesign the GPU runtime so the compiler can remove unused support code and bring scientific kernels closer to…"
canonical: "https://research.elamur.ai/free/en/papers/doerfert-2022-co-designing-openmp-gpu-runtime/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Shryfti](https://md.shryfti.elamur.ai/free/en/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/doerfert-2022-co-designing-openmp-gpu-runtime/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2022](https://md.research.elamur.ai/free/en/papers/2022/) / Co-Designing an OpenMP GPU Runtime and Optimizations for Near-Zero Overhead Execution

# Co-Designing an OpenMP GPU Runtime and Optimizations for Near-Zero Overhead Execution

Paper · 2022 · Johannes Doerfert, Atmn Patel, Joseph Huber et al.

**Authors:** Johannes Doerfert, Atmn Patel, Joseph Huber, Shilei Tian, Jose M. Monsalve Diaz, Barbara Chapman and [Giorgis Georgakoudis](https://md.research.elamur.ai/free/en/authors/giorgis-georgakoudis/) · **Year:** 2022 · **Venue:** Proceedings - IEEE International Parallel and Distributed Processing Symposium · **Licence:** No open licence stated (free-to-read copy; rights reserved) — text kept private

Cited by **3** papers in our library of more than 163,000 papers whose bibliographies we read · Proceedings - IEEE International Parallel and Distributed Processing Symposium

- [PDF](https://www.osti.gov/servlets/purl/1890094)
- [DOI 10.1109/ipdps53621.2022.00055](https://doi.org/10.1109/ipdps53621.2022.00055)

## Summary

A program that sends work to a GPU may spend part of its time managing how that work runs. OpenMP lets programmers describe parallel work with directives and use much of the same programming interface across different devices. Its flexibility comes with bookkeeping for features such as starting and joining groups of threads, sharing variables, and changing execution settings inside a parallel region. The paper asks how much of that bookkeeping has to survive in the compiled program. Could an OpenMP kernel retain support for rich parallel constructs at the source level and run with much of the simplicity of a CUDA kernel when it uses only common features? The question matters for [GPU and parallel computing](https://md.research.elamur.ai/free/en/topics/gpu-parallel-computing/) because the same support code that takes time to execute can also occupy registers and shared memory that the scientific calculation needs.

The authors redesign the OpenMP GPU runtime and extend LLVM’s optimizer together. The runtime keeps common execution settings in a team-wide record and creates a separate record for a thread when the program requires one. The optimizer follows reads and writes to these records across function calls. If it can establish that a setting always has a particular value at the point where it is read, it can replace the read and simplify the code that depends on it. Entire allocations and synchronization barriers can then become redundant. The authors also revise how threads divide loop iterations. When the programmer can guarantee that there are enough threads to cover the work in a single pass, a compiler option can remove the loop that would otherwise assign additional iterations to those threads.

The authors evaluate the implementation on an NVIDIA A100 using scientific proxy applications, which are programs that represent selected computations from larger applications. GridMini reaches CUDA-like throughput for its lattice calculation, and the reported difference between XSBench and CUDA narrows to 5% with assumptions enabled. MiniFMM improves by 1.85x over the old OpenMP runtime and still trails CUDA. RSBench already runs close to CUDA with the old runtime, and the development implementation restores that level after a regression in the nightly build. The optimization comparisons identify field-sensitive analysis, which tracks individual pieces of a memory object, as an important source of the gains. They also show that a smaller register count or simpler control flow does not always produce a detectable change in kernel time.

The results concern device kernels built with a development version of LLVM. They establish that much of the overhead in the tested OpenMP kernels comes from operations that a compiler can sometimes prove unnecessary. The amount it can remove depends on the program, the available information about its memory and synchronization, and any additional guarantees supplied by the programmer. The reduction implementation, which combines values produced by different threads, was outside the redesign and evaluation.

## Deep dive: Co-Designing an OpenMP GPU Runtime and Optimizations for Near-Zero Overhead Execution

How LLVM and OpenMP redesign the GPU runtime so the compiler can remove unused support code and bring scientific kernels closer to CUDA performance. · about 37 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### Why a portable directive can generate substantial device code

OpenMP offloading gives a host program a way to send a region of computation to an accelerator. The host CPU coordinates the resulting target tasks, including when they run, how the host waits for them, and how memory is allocated and moved between host and device. The paper focuses on what happens inside an offloaded region after the GPU starts executing it. On the device, the compiler has to turn the source directives into instructions that organize threads, schedule work, and give the program the behavior OpenMP specifies.

Consider an OpenMP directive that marks a loop for execution by a team of threads. The source can express that request in a line. The compiler must generate code that divides the iteration space and arranges for each participant to run its assigned work. A runtime library supplies some of the operations used in this translation. The program can also contain code that executes on the main thread of a team, enter a region that activates more threads, change a setting within that region, and continue after the participating threads have finished their work. Each construct has rules about which threads execute and what data they can see. Supporting combinations of those constructs can require bookkeeping even when an individual directive looks simple.

The authors describe CUDA and HIP as leaner interfaces that keep the device runtime’s responsibilities small. They characterize OpenACC as following a similar principle while offering a portable interface. OpenMP brings much of its existing host-side behavior into GPU offloading. That helps when a programmer wants to preserve the structure of an OpenMP application as it moves onto an accelerator. It also means the implementation has to support patterns that differ from the way GPU threads naturally start and share work. The research question is whether the implementation can carry that flexibility through compilation and still generate a lean kernel for the cases that admit one.

#### Fork and join on a GPU

OpenMP organizes the outer level of parallel work into a league of teams. In the execution scheme described by the authors, a team starts with a main thread. A `parallel` region can bring the team’s worker threads into the computation. Work sharing within a team assigns iterations to threads, and `distribute` assigns iterations across teams. The main thread resumes its independent work after the parallel region has joined. This alternating pattern of independent and collective work is called fork-join parallelism.

The hardware also has levels of parallel execution. The paper’s simplified mapping puts a team on a streaming multiprocessor, a unit that can execute groups of threads, and uses hardware threads for the members of the team. A scheduling group is called a warp on NVIDIA GPUs and a wavefront on AMD GPUs. Threads across the GPU can access global memory. Threads in the same team can additionally use the team’s shared memory, and each thread has private storage and registers. Registers hold intermediate values directly available to a thread. These distinctions matter because an ordinary thread-local variable may need different storage if another thread must read it.

The execution challenge is that GPU threads are already active when the kernel begins. In a region where OpenMP calls for a main thread to act alone for part of the computation, the implementation has to coordinate the other threads. LLVM’s generic execution mode does that with a state machine. The workers follow a control loop, and the runtime uses it to send them work and synchronize their participation. The state machine implements the fork and join behavior on hardware that starts the threads together.

Some regions admit a simpler execution scheme. In single program multiple data, or SPMD, mode, the threads run the kernel together. They can do different pieces of the work, such as processing different loop indices. The compiler can also arrange for an operation that needs a single executor to run only on a designated thread. When a kernel qualifies for SPMD execution, the runtime can dispense with the generic worker state machine. The distinction between modes gives the optimizer a major opportunity, though reaching SPMD execution leaves additional questions about memory allocation, state tracking, and synchronization.

#### The earlier compiler and runtime work

The paper traces LLVM’s GPU offloading support to work by Bertolli and colleagues that introduced the worker control loop. Earlier work on the Clang front end, the part of the compiler that translates the programmer’s source, also addressed how many teams and threads to use for parallel loops. Its goals included limiting idle threads and reducing register use. In the account given here, IBM XL C/C++ subsequently implemented an SPMD lowering for an offloaded region containing a single parallel construct. LLVM/Clang adopted that approach. Work on the TRegion interface moved the discovery of SPMD opportunities further into compilation, where analysis of LLVM’s intermediate representation could identify more eligible regions.

A related line of research addressed the visibility of parallel behavior to the optimizer. When a compiler outlines a region, it moves that region’s body into a function called by the surrounding code. The function boundary can make it harder for ordinary compiler passes to see relationships between the parallel region and its caller. The paper describes earlier host-side work that recovered optimization opportunities by interpreting what OpenMP runtime calls meant. It also discusses proposals to represent parallel constructs directly through added LLVM intrinsics, which are operations the compiler recognizes specially. The authors describe integration difficulties with those proposals and see advantages in reasoning about runtime calls through the infrastructure already available. Translation tools between OpenACC and OpenMP had also dealt with differences in how the two interfaces map work onto CPU and GPU execution.

The runtime implementation itself had already changed to accommodate more devices. Its original LLVM version used CUDA and was compiled to PTX with NVIDIA’s toolchain. Supporting AMD GPUs brought a HIP version, with macros handling some of the source differences. The work by Tian and colleagues then implemented the runtime using OpenMP 5.1 with a small set of extensions. That design put most functionality in shared source and left a narrower set of target-specific operations for each device. The new runtime follows that portability approach while substantially rewriting the code responsible for device execution.

Several of the optimizations the paper builds on were already in LLVM. One tries to make OpenMP regions resemble kernels that start all their workers together. Another tries to return potentially shared variables to private storage when analysis shows they need no broader visibility. The new work connects those transformations to the runtime’s own data structures. Once the compiler can recognize how a kernel executes, it can use that knowledge to decide which parts of the runtime still serve a purpose. Prior comparative studies cited by the authors had reported performance problems in LLVM’s OpenMP implementation. This paper investigates those costs at the level of specific runtime operations and the code that remains after compilation.

### The method, step by step

#### Compile the application and runtime together

The method starts from a feature of LLVM’s offloading pipeline. The device runtime is available as LLVM bitcode, a form of the compiler’s intermediate representation. Clang lowers the OpenMP directives into device code and links in the runtime at this level. The optimizer can therefore inspect the runtime functions alongside the application that calls them. LLVM then compiles the optimized code for the target GPU, and the vendor toolchain produces the device binary. The host binary carries the kernel under a symbol that the offloading plugin can find when it loads the device code.

That ordering matters because the usefulness of a runtime operation depends on the kernel that calls it. A routine might ordinarily need to read a setting from memory and decide between different paths. In a particular kernel, the setting may be fixed. When the optimizer can see where the value comes from, it can use the fixed value throughout the kernel and discard paths that can never execute. Another kernel built from the same runtime source may still need the read and both paths. The paper’s compilation examples illustrate this distinction with separate builds whose application code and compiler options select different pieces of runtime behavior.

The runtime is written in roughly 2000 lines of C++ with OpenMP directives for operations such as selecting where a variable lives. It uses no system headers and can be compiled for NVIDIA and AMD GPUs. The same source can also be compiled for CPU execution in a virtual GPU configuration. The authors use OpenMP 5.1 mechanisms for selecting function variants where an operation needs a target-specific implementation. This leaves the state management and work-sharing logic available to the compiler in a relatively consistent form across targets.

The procedure is driven by program analysis. Its inputs are the application code, the linked runtime, the target, and the compiler options. The optimizer uses information obtained from the code along with guarantees explicitly conveyed by the runtime or supplied through assumptions. The benchmark inputs are used later to run and measure the generated kernels. They play no role in learning which instructions to eliminate.

How the compiler specializes the OpenMP GPU runtime The steps in order.

#### Keep common settings in a team record

The runtime needs to represent whether a kernel executes in generic or SPMD mode. It uses a Boolean flag in static shared memory, with a copy belonging to each team. The main thread sets the flag at initialization, and the value is fixed for the rest of the execution. Initialization routines receive the mode by value so they can use it before the team reaches the barrier that makes the initialized shared state available to everyone. The mode is a small example of the overall design. Its representation preserves the semantics of a shared setting, while the path used to establish it gives the optimizer a chance to resolve it at compile time.

Other execution settings are kept in records for internal control variables, or ICVs. A team has a common ICV record in static shared memory, set up by the main thread. Threads consult that record whenever the team’s settings apply to them. The design anticipates that many target regions can use the team record throughout their execution. It also makes that common case recognizable to the compiler. If a team-wide value can be propagated to all its readers, even the common record may cease to be necessary in the final binary.

To support exceptions, the runtime reserves a shared array with an entry for each thread. An entry can point to the latest ICV record specific to that thread. Each thread initializes its entry to `NULL`, meaning that it should use the team record. A thread can need an individual record when it changes a setting that does not apply to the other active threads or enters a separate nested data environment. The runtime allocates a record at that point, copies the previous settings into it, and registers it in the list of records for that thread’s nested environments. The source for the copy can be either an earlier thread record or the team record.

The authors illustrate the mechanism with successive parallel constructs requesting `64`, `32`, and `16` threads. A condition selects the last thread at each enclosing level to reach the next construct. In the implementation described, the nested regions run sequentially, but entering them still creates new data environments. The runtime needs to track which settings belong to each environment. That example shows why eliminating parallel execution inside a nested region is insufficient to eliminate the region’s state. The compiler also needs evidence that the program cannot observe or change the settings that the runtime would otherwise preserve.

The paper treats this kind of nesting as costly in the current implementation. A nested region can both trigger individual record allocations and defeat the proof that no thread-specific records are created. If such a proof succeeds, each relevant pointer lookup can resolve to the team record. If the team record’s fields also have predictable values at their uses, the optimizer can substitute those values and remove both parts of the lookup.

#### Use a shared allocation stack where threads need common storage

The runtime provides a stack in team-shared memory for allocations that require visibility across threads. It initializes bookkeeping that tracks how each thread uses the stack. When the shared space is exhausted, the implementation can allocate memory in the GPU’s global memory through `malloc`. It also supports dynamic shared memory so the amount available can be set at runtime.

There are two reasons the implementation described in the paper uses this stack. The first is to store individual ICV records. The second is to accommodate variables from application code whose addresses may be used across threads. LLVM/Clang calls the latter process globalization. If the front end encounters a local variable that may need to be shared, it can place that variable in a shareable memory area. Private thread storage alone would be insufficient to implement that source behavior.

LLVM’s existing OpenMP optimization pass can remove some of these allocations. It looks for cases where a variable is private to a thread or where the main thread accesses it in isolation. If the optimization removes the application’s remaining requests for shareable allocations, and ICV analysis also removes the need to allocate thread records, the stack itself can be eliminated. That outcome depends on both users of the stack. Success in simplifying the runtime’s execution settings alone can still leave application variables that need shared storage. Likewise, proving that application variables are private can leave the stack in place for thread-specific runtime state.

This dependence is central to the co-design. Provisioning a stack lets the runtime handle programs whose sharing needs become apparent during execution. Giving the compiler a view of the reasons for provisioning it makes the same facility removable in simpler programs. The optimizer needs to reason about the objects each path uses and the instances in which those paths can execute.

#### Give each thread its part of the loop directly

A work-sharing loop is another point where the runtime can be made simpler for the compiler. Ordinarily, the compiler can generate separate scheduling calls for distribution across teams and work sharing within a team. The authors introduce a combined scheme that uses a thread’s position within its team and the team’s position in the grid to assign work. A grid is the collection of blocks launched for a kernel, and the block indices in the pseudocode correspond to the teams participating in the loop. The new scheduling interface departs from the API used by the OpenMP host runtime.

The paper gives pseudocode for the case without user-defined chunks. A chunk is a group of iterations treated as a unit for scheduling. In the pseudocode, the runtime works in a normalized iteration space, so it can assign a starting index and step through the space with a single stride. The first calculation establishes that stride.

```
TotalThreads = NumBlocks × NumThreads
```

`TotalThreads` is the number of threads across the participating blocks. `NumBlocks` counts those blocks, and `NumThreads` gives the number of threads in each. The multiplication sign `×` combines those quantities. The equals sign assigns their product to `TotalThreads`.

```
IV = BId × NumThreads + TId
```

`IV` is the normalized index for the thread’s initial iteration. `BId` is the index of the block, `NumThreads` is the block’s thread count, and `TId` is the index of the thread within that block. Multiplication gives the block’s starting position in the flattened sequence of threads. The plus sign adds the thread’s position within the block, and the equals sign assigns the result to `IV`.

```
IV < NumIters
```

`IV` is the index assigned to the thread at the current check. `NumIters` is the number of iterations in the normalized loop. The less-than operator tests whether the index falls below that upper bound. The runtime checks this condition before executing the thread’s initial iteration and uses it to determine whether there is further work after advancing the index.

```
IV ← IV + TotalThreads
```

On the right, `IV` is the index of the iteration just assigned, and `TotalThreads` is the stride through the normalized space. The plus sign advances the index by that stride. The arrow assigns the resulting index back to `IV`. Together, the starting index and the stride let each thread take its share of subsequent iterations when the first set of assignments does not cover the whole loop.

When the available threads cover the iteration space on the initial assignment, nobody needs to take a later stride. Threads whose starting index is beyond the bound still need to skip the body. The compiler can remove the repeated scheduling once it has the guarantee that each participant will execute at most one assignment. The scope of the guarantee depends on the directive. For sharing within a team, it concerns the threads of that team. For a combined distributed parallel loop, it concerns the participating threads across teams. The paper also distinguishes the team-level assumption for work distributed in blocks.

The authors expose assumptions about the amount of work through compiler options. An enabled option becomes a constant in the intermediate representation, which the compiler can propagate into the runtime’s scheduling routines. The pseudocode’s `OverSubscriptionAssumption` is the condition that allows scheduling to stop after the initial iteration. An assertion can check the guarantee in a build configured for that purpose. Simplification then eliminates the back edge of the scheduling loop and the values that would have to live from one iteration to the next. The underlying loop still performs the application’s calculation for the assigned index. It is the runtime’s repeated assignment of work that can disappear.

#### Prepare the kernel for whole-function analysis

The OpenMP optimization pass, called `openmp-opt`, is enabled by default starting in LLVM 12 and runs repeatedly at optimization level O1 or higher. Several existing capabilities help prepare the intermediate representation for the new analyses. One is internalization. The pass can create a copy of a function for use inside the compilation unit, so calls from kernels in that unit go to an implementation whose uses are easier to inspect. Some kinds of linkage prevent the transformation. In those cases, the compiler can emit an optimization remark.

Another existing capability converts eligible kernels from generic to SPMD mode. The optimizer examines code that the main thread would have run alone, including behavior reached through calls. If an operation has no side effects, threads can recompute it in parallel. Operations that need single-threaded execution can be placed behind a guard when the pass can establish that the approach preserves their meaning. This analysis determines whether the kernel can dispense with the worker state machine. Existing globalization elimination addresses the separate question of whether application variables need to remain in shareable memory.

The new optimizer uses LLVM’s Attributor infrastructure to propagate values across function boundaries, including values carried through memory. Ordinary constant folding covers an operation whose inputs are already known. The pass can also simplify a value selected according to which incoming control-flow path was taken if some paths turn out to be unreachable. The harder case is a value that one function stores in a shared object and another later reads. To substitute for that load, the optimizer needs to identify the object, determine which parts were accessed, and establish which writes could affect the read. For the analysis described in the paper to work, it needs inspectable objects, which include internal global variables, allocations on the stack, and memory that a recognized allocator returns.

#### Follow fields as byte ranges

A team ICV record may contain several settings written and read at different points. A compiler that treated every store into the record as a possible change to every setting would discard useful information. The authors’ analysis groups accesses by their constant byte offset from the underlying object and by the access size. If either the relevant position or the use is unknown, the analysis tracks it separately. A query about a particular read or write then asks which accesses could interfere with that byte range.

This approach gives the optimizer field sensitivity, the ability to reason independently about different parts of a record. It operates on actual byte ranges because LLVM’s intermediate representation does not guarantee that each access will respect a source-language field boundary. An access may partially overlap a field. One at the same offset and of the same size is an exact match for the compiler’s purposes. An access that shares some bytes with the requested range can be harder to resolve, and analyses frequently have to give up on the substitution. A store to a disjoint range can be excluded directly.

The thread-state pointer array illustrates a useful exception to the usual need for a known index. The index comes from the executing thread’s identity, which can remain unknown during compilation. Initialization puts null pointers across the array. If the compiler proves that all subsequent writes to it are irrelevant or unreachable, any slot a thread reads still has its initial zero representation. In that case the compiler can resolve a read to null without identifying the slot for that thread. Every such lookup can then take the branch that consults the team state. Eliminating the pointer reads can expose further opportunities to remove the array and the code that initializes it.

The field analysis can also help identify a store whose value is never used. Suppose an initialization writes one field, a later operation overwrites it, and the optimizer can establish that no intervening reader depends on the first value. The earlier store can become dead. Conversely, if only one relevant store can reach a read, its value may substitute for the read. Both deductions depend on more than the bytes involved. The optimizer also needs a sound account of the execution order.

#### Establish which write can reach a read

Reachability asks whether control can proceed from one point in a program to another. Dominance asks whether reaching a particular point requires passing through another point first. In a sequential setting, if a store cannot reach a load, the load cannot obtain its value from that store. If an intervening store always executes before the load, it can hide an earlier store to the same part of memory. These relationships let the compiler discard accesses that appear relevant when it looks only at their addresses.

The authors extend these queries across function calls. Two accesses can be in separate routines invoked by the same kernel, or they can be reached through different paths from a function that creates a stack object. The analysis can use a shared ancestor in the call graph as the point where it compares the call sites leading to the accesses. The lifetime of the memory identifies a suitable boundary. A stack object belongs to its allocating function and is unavailable to that function’s caller. Shared memory for a GPU kernel is unavailable to the kernel’s caller. The pass uses an ancestor associated with that lifetime to interpret the accesses in the same instance of the object.

The lifetime condition matters when a function can be reached through several routes or invoked repeatedly. Two syntactically similar stores can refer to different instances of an allocation. Conversely, two calls from different branches can operate on the same live object. The optimizer therefore has to account for loops, recursion, unknown callers and callees, and control flow with multiple entries into a region. When it cannot connect accesses through the required ancestor, it treats them as unrelated for the analysis described. Finding a common context lets it make reachability and dominance queries about the paths that lead to each access.

The propagation can also carry a value whose numeric result is unknown to the compiler. A GPU intrinsic that reads a grid dimension produces a value that is fixed during the kernel. A load that would retrieve that value from memory can sometimes use the intrinsic or an equivalent computation instead. In other cases the value being forwarded is a function argument or the result of an instruction. The optimizer must establish that the load sees the same dynamic instance of that value. A function without recursion or a global memory object with a single instance can provide evidence for such a deduction. This lets the analysis replace a memory operation even when compile-time constant folding is unavailable.

#### Represent broadcasts in a form the optimizer can understand

Some of the runtime’s shared settings are written by one thread and read by the rest. The writing thread updates the setting, and the team reaches a barrier before readers use it. A barrier is a synchronization point that prevents the participating threads from proceeding until the required arrivals have taken place. When the same barrier instruction is reached by all members of the team, the paper calls it aligned.

The authors show two ways to express a broadcast write. In the first, the condition on the thread ID guards the store itself. The destination is evident, but a conventional control-flow analysis sees a route to the barrier that skips the store. In the other, every thread executes the store instruction, and the condition selects its destination. The designated thread writes the setting, and the others use a dummy location. The runtime uses this form to avoid conditional execution of the store. Now the store instruction precedes the barrier on every path, but the analysis has to prove which address it targets for at least one thread.

The missing fact in both representations is that a thread with the designated ID takes part. The authors describe how knowledge of the thread IDs could eventually support that proof directly. Their implementation puts an assumption after the aligned barrier to say what value the synchronized memory now contains. The optimizer can treat that point as establishing the value for later reads. This is especially helpful for settings updated at the boundaries of structured regions such as `parallel`.

The paper’s example follows a field named `levels_var` in the team ICV record. It is initialized outside the parallel region, updated on entry, and set again on exit. The designated writer is the thread for which `tid` is `0`. The example’s values are `0` outside the region and `1` inside it. One of the post-barrier assumptions establishes the outside value as follows.

```
TeamICVState.levels_var == 0
```

`TeamICVState` is the team’s record of internal control variables. The dot selects its `levels_var` field. The equality operator `==` expresses the property the compiler may use, and `0` is the value asserted for that field after the broadcast in the example. The store and barrier implement the update. The assumption communicates its result to the optimizer so subsequent reasoning can start from the known field value.

The same facility is used for runtime invariants more generally. The authors provide a check that acts as an assertion when compiled with the relevant debugging support and supplies a compiler assumption in a release build. Debugging must be included at compilation and can then be activated at runtime. Separate settings control assertions and the tracing of runtime calls. The runtime also supplies the support needed for ordinary C and C++ assertions inside target regions. A release build makes the optional debugging paths unreachable at compilation, allowing the optimizer to discard them.

#### Account for concurrency and then remove barriers

Program order within a thread is an incomplete account of shared memory. A thread that stores a value and then reads the same location can encounter a value supplied by another thread if synchronization allows that other thread to intervene. The authors address this through analysis of where the main thread operates alone and where the team executes in an aligned context. Existing main-thread analysis already supported decisions about globalization. The new work also follows aligned execution across functions.

The paper distinguishes an aligned access from an aligned epoch. An access is aligned in the relevant direction if a preceding or succeeding aligned barrier is connected to it without another potentially synchronizing instruction intervening. In an aligned epoch, this property holds in both directions. The analyst can then use surrounding barriers to constrain which accesses can have taken place when a thread reaches a load. An annotation on the runtime’s inline assembly tells the optimizer that a particular instruction is an aligned barrier and that the assembly does not transfer execution to another function. This makes information about the synchronization visible even where the implementation uses instructions outside ordinary portable C++.

For stores made by the same main thread, the analysis can use the ordering supplied by that thread. The authors also establish conditions under which aligned non-atomic stores can be reasoned about in control-flow order. Their argument assumes that the accesses cannot race and accounts for loops and recursion. Informally, threads that reach the later store can be held just before it while other participants finish the earlier work they can do. That ordering makes it possible to reason about which store a subsequent load, dominated by both stores, can observe. The placement and behavior of barriers provide the restrictions on thread progress that the argument requires.

Reachability can also exclude a store for a load in an aligned epoch. Within the same interval between team barriers, a store that lies after the load on the relevant paths has no path back to change the value at that load. If a barrier separates the store and load, all participants must respect the boundary. The analysis uses the reachability of that boundary and the absence of other intervening synchronization to decide whether the store could matter. These are particular conditions under which sequential-style reasoning can be recovered for code executed concurrently.

Barriers themselves are candidates for removal after the memory transformations. The runtime and compiler put them around operations that may communicate across threads. A later optimization can turn a shared read into a known value or move an allocation into private storage. When two consecutive aligned barriers are in the same basic block and the instructions between them have no effects beyond the executing thread, the barrier pass can remove one. A basic block is a straight-line portion of the intermediate representation. Kernel entry and exit can serve as implicit aligned barriers in this comparison. That gives the compiler an opportunity to remove an otherwise explicit synchronization near either end of the kernel.

The aligned qualification is essential. Generic-mode workers can reach a barrier through divergent paths as they follow the state machine. Their synchronization may continue to coordinate work even when nearby instructions in a single block appear innocuous. The pass uses aligned barriers where the runtime can promise that the entire team arrives at the same instruction. Shared-state propagation and storage elimination can then simplify the code between those barriers until the redundancy is apparent to the compiler.

### Experiments and results

#### What the comparisons measure

The evaluation ran on an NVIDIA A100 in a server with an AMD EPYC 7532 host processor. The software environment used CUDA 11.4.0, and the authors collected kernel times with Nsight Compute CLI. The CUDA versions were compiled with NVCC 11.4. The OpenMP comparisons use an LLVM/Clang nightly build and the authors’ development version, with configurations that distinguish the old device runtime, the new runtime at different stages, and the effect of enabling assumptions. The paper identifies the compiler revisions and names the `IPDPS22` branch of the LLVM development repository as the location of the evaluated prototype.

The primary unit of comparison is the main GPU kernel of each scientific proxy application. A proxy keeps a computation of interest from a larger application in a form that can be studied separately. Here, the workloads range from cross-section lookups to lattice calculations and an irregular traversal. Their differences matter because runtime costs can interact with a kernel’s own demands on computation, memory, or control flow. Comparing device kernels helps the authors see the effects of individual changes in the generated device code.

The main performance figure normalizes results to the OpenMP implementation compiled with LLVM Nightly and the default GPU runtime. A value above `1` indicates higher performance than the reference, and a value below `1` indicates lower performance. The paper also reports the absolute time of the longest-running kernel and its shared-memory and register use. The normalized measure shows how implementations compare within a workload. The time and resource measurements help explain why a particular configuration might move relative to the reference. GridMini has a further comparison using throughput reported by the application, measured in GFlops/s, across lattice sizes.

These measures answer different questions. Time captures the overall behavior of the timed kernel, including the interactions of compiler transformations. Shared-memory use and register count describe resources used by the generated kernel. They can change without a corresponding change in measured time. The paper examines the metrics together because removing runtime state has practical value through both the instructions that disappear and the resources those instructions would have held.

#### Neutron transport lookups

XSBench and RSBench both represent continuous-energy neutron cross-section lookups associated with OpenMC. For the reported setup, XSBench is limited by memory behavior, while RSBench is an alternative implementation whose limiting work is computation. The pair gives the paper two cases from the same scientific setting in which the surrounding kernel places different demands on the GPU. For the OpenMP timings, the authors moved the reduction outside the timed kernel to make the scope of measurement correspond to the CUDA version.

XSBench improves appreciably in the latest development configuration. The authors report a `5%` performance difference from CUDA when the new device runtime is used with the assumptions enabled. That number describes the remaining gap under the reported configuration. The loop-scheduling assumptions also produce a reported reduction of `14` registers in XSBench, accompanied by a kernel-time change of `-5.6%`. The timing change is associated with enabling those assumptions in the OpenMP comparison. The CUDA gap describes a separate comparison between implementations.

The simplified scheduling code removes values that otherwise have to stay live as the runtime loop advances. It also removes a control-flow edge, which can expose further opportunities to the general optimizer. The authors observe lower register use and fewer control-flow conditions in other benchmarks as well, but little corresponding effect on their kernel times. XSBench therefore gives a case in which the assumption affects both generated code and measured time. The wider comparison shows why the resource result alone cannot predict the magnitude of the timing effect.

RSBench enters the evaluation with performance already close to CUDA. The development implementation and CUDA have essentially similar performance in the comparison reported by the authors. There is also a regression with the new runtime as it stood in the nightly build, resolved in the development branch used for the paper. RSBench shows the importance of identifying a particular compiler and runtime configuration when reporting how OpenMP performs. Its result also places the XSBench gain in context. The more elaborate runtime design can offer substantial benefits where old overhead is visible, while a benchmark already close to CUDA offers less room for improvement in the reported metric.

The separate XSBench optimization comparisons quantify two of the gains attributed to state analysis. Each row gives the improvement associated with the named change in its own comparison. The assumed-content result is an additional gain after the base analysis is present.

Reported XSBench kernel performance gains from runtime state analysis The base field analysis accounts for the larger reported gain.

**The numbers**

| System or setting | performance improvement % |
| --- | --- |
| Field-sensitive access analysis enabled (this paper) | 20 |
| Assumed memory content added | 10 |

#### Lattice throughput and an irregular traversal

GridMini represents part of Grid, a lattice quantum chromodynamics library. The computation runs on a discretized space-time lattice and exposes throughput as a function of the grid size `L`. The authors adjust the OpenMP version to pass the loop upper bound by value, bringing its input to the kernel closer to the CUDA version. The choice is pertinent to the method because a bound read from memory can leave an apparent side effect near a barrier and inhibit barrier removal.

With that adjustment, the development runtime reaches CUDA-like GridMini throughput. The paper reports a substantial improvement over the LLVM nightly and old-runtime alternatives and presents the throughput comparison across grid sizes. This measurement makes the scope of the GridMini result concrete. It concerns a scientific kernel whose arguments have been aligned with its CUDA counterpart, and it is seen through the throughput the application reports for that calculation.

MiniFMM represents an application of the fast multipole method to the Laplace equation. The proxy uses a dual-tree traversal, in which work is discovered through the traversal of two trees. The paper treats it as a case for dynamic task parallelism. Its role in the evaluation is therefore different from that of a proxy centered on a regularly distributed loop.

The new implementation reports a `1.85x` performance improvement over the old OpenMP runtime for MiniFMM. CUDA remains ahead in that comparison. The authors also encountered a race condition when using the nightly compiler with the new device runtime, which prevented them from profiling that configuration. The comparison with the old runtime still demonstrates a meaningful improvement for the proxy. The missing nightly profile limits what the experiment can establish about the transition from that intermediate configuration to the development one.

#### A molecular dynamics proxy with different kernel boundaries

TestSNAP exercises a force calculation used in LAMMPS molecular dynamics. The proxy provides synthetic neighbor-atom positions and reference forces for several settings, runs the calculation repeatedly, and checks its output against those references. It reports grind time in `msec/atomstep` and root-mean-square force error in `eV/A`. Grind time expresses the computational time per atom step, and the error measure compares calculated forces with the reference forces.

The authors could not establish a one-to-one mapping between the kernels in the OpenMP version and those in the supplied CUDA implementation, which used Kokkos. That distinction matters for a study centered on individual GPU kernels. A differently partitioned version can put part of the same calculation in another kernel. Timing kernels with dissimilar responsibilities would mix differences in the organization of the work with differences in runtime overhead. The kernel comparison figure consequently covers four proxies, while the workload discussion covers five.

Across the cases for which they report the relevant resource measurements, the authors associate much of the improvement with reductions in shared-memory and register use. The register findings for the loop assumptions also show why that observation needs the timing evidence alongside it. The compiler can eliminate bookkeeping and produce a smaller resource footprint in a configuration whose main scientific computation still takes about the same time. The performance claim is strongest where both the measured time and the analysis of the generated kernel support it.

### What the ablations show

#### Turn off compiler capabilities while keeping the runtime

The authors test GridMini, XSBench, and MiniFMM with individual optimization capabilities disabled. An ablation of this kind measures the behavior of a configuration with a particular part removed. Its interpretation depends on which other parts can still function. Here, the base field-sensitive access analysis supports other parts of conditional value propagation. Disabling it also removes the extensions for lifetime-aware reachability and dominance, assumed memory content, and invariant value propagation. Disabling one of those extensions leaves the underlying field analysis available.

That dependency affects how the changes should be read. The removal of the base is a test of a family of capabilities. The removal of an extension tests its contribution when the other available analyses remain in place. The figures therefore address what each configuration generates and how it runs. The effects can overlap because the transformations share information and can expose opportunities for each other. In particular, a successful replacement of a shared load can clear the way for later barrier elimination.

#### Two distinct sources of gain in XSBench

For XSBench, the authors attribute a `20%` performance improvement to field-sensitive access optimization. They report an additional `10%` from the optimization that supplies assumed memory content. The first comparison shows the value of reasoning about precise accesses to runtime objects. The second shows that the optimizer benefits from explicit knowledge of what a shared field contains after a broadcast. Together they fit the design of the runtime, where the designated writer and the barrier establish a state the compiler needs to recognize across the team.

The two percentages refer to different changes in the available analysis. They can be interpreted as evidence that the basic capability produces a substantial gain and that resolving broadcast state gives it further reach. The experiment does not itemize every memory instruction removed by each capability. A change in the availability of one analysis can affect subsequent code generation, including whether the compiler retains a value in a register or can remove a branch after resolving a read.

The scheduling-assumption comparison provides a complementary observation. Its effect on XSBench is visible in register use and in kernel time, and the paper connects it to deletion of the scheduling loop and its associated live values. Several other cases show code simplification with little timing change. Taken together, the comparisons let a reader distinguish an analysis that discovers which runtime state is unnecessary from a separate guarantee about how much loop work the participating threads need to take.

#### Different kernels need different parts of the optimizer

For MiniFMM, the authors trace the improvement to the basic field-sensitive optimization. They report no discernible performance effect from the other individual optimizations in that ablation. That finding supplies one explanation for the speedup over the old runtime. It does not allocate the remaining difference from CUDA to a specific cause. The setup also leaves the nightly configuration with the new runtime outside the profiled comparison because of its race condition.

For GridMini, the authors vary the grid size and plot application-reported GFlops/s with the different capabilities disabled. Most of the reported improvement comes from field-sensitive analysis and the optimizations that build on it. The analysis of exclusive and aligned execution and the elimination of aligned barriers also contribute to the configuration that reaches CUDA-like performance. The result is consistent with the order of transformations in the method. If accounting for shared state becomes simpler, fewer operations can stand between barriers. Proving facts about which threads reach those operations and how they synchronize helps the compiler take advantage of that simpler code.

The GridMini figure and the MiniFMM ablation suggest a workload-specific interpretation of compiler specialization. Both benefit from a better view of memory. GridMini’s throughput comparison also exposes a contribution from reasoning about synchronization. The paper’s overall configuration combines these capabilities so each kernel can benefit from the proofs available for its own structure.

### Limitations

#### Limits the authors identify

The authors deliberately leave the OpenMP reduction implementation outside the redesign. A reduction collects partial results from threads and combines them into a common value. Its implementation can involve its own storage and coordination. The paper neither evaluates its performance nor expects it to change much from the new runtime work. Moving the OpenMP reduction outside the timed neutron lookup kernel matches the scope of the corresponding CUDA timing. It also limits the result to the lookup work covered by that measurement.

The authors identify integration into community LLVM as unfinished at the time of writing. Parts of the implementation were available, and their development version contained changes that affected the results. The RSBench regression in the nightly implementation and its resolution in the development version give a concrete reason for that qualification. The MiniFMM race is another example of why the exact configuration matters. The measured timings and resource counts apply to the compiler builds used in the experiments.

Some overhead comes from the way arguments reach the kernel. The authors explain that aggregate types such as the XSBench configuration structure are passed by reference under the implementation’s restrictions. Accessing a member requires first obtaining the address of the structure, whereas passing the structure by value would make its members available through a different argument representation. The residual load is a calling-convention issue. Eliminating unnecessary ICV state by itself does not change it.

The authors also identify remaining barriers around parallel constructs when the loop bounds are loaded from memory. Even an invariant bound can leave a memory operation that the barrier pass treats as a relevant side effect. In GridMini they manually pass the bound into the target region by value before evaluating it. The paper says that addressing the corresponding bound issue for XSBench would bring its OpenMP register count into line with CUDA’s. That is the authors’ analysis of a possible improvement. The register and timing measurements for the evaluated XSBench configuration stand separately from it.

The common-case design depends on the compiler’s ability to recognize opportunities for SPMD execution and private storage. If a region retains generic execution, it can still require the worker state machine. If shared allocation remains necessary, it can still require the data-sharing stack. The authors provide optimization diagnostics for these cases. They also discourage nested parallel regions in the implementation described, since nesting incurs state allocation and can prevent complete elimination of the records. The retained runtime operations in richer cases are part of supporting those cases correctly.

#### Limits of what the experiment establishes

The runtime can be compiled for multiple targets, but the performance data come from one NVIDIA A100 setup. The portability claims concern the source design and the ability to compile for other targets. The performance measurements alone cannot establish that the same overheads, register changes, and speedups would occur on AMD hardware. They also provide no performance estimate for execution with the CPU virtual GPU. The mechanisms may apply to those targets, with the size of their effects left open by the evaluation.

The proxy workloads and their main kernels are a selected sample of scientific computation. Host scheduling, data movement, and synchronization between target tasks lie outside the timed kernel itself. Improvements at the kernel level can contribute to faster applications, but the study does not measure a corresponding end-to-end speedup for every application the proxies represent. GridMini’s adjusted argument passing and the treatment of the reductions in the neutron benchmarks also make the most direct comparisons specific to the workload boundaries and inputs the authors chose.

Even within the GPU measurements, CUDA is a benchmark-specific reference. TestSNAP illustrates why comparisons depend on where implementations place their kernel boundaries. MiniFMM illustrates a different constraint, where one build was unavailable for profiling. GridMini offers throughput measurements over a range of grid sizes, while the principal timing comparisons focus on selected kernels. These results explain how the runtime behaves in those configurations. They cannot establish a typical performance gap for applications with substantially different parallel constructs or allocation needs.

User-supplied loop assumptions have a further condition. The shortcut is correct while the available teams or threads cover the work in the way the assumption specifies. A change in the input or launch configuration may change that relationship. The runtime’s debug assertions offer a way to test such conditions in the configurations that are run with checking enabled. The results with assumptions therefore represent specialization under a guarantee supplied to the compiler. An ordinary build without that guarantee has to retain the scheduling path that allows participants to take further work.

Finally, the ablation separates some compiler capabilities within the new design. The experiment does not vary every element of the runtime architecture independently. The allocation strategy, state layout, representation of broadcast writes, and compiler analyses were developed together. Turning off an optimization can leave several pieces of code in place, and the dependency on field-sensitive analysis means an ablation of that capability also removes its extensions. The results identify where optimization matters for specific kernels without assigning an independent performance value to every design choice.

### What came after

No later citing work is identified for discussion. The paper’s account ends with the prototype, the parts then entering community LLVM, and the remaining work on argument passing, synchronization, and missed optimization opportunities.

## Cite

Cite as Johannes Doerfert, Atmn Patel, Joseph Huber, Shilei Tian, Jose M. Monsalve Diaz, Barbara Chapman and Giorgis Georgakoudis. 2022. Co-Designing an OpenMP GPU Runtime and Optimizations for Near-Zero Overhead Execution. Proceedings - IEEE International Parallel and Distributed Processing Symposium.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.1109/ipdps53621.2022.00055](https://doi.org/10.1109/ipdps53621.2022.00055)

```bibtex
@inproceedings{doerfert2022co,
  title = {{Co-Designing an OpenMP GPU Runtime and Optimizations for Near-Zero Overhead Execution}},
  author = {Johannes Doerfert, Atmn Patel, Joseph Huber, Shilei Tian, Jose M. Monsalve Diaz, Barbara Chapman and Giorgis Georgakoudis},
  booktitle = {Proceedings - IEEE International Parallel and Distributed Processing Symposium},
  year = {2022},
  doi = {10.1109/ipdps53621.2022.00055},
  url = {https://doi.org/10.1109/ipdps53621.2022.00055}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
