Debian Codegraph @

docs/drivers/nvk/external_hardware_docs.rst

raw
1
2 External Hardware Documentation and Resources
3 =============================================
4
5 Information about hardware behavior comes from a mix of official and
6 reverse-engineered sources.
7
8 Command buffers
9 ^^^^^^^^^^^^^^^
10
11 * `NVIDIA open-gpu-doc repository`_ is official documentation from NVIDIA that
12 has been released to the public. The majority of this documentation comes in
13 the form of class headers which describe the class state registers.
14
15 * `NVIDIA open-gpu-kernel-modules repository`_ is the open-source kernel mode
16 driver that NVIDIA ships on Turing+ GPUs with GSP. The code here can provide
17 examples of how to use some hardware features. If open-gpu-doc is missing a
18 class header, sometimes there will be one here.
19
20 * Reverse-engineered command names from `envytools`_ are available in mesa
21 under eg. ``src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h``. These are no
22 longer updated. nvk instead uses the open-gpu-doc headers
23
24 * `envyhooks`_ is the modern way to dump command sequences from the proprietary
25 driver
26
27 * ``nv_push_dump`` is part of mesa and can disassemble command sequences (build
28 with ``-D tools=nouveau``, run ``src/nouveau/headers/nv_push_dump`` from the
29 build dir)
30
31 .. _NVIDIA open-gpu-doc repository: https://github.com/NVIDIA/open-gpu-doc
32 .. _NVIDIA open-gpu-kernel-modules repository: https://github.com/NVIDIA/open-gpu-kernel-modules
33 .. _envyhooks: https://gitlab.freedesktop.org/nouveau/envyhooks
34
35 Shader ISA
36 ^^^^^^^^^^
37
38 * `NVIDIA PTX documentation`_ is NVIDIA documentation for CUDA's
39 intermediate representation. We don't use PTX directly, but this often has
40 hints about how underlying hardware instructions work. For example, the PTX
41 `redux` instruction is pretty much identical to the hardware instruction of
42 the same name.
43
44 * `CUDA Binary Utilities`_ is documentation for CUDA's disassembler,
45 `nvdisasm`. It includes a brief description of most hardware instructions.
46 There's also an `older version`_ that has older architectures (Kepler through
47 Volta).
48
49 * Kuter Dinel has reverse-engineered instruction encodings for the `Hopper
50 ISA`_ and `Ada ISA`_ which are autogenerated from his `nv_isa_solver`_
51 project.
52
53 * `nv-shader-tools`_ has some additional tools for disassembling and fuzzing
54 the hardware ISA
55
56 * Mel has dumped a `list of avaiable instructions`_ and their opcodes on recent
57 architectures by scraping nvdisasm error messages.
58
59 * The `Volta whitepaper`_ section "Independent Thread Scheduling" has an
60 overview of the control flow model used on Volta+ GPUs.
61
62 * `Dissecting the NVidia Turing T4 GPU via Microbenchmarking`_ has
63 reverse-engineered info about the Turing instruction encoding. See especially
64 section "2.1 Control information" for an overview of compiler-inserted delays
65 and waits on Maxwell and later.
66
67 * `Analyzing Modern NVIDIA GPU cores`_ has additional reverse-engineered info
68 about the semantics of compiler-inserted delays and waits.
69
70 * `Control Flow Management in Modern GPUs`_ has more detail about control flow
71 reconvergence on Volta+
72
73 * `maxas`_ has some reverse-engineered info on the Maxwell ISA
74
75 * `asfermi`_ has some reverse-engineered info on the older Fermi ISA
76
77 * Red Hat has some NDA'd documentation on instruction latencies from NVIDIA.
78 Bother karolherbst or airlied on irc if you're missing a latency class for an
79 instruction on recent architectures.
80
81 * Behavior of instructions are tested using the hardware tests in
82 ``src/nouveau/compiler/nak/hw_tests.rs`` and the corresponding ``Foldable``
83 implementations in ``src/nouveau/compiler/nak/ir.rs`` (build with ``-D
84 build-tests=true`` and run ``src/nouveau/compiler/nak hw_tests`` from the
85 build dir)
86
87 * NAK's instruction encodings are tested against nvdisasm using
88 ``src/nouveau/compiler/nak/nvdisasm_tests.rs`` (build with ``-D
89 build-tests=true`` and run ``src/nouveau/compiler/nak nvdisasm_tests`` from
90 the build dir)
91
92 * The old GL driver's compiler, under ``src/gallium/drivers/nouveau/codegen``,
93 has some information. This is especially useful for graphics-only
94 instructions, which are often not covered by other sources.
95
96 * `Compiler explorer`_ is a convenient tool to see what assembly NVIDIA
97 generates for a given CUDA program.
98
99 .. _NVIDIA PTX documentation: https://docs.nvidia.com/cuda/parallel-thread-execution/index.html
100 .. _CUDA Binary Utilities: https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#instruction-set-reference
101 .. _older version: https://docs.nvidia.com/cuda/archive/11.8.0/cuda-binary-utilities/index.html#instruction-set-ref
102 .. _Hopper ISA: https://kuterdinel.com/nv_isa/
103 .. _Ada ISA: https://kuterdinel.com/nv_isa_sm89/
104 .. _nv_isa_solver: https://github.com/kuterd/nv_isa_solver
105 .. _nv-shader-tools: https://gitlab.freedesktop.org/nouveau/nv-shader-tools
106 .. _list of avaiable instructions: https://gitlab.freedesktop.org/mhenning/re/-/tree/main/opclass?ref_type=heads
107 .. _Volta whitepaper: https://images.nvidia.com/content/volta-architecture/pdf/volta-architecture-whitepaper.pdf
108 .. _Dissecting the NVidia Turing T4 GPU via Microbenchmarking: https://arxiv.org/pdf/1903.07486
109 .. _Analyzing Modern NVIDIA GPU cores: https://arxiv.org/pdf/2503.20481
110 .. _Control Flow Management in Modern GPUs: https://arxiv.org/pdf/2407.02944
111 .. _maxas: https://github.com/NervanaSystems/maxas/wiki
112 .. _asfermi: https://github.com/hyqneuron/asfermi/wiki
113 .. _Compiler explorer: https://godbolt.org/z/1jrfhq5G7
114
115 Misc
116 ^^^^
117
118 * `envytools`_ has reverse-engineered documentation for maxwell and earlier
119 hardware.
120 * The nvidia architecture whitepapers give a basic overview of what has changed
121 between hardware revisions. See eg. the `Blackwell whitepaper`_
122 * The nvidia architecture tuning guides often mention how details of a hardware
123 generation has changed, often with information about the memory subsystem or
124 occupancy. See eg. the `Blackwell tuning guide`_
125 * `The Nouveau wiki's CodeNames page`_ is useful for mapping NVIDIA marketing
126 names to engineering names
127 * `Matching CUDA arch and CUDA gencode for various NVIDIA architectures`_ has a
128 useful table comparing SM versions to engineering names
129
130 .. _envytools: https://envytools.readthedocs.io/en/latest/hw/index.html
131 .. _Blackwell whitepaper: https://images.nvidia.com/aem-dam/Solutions/geforce/blackwell/nvidia-rtx-blackwell-gpu-architecture.pdf
132 .. _Blackwell tuning guide: https://docs.nvidia.com/cuda/blackwell-tuning-guide/index.html
133 .. _The Nouveau wiki's CodeNames page: https://nouveau.freedesktop.org/CodeNames.html
134 .. _Matching CUDA arch and CUDA gencode for various NVIDIA architectures: https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/