Skip to content

Commit f425db8

Browse files
authored
[clang][docs] Add preliminary documentation for SPIR-V support in the HIPAMD ToolChain (#96657)
This is mostly stealing from #75357, and updating it to reflect the pivot towards AMDGCN flavoured SPIR-V and the slightly different set of limitations. As we bring up more functionality it will be updated accordingly. With thanks to @yxsamliu.
1 parent b0f20f2 commit f425db8

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

clang/docs/HIPSupport.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,48 @@ Example Usage
284284
Base* basePtr = &obj;
285285
basePtr->virtualFunction(); // Allowed since obj is constructed in device code
286286
}
287+
288+
SPIR-V Support on HIPAMD ToolChain
289+
==================================
290+
291+
The HIPAMD ToolChain supports targetting
292+
`AMDGCN Flavoured SPIR-V <https://llvm.org/docs/SPIRVUsage.html#target-triples>`_.
293+
The support for SPIR-V in the ROCm and HIPAMD ToolChain is under active
294+
development.
295+
296+
Compilation Process
297+
-------------------
298+
299+
When compiling HIP programs with the intent of utilizing SPIR-V, the process
300+
diverges from the traditional compilation flow:
301+
302+
Using ``--offload-arch=amdgcnspirv``
303+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
304+
305+
- **Target Triple**: The ``--offload-arch=amdgcnspirv`` flag instructs the
306+
compiler to use the target triple ``spirv64-amd-amdhsa``. This approach does
307+
generates generic AMDGCN SPIR-V which retains architecture specific elements
308+
without hardcoding them, thus allowing for optimal target specific code to be
309+
generated at run time, when the concrete target is known.
310+
311+
- **LLVM IR Translation**: The program is compiled to LLVM Intermediate
312+
Representation (IR), which is subsequently translated into SPIR-V. In the
313+
future, this translation step will be replaced by direct SPIR-V emission via
314+
the SPIR-V Back-end.
315+
316+
- **Clang Offload Bundler**: The resulting SPIR-V is embedded in the Clang
317+
offload bundler with the bundle ID ``hip-spirv64-amd-amdhsa--amdgcnspirv``.
318+
319+
Mixed with Normal ``--offload-arch``
320+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
321+
322+
**Mixing ``amdgcnspirv`` and concrete ``gfx###`` targets via ``--offload-arch``
323+
is not currently supported; this limitation is temporary and will be removed in
324+
a future release**
325+
326+
Architecture Specific Macros
327+
----------------------------
328+
329+
None of the architecture specific :doc:`AMDGPU macros <AMDGPUSupport>` are
330+
defined when targeting SPIR-V. An alternative, more flexible mechanism to enable
331+
doing per target / per feature code selection will be added in the future.

0 commit comments

Comments
 (0)