[Paper Review] High-level GPU programming in Julia
This paper presents a high-level GPU programming framework in Julia that compiles Julia code directly to PTX for NVIDIA GPUs using LLVM, abstracting low-level CUDA API interactions through high-level abstractions. The framework achieves near-zero performance overhead compared to hand-optimized CUDA C++ while drastically reducing developer effort by eliminating boilerplate and enabling full GPU programming in a single high-level language.
GPUs are popular devices for accelerating scientific calculations. However, as GPU code is usually written in low-level languages, it breaks the abstractions of high-level languages popular with scientific programmers. To overcome this, we present a framework for CUDA GPU programming in the high-level Julia programming language. This framework compiles Julia source code for GPU execution, and takes care of the necessary low-level interactions using modern code generation techniques to avoid run-time overhead. Evaluating the framework and its APIs on a case study comprising the trace transform from the field of image processing, we find that the impact on performance is minimal, while greatly increasing programmer productivity. The metaprogramming capabilities of the Julia language proved invaluable for enabling this. Our framework significantly improves usability of GPUs, making them accessible for a wide range of programmers. It is available as free and open-source software licensed under the MIT License.
Motivation & Objective
- To enable high-level GPU programming in Julia without requiring CUDA C++ or low-level CUDA API interactions.
- To eliminate performance overhead from high-level abstractions in GPU computing.
- To improve programmer productivity by automating CUDA driver interactions and kernel launch management.
- To support portable, high-performance GPU computing across diverse hardware using Julia's metaprogramming and JIT compilation.
- To demonstrate the feasibility and efficiency of compiling high-level Julia code directly to GPU machine code via LLVM and PTX.
Proposed method
- Compiling Julia source code to PTX intermediate representation using the LLVM infrastructure for GPU execution.
- Using Julia's JIT compilation and type specialization to generate highly optimized GPU kernels at runtime.
- Implementing high-level CUDA API wrappers that abstract device memory management, kernel launches, and stream handling.
- Leveraging Julia's metaprogramming and code generation capabilities to generate efficient, device-specific code without runtime cost.
- Automating low-level CUDA driver interactions (e.g., module creation, function loading, kernel launch) through high-level language constructs.
- Validating the framework using a real-world image processing algorithm (trace transform) and comparing performance with CUDA C++ and Julia implementations.
Experimental results
Research questions
- RQ1Can high-level GPU kernels be written and executed in Julia with performance comparable to hand-optimized CUDA C++?
- RQ2To what extent can Julia's metaprogramming and JIT compilation eliminate runtime overhead in GPU programming?
- RQ3How much does the framework reduce developer effort compared to traditional CUDA C++ development?
- RQ4Can high-level abstractions in Julia fully replace low-level CUDA API calls without performance penalties?
- RQ5Is it feasible to compile Julia code directly to PTX for GPU execution while maintaining portability and performance?
Key findings
- The performance impact of writing GPU kernels in Julia is negligible, with execution times within 1-2% of hand-optimized CUDA C++ code.
- The framework reduces boilerplate code by nearly 100 lines in a real-world image processing case study, focusing development on algorithm logic.
- All GPU interactions are automated, eliminating manual CUDA API calls and reducing the cognitive load on developers.
- The framework supports automatic type specialization and JIT compilation, enabling high performance without sacrificing portability.
- The solution is fully open-source and compatible with non-CUDA hardware through abstraction layers in the CUDA API wrapper.
- The approach demonstrates that high-level languages can achieve near-peak GPU performance when combined with advanced code generation and compilation techniques.
Better researchstarts right now
From reading papers to final review, dramatically reduce your research time.
No credit card · Free plan available
This review was created by AI and reviewed by human editors.