设备软件 · SASS

流式汇编器Streaming Assembler

流式汇编器 (Streaming ASSembler, SASS) 是在 NVIDIA GPU 上运行的程序的汇编格式。它是编写人类可读代码的最低级别格式,是 nvccNVIDIA CUDA 编译器驱动程序)输出的格式之一,与 PTX 格式并列。它在执行过程中,会被转换为特定于设备的二进制微码。 "流式汇编器"中的"流式"大概指的是该汇编语言程序所面向的是 流式多处理器 (SM)。

SASS 是有版本的,并且与特定的 NVIDIA GPU SM 架构 相关联。另请参阅 计算能力

以下是 Hopper GPU 的 SM90a 架构的一些 SASS 示例指令: - FFMA R0, R7, R0, 1.5 ; - 执行 Fused Floating point Multiply Add(融合浮点乘加运算),将寄存器 R7 和寄存器 R0 的内容相乘,再加上 1.5,并将结果存储在寄存器 R0 中。 - S2UR UR4, SR_CTAID.X ; - 将 协作线程数组 (CTA) 索引的 X 值从其 Special Register(特殊寄存器)复制到 Uniform Register(通用寄存器) 4。

与 CPU 相比,手动编写这种"GPU 汇编器"更为罕见。在性能分析和编辑高级 CUDA C/C++ 代码或内联 PTX 时,查看编译器生成的 SASS 更为常见,尤其是在开发高性能内核时。Godbolt 平台支持同时查看 CUDA C/C++、SASS 和 PTX 代码。若想了解更多以性能调试流程为重点的SASS细节,请参阅 Arun Demeure 的这个演讲

SASS 的文档记录 非常 少——虽然 NVIDIA CUDA 二进制工具文档 中列出了相关指令,但未定义其语义。从 ASCII 汇编到二进制操作码及操作数的映射完全没有公开文档,但在某些情况下已被逆向工程(MaxwellLovelace)。

英文原文(Modal GPU Glossary)

Streaming ASSembler (SASS) is the assembly format for programs running on NVIDIA GPUs. This is the lowest-level format in which human-readable code can be written. It is one of the formats output by nvcc, the NVIDIA CUDA Compiler Driver, alongside PTX. It is converted to device-specific binary microcodes during execution. Presumably, the "Streaming" in "Streaming Assembler" refers to the Streaming Multiprocessors which the assembly language programs.

SASS is versioned and tied to a specific NVIDIA GPU SM architecture. See also Compute Capability.

Some exemplary instructions in SASS for the SM90a architecture of Hopper GPUs:

  • FFMA R0, R7, R0, 1.5 ; - perform a Fused Floating point Multiply Add
  • that multiplies the contents of Register 7 and Register 0, adds 1.5, and
  • stores the result in Register 0.
  • S2UR UR4, SR_CTAID.X ; - copy the X value of the
  • Cooperative Thread Array's
  • InDex from its Special Register to Uniform Register 4.

Even more so than for CPUs, writing this "GPU assembler" by hand is very uncommon. Viewing compiler-generated SASS while profiling and editing high-level CUDA C/C++ code or in-line PTX is more common, especially in the production of the highest-performance kernels. Viewing CUDA C/C++, SASS, and PTX together is supported on Godbolt. For more detail on SASS with a focus on performance debugging workflows, see this talk from Arun Demeure.

SASS is _very_ lightly documented — the instructions are listed in the documentation for NVIDIA's CUDA binary utilities, but their semantics are not defined. The mapping from ASCII assembler to binary opcodes and operands is entirely undocumented, but it has been reverse-engineered in certain cases (Maxwell, Lovelace).

相关词条

本词条改编自 Modal GPU Glossary(CC BY 4.0)· 中文翻译 miter6/gpu-glossary-zh,MAE 整理排版。