a0dc485ceb
* pip-compile docs/requirements.txt Signed-off-by: Peter Jun Park <peter.park@amd.com> Add Sphinx docs config Signed-off-by: Peter Jun Park <peter.park@amd.com> Add Sphinx config Signed-off-by: Peter Jun Park <peter.park@amd.com> Update docs build config Signed-off-by: Peter Jun Park <peter.park@amd.com> * style(conf.py): Apply black formatting to docs/conf.py Signed-off-by: Sam Wu <22262939+samjwu@users.noreply.github.com> * Update docs requirements Signed-off-by: Peter Jun Park <peter.park@amd.com> Update to rocm-docs-core 1.3.0 Signed-off-by: Peter Jun Park <peter.park@amd.com> Update docs requirements Signed-off-by: Peter Jun Park <peter.park@amd.com> pip-compile requirements Signed-off-by: Peter Jun Park <peter.park@amd.com> bump rocm-docs-core to 1.5.0 bump rocm-docs-core to 1.4.1 Signed-off-by: Peter Jun Park <peter.park@amd.com> * Add dependabot.yml and update CODEOWNERS Signed-off-by: Peter Jun Park <peter.park@amd.com> Update toc and conf Signed-off-by: Peter Jun Park <peter.park@amd.com> update dependabot * Port docs to rocm-docs standard Signed-off-by: Peter Jun Park <peter.park@amd.com> Add toc and Diataxis cards Signed-off-by: Peter Jun Park <peter.park@amd.com> Add basic file structure Signed-off-by: Peter Jun Park <peter.park@amd.com> add glossary Signed-off-by: Peter Jun Park <peter.park@amd.com> add includes Signed-off-by: Peter Jun Park <peter.park@amd.com> Add license.rst Signed-off-by: Peter Jun Park <peter.park@amd.com> add compatible hw Signed-off-by: Peter Jun Park <peter.park@amd.com> fix spelling and license Signed-off-by: Peter Jun Park <peter.park@amd.com> clean up index Signed-off-by: Peter Jun Park <peter.park@amd.com> clean up installation guides Signed-off-by: Peter Jun Park <peter.park@amd.com> add basic usage (quickstart) Signed-off-by: Peter Jun Park <peter.park@amd.com> add ref to global options update toc Signed-off-by: Peter Jun Park <peter.park@amd.com> modularize modes and global options Signed-off-by: Peter Jun Park <peter.park@amd.com> add profile mode Signed-off-by: Peter Jun Park <peter.park@amd.com> fixes Signed-off-by: Peter Jun Park <peter.park@amd.com> reorg and clean up Signed-off-by: Peter Jun Park <peter.park@amd.com> add dynamic omniperf version number in installation guide Signed-off-by: Peter Jun Park <peter.park@amd.com> add datatemplate more reorg Signed-off-by: Peter Jun Park <peter.park@amd.com> clean up Signed-off-by: Peter Jun Park <peter.park@amd.com> reorg images move profile mode reorg reorg reorg more fix formatting fix headings ref anchor mi2xx note add extlinks add extlinks Signed-off-by: Peter Jun Park <peter.park@amd.com> black format fix formatting, anchors Signed-off-by: Peter Jun Park <peter.park@amd.com> reorg fix words and formatting Signed-off-by: Peter Jun Park <peter.park@amd.com> formatting Signed-off-by: Peter Jun Park <peter.park@amd.com> same reorg format fix formatting fix toc Signed-off-by: Peter Jun Park <peter.park@amd.com> format * impr internal linking and fix sphinx warnings Signed-off-by: Peter Jun Park <peter.park@amd.com> * add spellcheck/linting from rocm-docs-core Signed-off-by: Peter Jun Park <peter.park@amd.com> fix rst directives satisfy spellcheck fix more spelling rm unused files fix spelling and update wordlist * bump rocm-docs-core to 1.6.0 Signed-off-by: Peter Jun Park <peter.park@amd.com> * add fixes from @skyreflectedinmirrors and @lpaoletti Signed-off-by: Peter Jun Park <peter.park@amd.com> add references to toc Signed-off-by: Peter Jun Park <peter.park@amd.com> add more fixes Signed-off-by: Peter Jun Park <peter.park@amd.com> * add package manager install section Signed-off-by: Peter Jun Park <peter.park@amd.com> * add fixes Signed-off-by: Peter Jun Park <peter.park@amd.com> add metadata and fixes Signed-off-by: Peter Jun Park <peter.park@amd.com> add fixes bump to 1.6.1 more fixes fix fmt in profiling examples Signed-off-by: Peter Jun Park <peter.park@amd.com> add missing mem type table Signed-off-by: Peter Jun Park <peter.park@amd.com> fix formatting fmt * add custom css Signed-off-by: Peter Jun Park <peter.park@amd.com> fix css fs * make images/figs click-to-expand Signed-off-by: Peter Jun Park <peter.park@amd.com> add missed image update fix link * update documentation link in README Signed-off-by: Peter Jun Park <peter.park@amd.com> * formatting fixes Signed-off-by: Peter Jun Park <peter.park@amd.com> more formatting * fix heading Signed-off-by: Peter Jun Park <peter.park@amd.com> * move archived docs Signed-off-by: Peter Jun Park <peter.park@amd.com> * exclude archived docs from docs build Signed-off-by: Peter Jun Park <peter.park@amd.com> * update archived docs workflow Signed-off-by: Peter Jun Park <peter.park@amd.com> move files update archived docs workflow Signed-off-by: Peter Jun Park <peter.park@amd.com> fix version number clean up workflow workflow test workflow test another workflow test * rm docs linting Signed-off-by: Peter Jun Park <peter.park@amd.com> * Apply cmake-format suggested changes Signed-off-by: Sam Wu <22262939+samjwu@users.noreply.github.com> * Apply cmake-format Signed-off-by: Sam Wu <22262939+samjwu@users.noreply.github.com> --------- Signed-off-by: Peter Jun Park <peter.park@amd.com> Signed-off-by: Sam Wu <22262939+samjwu@users.noreply.github.com> Co-authored-by: Sam Wu <22262939+samjwu@users.noreply.github.com>
300 lines
12 KiB
ReStructuredText
300 lines
12 KiB
ReStructuredText
.. meta::
|
||
:description: Omniperf performance model: Shader engine (SE)
|
||
:keywords: Omniperf, ROCm, profiler, tool, Instinct, accelerator, pipeline, VALU, SALU, VMEM, SMEM, LDS, branch,
|
||
scheduler, MFMA, AGPRs
|
||
|
||
*********************
|
||
Pipeline descriptions
|
||
*********************
|
||
|
||
This section details the various execution pipelines of the
|
||
:doc:`compute unit <compute-unit>`.
|
||
|
||
.. _desc-valu:
|
||
|
||
.. _desc-vmem:
|
||
|
||
Vector arithmetic logic unit (VALU)
|
||
-----------------------------------
|
||
|
||
The vector arithmetic logic unit (VALU) executes vector instructions
|
||
over an entire wavefront, each :ref:`work-item <desc-work-item>` (or,
|
||
vector-lane) potentially operating on distinct data. The VALU of a CDNA™
|
||
accelerator or GCN™ GPU typically consists of:
|
||
|
||
* Four 16-wide SIMD processors (see :hip-training-pdf:`24` for more details).
|
||
|
||
* Four 64 or 128 KiB VGPR files (yielding a total of 256-512 KiB total
|
||
per CU), see :ref:`AGPRs <desc-agprs>` for more detail.
|
||
|
||
* An instruction buffer (per-SIMD) that contains execution slots for up
|
||
to 8 wavefronts (for 32 total wavefront slots on each CU).
|
||
|
||
* A vector memory (VMEM) unit which transfers data between VGPRs and
|
||
memory; each work-item supplies its own memory address and supplies
|
||
or receives unique data.
|
||
|
||
* CDNA accelerators, such as the MI100 and :ref:`MI2XX <mixxx-note>`, contain
|
||
additional
|
||
:amd-lab-note:`Matrix Fused Multiply-Add (MFMA) <amd-lab-notes-matrix-cores-readme>`
|
||
units.
|
||
|
||
To support branching and conditionals, each wavefront in the VALU
|
||
has a distinct execution mask which determines which work-items in the
|
||
wavefront are active for the currently executing instruction. When
|
||
executing a VALU instruction, inactive work-items (according to the
|
||
current execution mask of the wavefront) do not execute the instruction
|
||
and are treated as no-ops.
|
||
|
||
.. note::
|
||
|
||
On GCN GPUs and the CDNA MI100 accelerator, there are slots for up to 10
|
||
wavefronts in the instruction buffer, but generally occupancy is limited by
|
||
other factors to 32 waves per :doc:`compute unit <compute-unit>`.
|
||
On the CDNA2 :ref:`MI2XX <mixxx-note>` series accelerators, there are only 8
|
||
waveslots per-SIMD.
|
||
|
||
.. _desc-salu:
|
||
|
||
.. _desc-smem:
|
||
|
||
Scalar arithmetic logic unit (SALU)
|
||
-----------------------------------
|
||
|
||
The scalar arithmetic logic unit (SALU) executes instructions that are
|
||
shared between all work-items in a wavefront. This includes control flow
|
||
such as if/else conditionals, branches and looping pointer arithmetic, loading
|
||
common values, and more.
|
||
|
||
The SALU consists of:
|
||
|
||
* A scalar processor capable of various arithmetic, conditional, and
|
||
comparison (etc.) operations. See
|
||
:mi200-isa-pdf:`Chapter 5. Scalar ALU Operations <35>`
|
||
of the CDNA2 Instruction Set Architecture (ISA) Reference Guide for more
|
||
detail.
|
||
|
||
* A 12.5 KiB Scalar General Purpose Register (SGPR) file
|
||
|
||
* A scalar memory (SMEM) unit which transfers data between SGPRs and
|
||
memory
|
||
|
||
Data loaded by the SMEM can be cached in the :ref:`scalar L1 data cache <desc-sl1d>`,
|
||
and is typically only used for read-only, uniform accesses such as kernel
|
||
arguments, or HIP’s ``__constant__`` memory.
|
||
|
||
.. _desc-lds:
|
||
|
||
Local data share (LDS)
|
||
----------------------
|
||
|
||
The local data share (LDS, a.k.a., "shared memory") is fast on-CU scratchpad
|
||
that can be explicitly managed by software to effectively share data and to
|
||
coordinate between wavefronts in a workgroup.
|
||
|
||
.. figure:: ../data/performance-model/lds.*
|
||
:align: center
|
||
:alt: Performance model of the local data share (LDS) on AMD Instinct
|
||
accelerators
|
||
:width: 800
|
||
|
||
Performance model of the local data share (LDS) on AMD Instinct MI-series
|
||
accelerators.
|
||
|
||
Above is Omniperf's performance model of the LDS on CDNA accelerators (adapted
|
||
from :mantor-gcn-pdf:`20`). The SIMDs in the :ref:`VALU <desc-valu>` are
|
||
connected to the LDS in pairs (see above). Only one SIMD per pair may issue an
|
||
LDS instruction at a time, but both pairs may issue concurrently.
|
||
|
||
On CDNA accelerators, the LDS contains 32 banks and each bank is 4B wide.
|
||
The LDS is designed such that each bank can be read from, written to, or
|
||
atomically updated every cycle, for a total throughput of 128B/clock
|
||
(:gcn-crash-course:`40`).
|
||
|
||
On each of the two ports to the SIMDs, 64B can be sent in each direction per
|
||
cycle. So, a single wavefront, coming from one of the 2 SIMDs in a pair, can
|
||
only get back 64B/cycle (16 lanes per cycle). The input port is shared between
|
||
data and address and this can affect achieved bandwidth for different data
|
||
sizes. For example, a 64-wide store where each lane is sending a 4B value takes
|
||
8 cycles (50% peak bandwidth) while a 64-wide store where each lane is sending
|
||
a 16B value takes 20 cycles (80% peak bandwidth).
|
||
|
||
In addition, the LDS contains conflict-resolution hardware to detect and handle
|
||
bank conflicts. A bank conflict occurs when two (or more)
|
||
:ref:`work-items <desc-work-item>` in a :ref:`wavefront <desc-wavefront>` want
|
||
to read, write, or atomically update different addresses that map to the same
|
||
bank in the same cycle. In this case, the conflict detection hardware will
|
||
determine a new schedule such that the access is split into multiple cycles with
|
||
no conflicts in any single cycle.
|
||
|
||
When multiple work-items want to read from the same address within a bank, the
|
||
result can be efficiently broadcasted (:gcn-crash-course:`41`). Multiple
|
||
work-items writing to the same address within a bank typically results undefined
|
||
behavior in HIP and other high-level languages, as the LDS will write the value from the
|
||
last work-item as determined by the hardware scheduler (:gcn-crash-course:`41`).
|
||
This behavior may be useful in the very specific case of storing a uniform
|
||
value.
|
||
|
||
Relatedly, an address conflict is defined as occurring when two (or more)
|
||
work-items in a wavefront want to atomically update the same address on the same
|
||
cycle. As in a bank-conflict, this may cause additional cycles of work for the
|
||
LDS operation to complete.
|
||
|
||
.. _desc-branch:
|
||
|
||
Branch
|
||
------
|
||
|
||
The branch unit is responsible for executing jumps and branches to execute
|
||
control flow operations.
|
||
Note that Branch operations are not used for execution mask updates, but only
|
||
for “whole wavefront” control-flow changes.
|
||
|
||
.. _desc-scheduler:
|
||
|
||
Scheduler
|
||
---------
|
||
|
||
The scheduler is responsible for arbitration and issue of instructions for all
|
||
the wavefronts currently executing on the :doc:`CU <compute-unit>`. On every
|
||
clock cycle, the scheduler:
|
||
|
||
* Considers waves from one of the SIMD units for execution, selected in a
|
||
round-robin fashion between the SIMDs in the compute unit
|
||
|
||
* Issues up to one instruction per wavefront on the selected SIMD
|
||
|
||
* Issues up to one instruction per each of the instruction categories among the waves on the selected SIMD:
|
||
|
||
* :ref:`VALU <desc-valu>`
|
||
|
||
* :ref:`VMEM <desc-vmem>` operations
|
||
|
||
* :ref:`SALU <desc-salu>` / SMEM operations
|
||
|
||
* :ref:`LDS <desc-lds>`
|
||
|
||
* :ref:`Branch <desc-branch>` operations
|
||
|
||
This gives a maximum of five issued Instructions Per Cycle (IPC), per-SIMD,
|
||
per-CU (:hip-training-pdf:`Introduction to AMD GPU Programming with HIP <>`,
|
||
:gcn-crash-course:`The AMD GCN Architecture - A Crash Course <>`). On CDNA
|
||
accelerators with :ref:`MFMA <desc-mfma>` instructions, these are issued via the
|
||
:ref:`VALU <desc-valu>`. Some of them will execute on a separate functional unit
|
||
and typically allow other :ref:`VALU <desc-valu>` operations to execute in their
|
||
shadow (see the :ref:`MFMA <desc-mfma>` section for more detail).
|
||
|
||
.. note::
|
||
|
||
The IPC model used by Omniperf omits the following two complications for
|
||
clarity. First, CDNA accelerators contain other execution units on the CU
|
||
that are unused for compute applications. Second, so-called "internal"
|
||
instructions (see :gcn-crash-course:`29`) are not issued to a functional
|
||
unit, and can technically cause the maximum IPC to *exceed* 5 instructions
|
||
per-cycle in special (largely unrealistic) cases. The latter issue is
|
||
discussed in more detail in the
|
||
:ref:`'internal' IPC <ipc-internal-instructions>` example.
|
||
|
||
.. _desc-mfma:
|
||
|
||
Matrix fused multiply-add (MFMA)
|
||
--------------------------------
|
||
|
||
CDNA accelerators, such as the MI100 and :ref:`MI2XX <mixxx-note>`, contain
|
||
specialized hardware to accelerate matrix-matrix multiplications, also
|
||
known as Matrix Fused Multiply-Add (MFMA) operations. The exact
|
||
operation types and supported formats may vary by accelerator. Refer to the
|
||
:amd-lab-note:`AMD matrix cores <amd-lab-notes-matrix-cores-readme>`
|
||
blog post on GPUOpen for a general discussion of these hardware units.
|
||
In addition, to explore the available MFMA instructions in-depth on
|
||
various AMD accelerators (including the CDNA line), we recommend the
|
||
`AMD Matrix Instruction Calculator <https://github.com/ROCm/amd_matrix_instruction_calculator>`_:
|
||
|
||
.. code-block:: shell
|
||
:caption: Partial snapshot of the AMD Matrix Instruction Calculator Tool
|
||
|
||
$ ./matrix_calculator.py –architecture cdna2 –instruction v_mfma_f32_4x4x1f32 –detail-instruction
|
||
Architecture: CDNA2
|
||
Instruction: V_MFMA_F32_4X4X1F32
|
||
Encoding: VOP3P-MAI
|
||
VOP3P Opcode: 0x42
|
||
VOP3P-MAI Opcode: 0x2
|
||
Matrix Dimensions:
|
||
M: 4
|
||
N: 4
|
||
K: 1
|
||
blocks: 16
|
||
Execution statistics:
|
||
FLOPs: 512
|
||
Execution cycles: 8
|
||
FLOPs/CU/cycle: 256
|
||
Can co-execute with VALU: True
|
||
VALU co-execution cycles possible: 4
|
||
Register usage:
|
||
GPRs required for A: 1
|
||
GPRs required for B: 1
|
||
GPRs required for C: 4
|
||
GPRs required for D: 4
|
||
GPR alignment requirement: 8 bytes
|
||
|
||
For the purposes of Omniperf, the MFMA unit is typically treated as a separate
|
||
pipeline from the :ref:`VALU <desc-valu>`, as other VALU instructions (along
|
||
with other execution pipelines such as the :ref:`SALU <desc-salu>`) typically can be
|
||
issued during a portion of the total duration of an MFMA operation.
|
||
|
||
.. note::
|
||
|
||
The exact details of VALU and MFMA operation co-execution vary by
|
||
instruction, and can be explored in more detail via the following fields in
|
||
the
|
||
`AMD Matrix Instruction Calculator's detailed instruction information <https://github.com/ROCm/amd_matrix_instruction_calculator#example-of-querying-instruction-information>`_:
|
||
|
||
* ``Can co-execute with VALU``
|
||
|
||
* ``VALU co-execution cycles possible``
|
||
|
||
|
||
Non-pipeline resources
|
||
----------------------
|
||
|
||
In this section, we describe a few resources that are not standalone
|
||
pipelines but are important for understanding performance optimization
|
||
on CDNA accelerators.
|
||
|
||
.. _desc-barrier:
|
||
|
||
Barrier
|
||
^^^^^^^
|
||
|
||
Barriers are resources on the compute-unit of a CDNA accelerator that
|
||
are used to implement synchronization primitives (for example, HIP’s
|
||
``__syncthreads``). Barriers are allocated to any workgroup that
|
||
consists of more than a single wavefront.
|
||
|
||
.. _desc-agprs:
|
||
|
||
Accumulation vector general-purpose registers (AGPRs)
|
||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||
|
||
Accumulation vector general-purpose registers, or AGPRs, are special
|
||
resources that are accessible to a subset of instructions focused on
|
||
:ref:`MFMA <desc-mfma>` operations. These registers allow the MFMA
|
||
unit to access more than the normal maximum of 256 architected
|
||
:ref:`vector general-purpose registers (VGPRs) <desc-valu>` by having up to 256
|
||
in the architected space and up to 256 in the accumulation space.
|
||
Traditional VALU instructions can only use VGPRs in the architected
|
||
space, and data can be moved to/from VGPRs↔AGPRs using specialized
|
||
instructions (``v_accvgpr_*``). These data movement instructions may be
|
||
used by the compiler to implement lower-cost register-spill/fills on
|
||
architectures with AGPRs.
|
||
|
||
AGPRs are not available on all AMD Instinct™ accelerators. GCN GPUs,
|
||
such as the AMD Instinct MI50 had a 256 KiB VGPR file. The AMD
|
||
Instinct MI100 (CDNA) has a 2x256 KiB register file, where one half
|
||
is available as general-purpose VGPRs, and the other half is for matrix
|
||
math accumulation VGPRs (AGPRs). The AMD Instinct :ref:`MI2XX <mixxx-note>`
|
||
(CDNA2) has a 512 KiB VGPR file per CU, where each wave can dynamically request
|
||
up to 256 KiB of VGPRs and an additional 256 KiB of AGPRs. For more information,
|
||
refer to `this comment <https://github.com/ROCm/ROCm/issues/1689#issuecomment-1553751913>`_.
|
||
|