|
| 1 | +# GPU Acceleration |
| 2 | + |
| 3 | +This section will teach you GPU programming in Julia, with a focus on using CUDA.jl and KernelAbstractions.jl. |
| 4 | + |
| 5 | +To run the notebooks on Perlmutter, please clone this repository if you haven't done so already: |
| 6 | + |
| 7 | +```sh |
| 8 | +git clone https://github.com/JuliaParallel/julia-hpc-tutorial-sc24 |
| 9 | +cd julia-hpc-tutorial-sc24 |
| 10 | +``` |
| 11 | + |
| 12 | +It is recommended to access the Jupyter notebook for this section through this website: |
| 13 | + |
| 14 | +[NERSC Jupyter notebook](https://jupyter.nersc.gov/) |
| 15 | + |
| 16 | +## Introduction to GPU Programming in Julia |
| 17 | + |
| 18 | +If you're looking for an introductory overview of GPU programming in Julia or GPU programming concepts in general, feel free to explore this [notebook](https://github.com/JuliaParallel/julia-hpc-tutorial-sc24/blob/main/parts/gpu/gpu_introduction.ipynb). |
| 19 | + |
| 20 | +## Heat Diffusion Simulation Using Julia |
| 21 | + |
| 22 | +This [notebook](https://github.com/JuliaParallel/julia-hpc-tutorial-sc24/blob/main/parts/gpu/heat-diffusion.ipynb) demonstrates the implementation of a 2D heat diffusion model using Julia, showcasing GPU acceleration with CUDA.jl and support for both CPU and GPU execution using KernelAbstractions.jl. It highlights efficient solutions for partial differential equations (PDEs). |
| 23 | + |
| 24 | +### Benchmarking Results |
| 25 | + |
| 26 | +The notebook presents a series of benchmarks comparing execution times across different configurations: |
| 27 | + |
| 28 | +1. **CPU Implementation** |
| 29 | + - Utilizes Julia's native array operations. |
| 30 | + - Serves as a baseline for performance comparison. |
| 31 | + |
| 32 | +2. **GPU Implementation with `CUDA.jl`** |
| 33 | + - Employs `CUDA.jl` for direct GPU programming. |
| 34 | + - Demonstrates significant speedup over the CPU version. |
| 35 | + |
| 36 | +3. **GPU Implementation with `KernelAbstractions.jl`** |
| 37 | + - Uses `KernelAbstractions.jl` to write code that can run on both CPU and GPU. |
| 38 | + - Offers flexibility with performance close to the `CUDA.jl` implementation. |
| 39 | + |
| 40 | +Here's the plot showing the benchmark results on a single A100 GPU in Perlmutter using problem of size `10240x10240` and number of time steps `2000`: |
| 41 | + |
| 42 | + |
| 43 | + <img src="img/benchmarking.png" alt="Benchmark Results" width="500"> |
| 44 | + |
| 45 | + |
| 46 | +### Key Takeaways |
| 47 | + |
| 48 | +- **Performance Gains:** GPU implementations, both with `CUDA.jl` and `KernelAbstractions.jl`, exhibit substantial performance improvements over the CPU version, highlighting the advantages of GPU acceleration for computationally intensive tasks like heat diffusion. |
| 49 | + |
| 50 | +- **Flexibility vs. Performance:** While `CUDA.jl` provides optimal performance for NVIDIA GPUs, `KernelAbstractions.jl` offers a more flexible approach, allowing code to run on multiple backends (CPU, GPU) with minimal changes, albeit with a slight performance trade-off. |
| 51 | + |
| 52 | +- **Ease of Use:** Both packages integrate seamlessly with Julia, enabling efficient development of high-performance applications without sacrificing code readability or maintainability. |
| 53 | + |
| 54 | + |
| 55 | +## Gray-Scott Reaction-Diffusion Model Using Julia |
| 56 | +This [notebook](https://github.com/JuliaParallel/julia-hpc-tutorial-sc24/blob/main/parts/gpu/gray-scott.ipynb) introduces Gray-Scott Reaction-Diffusion model using Julia. |
| 57 | + |
| 58 | +### Example Plots |
| 59 | + |
| 60 | +The notebook showcases the evolution of the Gray-Scott model over time, illustrating the intricate patterns generated by the reaction-diffusion process. Here are some example plots: |
| 61 | + |
| 62 | +<img src="img/gs-plain.png" alt="Benchmark Results" width="600"> |
| 63 | +<img src="img/gs-small.png" alt="Benchmark Results" width="600"> |
| 64 | +<img src="img/gs-funky.png" alt="Benchmark Results" width="600"> |
0 commit comments