English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Open-Source CUDA Compatibility Layers: Project Comparison and Usability Analysis

Forum topic · ✨步子哥 · 2026-04-19

Summary

CUDA is the dominant GPU computing platform but runs only on NVIDIA hardware, creating vendor lock-in. This article compares major open-source and notable commercial projects that aim to run CUDA code on non-NVIDIA GPUs. Runtime compatibility layers like ZLUDA intercept CUDA driver API calls and redirect them to AMD ROCm, letting unmodified CUDA binaries run on AMD GPUs; ZLUDA 5 adds an offline PTX compiler (zoc) and initial support for llama.cpp and llm.c. Source-level approaches include AMD's HIP and HIPIFY, the most mature option, which translates CUDA code with minimal changes and achieves near-native performance, though it cannot handle closed-source binaries. BarraCUDA is an ambitious from-scratch CUDA compiler written in pure C99 with no LLVM dependency, targeting AMD RDNA GPUs, but remains in early development. CU2CL, an academic prototype translating CUDA to OpenCL, supports only legacy CUDA 3.2-era features. The commercial SCALE compiler by Spectral Compute compiles CUDA directly to multiple GPU backends, reporting API coverage of 47% runtime, 22% driver, and 80% math APIs, and in some Rodinia benchmarks outperforms HIP by up to 6x. The analysis covers compatibility, performance, ecosystem support, and legal considerations, concluding that a diverse GPU computing future depends on these complementary approaches.

Background: The CUDA Ecosystem and Compatibility Needs

CUDA, NVIDIA's parallel computing platform released in 2007, dominates GPU-accelerated computing thanks to its mature ecosystem and deeply optimized libraries such as cuBLAS and cuDNN. However, CUDA runs exclusively on NVIDIA hardware, creating vendor lock-in: AMD and Intel GPUs cannot directly execute CUDA programs, limiting software portability and hardware choice.

