CuPBoP: CUDA for Parallelized and Broad-range Processors

Ruobing Han, Jun Chen, Bhanu Garg, Jeffrey Young, Jaewoong Sim, Hyesoon KimarXiv 2022 · DOI

Introduction

CUDA has long served as the industry standard for high-performance computing (HPC) and GPU programming. However, its proprietary nature locks developers into the NVIDIA ecosystem. As the hardware landscape evolves to include high-performance CPUs from ARM and emerging RISC-V platforms, the lack of portability for CUDA source code has created a significant "portability crisis."

Existing solutions, such as Intel’s DPCT or AMD’s HIPIFY, typically rely on source-to-source translation. These tools often struggle with complex C++ macros and NVIDIA-specific intrinsics, necessitating manual intervention. CuPBoP addresses this by providing a fully compiler-automated framework that executes unmodified CUDA source code on non-NVIDIA processors, including x86, ARM, and RISC-V, by operating at the compiler intermediate representation (IR) level.

System Architecture and Methodology

CuPBoP bypasses the complexities of source-level translation by working directly with LLVM/NVVM IR. This approach allows the framework to handle code after the compiler has resolved complex C++ definitions and macros. The system is divided into a compilation phase and a runtime phase.

The CuPBoP framework architecture, illustrating the compilation and runtime phases.

Compilation Phase: SPMD-to-MPMD

The core of the compilation phase is the transformation of CUDA’s Single Program Multiple Data (SPMD) model into a Multiple Program Multiple Data (MPMD) model suitable for CPUs. While GPUs manage thousands of tiny threads in hardware, CuPBoP wraps these workloads into explicit loops that a CPU can execute efficiently.

Comparison of kernel transformation strategies: CuPBoP uses explicit loops to handle synchronization.

This transformation also involves mapping GPU-specific memory hierarchies—such as shared and global memory—onto the CPU’s stack and heap. Additionally, the framework analyzes host code to insert necessary barriers, preventing race conditions in the shared memory space of the "virtual GPU."

Runtime Phase

To minimize execution overhead, CuPBoP employs a persistent thread pool and a task queue. A key optimization is "Coarse-grained Fetching," which allows CPU threads to fetch multiple blocks of work simultaneously. This reduces the synchronization bottleneck caused by frequent mutex locking, which is significantly more expensive on CPUs than on GPU hardware.

Evaluation Methodology

The effectiveness of CuPBoP was evaluated using several industry-standard benchmark suites:

  • Rodinia: A classic suite for heterogeneous computing.
  • Crystal: A high-performance GPU database implementation with complex SQL operators.
  • Hetero-Mark: A diverse set of kernels including AES encryption and K-Means clustering.
  • CloverLeaf: A real-world HPC "mini-app" for solving Euler equations.

Performance and Compatibility Results

CuPBoP demonstrates superior compatibility and performance across various architectures:

  • Compatibility: CuPBoP achieved 69.6% coverage on the Rodinia benchmark, significantly higher than the 56.6% achieved by existing frameworks. On the Crystal database benchmark, it supported 100% of queries, outperforming AMD’s HIP-CPU (76.9%).
  • ISA Support: The framework successfully executed CUDA code on x86 (Intel/AMD), AArch64 (ARM A64FX/Ampere), and RISC-V (SiFive) platforms.
  • Performance: On ARM and RISC-V devices, CuPBoP was approximately 30% faster than HIP-CPU. While it does not yet match the performance of manually optimized OpenMP code, it offers a viable automated path for running CUDA applications on diverse hardware.

Discussion and Key Insights

The transition from GPU to CPU reveals several critical insights:

  • IR-Level Transformation: Operating at the IR level is essential for reliability, as it avoids the "macro hell" of C++ source code.
  • Synchronization Costs: Software-based synchronization on CPUs is a major overhead. Aggressive coarse-grained fetching is vital to mitigate this "synchronization tax."
  • Memory Layout Challenges: GPU-optimized memory patterns (coalesced access) often result in strided access on CPUs, degrading cache performance. This "memory layout trap" suggests that future optimizations must include automatic memory reordering.

Conclusion and Future Work

CuPBoP represents a significant step toward breaking the NVIDIA lock-in for CUDA developers. While it provides broad compatibility, future work will focus on closing the performance gap by improving auto-vectorization for CPU SIMD instructions and implementing automatic memory reordering to better suit CPU cache hierarchies. Additionally, adding support for missing features like texture memory will further increase its coverage of complex HPC applications.

Summary updated

BibTeX
@misc{han2022cupbop,
  author = {Ruobing Han and Jun Chen and Bhanu Garg and Jeffrey Young and Jaewoong Sim and Hyesoon Kim},
  title = {{CuPBoP: CUDA for Parallelized and Broad-range Processors}},
  year = {2022},
  eprint = {2206.07896},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2206.07896},
}
Figure