agent/: greppable offline docs, and a chapter-level guide to NVIDIA's documentation
Browse filesPDFs dropped. A 700-page reference you cannot grep is not useful offline, so the fetcher now emits greppable text -- 7 documents, ~11 MB instead of 36 MB, with code examples keeping their indentation.
ref/official-docs.md is now a working guide: what each official document contains chapter by chapter, with section numbers read out of the CUDA 12.8 documents themselves. Includes a routing table from question to chapter, and the two things not to look up on the web -- device properties (query them) and runtime API signatures (grep the installed headers).
search_docs.sh greps the fetched corpus and falls back to the CUDA headers. Verified with --network none: wgmma syntax, fence.proxy.async ordering, and the cuTensorMapEncodeTiled signature all resolve offline.
The documents themselves remain un-redistributable and are not included; each user fetches their own copy from NVIDIA under NVIDIA's terms.
- agent/README.md +9 -7
- agent/SKILL.md +1 -1
- agent/ref/official-docs.md +172 -61
- agent/tools/_html2txt.py +70 -0
- agent/tools/fetch_nvidia_docs.sh +38 -51
- agent/tools/search_docs.sh +34 -0
|
@@ -43,7 +43,7 @@ faster", "implement a fused attention kernel", or "solve this KBench task".
|
|
| 43 |
| `ref/cuda-cpp.md` | CUDA C++: opt-in shared memory, `cuda::pipeline`, cooperative groups, clusters/DSMEM, host-side TMA descriptors, build and debug flags |
|
| 44 |
| `ref/triton.md` | the Triton 3.6 API surface, launch knobs, idioms, and where it caps out |
|
| 45 |
| `ref/cute-cutlass.md` | CuTe layout algebra, swizzles, atoms, and where CUTLASS lives in the image |
|
| 46 |
-
| `ref/official-docs.md` |
|
| 47 |
|
| 48 |
**These are verified, not recalled.** Every instruction and API was compiled with the container's own
|
| 49 |
`nvcc` on `sm_90a` / CUDA 12.8: 39/41 PTX instructions assemble (the two that do not are recorded —
|
|
@@ -71,12 +71,14 @@ in `ref/triton.md`.
|
|
| 71 |
- **`check_toolchain.py`** — re-derives every table in `ref/` by compiling on the machine you are
|
| 72 |
actually on. The docs were verified on sm_90a / CUDA 12.8; on a different GPU or toolkit some rows
|
| 73 |
change, and this tool wins over the docs.
|
| 74 |
-
- **`fetch_nvidia_docs.sh`** — downloads NVIDIA's official CUDA/PTX guides
|
| 75 |
-
**
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
| 80 |
- **`ledger.md`** — one row per variant. The column that matters records whether an abandoned variant
|
| 81 |
was *slower* or merely *broken*; dropping a good optimization over a fixable bug is the most common
|
| 82 |
way to leave 2x on the table.
|
|
|
|
| 43 |
| `ref/cuda-cpp.md` | CUDA C++: opt-in shared memory, `cuda::pipeline`, cooperative groups, clusters/DSMEM, host-side TMA descriptors, build and debug flags |
|
| 44 |
| `ref/triton.md` | the Triton 3.6 API surface, launch knobs, idioms, and where it caps out |
|
| 45 |
| `ref/cute-cutlass.md` | CuTe layout algebra, swizzles, atoms, and where CUTLASS lives in the image |
|
| 46 |
+
| `ref/official-docs.md` | a working guide to NVIDIA's own documentation: what each guide contains, chapter by chapter, which one answers which question, version matching, and the licence position |
|
| 47 |
|
| 48 |
**These are verified, not recalled.** Every instruction and API was compiled with the container's own
|
| 49 |
`nvcc` on `sm_90a` / CUDA 12.8: 39/41 PTX instructions assemble (the two that do not are recorded —
|
|
|
|
| 71 |
- **`check_toolchain.py`** — re-derives every table in `ref/` by compiling on the machine you are
|
| 72 |
actually on. The docs were verified on sm_90a / CUDA 12.8; on a different GPU or toolkit some rows
|
| 73 |
change, and this tool wins over the docs.
|
| 74 |
+
- **`fetch_nvidia_docs.sh`** / **`search_docs.sh`** — downloads NVIDIA's official CUDA/PTX guides as
|
| 75 |
+
**greppable text** (~11 MB) and searches them offline. The documents are **not bundled here**:
|
| 76 |
+
NVIDIA's documentation is copyrighted and the CUDA EULA distributes only the runtime libraries listed
|
| 77 |
+
in its Attachment A, which does not include documentation — so you fetch your own copy under NVIDIA's
|
| 78 |
+
terms. Task containers have network at image-build time and none at run time, so a Dockerfile `RUN`
|
| 79 |
+
step puts the guides inside an offline container. It auto-matches your CUDA version, which matters:
|
| 80 |
+
the live docs always serve the newest CUDA, and 12.8 wants PTX ISA 8.7, not the 9.3 now published.
|
| 81 |
+
PDFs are deliberately not fetched — a 700-page reference you cannot grep is not useful offline.
|
| 82 |
- **`ledger.md`** — one row per variant. The column that matters records whether an abandoned variant
|
| 83 |
was *slower* or merely *broken*; dropping a good optimization over a fixable bug is the most common
|
| 84 |
way to leave 2x on the table.
|
|
@@ -20,7 +20,7 @@ as you hit the corresponding phase. Tools are in `tools/`.
|
|
| 20 |
| `ref/cuda-cpp.md` | CUDA C++: opt-in shared memory, pipelines, cooperative groups, clusters, TMA descriptors, build flags |
|
| 21 |
| `ref/triton.md` | Triton 3.6 API surface, launch knobs, idioms, and the traps |
|
| 22 |
| `ref/cute-cutlass.md` | CuTe layout algebra and where CUTLASS lives in the image |
|
| 23 |
-
| `ref/official-docs.md` | NVIDIA's own
|
| 24 |
|
| 25 |
Every instruction and API in `ref/` was verified by compiling it on the container toolchain (sm_90a,
|
| 26 |
CUDA 12.8) — but **you may not be on that machine**. Run `python3 tools/check_toolchain.py` to
|
|
|
|
| 20 |
| `ref/cuda-cpp.md` | CUDA C++: opt-in shared memory, pipelines, cooperative groups, clusters, TMA descriptors, build flags |
|
| 21 |
| `ref/triton.md` | Triton 3.6 API surface, launch knobs, idioms, and the traps |
|
| 22 |
| `ref/cute-cutlass.md` | CuTe layout algebra and where CUTLASS lives in the image |
|
| 23 |
+
| `ref/official-docs.md` | NVIDIA's own documentation, chapter by chapter: which guide answers which question, and how to consult them offline |
|
| 24 |
|
| 25 |
Every instruction and API in `ref/` was verified by compiling it on the container toolchain (sm_90a,
|
| 26 |
CUDA 12.8) — but **you may not be on that machine**. Run `python3 tools/check_toolchain.py` to
|
|
@@ -1,89 +1,200 @@
|
|
| 1 |
-
# NVIDIA official documentation —
|
| 2 |
|
| 3 |
-
The
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
> CUDA EULA: <https://docs.nvidia.com/cuda/eula/>
|
| 9 |
|
| 10 |
-
|
| 11 |
-
files enumerated in its **Attachment A** — runtime libraries such as `libcudart.so`, `cufft.dll` — and
|
| 12 |
-
documentation does not appear there. §1.2.5 separately prohibits using the SDK in a way that would make
|
| 13 |
-
it subject to a licence requiring it be "redistributable at no charge", which is what publishing it in
|
| 14 |
-
an open dataset would do. The documents are also no longer shipped inside the toolkit: `$CUDA_HOME/DOCS`
|
| 15 |
-
says so and points at docs.nvidia.com.
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
```
|
| 20 |
-
|
| 21 |
-
tools/fetch_nvidia_docs.sh /opt/nvidia-docs 12.8.0 # or pin it
|
| 22 |
```
|
| 23 |
|
| 24 |
-
|
| 25 |
-
build` and none at run time:
|
| 26 |
|
| 27 |
-
```
|
| 28 |
-
|
|
|
|
| 29 |
```
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
`https://docs.nvidia.com/cuda/archive/<version>/…`.
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
##
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
|---|---|
|
| 49 |
-
|
|
| 50 |
-
|
|
| 51 |
-
| Exact syntax/semantics of a PTX instruction, its modifiers and which `.target` it needs | **PTX ISA** — <https://docs.nvidia.com/cuda/parallel-thread-execution/> |
|
| 52 |
-
| How do I write inline PTX, and what do the operand constraints mean? | **Inline PTX Assembly** — <https://docs.nvidia.com/cuda/inline-ptx-assembly/> |
|
| 53 |
-
| What is different about Hopper — clusters, TMA, wgmma, DSMEM? | **Hopper Tuning Guide** — <https://docs.nvidia.com/cuda/hopper-tuning-guide/> |
|
| 54 |
-
| Exact signature/semantics of a runtime call | **CUDA Runtime API** — <https://docs.nvidia.com/cuda/cuda-runtime-api/> |
|
| 55 |
-
| What does this `ncu` metric mean? Which section reports it? | **Nsight Compute Profiling Guide** — <https://docs.nvidia.com/nsight-compute/ProfilingGuide/> |
|
| 56 |
-
| `ncu` command-line flags, `--replay-mode`, filtering kernels | **Nsight Compute CLI** — <https://docs.nvidia.com/nsight-compute/NsightComputeCli/> |
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
-
container toolchain, so they tell you what actually works *here*. The official documents are the
|
| 65 |
-
**authority on semantics** — what an instruction means, every modifier it accepts, the precise memory
|
| 66 |
-
ordering it guarantees.
|
| 67 |
|
| 68 |
-
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
- *"What exactly does `.multicast::cluster` do to the mbarrier transaction count?"* → PTX ISA.
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
|
| 77 |
-
|
| 78 |
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|---|---|---|
|
| 83 |
-
|
|
| 84 |
-
|
|
| 85 |
-
|
|
| 86 |
-
|
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NVIDIA official documentation — a working guide for agents
|
| 2 |
|
| 3 |
+
The other files in `ref/` are verified summaries of what *works*. This file is about the **authorities**:
|
| 4 |
+
what each official document contains, which chapter answers which question, and how to consult them with
|
| 5 |
+
no internet.
|
| 6 |
|
| 7 |
+
Section numbers below were read out of the **CUDA 12.8** documents, the version in the task containers.
|
| 8 |
|
| 9 |
+
---
|
|
|
|
| 10 |
|
| 11 |
+
## 1. Getting them offline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
Task containers have network at **image build time** and none at run time. So fetch during the build:
|
| 14 |
|
| 15 |
+
```dockerfile
|
| 16 |
+
RUN bash fetch_nvidia_docs.sh /opt/nvidia-docs 12.8.0
|
|
|
|
| 17 |
```
|
| 18 |
|
| 19 |
+
or by hand:
|
|
|
|
| 20 |
|
| 21 |
+
```bash
|
| 22 |
+
tools/fetch_nvidia_docs.sh /opt/nvidia-docs # auto-matches your CUDA version
|
| 23 |
+
KDOCS=/opt/nvidia-docs tools/search_docs.sh "mbarrier.arrive.expect_tx"
|
| 24 |
```
|
| 25 |
|
| 26 |
+
The fetcher writes `<name>.html` and **`<name>.txt`** per document (~11 MB total). The `.txt` is the one
|
| 27 |
+
that matters: a 700-page reference is only usable offline if you can `grep` it. Code examples keep their
|
| 28 |
+
indentation, so a worked TMA example reads correctly.
|
| 29 |
|
| 30 |
+
**PDFs are deliberately not fetched.** They cannot be grepped, are read in 20-page slices, and cost
|
| 31 |
+
~30 MB for no capability you do not already have.
|
|
|
|
| 32 |
|
| 33 |
+
**If you have no fetched corpus**, you are not stuck — `ref/ptx.md`, `ref/cuda-cpp.md`, `ref/triton.md`
|
| 34 |
+
and `ref/cute-cutlass.md` cover the working set, `tools/check_toolchain.py` tells you what compiles, and
|
| 35 |
+
`$CUDA_HOME/include` has the headers.
|
| 36 |
+
|
| 37 |
+
### Licence — why the documents are not in this repo
|
| 38 |
+
|
| 39 |
+
> © NVIDIA Corporation. All rights reserved. CUDA EULA: <https://docs.nvidia.com/cuda/eula/>
|
| 40 |
|
| 41 |
+
NVIDIA's documentation is copyrighted and **not redistributable**. The EULA distributes only what its
|
| 42 |
+
**Attachment A** enumerates — runtime libraries such as `libcudart.so` — and documentation is not in that
|
| 43 |
+
list. §1.2.5 separately forbids using the SDK in a way that subjects it to a licence requiring it be
|
| 44 |
+
"redistributable at no charge". You fetch your own copy under NVIDIA's terms; do not re-publish it.
|
| 45 |
|
| 46 |
+
### Match the version to your toolkit
|
| 47 |
|
| 48 |
+
`docs.nvidia.com/cuda/` always serves the **newest** CUDA. Archives live at
|
| 49 |
+
`docs.nvidia.com/cuda/archive/<version>/`.
|
| 50 |
+
|
| 51 |
+
| toolkit | PTX ISA |
|
| 52 |
|---|---|
|
| 53 |
+
| CUDA 12.8 (KBench containers) | **8.7** |
|
| 54 |
+
| current live docs | 9.3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
Reading 9.3 while compiling with 12.8 is how you reach for an instruction `ptxas` rejects with
|
| 57 |
+
*"not supported on target"*.
|
| 58 |
|
| 59 |
+
---
|
| 60 |
|
| 61 |
+
## 2. CUDA C++ Programming Guide — the semantics authority
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
+
22 chapters. The reference for *what a construct means*. Four chapters carry almost everything a kernel
|
| 64 |
+
author needs.
|
| 65 |
|
| 66 |
+
**§2 Programming Model** — thread/block/cluster/grid hierarchy, memory spaces, the fact that blocks are
|
| 67 |
+
scheduled in **no guaranteed order**. Read the cluster part before writing anything Hopper-specific.
|
|
|
|
| 68 |
|
| 69 |
+
**§5 Performance Guidelines** — the official statement of the three levers: maximize utilization,
|
| 70 |
+
maximize memory throughput, maximize instruction throughput. Where coalescing rules are stated normatively.
|
| 71 |
|
| 72 |
+
**§7 C++ Language Extensions** — the chapter you will actually live in. 43 sections; the ones that matter:
|
| 73 |
|
| 74 |
+
| § | topic | why you care |
|
| 75 |
+
|---|---|---|
|
| 76 |
+
| 7.5 | Memory Fence Functions | `__threadfence*`, and what ordering each actually guarantees |
|
| 77 |
+
| 7.6 | Synchronization Functions | `__syncthreads`, `__syncwarp`, and the variants with predicates |
|
| 78 |
+
| 7.10–7.12 | Read-only / cache-hint load and store | `__ldg`, `__ldcs`, `__ldlu`, `__stcs` — the C++ face of the PTX cache modifiers |
|
| 79 |
+
| 7.14 | Atomic Functions | scopes (`_block`, `_system`), which types have native atomics |
|
| 80 |
+
| 7.19–7.22 | Warp vote / match / reduce / shuffle | `__ballot_sync`, `__reduce_add_sync`, `__shfl_xor_sync` |
|
| 81 |
+
| 7.24 | Warp Matrix Functions | the `wmma` fragment API |
|
| 82 |
+
| 7.26 | Asynchronous Barrier | `cuda::barrier`, the C++ face of `mbarrier` |
|
| 83 |
+
| 7.27–7.28 | Asynchronous Data Copies (+ `cuda::pipeline`) | `memcpy_async`, the pipeline object, and how `cp.async` groups commit |
|
| 84 |
+
| 7.29–7.30 | TMA transfers, encoding a tensor map | the worked TMA example — read this before writing your own descriptor code |
|
| 85 |
+
| 7.38–7.39 | Launch Bounds, Max Registers per Thread | `__launch_bounds__` and how it caps registers |
|
| 86 |
+
| 7.40 | `#pragma unroll` | |
|
| 87 |
|
| 88 |
+
**§16 Compute Capabilities** — the per-architecture tables: registers per SM, shared memory per block,
|
| 89 |
+
max blocks per SM, warp scheduler counts. When you need a hard architectural number, this is the source
|
| 90 |
+
— but prefer querying the device (see below), which cannot go stale.
|
| 91 |
+
|
| 92 |
+
Also: §8 Cooperative Groups (tiles, `grid_group::sync` and its co-residency requirement), §19 Unified
|
| 93 |
+
Memory, §18 Environment Variables.
|
| 94 |
+
|
| 95 |
+
---
|
| 96 |
+
|
| 97 |
+
## 3. PTX ISA — the instruction authority
|
| 98 |
+
|
| 99 |
+
14 chapters. Consult it for *exact syntax, every modifier, and which `.target` an instruction needs*.
|
| 100 |
+
|
| 101 |
+
**§9.7 Instruction Set** is the bulk, organized by family:
|
| 102 |
+
|
| 103 |
+
| § | family | contains |
|
| 104 |
|---|---|---|
|
| 105 |
+
| 9.7.3–9.7.5 | Floating-point, half, mixed precision | `fma`, `ex2.approx`, `rcp.approx`, `cvt` including the fp8 packing forms |
|
| 106 |
+
| 9.7.8 | Logic and shift | |
|
| 107 |
+
| 9.7.9 | **Data Movement and Conversion** | `ld`/`st` with every cache modifier, `cp.async`, `cp.async.bulk.tensor` (TMA), `ldmatrix`, `stmatrix` |
|
| 108 |
+
| 9.7.12 | Control flow | |
|
| 109 |
+
| 9.7.13 | **Parallel Synchronization and Communication** | `bar`, `mbarrier` (init/arrive/expect_tx/try_wait), `fence` including `fence.proxy.async`, `redux`, `vote`, `shfl`, `elect`, cluster barriers, `atom`/`red` |
|
| 110 |
+
| 9.7.14 | Warp-level MMA | `mma.sync` — every shape and dtype combination |
|
| 111 |
+
| 9.7.15 | **Warpgroup** | `wgmma.mma_async` and its descriptors — Hopper's top instruction |
|
| 112 |
+
| 9.7.16 | TensorCore 5th generation | `tcgen05` — **Blackwell only**, will not assemble on sm_90a |
|
| 113 |
+
|
| 114 |
+
**§8 Memory Consistency Model** — the formal ordering rules. Go here when a hand-written barrier is
|
| 115 |
+
"almost" working: it defines what `.relaxed`/`.acquire`/`.release` and each `.scope` actually promise,
|
| 116 |
+
and why `fence.proxy.async` is required between a TMA write and a generic read.
|
| 117 |
+
|
| 118 |
+
**§5 State Spaces, Types, Variables** and **§6 Instruction Operands** — how `.shared`/`.global`/`.param`
|
| 119 |
+
differ and the addressing rules. Relevant when an inline-asm constraint will not bind: shared addresses
|
| 120 |
+
are 32-bit (`"r"`), global are 64-bit (`"l"`).
|
| 121 |
+
|
| 122 |
+
**§10 Special Registers** — `%laneid`, `%warpid`, `%smid`, `%clock`, `%globaltimer`.
|
| 123 |
+
|
| 124 |
+
---
|
| 125 |
+
|
| 126 |
+
## 4. Inline PTX Assembly — the glue
|
| 127 |
+
|
| 128 |
+
Short. Read it once, fully. Operand constraint letters, how `%0` numbering maps to the output-then-input
|
| 129 |
+
order, `volatile`, the `"memory"` clobber, and why a multi-instruction `asm` block needs `{ }` and `.reg`
|
| 130 |
+
declarations. Every inline-asm bug you will hit is described here.
|
| 131 |
+
|
| 132 |
+
## 5. Best Practices Guide — the optimization argument
|
| 133 |
+
|
| 134 |
+
Read **§9 Memory Optimizations** (coalescing, shared memory bank conflicts, the cost of each memory
|
| 135 |
+
space), **§10 Execution Configuration** (occupancy and *why more is not always better*), **§11
|
| 136 |
+
Instruction Optimization**, **§12 Control Flow** (warp divergence). §3 Application Profiling states the
|
| 137 |
+
profile-first discipline. Ignore the deployment chapters (§13–§18).
|
| 138 |
+
|
| 139 |
+
## 6. Hopper Tuning Guide — what changed on sm_90
|
| 140 |
+
|
| 141 |
+
Short and worth reading end to end if you target Hopper: thread block clusters and distributed shared
|
| 142 |
+
memory, TMA, the wgmma warpgroup MMA, the larger shared memory, and the async transaction barrier. It is
|
| 143 |
+
the fastest way to learn what Hopper added over Ampere. Swap in the **Blackwell Tuning Guide** for sm_100.
|
| 144 |
+
|
| 145 |
+
## 7. Nsight Compute Profiling Guide + CLI
|
| 146 |
+
|
| 147 |
+
The Profiling Guide defines **what each metric means** and which section reports it — the authority when
|
| 148 |
+
you are unsure whether a counter says what you think. The CLI reference covers `--section`, `--metrics`,
|
| 149 |
+
`--kernel-name regex:`, `--launch-skip/--launch-count`, and `--replay-mode` (use `application` for
|
| 150 |
+
persistent or grid-synchronizing kernels, which kernel replay breaks).
|
| 151 |
+
|
| 152 |
+
See `profiling.md` for the practical order — nsys before ncu — and `pitfalls.md` for reading counters
|
| 153 |
+
without chasing a healthy-looking number.
|
| 154 |
+
|
| 155 |
+
---
|
| 156 |
+
|
| 157 |
+
## 8. Routing table
|
| 158 |
+
|
| 159 |
+
| question | where |
|
| 160 |
+
|---|---|
|
| 161 |
+
| What does this CUDA C++ construct mean? | Programming Guide §7 |
|
| 162 |
+
| Exact PTX syntax / modifiers / required target | PTX ISA §9.7 |
|
| 163 |
+
| Is my barrier actually ordered correctly? | PTX ISA §8 |
|
| 164 |
+
| How do I write inline asm and bind operands? | Inline PTX Assembly |
|
| 165 |
+
| Why is my access pattern slow? | Best Practices §9 |
|
| 166 |
+
| Should I raise occupancy? | Best Practices §10, then `pitfalls.md` |
|
| 167 |
+
| What is new on Hopper? | Hopper Tuning Guide |
|
| 168 |
+
| What does this ncu metric mean? | Nsight Compute Profiling Guide |
|
| 169 |
+
| What is my device's SM count / shared memory / registers? | **query the device** — see below |
|
| 170 |
+
| What is the signature of a runtime call? | **the installed headers** — see below |
|
| 171 |
+
|
| 172 |
+
## 9. Two things NOT to look up on the web
|
| 173 |
+
|
| 174 |
+
**Device properties — query them.** Any hard number you copy from a table is wrong on the next GPU:
|
| 175 |
+
|
| 176 |
+
```python
|
| 177 |
+
p = torch.cuda.get_device_properties(0)
|
| 178 |
+
p.multi_processor_count, p.shared_memory_per_block_optin, p.regs_per_multiprocessor
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
Measured on the H200 NVL in this environment: 132 SMs, 232,448 B opt-in shared memory per block,
|
| 182 |
+
233,472 B per SM, 65,536 registers per SM, 2,048 threads per SM, 60 MB L2. Those are *this* machine's
|
| 183 |
+
numbers, quoted to show the shape of the answer — not to be pasted into a kernel.
|
| 184 |
+
|
| 185 |
+
**Runtime API signatures — grep the headers.** `$CUDA_HOME/include` is authoritative, always present,
|
| 186 |
+
and never version-skewed against your compiler. The Runtime API web page is only a table of contents
|
| 187 |
+
(its content is on generated subpages), which is why the fetcher skips it.
|
| 188 |
+
|
| 189 |
+
```bash
|
| 190 |
+
grep -rn "cuTensorMapEncodeTiled" /usr/local/cuda/targets/*/include/
|
| 191 |
+
```
|
| 192 |
+
|
| 193 |
+
## 10. Precedence
|
| 194 |
|
| 195 |
+
1. **The compiler.** If `nvcc`/`ptxas` rejects it, it does not exist on your target, whatever any
|
| 196 |
+
document says. `tools/check_toolchain.py` settles this in seconds.
|
| 197 |
+
2. **The device.** For counts and capacities, query it.
|
| 198 |
+
3. **The official docs.** For *meaning* — semantics, ordering, modifier effects — NVIDIA is the authority.
|
| 199 |
+
4. **`ref/*.md`.** Verified working sets and the traps, but summaries; where they disagree with NVIDIA on
|
| 200 |
+
semantics, NVIDIA wins.
|
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""HTML -> greppable plain text. Pure stdlib: the task images have no bs4 and no internet to get it.
|
| 2 |
+
|
| 3 |
+
Whitespace inside <pre>/<code> is preserved -- these documents carry their worked examples in code
|
| 4 |
+
blocks, and a collapsed one ("mbarrier_init(&bar,1);// Initialize barrier") is unreadable.
|
| 5 |
+
"""
|
| 6 |
+
import re
|
| 7 |
+
import sys
|
| 8 |
+
from html.parser import HTMLParser
|
| 9 |
+
|
| 10 |
+
DROP = {"script", "style", "nav", "head", "noscript", "svg", "form"}
|
| 11 |
+
BLOCK = {"p", "div", "li", "tr", "br", "section", "article"}
|
| 12 |
+
HEAD = {"h1", "h2", "h3", "h4", "h5", "h6"}
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class T(HTMLParser):
|
| 16 |
+
def __init__(self):
|
| 17 |
+
super().__init__(convert_charrefs=True)
|
| 18 |
+
self.out, self.skip, self.pre = [], 0, 0
|
| 19 |
+
|
| 20 |
+
def handle_starttag(self, tag, attrs):
|
| 21 |
+
if tag in DROP:
|
| 22 |
+
self.skip += 1
|
| 23 |
+
elif tag in ("pre", "code"):
|
| 24 |
+
if tag == "pre":
|
| 25 |
+
self.out.append("\n")
|
| 26 |
+
self.pre += 1
|
| 27 |
+
elif self.pre:
|
| 28 |
+
if tag == "br":
|
| 29 |
+
self.out.append("\n")
|
| 30 |
+
elif tag in HEAD:
|
| 31 |
+
self.out.append("\n\n### ")
|
| 32 |
+
elif tag in BLOCK:
|
| 33 |
+
self.out.append("\n")
|
| 34 |
+
elif tag in ("td", "th"):
|
| 35 |
+
self.out.append(" ")
|
| 36 |
+
|
| 37 |
+
def handle_endtag(self, tag):
|
| 38 |
+
if tag in DROP and self.skip:
|
| 39 |
+
self.skip -= 1
|
| 40 |
+
elif tag in ("pre", "code"):
|
| 41 |
+
if self.pre:
|
| 42 |
+
self.pre -= 1
|
| 43 |
+
if tag == "pre":
|
| 44 |
+
self.out.append("\n")
|
| 45 |
+
elif not self.pre and tag in HEAD | {"table"}:
|
| 46 |
+
self.out.append("\n")
|
| 47 |
+
|
| 48 |
+
def handle_data(self, d):
|
| 49 |
+
if self.skip:
|
| 50 |
+
return
|
| 51 |
+
if self.pre:
|
| 52 |
+
self.out.append(d) # verbatim: newlines and indentation are the content
|
| 53 |
+
elif d.strip():
|
| 54 |
+
self.out.append(d)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def convert(src):
|
| 58 |
+
p = T()
|
| 59 |
+
p.feed(src)
|
| 60 |
+
t = "".join(p.out)
|
| 61 |
+
# collapse runs of spaces only OUTSIDE code: do it line-wise, leaving indented lines alone
|
| 62 |
+
lines = []
|
| 63 |
+
for ln in t.splitlines():
|
| 64 |
+
lines.append(ln if ln[:1] in (" ", "\t") else re.sub(r"[ \t]{2,}", " ", ln).rstrip())
|
| 65 |
+
t = "\n".join(lines)
|
| 66 |
+
return re.sub(r"\n{3,}", "\n\n", t).strip() + "\n"
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
if __name__ == "__main__":
|
| 70 |
+
sys.stdout.write(convert(open(sys.argv[1], encoding="utf-8", errors="ignore").read()))
|
|
@@ -1,10 +1,14 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
# Fetch NVIDIA's official CUDA/PTX documentation into a local directory, for offline use.
|
| 3 |
#
|
| 4 |
-
# ./fetch_nvidia_docs.sh [dest]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
#
|
| 6 |
# WHY A FETCHER AND NOT BUNDLED FILES
|
| 7 |
-
# NVIDIA's documentation is copyrighted and
|
| 8 |
# files listed in its Attachment A -- runtime libraries such as libcudart.so -- and documentation is not
|
| 9 |
# among them. So this repo cannot ship the guides; you download your own copy, direct from NVIDIA, under
|
| 10 |
# their terms. Linking and citing is fine; copying is not.
|
|
@@ -12,83 +16,65 @@
|
|
| 12 |
# OFFLINE USE: task containers have network at IMAGE BUILD time and none at run time. Run this in a
|
| 13 |
# Dockerfile RUN step and the agent has the official docs available offline while it works:
|
| 14 |
#
|
| 15 |
-
# RUN bash fetch_nvidia_docs.sh /opt/nvidia-docs
|
| 16 |
#
|
| 17 |
# (c) NVIDIA Corporation. Terms: https://docs.nvidia.com/cuda/eula/
|
| 18 |
set -uo pipefail
|
| 19 |
DEST=${1:-./nvidia-docs}
|
| 20 |
-
VER=${2:-}
|
| 21 |
mkdir -p "$DEST"
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# Match the docs to the toolkit you compile with. docs.nvidia.com/cuda/ always serves the NEWEST CUDA,
|
| 24 |
-
# and instructions documented there may not assemble on an older ptxas
|
| 25 |
-
#
|
| 26 |
if [ -z "$VER" ] && command -v nvcc >/dev/null 2>&1; then
|
| 27 |
V=$(nvcc --version | grep -oE 'release [0-9]+\.[0-9]+' | head -1 | cut -d' ' -f2)
|
| 28 |
[ -n "$V" ] && VER="$V.0"
|
| 29 |
fi
|
| 30 |
if [ -n "$VER" ] && curl -sSL --fail --max-time 60 -o /dev/null \
|
| 31 |
"https://docs.nvidia.com/cuda/archive/$VER/cuda-c-programming-guide/index.html" 2>/dev/null; then
|
| 32 |
-
BASE=https://docs.nvidia.com/cuda/archive/$VER
|
| 33 |
-
BASE_NS=$BASE
|
| 34 |
echo "fetching docs for CUDA $VER (matched to this toolkit)"
|
| 35 |
else
|
| 36 |
[ -n "$VER" ] && echo "no archive for CUDA $VER; falling back to the current docs"
|
| 37 |
-
BASE=https://docs.nvidia.com/cuda
|
| 38 |
-
BASE_NS=https://docs.nvidia.com/cuda
|
| 39 |
fi
|
| 40 |
-
NSIGHT=https://docs.nvidia.com
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
# name|html index|pdf hint (optional)
|
| 43 |
-
# The hint is tried first; if it 404s we fall back to whatever PDF the page itself advertises. Both
|
| 44 |
-
# paths are needed: the PTX ISA pdf is version-stamped (ptx_isa_9.3.pdf) so it MUST be discovered,
|
| 45 |
-
# while the Programming Guide page advertises a link that 404s so it MUST be hinted.
|
| 46 |
DOCS="
|
| 47 |
-
cuda-c-programming-guide|$BASE/cuda-c-programming-guide/index.html
|
| 48 |
-
cuda-c-best-practices-guide|$BASE/cuda-c-best-practices-guide/index.html
|
| 49 |
-
parallel-thread-execution|$BASE/parallel-thread-execution/index.html
|
| 50 |
-
inline-ptx-assembly|$BASE/inline-ptx-assembly/index.html
|
| 51 |
-
hopper-tuning-guide|$BASE/hopper-tuning-guide/index.html
|
| 52 |
-
|
| 53 |
-
nsight-compute-
|
| 54 |
-
nsight-compute-cli|$NSIGHT/nsight-compute/NsightComputeCli/index.html|
|
| 55 |
"
|
| 56 |
|
| 57 |
ok=0; fail=0
|
| 58 |
for entry in $DOCS; do
|
| 59 |
-
name=${entry%%|*}
|
| 60 |
-
url=${
|
| 61 |
-
[ "$hint" = "$url" ] && hint=""
|
| 62 |
-
dir=$(dirname "$url")
|
| 63 |
html="$DEST/$name.html"
|
| 64 |
if ! curl -sSL --fail --max-time 120 -o "$html" "$url" 2>/dev/null; then
|
| 65 |
-
echo " FAIL
|
|
|
|
|
|
|
| 66 |
fi
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
disc=""
|
| 70 |
-
if [ -n "$rel" ]; then
|
| 71 |
-
case "$rel" in
|
| 72 |
-
# "../pdf/x.pdf" is relative to the page's directory, so go UP one level -- for
|
| 73 |
-
# .../cuda/parallel-thread-execution/index.html that resolves to .../cuda/pdf/x.pdf
|
| 74 |
-
../*) disc="$(dirname "$dir")/${rel#../}" ;;
|
| 75 |
-
*) disc="https://docs.nvidia.com$rel" ;;
|
| 76 |
-
esac
|
| 77 |
fi
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
[ -z "$pdf" ] && continue
|
| 81 |
-
if curl -sSL --fail --max-time 300 -o "$DEST/$name.pdf" "$pdf" 2>/dev/null; then
|
| 82 |
-
got="$pdf"; break
|
| 83 |
-
fi
|
| 84 |
-
done
|
| 85 |
-
if [ -n "$got" ]; then
|
| 86 |
-
echo " ok $name (html + pdf $(du -h "$DEST/$name.pdf" | cut -f1))"
|
| 87 |
else
|
| 88 |
-
|
| 89 |
-
echo " ok $name (html only)"
|
| 90 |
fi
|
| 91 |
-
ok=$((ok+1))
|
| 92 |
done
|
| 93 |
|
| 94 |
cat > "$DEST/LICENSE-NOTICE.txt" <<'NOTE'
|
|
@@ -101,9 +87,10 @@ permits distribution only of the files enumerated in its Attachment A -- runtime
|
|
| 101 |
libraries such as libcudart.so -- and documentation is not among them.
|
| 102 |
|
| 103 |
You obtained this copy directly from NVIDIA, for your own use, under NVIDIA's terms.
|
| 104 |
-
Do not re-publish these files. If you need to share them, share
|
| 105 |
NOTE
|
| 106 |
|
| 107 |
echo
|
| 108 |
echo "$ok fetched, $fail failed -> $DEST"
|
|
|
|
| 109 |
echo "Copyright (c) NVIDIA Corporation. Not redistributable; see $DEST/LICENSE-NOTICE.txt"
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
# Fetch NVIDIA's official CUDA/PTX documentation into a local directory, for offline use.
|
| 3 |
#
|
| 4 |
+
# ./fetch_nvidia_docs.sh [dest] [cuda-version] # default: ./nvidia-docs, version auto-detected
|
| 5 |
+
#
|
| 6 |
+
# Emits <name>.html and <name>.txt per document. The .txt is the one that matters: it is greppable,
|
| 7 |
+
# which is the only way a ~700-page reference is usable offline. PDFs are deliberately NOT fetched --
|
| 8 |
+
# they cannot be grepped, are read in 20-page slices, and cost ~30 MB for no added capability.
|
| 9 |
#
|
| 10 |
# WHY A FETCHER AND NOT BUNDLED FILES
|
| 11 |
+
# NVIDIA's documentation is copyrighted and NOT redistributable. The CUDA EULA distributes only the
|
| 12 |
# files listed in its Attachment A -- runtime libraries such as libcudart.so -- and documentation is not
|
| 13 |
# among them. So this repo cannot ship the guides; you download your own copy, direct from NVIDIA, under
|
| 14 |
# their terms. Linking and citing is fine; copying is not.
|
|
|
|
| 16 |
# OFFLINE USE: task containers have network at IMAGE BUILD time and none at run time. Run this in a
|
| 17 |
# Dockerfile RUN step and the agent has the official docs available offline while it works:
|
| 18 |
#
|
| 19 |
+
# RUN bash fetch_nvidia_docs.sh /opt/nvidia-docs 12.8.0
|
| 20 |
#
|
| 21 |
# (c) NVIDIA Corporation. Terms: https://docs.nvidia.com/cuda/eula/
|
| 22 |
set -uo pipefail
|
| 23 |
DEST=${1:-./nvidia-docs}
|
| 24 |
+
VER=${2:-}
|
| 25 |
mkdir -p "$DEST"
|
| 26 |
+
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
| 27 |
+
PY=$(command -v python3 || command -v python || true)
|
| 28 |
|
| 29 |
# Match the docs to the toolkit you compile with. docs.nvidia.com/cuda/ always serves the NEWEST CUDA,
|
| 30 |
+
# and instructions documented there may not assemble on an older ptxas -- CUDA 12.8 ships PTX ISA 8.7
|
| 31 |
+
# while the live page currently documents 9.3.
|
| 32 |
if [ -z "$VER" ] && command -v nvcc >/dev/null 2>&1; then
|
| 33 |
V=$(nvcc --version | grep -oE 'release [0-9]+\.[0-9]+' | head -1 | cut -d' ' -f2)
|
| 34 |
[ -n "$V" ] && VER="$V.0"
|
| 35 |
fi
|
| 36 |
if [ -n "$VER" ] && curl -sSL --fail --max-time 60 -o /dev/null \
|
| 37 |
"https://docs.nvidia.com/cuda/archive/$VER/cuda-c-programming-guide/index.html" 2>/dev/null; then
|
| 38 |
+
BASE="https://docs.nvidia.com/cuda/archive/$VER"
|
|
|
|
| 39 |
echo "fetching docs for CUDA $VER (matched to this toolkit)"
|
| 40 |
else
|
| 41 |
[ -n "$VER" ] && echo "no archive for CUDA $VER; falling back to the current docs"
|
| 42 |
+
BASE="https://docs.nvidia.com/cuda"
|
|
|
|
| 43 |
fi
|
| 44 |
+
NSIGHT="https://docs.nvidia.com/nsight-compute"
|
| 45 |
+
# NOTE: the CUDA Runtime API reference is deliberately absent. Its index page is only a table of
|
| 46 |
+
# contents -- the real content is on generated per-module subpages -- and for signatures the installed
|
| 47 |
+
# headers under $CUDA_HOME/include are both authoritative and already local. Grep those instead.
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
DOCS="
|
| 50 |
+
cuda-c-programming-guide|$BASE/cuda-c-programming-guide/index.html
|
| 51 |
+
cuda-c-best-practices-guide|$BASE/cuda-c-best-practices-guide/index.html
|
| 52 |
+
parallel-thread-execution|$BASE/parallel-thread-execution/index.html
|
| 53 |
+
inline-ptx-assembly|$BASE/inline-ptx-assembly/index.html
|
| 54 |
+
hopper-tuning-guide|$BASE/hopper-tuning-guide/index.html
|
| 55 |
+
nsight-compute-profiling-guide|$NSIGHT/ProfilingGuide/index.html
|
| 56 |
+
nsight-compute-cli|$NSIGHT/NsightComputeCli/index.html
|
|
|
|
| 57 |
"
|
| 58 |
|
| 59 |
ok=0; fail=0
|
| 60 |
for entry in $DOCS; do
|
| 61 |
+
name=${entry%%|*}
|
| 62 |
+
url=${entry#*|}
|
|
|
|
|
|
|
| 63 |
html="$DEST/$name.html"
|
| 64 |
if ! curl -sSL --fail --max-time 120 -o "$html" "$url" 2>/dev/null; then
|
| 65 |
+
echo " FAIL $name"
|
| 66 |
+
fail=$((fail + 1))
|
| 67 |
+
continue
|
| 68 |
fi
|
| 69 |
+
if [ -n "$PY" ] && [ -f "$HERE/_html2txt.py" ]; then
|
| 70 |
+
"$PY" "$HERE/_html2txt.py" "$html" > "$DEST/$name.txt" 2>/dev/null || rm -f "$DEST/$name.txt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
fi
|
| 72 |
+
if [ -f "$DEST/$name.txt" ]; then
|
| 73 |
+
echo " ok $name ($(du -h "$DEST/$name.txt" | cut -f1) text)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
else
|
| 75 |
+
echo " ok $name (html only -- no python3 for the text rendering)"
|
|
|
|
| 76 |
fi
|
| 77 |
+
ok=$((ok + 1))
|
| 78 |
done
|
| 79 |
|
| 80 |
cat > "$DEST/LICENSE-NOTICE.txt" <<'NOTE'
|
|
|
|
| 87 |
libraries such as libcudart.so -- and documentation is not among them.
|
| 88 |
|
| 89 |
You obtained this copy directly from NVIDIA, for your own use, under NVIDIA's terms.
|
| 90 |
+
Do not re-publish these files. If you need to share them, share the fetch script instead.
|
| 91 |
NOTE
|
| 92 |
|
| 93 |
echo
|
| 94 |
echo "$ok fetched, $fail failed -> $DEST"
|
| 95 |
+
echo "search with: KDOCS=$DEST tools/search_docs.sh <pattern>"
|
| 96 |
echo "Copyright (c) NVIDIA Corporation. Not redistributable; see $DEST/LICENSE-NOTICE.txt"
|
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Search the offline NVIDIA docs corpus fetched by fetch_nvidia_docs.sh.
|
| 3 |
+
#
|
| 4 |
+
# KDOCS=/opt/nvidia-docs ./search_docs.sh "cp.async.bulk" # find it
|
| 5 |
+
# KDOCS=/opt/nvidia-docs ./search_docs.sh -C 12 "expect_tx" # with more context
|
| 6 |
+
#
|
| 7 |
+
# Searches the .txt renderings (greppable); falls back to the installed CUDA headers for API
|
| 8 |
+
# signatures, which are more authoritative than any web page and are always present.
|
| 9 |
+
set -uo pipefail
|
| 10 |
+
DOCS=${KDOCS:-/opt/nvidia-docs}
|
| 11 |
+
CTX=4
|
| 12 |
+
if [ "${1:-}" = "-C" ]; then CTX=$2; shift 2; fi
|
| 13 |
+
PAT=${1:-}
|
| 14 |
+
[ -z "$PAT" ] && { echo "usage: [KDOCS=dir] search_docs.sh [-C n] <pattern>" >&2; exit 1; }
|
| 15 |
+
|
| 16 |
+
if [ -d "$DOCS" ] && ls "$DOCS"/*.txt >/dev/null 2>&1; then
|
| 17 |
+
echo "== $DOCS =="
|
| 18 |
+
grep -rn --color=never -C "$CTX" -- "$PAT" "$DOCS"/*.txt 2>/dev/null | head -80
|
| 19 |
+
else
|
| 20 |
+
echo "no fetched docs at $DOCS (run fetch_nvidia_docs.sh, or set KDOCS)" >&2
|
| 21 |
+
fi
|
| 22 |
+
|
| 23 |
+
# Search EVERY include root, deduped by real path: /usr/local/cuda/include and
|
| 24 |
+
# /usr/local/cuda/targets/<arch>/include are different trees, and cuda.h (where the driver API lives)
|
| 25 |
+
# is only in the latter -- picking just the first one silently finds nothing.
|
| 26 |
+
INCS=$(for d in /usr/local/cuda*/targets/*/include /usr/local/cuda*/include; do
|
| 27 |
+
[ -d "$d" ] && readlink -f "$d"
|
| 28 |
+
done | sort -u)
|
| 29 |
+
if [ -n "$INCS" ]; then
|
| 30 |
+
echo
|
| 31 |
+
echo "== CUDA headers -- authoritative for signatures =="
|
| 32 |
+
# shellcheck disable=SC2086
|
| 33 |
+
grep -rn --include="*.h" --include="*.hpp" --include="*.cuh" --color=never -- "$PAT" $INCS 2>/dev/null | head -15
|
| 34 |
+
fi
|