NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Lifting C Semantics for Dataflow Optimization

Alexandru Calotoiu, Tal Ben-Nun, Grzegorz Kwasniewski, Johannes de Fine Licht, Timo Schneider, Philipp Schaad, Torsten Hoefler · DOI

Abstract

C is the lingua franca of programming and almost any device can be programmed using C. However, programming modern heterogeneous architectures such as multi-core CPUs and GPUs requires explicitly expressing parallelism as well as device-specific properties such as memory hierarchies. The resulting code is often hard to understand, debug, and modify for different architectures. We propose to lift C programs to a parametric dataflow representation that lends itself to static data-centric analysis and enables automatic high-performance code generation. We separate writing code from optimizing for different hardware: simple, portable C source code is used to generate efficient specialized versions with a click of a button. Our approach can identify parallelism when no other compiler can, and outperforms a bespoke parallelized version of a scientific proxy application by up to 21%.

Introduction

High-performance computing (HPC) relies heavily on C for its low-level control. However, achieving peak performance on modern multi-core CPUs and GPUs often necessitates hardcoding architecture-specific optimizations using extensions like OpenMP or CUDA. This practice destroys portability and makes codebases difficult to maintain, as the optimization logic frequently obscures the underlying algorithm.

While auto-parallelizing compilers like Polly or Pluto exist, they are typically limited to programs with predictable, affine memory accesses. In real-world applications—such as sparse linear algebra or unstructured grid simulations—indirect memory accesses (e.g., A[col_idx[i]]) are ubiquitous. Traditional compilers conservatively assume data dependencies in these cases, failing to parallelize the code. This research introduces a workflow that shifts from a control-centric view to a data-centric one, automatically parallelizing complex C code without requiring manual annotations.

The Data-Centric Compilation Workflow

The core of this approach is the translation of unmodified C code into Stateful Dataflow Multigraphs (SDFGs) using the DaCe framework. SDFGs explicitly separate data containers, data movement (memlets), and computation (tasklets). This separation allows the compiler to reason about the global data movement of a program independently of its sequential control flow.

The end-to-end workflow from standard C to optimized parallel code via the SDFG representation.

The workflow involves several key stages: C-to-DaCe translation, dataflow coarsening, and dataflow optimization. Additionally, the system statically calculates the theoretical work and depth of the generated SDFG, providing an objective measure of the exposed parallelism before final code generation.

Overcoming Indirect Memory Accesses

To handle the challenges of indirect memory accesses, the compiler introduces novel static analysis passes. Instead of treating array indices as runtime unknowns, it converts them into mathematical symbols. By utilizing symbolic math engines (like SymPy), the compiler can track access sets and prove that certain indirect accesses do not overlap, safely unlocking parallel execution.

Transformation of a sparse matrix-vector multiplication kernel, showing index extraction and dataflow optimization.

Furthermore, the system detects associative read-modify-write operations (e.g., a[i] += b). By abstracting these as "updates" rather than separate reads and writes, the compiler can ignore false write-write conflicts. This allows for the transformation of serial loops into parallel maps with conflict resolution (e.g., atomic additions), mirroring the optimizations manually implemented by expert engineers.

Results and Evaluation

The approach was evaluated using the Polybench suite and the LULESH scientific proxy application.

  • Polybench: The data-centric compiler outperformed state-of-the-art tools like icc, gcc, and Pluto on 13 out of 30 tests. Notably, it successfully parallelized kernels like Sparse Matrix-Vector Multiplication (SpMV) where traditional polyhedral tools failed.
  • LULESH: In an unstructured grid application where traditional compilers like icc and Pluto found zero parallelizable loops, this workflow automatically identified and parallelized all 16 loops. The resulting code outperformed the manually-tuned OpenMP version by up to 21%, thanks to more scalable memory management and reduction schemes discovered through the SDFG representation.

Conclusion

By lifting C semantics into a data-centric representation, compilers can expose global data movement and parallelism hidden by sequential control flow. This approach proves that indirect accesses are not an insurmountable barrier to auto-parallelization. While currently limited by certain C features like function pointers or recursion, future work aims to extend this to C++, potentially automating optimization for a vast majority of performance-critical software.

Summary updated

BibTeX
@inproceedings{calotoiu2021lifting,
  author = {Alexandru Calotoiu and Tal Ben-Nun and Grzegorz Kwasniewski and Johannes de Fine Licht and Timo Schneider and Philipp Schaad and Torsten Hoefler},
  title = {{Lifting C Semantics for Dataflow Optimization}},
  booktitle = {ICS},
  year = {2021},
  doi = {10.1145/3524059.3532389},
}
Figure