mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-10-13 00:08:26 +08:00
Release v13.3 of the CUDA samples with CUDA 13.3 Toolkit (#435)
This is the release of the CUDA 13.3 samples, which include additions for CUDA Tile C++, and updated CCCL and Python samples.
This commit is contained in:
@@ -33,13 +33,24 @@ Pick a CuPy wheel that matches your CUDA major version (e.g. `cupy-cuda13x` in `
|
||||
|
||||
## How to run
|
||||
|
||||
**`--cuda-include-dir` is required** (colon-separated list). Typical desktop layout:
|
||||
**`--cuda-include-dir` is required.** Multiple paths can be combined using the
|
||||
OS path separator (`:` on Linux/macOS, `;` on Windows).
|
||||
|
||||
Linux / macOS:
|
||||
|
||||
```bash
|
||||
python reductionMultiBlockCG.py \
|
||||
--cuda-include-dir /usr/local/cuda/include/cccl:/usr/local/cuda/include
|
||||
```
|
||||
|
||||
Windows (PowerShell or cmd, note the `;` separator and quotes around the
|
||||
combined value):
|
||||
|
||||
```powershell
|
||||
python reductionMultiBlockCG.py `
|
||||
--cuda-include-dir "$env:CUDA_PATH\include;$env:CUDA_PATH\include\cccl"
|
||||
```
|
||||
|
||||
**Jetson / split include trees:** pass every directory NVRTC needs in one `--cuda-include-dir` argument, e.g.
|
||||
`/usr/local/cuda/include/cccl:/usr/local/cuda/targets/sbsa-linux/include` (adjust paths to your image). If headers are scattered, you can instead merge them into one tree with symlinks and point `--cuda-include-dir` at that folder.
|
||||
|
||||
@@ -94,15 +105,15 @@ Summary
|
||||
======================================================================
|
||||
|
||||
Single-kernel two-stage reduction:
|
||||
Stage 1: 20 blocks → 20 partial sums
|
||||
grid.sync() ← All blocks synchronize (KEY innovation)
|
||||
Stage 2: Block 0 → 1 final result
|
||||
Stage 1: 20 blocks -> 20 partial sums
|
||||
grid.sync() <- All blocks synchronize (KEY innovation)
|
||||
Stage 2: Block 0 -> 1 final result
|
||||
Total: 1 kernel launch, 137.35 GB/s
|
||||
|
||||
Comparison:
|
||||
• Traditional: 2 kernel launches or kernel + CPU
|
||||
• This sample: 1 kernel with grid.sync() between stages
|
||||
• Benefit: Eliminates ~5-20μs launch overhead per stage
|
||||
• Benefit: Eliminates ~5-20us launch overhead per stage
|
||||
|
||||
======================================================================
|
||||
Single-Pass Multi-Block Reduction completed successfully!
|
||||
|
||||
@@ -238,8 +238,10 @@ def run(
|
||||
|
||||
# Compile kernel
|
||||
print("\nCompiling CUDA kernel...")
|
||||
# Support colon-separated multiple include paths
|
||||
include_paths = cuda_include_dir.split(":")
|
||||
# Support multiple include paths separated by the OS path separator
|
||||
# (':' on POSIX, ';' on Windows). os.pathsep avoids splitting Windows
|
||||
# drive prefixes like "C:\..." by accident.
|
||||
include_paths = cuda_include_dir.split(os.pathsep)
|
||||
program_options = ProgramOptions(
|
||||
std="c++17", arch=f"sm_{device.arch}", include_path=include_paths
|
||||
)
|
||||
@@ -295,7 +297,7 @@ def run(
|
||||
grid=(num_blocks, 1, 1),
|
||||
block=(threads_per_block, 1, 1),
|
||||
shmem_size=shared_mem_bytes,
|
||||
cooperative_launch=True,
|
||||
is_cooperative=True,
|
||||
)
|
||||
|
||||
n_u32 = np.uint32(num_elements)
|
||||
@@ -313,7 +315,7 @@ def run(
|
||||
|
||||
# Benchmark (CUDA events — not host wall clock around the whole loop)
|
||||
print(f"\n> Running benchmark ({test_iterations} iterations)...")
|
||||
event_options = EventOptions(enable_timing=True)
|
||||
event_options = EventOptions(timing_enabled=True)
|
||||
start_event = stream.device.create_event(options=event_options)
|
||||
end_event = stream.device.create_event(options=event_options)
|
||||
# cuda.core event elapsed time (end - start) is in milliseconds (CUDA API).
|
||||
@@ -362,15 +364,15 @@ def run(
|
||||
print("=" * 70)
|
||||
print(f"""
|
||||
Single-kernel two-stage reduction:
|
||||
Stage 1: {num_blocks} blocks → {num_blocks} partial sums
|
||||
grid.sync() ← All blocks synchronize (KEY innovation)
|
||||
Stage 2: Block 0 → 1 final result
|
||||
Stage 1: {num_blocks} blocks -> {num_blocks} partial sums
|
||||
grid.sync() <- All blocks synchronize (KEY innovation)
|
||||
Stage 2: Block 0 -> 1 final result
|
||||
Total: 1 kernel launch, {throughput_gb_s:.2f} GB/s
|
||||
|
||||
Comparison:
|
||||
• Traditional: 2 kernel launches or kernel + CPU
|
||||
• This sample: 1 kernel with grid.sync() between stages
|
||||
• Benefit: Eliminates ~5-20μs launch overhead per stage
|
||||
• Benefit: Eliminates ~5-20us launch overhead per stage
|
||||
""")
|
||||
|
||||
print("=" * 70)
|
||||
@@ -430,8 +432,9 @@ def main():
|
||||
type=str,
|
||||
required=True,
|
||||
help=(
|
||||
"CUDA include directory for NVRTC "
|
||||
"(can use colon-separated paths, e.g., /path1:/path2)"
|
||||
"CUDA include directory for NVRTC. "
|
||||
"Use os.pathsep to separate multiple paths "
|
||||
"(':' on POSIX, ';' on Windows)."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Install with: pip install -r requirements.txt
|
||||
|
||||
numpy>=2.3.2
|
||||
cuda-core>=0.6.0
|
||||
cuda-core>=1.0.0
|
||||
cuda-python>=13.0.0
|
||||
# Headers for NVRTC: cooperative_groups.h includes cuda/std/* (CCCL)
|
||||
cuda-cccl>=1.0.0
|
||||
|
||||
Reference in New Issue
Block a user