CUDA_Binary_Utilities
CUDA_Binary_Utilities
Application Note
TABLE OF CONTENTS
Chapter 1. Overview............................................................................................ 1
1.1. What is a CUDA Binary?................................................................................. 1
1.2. Differences between cuobjdump and nvdisasm..................................................... 1
Chapter 2. cuobjdump.......................................................................................... 3
2.1. Usage........................................................................................................3
2.2. Command-line Options................................................................................... 5
Chapter 3. nvdisasm............................................................................................. 7
3.1. Usage........................................................................................................7
3.2. Command-line Options................................................................................. 10
Chapter 4. Instruction Set Reference...................................................................... 12
4.1. GT200 Instruction Set.................................................................................. 12
4.2. Fermi Instruction Set................................................................................... 14
4.3. Kepler Instruction Set.................................................................................. 18
4.4. Maxwell Instruction Set................................................................................ 21
Chapter 5. nvprune............................................................................................ 26
5.1. Usage...................................................................................................... 26
5.2. Command-line Options................................................................................. 26
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | ii
LIST OF FIGURES
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | iii
LIST OF TABLES
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | iv
Chapter 1.
OVERVIEW
This document introduces cuobjdump, nvdisasm, and nvprune, three CUDA binary
tools for Linux(x86 and ARM), Windows, Mac OS and Android.
For more details on cubin files or the CUDA compilation trajectory, refer to NVIDIA
CUDA Compiler Driver NVCC.
cuobjdump nvdisasm
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 1
Overview
cuobjdump nvdisasm
Extract ptx and extract and disassemble cubin from the Yes No
following input files:
‣ Host binaries
‣ Executables
‣ Object files
‣ Static libraries
‣ External fatbinary files
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 2
Chapter 2.
CUOBJDUMP
cuobjdump extracts information from CUDA binary files (both standalone and those
embedded in host binaries) and presents them in human readable format. The output of
cuobjdump includes CUDA assembly code for each kernel, CUDA ELF section headers,
string tables, relocators and other CUDA specific sections. It also extracts embedded ptx
text from host binaries.
For a list of CUDA assembly instruction set of each GPU architecture, see Instruction Set
Reference.
2.1. Usage
cuobjdump accepts a single input file each time it's run. The basic usage is as following:
To dump cuda elf sections in human readable format from a cubin file, use the following
command:
cuobjdump -elf <cubin file>
To extract ptx text from a host binary, use the following command:
cuobjdump -ptx <host binary>
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 3
cuobjdump
.version 4.0
.target sm_20
.address_size 64
As shown in the output, the a.out host binary contains cubin and ptx code for sm_20.
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 4
cuobjdump
To extract all the cubins as files from the host binary use -xelf all option:
You can pass any substring to -xelf and -xptx options. Only the files having the
substring in the name will be extracted from the input binary.
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 5
cuobjdump
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 6
Chapter 3.
NVDISASM
nvdisasm extracts information from standalone cubin files and presents them in human
readable format. The output of nvdisasm includes CUDA assembly code for each
kernel, listing of ELF data sections and other CUDA specific sections. Output style and
options are controlled through nvdisasm command-line options. nvdisasm also does
control flow analysis to annotate jump/branch targets and makes the output easier to
read.
For a list of CUDA assembly instruction set of each GPU architecture, see Instruction Set
Reference.
3.1. Usage
nvdisasm accepts a single input file each time it's run. The basic usage is as following:
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 7
nvdisasm
......
.type vprintf,@function
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 8
nvdisasm
This feature is only supported on cubins generated for Compute Capability 3.0 and
later.
Here's how you can generate a PNG image (cfg.png) of the control flow of the above
cubin (a.cubin) with nvdisasm and Graphviz:
nvdisasm -cfg a.cubin | dot -ocfg.png -Tpng
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 9
nvdisasm
number of registers used. This is useful if the user is interested in the life range of any
particular register, or register usage in general.
This feature is only supported on cubins generated for Compute Capability 3.0 and
later.
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 10
nvdisasm
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 11
Chapter 4.
INSTRUCTION SET REFERENCE
This is an instruction set reference of NVIDIA® GPU architectures GT200, Fermi, Kepler
and Maxwell.
Opcode Description
A2R Move address register to data register
ADA Add immediate to address register
BAR CTA-wide barrier synchronization
BRA Conditional branch
BRK Conditional break from a loop
BRX Fetch an address from constant memory and branch to it
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 12
Instruction Set Reference
Opcode Description
C2R Conditional code to data register
CAL Unconditional subroutine call
COS Cosine
DADD Double-precision floating point addition
DFMA Double-precision floating point fused multiply-add
DMAX Double-precision floating point maximum
DMIN Double-precision floating point minimum
DMUL Double-precision floating point multiply
DSET Double-precision floating point conditional set
EX2 Exponential base two function
F2F Copy floating-point value with conversion to a different floating-
point type
F2I Copy floating-point value with conversion to integer
FADD/FADD32/FADD32I Single-precision floating point addition
FCMP Single-precision floating point compare
FMAD/FMAD32/FMAD32I Single-precision floating point multiply-add
FMAX Single-precision floating point maximum
FMIN Single-precision floating point minimum
FMUL/FMUL32/FMUL32I Single-precision floating point multiply
FSET Single-precision floating point conditional set
G2R Move from shared memory to register. A .LCK suffix indicates that
the bank is locked until a R2G.UNL has been performed; this is used
to implement shared memory atomics.
GATOM.IADD/EXCH/CAS/IMIN/ Global memory atomic operations; performs both an atomic
IMAX/INC/DEC/IAND/IOR/IXOR operation and returns the original value
GLD Load from global memory
GRED.IADD/IMIN/IMAX/INC/DEC/ Global memory reduction operations; performs only an atomic
IAND/IOR/IXOR operation with no return value
GST Store to global memory
I2F Copy integer value to floating-point with conversion
I2I Copy integer value to integer with conversion
IADD/IADD32/IADD32I Integer addition
IMAD/IMAD32/IMAD32I Integer multiply-add
IMAX Integer maximum
IMIN Integer minimum
IMUL/IMUL32/IMUL32I Integer multiply
ISAD/ISAD32 Sum of absolute difference
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 13
Instruction Set Reference
Opcode Description
ISET Integer conditional set
LG2 Floating point logarithm base 2
LLD Load from local memory
LST Store to local memory
LOP Logical operation (AND/OR/XOR)
MOV/MOV32 Move source to destination
MVC Move from constant memory to destination
MVI Move immediate to destination
NOP No operation
R2A Move register to address register
R2C Move data register to conditional code
R2G Store to shared memory. When used with the .UNL suffix, releases a
previously held lock on that shared memory bank
RCP Single-precision floating point reciprocal
RET Conditional return from subroutine
RRO Range reduction operator
RSQ Reciprocal square root
S2R Move special register to register
SHL Shift left
SHR Shift right
SIN Sine
SSY Set synchronization point; used before potentially divergent
instructions
TEX/TEX32 Texture fetch
VOTE Warp-vote primitive
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 14
Instruction Set Reference
Opcode Description
Floating Point Instructions
FFMA FP32 Fused Multiply Add
FADD FP32 Add
FCMP FP32 Compare
FMUL FP32 Multiply
FMNMX FP32 Minimum/Maximum
FSWZ FP32 Swizzle
FSET FP32 Set
FSETP FP32 Set Predicate
RRO FP Range Reduction Operator
MUFU FP Multi-Function Operator
DFMA FP64 Fused Multiply Add
DADD FP64 Add
DMUL FP64 Multiply
DMNMX FP64 Minimum/Maximum
DSET FP64 Set
DSETP FP64 Set Predicate
Integer Instructions
IMAD Integer Multiply Add
IMUL Integer Multiply
IADD Integer Add
ISCADD Integer Scaled Add
ISAD Integer Sum Of Abs Diff
IMNMX Integer Minimum/Maximum
BFE Integer Bit Field Extract
BFI Integer Bit Field Insert
SHR Integer Shift Right
SHL Integer Shift Left
LOP Integer Logic Op
FLO Integer Find Leading One
ISET Integer Set
ISETP Integer Set Predicate
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 15
Instruction Set Reference
Opcode Description
ICMP Integer Compare and Select
POPC Population Count
Conversion Instructions
F2F Float to Float
F2I Float to Integer
I2F Integer to Float
I2I Integer to Integer
Movement Instructions
MOV Move
SEL Conditional Select/Move
PRMT Permute
Predicate/CC Instructions
P2R Predicate to Register
R2P Register to Predicate
CSET CC Set
CSETP CC Set Predicate
PSET Predicate Set
PSETP Predicate Set Predicate
Texture Instructions
TEX Texture Fetch
TLD Texture Load
TLD4 Texture Load 4 Texels
TXQ Texture Query
Compute Load/Store Instructions
LDC Load from Constant
LD Load from Memory
LDU Load Uniform
LDL Load from Local Memory
LDS Load from Shared Memory
LDLK Load and Lock
LDSLK Load from Shared Memory and Lock
LD_LDU LD_LDU is a combination of a generic load LD with a load uniform
LDU
LDS_LDU LDS_LDU is combination of a Shared window load LDS with a load
uniform LDU.
ST Store to Memory
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 16
Instruction Set Reference
Opcode Description
STL Store to Local Memory
STUL Store and Unlock
STS Store to Shared Memory
STSUL Store to Shared Memory and Unlock
ATOM Atomic Memory Operation
RED Atomic Memory Reduction Operation
CCTL Cache Control
CCTLL Cache Control (Local)
MEMBAR Memory Barrier
Surface Memory Instructions
SULD Surface Load
SULEA Surface Load Effective Address
SUST Surface Store
SURED Surface Reduction
SUQ Surface Query
Control Instructions
BRA Branch to Relative Address
BRX Branch to Relative Indexed Address
JMP Jump to Absolute Address
JMX Jump to Absolute Indexed Address
CAL Call to Relative Address
JCAL Call to Absolute Address
RET Return from Call
BRK Break from Loop
CONT Continue in Loop
LONGJMP Long Jump
SSY Set Sync Relative Address
PBK Pre-Break Relative Address
PCNT Pre-Continue Relative Address
PRET Pre-Return Relative Address
PLONGJMP Pre-Long-Jump Relative Address
BPT Breakpoint/Trap
EXIT Exit Program
Miscellaneous Instructions
NOP No Operation
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 17
Instruction Set Reference
Opcode Description
S2R Special Register to Register
B2R Barrier to Register
LEPC Load Effective PC
BAR Barrier Synchronization
VOTE Query condition across threads
Opcode Description
Floating Point Instructions
FFMA FP32 Fused Multiply Add
FADD FP32 Add
FCMP FP32 Compare
FMUL FP32 Multiply
FMNMX FP32 Minimum/Maximum
FSWZ FP32 Swizzle
FSET FP32 Set
FSETP FP32 Set Predicate
FCHK FP32 Division Test
RRO FP Range Reduction Operator
MUFU FP Multi-Function Operator
DFMA FP64 Fused Multiply Add
DADD FP64 Add
DMUL FP64 Multiply
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 18
Instruction Set Reference
Opcode Description
DMNMX FP64 Minimum/Maximum
DSET FP64 Set
DSETP FP64 Set Predicate
Integer Instructions
IMAD Integer Multiply Add
IMADSP Integer Extract Multiply Add
IMUL Integer Multiply
IADD Integer Add
ISCADD Integer Scaled Add
ISAD Integer Sum Of Abs Diff
IMNMX Integer Minimum/Maximum
BFE Integer Bit Field Extract
BFI Integer Bit Field Insert
SHR Integer Shift Right
SHL Integer Shift Left
SHF Integer Funnel Shift
LOP Integer Logic Op
FLO Integer Find Leading One
ISET Integer Set
ISETP Integer Set Predicate
ICMP Integer Compare and Select
POPC Population Count
Conversion Instructions
F2F Float to Float
F2I Float to Integer
I2F Integer to Float
I2I Integer to Integer
Movement Instructions
MOV Move
SEL Conditional Select/Move
PRMT Permute
SHFL Warp Shuffle
Predicate/CC Instructions
P2R Predicate to Register
R2P Register to Predicate
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 19
Instruction Set Reference
Opcode Description
CSET CC Set
CSETP CC Set Predicate
PSET Predicate Set
PSETP Predicate Set Predicate
Texture Instructions
TEX Texture Fetch
TLD Texture Load
TLD4 Texture Load 4 Texels
TXQ Texture Query
Compute Load/Store Instructions
LDC Load from Constant
LD Load from Memory
LDG Non-coherent Global Memory Load
LDL Load from Local Memory
LDS Load from Shared Memory
LDSLK Load from Shared Memory and Lock
ST Store to Memory
STL Store to Local Memory
STS Store to Shared Memory
STSCUL Store to Shared Memory Conditionally and Unlock
ATOM Atomic Memory Operation
RED Atomic Memory Reduction Operation
CCTL Cache Control
CCTLL Cache Control (Local)
MEMBAR Memory Barrier
Surface Memory Instructions
SUCLAMP Surface Clamp
SUBFM Surface Bit Field Merge
SUEAU Surface Effective Address
SULDGA Surface Load Generic Address
SUSTGA Surface Store Generic Address
Control Instructions
BRA Branch to Relative Address
BRX Branch to Relative Indexed Address
JMP Jump to Absolute Address
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 20
Instruction Set Reference
Opcode Description
JMX Jump to Absolute Indexed Address
CAL Call to Relative Address
JCAL Call to Absolute Address
RET Return from Call
BRK Break from Loop
CONT Continue in Loop
SSY Set Sync Relative Address
PBK Pre-Break Relative Address
PCNT Pre-Continue Relative Address
PRET Pre-Return Relative Address
BPT Breakpoint/Trap
EXIT Exit Program
Miscellaneous Instructions
NOP No Operation
S2R Special Register to Register
B2R Barrier to Register
BAR Barrier Synchronization
VOTE Query condition across threads
Opcode Description
Floating Point Instructions
FADD FP32 Add
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 21
Instruction Set Reference
Opcode Description
FCHK Single Precision FP Divide Range Check
FCMP FP32 Compare to Zero and Select Source
FFMA FP32 Fused Multiply and Add
FMNMX FP32 Minimum/Maximum
FMUL FP32 Multiply
FSET FP32 Compare And Set
FSETP FP32 Compare And Set Predicate
FSWZADD FP32 Add used for FSWZ emulation
MUFU Multi Function Operation
RRO Range Reduction Operator FP
DADD FP64 Add
DFMA FP64 Fused Mutiply Add
DMNMX FP64 Minimum/Maximum
DMUL FP64 Multiply
DSET FP64 Compare And Set
DSETP FP64 Compare And Set Predicate
Integer Instructions
BFE Bit Field Extract
BFI Bit Field Insert
FLO Find Leading One
IADD Integer Addition
IADD3 3-input Integer Addition
ICMP Integer Compare to Zero and Select Source
IMAD Integer Multiply And Add
IMADSP Extracted Integer Multiply And Add.
IMNMX Integer Minimum/Maximum
IMUL Integer Multiply
ISCADD Scaled Integer Addition
ISET Integer Compare And Set
ISETP Integer Compare And Set Predicate
LEA Compute Effective Address
LOP Logic Operation
LOP3 3-input Logic Operation
POPC Population count
SHF Funnel Shift
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 22
Instruction Set Reference
Opcode Description
SHL Shift Left
SHR Shift Right
XMAD Integer Short Multiply Add
Conversion Instructions
F2F Floating Point To Floating Point Conversion
F2I Floating Point To Integer Conversion
I2F Integer To Floating Point Conversion
I2I Integer To Integer Conversion
Movement Instructions
MOV Move
PRMT Permute Register Pair
SEL Select Source with Predicate
SHFL Warp Wide Register Shuffle
Predicate/CC Instructions
CSET Test Condition Code And Set
CSETP Test Condition Code and Set Predicate
PSET Combine Predicates and Set
PSETP Combine Predicates and Set Predicate
P2R Move Predicate Register To Register
R2P Move Register To Predicate/CC Register
Texture Instructions
TEX Texture Fetch
TLD Texture Load
TLD4 Texture Load 4
TXQ Texture Query
TEXS Texture Fetch with scalar/non-vec4 source/destinations
TLD4S Texture Load 4 with scalar/non-vec4 source/destinations
TLDS Texture Load with scalar/non-vec4 source/destinations
Compute Load/Store Instructions
LD Load from generic Memory
LDC Load Constant
LDG Load from Global Memory
LDL Load within Local Memory Window
LDS Local within Shared Memory Window
ST Store to generic Memory
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 23
Instruction Set Reference
Opcode Description
STG Store to global Memory
STL Store within Local or Shared Window
STS Store within Local or Shared Window
ATOM Atomic Operation on generic Memory
ATOMS Atomic Operation on Shared Memory
RED Reduction Operation on generic Memory
CCTL Cache Control
CCTLL Cache Control
MEMBAR Memory Barrier
CCTLT Texture Cache Control
Surface Memory Instructions
SUATOM Surface Reduction
SULD Surface Load
SURED Atomic Reduction on surface memory
SUST Surface Store
Control Instructions
BRA Relative Branch
BRX Relative Branch Indirect
JMP Absolute Jump
JMX Absolute Jump Indirect
SSY Set Synchronization Point
SYNC Converge threads after conditional branch
CAL Relative Call
JCAL Absolute Call
PRET Pre-Return From Subroutine
RET Return From Subroutine
BRK Break
PBK Pre-Break
CONT Continue
PCNT Pre-continue
EXIT Exit Program
PEXIT Pre-Exit
BPT BreakPoint/Trap
Miscellaneous Instructions
NOP No Operation
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 24
Instruction Set Reference
Opcode Description
CS2R Move Special Register to Register
S2R Move Special Register to Register
B2R Move Barrier To Register
BAR Barrier Synchronization
R2B Move Register to Barrier
VOTE Vote Across SIMD Thread Group
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 25
Chapter 5.
NVPRUNE
nvprune prunes host object files and libraries to only contain device code for the
specified targets.
5.1. Usage
nvprune accepts a single input file each time it's run, emitting a new output file. The
basic usage is as following:
nvprune [options] -o <outfile> <infile>
The input file must be either a relocatable host object or static library (not a host
executable), and the output file will be the same format.
Either the --arch or --generate-code option must be used to specify the target(s) to keep.
All other device code is discarded from the file. The targets can be either a sm_NN arch
(cubin) or compute_NN arch (ptx).
For example, the following will prune libcublas_static.a to only contain sm_35 cubin
rather than all the targets which normally exist:
nvprune -arch sm_35 libcublas_static.a -o libcublas_static35.a
Note that this means that libcublas_static35.a will not run on any other architecture, so
should only be used when you are building for a single architecture.
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 26
nvprune
www.nvidia.com
CUDA Binary Utilities DA-06762-001_v7.0 | 27
Notice
ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS,
DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY,
"MATERIALS") ARE BEING PROVIDED "AS IS." NVIDIA MAKES NO WARRANTIES,
EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE
MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF
NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR
PURPOSE.
Information furnished is believed to be accurate and reliable. However, NVIDIA
Corporation assumes no responsibility for the consequences of use of such
information or for any infringement of patents or other rights of third parties
that may result from its use. No license is granted by implication of otherwise
under any patent rights of NVIDIA Corporation. Specifications mentioned in this
publication are subject to change without notice. This publication supersedes and
replaces all other information previously supplied. NVIDIA Corporation products
are not authorized as critical components in life support devices or systems
without express written approval of NVIDIA Corporation.
Trademarks
NVIDIA and the NVIDIA logo are trademarks or registered trademarks of NVIDIA
Corporation in the U.S. and other countries. Other company and product names
may be trademarks of the respective companies with which they are associated.
Copyright
© 2014 NVIDIA Corporation. All rights reserved.
www.nvidia.com