To break this barrier, the open-source community and vendors have explored CUDA compatibility layers and porting solutions. These fall into two broad categories:

  • Runtime compatibility layers — intercept and redirect CUDA runtime/driver API calls so existing CUDA binaries run unmodified on non-NVIDIA GPUs.
  • Source porting / compiler solutions — translate CUDA source to another GPU programming model (HIP, OpenCL) or compile it directly to target GPU machine code.
  • Project Overview

    ZLUDA: CUDA Runtime on Non-NVIDIA GPUs

    ZLUDA lets CUDA applications run on AMD GPUs without source modification by intercepting driver API calls (e.g., cuMemAlloc, cuLaunchKernel) and redirecting them to AMD ROCm/HIP. Initially funded by AMD, the project was halted over legal concerns, then revived and open-sourced by the community.

  • Supports much of the CUDA 12.x runtime, including memory management, streams, events, and cuBLAS Level-1/2/3 functions; cuDNN support is still pending.
  • ZLUDA 5 introduced the offline PTX compiler zoc (compiling PTX to AMD GPU machine code) and the zluda_trace API tracing tool.
  • Achieved initial support for llama.cpp and llm.c, marking a breakthrough for AI workloads; its llama.cpp performance is reportedly on par with native ROCm.
  • Advanced features like multi-GPU parallelism, virtual memory management, and PyTorch/cuDNN-dependent frameworks remain works in progress.
  • BarraCUDA: A From-Scratch CUDA Compiler

    BarraCUDA aims to write a CUDA C++ compiler from scratch — no NVIDIA toolchain, no LLVM — implemented entirely in C99. The pipeline includes preprocessing, lexing, recursive-descent parsing, semantic analysis, an intermediate representation (BIR), instruction selection, and register allocation, ultimately emitting AMD RDNA binaries (also able to emit PTX or Tenstorrent Tensix C++).

  • Supports core CUDA features: __global__/__device__ functions, thread-hierarchy built-ins, shared memory, synchronization, atomics, warp shuffle, most math functions, cooperative groups, and constant memory.
  • Successfully compiled and ran classic CUDA examples (vector addition, matrix multiplication), proving the approach is viable.
  • Still early-stage: limited CUDA 12 features, no dynamic parallelism, streams, or cuBLAS/cuDNN; only basic support for complex C++ features like template instantiation.
  • HIP and HIPIFY: AMD's CUDA Porting Path

    HIP is a CUDA-superset programming model offering source-level (not binary) compatibility. Code written once in HIP compiles via hipcc to either NVIDIA (CUDA backend) or AMD (ROCm backend) targets. The HIPIFY tool automatically converts CUDA source to HIP (e.g., cudaMalloc → hipMalloc), supporting most CUDA 12.9.1 APIs including new FP4/FP6/FP128 types.

  • The most mature and widely adopted option: used by MIOpen, rocBLAS, and for porting PyTorch and TensorFlow to AMD GPUs.
  • Performance typically close to native CUDA due to compiler optimization.
  • Limitations: requires recompilation (cannot run closed-source CUDA binaries); not a perfect match for CUDA-specific features (e.g., certain cuDNN algorithms, OptiX).
  • CU2CL: CUDA-to-OpenCL Source Translation

    CU2CL is an academic prototype (circa 2016) that auto-translates CUDA source to OpenCL using the Clang framework, converting kernels to __kernel functions and mapping syntax like <<<...>>> and __shared__ to OpenCL equivalents while generating host-side OpenCL code.

  • Supports most CUDA 3.2-and-earlier runtime APIs and kernel features; lacks dynamic parallelism, texture memory, CUDA-OpenGL interop, templates, and cuBLAS/cuDNN.
  • Mainly of academic reference value; converted code usually needs significant manual fixing, and it does not support modern CUDA versions.
  • SCALE: A Commercial Cross-Platform CUDA Compiler

    SCALE, by Spectral Compute, is a commercial (not open-source) LLVM-based compiler that compiles CUDA source directly to multiple GPU architectures — "write once, run anywhere." It generates both NVIDIA PTX and AMD GCN/RDNA code and provides Drop-in Libraries replacing CUDA runtime calls at link time.

  • Reported API coverage: 47% runtime API, 22% driver API, 80% math API.
  • Claims performance on AMD GPUs approaching or exceeding HIP — in some Rodinia benchmarks up to 6x faster.
  • Handles inline PTX assembly with validation and diagnostics for cross-platform reliability.
  • Free for non-commercial use; commercial use requires a license.
  • Usability and Performance Analysis

    Runtime compatibility (ZLUDA) shines for zero-modification migration of existing binaries, e.g., running AI inference frameworks on AMD GPUs immediately. Performance depends on ROCm maturity; the gap with native CUDA is narrowing, but support for the newest CUDA 12.8+ APIs lags.

    Source-level approaches (HIP / BarraCUDA / SCALE) target near-native performance:

  • HIP offers the broadest CUDA compatibility and near-native performance, making it the de facto official path.
  • SCALE claims several-fold speedups over HIP on some benchmarks, though within a limited supported feature set.
  • BarraCUDA has performance potential via direct machine-code generation but has published no detailed performance data yet.
Key trade-offs across all solutions: closed-source binaries only work with runtime layers; API coverage and CUDA 12 feature support vary widely; ecosystem (cuDNN, cuBLAS) support determines whether deep learning frameworks actually run.

Conclusion: Toward a Diverse GPU Computing Future

Each project takes a distinct technical route toward the same goal — breaking CUDA's vendor lock-in. ZLUDA lowers migration barriers at the binary level, HIP/HIPIFY provides the most production-ready source-level path, BarraCUDA demonstrates that an independent compiler free of NVIDIA's EULA and LLVM is feasible, CU2CL offers historical lessons, and SCALE shows commercial investment can achieve near-native cross-vendor performance. Together they signal a more pluralistic future for GPU computing, though all still trail full CUDA compatibility and require continued development to keep pace with CUDA's rapid evolution.

> Note: Figures 1–2 in the original post are charts comparing SCALE's API coverage (47% runtime / 22% driver / 80% math) and HIP vs. SCALE performance on Rodinia benchmarks (illustrative).

Tags

#cuda#zluda#hip#rocm#amd#gpu-computing#open-source#compiler

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/177618574