This repository provides tutorials, demos, and analysis scripts for GPU programming, tailored for the Princeton CoDAS-HEP course. Materials are organized into modules covering CUDA basics, unified memory, streaming, profiling, HEP physics usecases and neural network demos.
Presentations:
-
Session 1 - https://1drv.ms/p/c/5a70ac10b7f66de0/EbfhsTCX3nZJjHrZLxds4tEB-xDZK00qdVukcO2Nc0b7Lg?e=3aYGxA
-
Session 2 - https://1drv.ms/p/c/5a70ac10b7f66de0/ERfEQVlc9P1Avl1ZHmfzGu8ByfAcnfC_iya-4LsfrViYXw?e=89gSlM
-
Session 3 - https://1drv.ms/p/c/5a70ac10b7f66de0/EaGidsT09EtFlgUtTcgQb4gBoWJmIyFjskZbDWFtlI0oUQ?e=78C8aH
-
01/ – Introductory CUDA C notebooks and exercises
- Presentations (
AC_CUDA_C_*.pptx) - Main tutorial notebook:
Session1.ipynb - Subfolders:
01-hello/to09-heat/: Step-by-step CUDA examples (hello world, parallelism, indices, loops, memory allocation, error handling, vector addition, matrix multiplication, heat conduction)edit/: Editable files for exercises
- Presentations (
-
02/ – Unified Memory tutorials
- Main notebook:
Session2_advanced.ipynb - Subfolders: Vector addition, device properties, page faults, prefetching, SAXPY example, and editable files
- Main notebook:
-
03/ – Streaming and Visual Profiling
- Main notebook:
Streaming and Visual Profiling.ipynb - Subfolders: Vector addition, kernel initialization, prefetch checks, stream introduction, manual memory allocation, overlap transfer, n-body simulation, and editable files
- Main notebook:
-
04/ – Additional CUDA modules
- Notebooks:
lesson-5-project.ipynb,lesson-5-workbook.ipynb,Session3_Python-GPU_HEP.ipynb
- Notebooks:
-
05/ – Generator tutorials
- Notebooks:
generator_tutorial_gpu.ipynb,generator_tutorial_gpu_annotated.ipynb
- Notebooks:
-
06/ – HEP analysis and demos
- Notebooks:
gpu_dd4hep_tilecal.ipynb - Documentation:
gpu_geant4_dd4hep_cuda_notebook.md - Tutorials:
particle_physics_generators_tutorial.ipynb
- Notebooks:
-
07/ – Neural Network Demos and Analysis Scripts
- Notebooks:
cuda_neural_network_demo_complete.ipynb - Scripts:
verify_notebook.py - Demos:
gpu-demo/
- Notebooks:
-
08/ – Miscellaneous challenges and verification
- Code:
01-nbody.cu - Notebook:
GPU challenge.ipynb
- Code:
Each module contains Jupyter notebooks (.ipynb) with explanations, code samples, and exercises. Topics include:
- CUDA programming basics
- Memory management (device, unified memory)
- Parallel algorithms (vector/matrix operations, heat conduction)
- Streaming and concurrency
- Profiling and performance analysis
- HEP event generation and analysis
- Neural network demos
07/verify_notebook.py:
Analyze notebook structure, extract code cells to files, and report statistics on content and coverage.
- The heat conduction CPU source code in
01/AC_CUDA_C.ipynbis credited to An OpenACC Example Code for a C-based heat conduction code from the University of Houston.
- Clone the repository.
- Open the notebooks in Jupyter or VS Code.
- Follow the step-by-step exercises in each module.
- Use the verification script to analyze or extract code from notebooks:
python 08/verify_notebook.py <notebook_path>
Refer to individual files and notebooks for licensing and attribution information.
For more details, explore the subfolders and notebooks in each module.