Skip to content

[clang][docs] Add preliminary documentation for SPIR-V support in the HIPAMD ToolChain #96657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 61 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
662f160
Add initial support for AMDGCN flavoured SPIRV.
AlexVlx Apr 23, 2024
393ce66
Fix formatting.
AlexVlx Apr 23, 2024
2a10ad0
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Apr 25, 2024
98db8f7
Use `fillAMDGPUFeatureMap` instead of copy-pasta.
AlexVlx Apr 25, 2024
c359e0a
Add `__has_builtin` test.
AlexVlx Apr 25, 2024
e98f3f5
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Apr 28, 2024
c41726d
Re-use `AMDGPUTargetInfo`, where feasible, instead of copypasta-ing.
AlexVlx Apr 28, 2024
4698b58
Incorporate review suggestions.
AlexVlx Apr 28, 2024
aa1cd7c
Fix header ordering.
AlexVlx Apr 28, 2024
f9729ef
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 8, 2024
8257cb1
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 9, 2024
900cd69
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 11, 2024
3307f17
Handle `wavefrontsize` (we need both 32 and 64); add more tests.
AlexVlx May 12, 2024
eee6063
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 13, 2024
d2f4244
Add an additional test.
AlexVlx May 14, 2024
4cb4026
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 14, 2024
84a621d
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 14, 2024
1841385
AMDGCN SPIRV should allow both AMDGCN and SPIRV builtins.
AlexVlx May 15, 2024
0ce2da3
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 15, 2024
120b73c
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 15, 2024
f3942bd
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 15, 2024
31ac77d
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 15, 2024
0e9b1a1
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 16, 2024
83cd5e0
Enable AMDGCN flavoured SPIRV in the experimental SPIRV BE.
AlexVlx May 16, 2024
e9158b0
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 16, 2024
05074e7
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 19, 2024
e1fb93f
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 20, 2024
36c4bf6
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 27, 2024
5ffa186
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 27, 2024
cf1880c
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx May 29, 2024
4d85a1b
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 5, 2024
516e14c
Revert spurios testing noise, AMDGCN SPIRV is still SPIRV.
AlexVlx Jun 5, 2024
bdc3eb5
First pass at updating SPIR-V docs to reflect the addition of AMDGCN …
AlexVlx Jun 6, 2024
361d47b
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 6, 2024
b088c72
Fix erroneous versioning claim.
AlexVlx Jun 6, 2024
e85b557
Remove function pointer tests.
AlexVlx Jun 6, 2024
1d41787
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 6, 2024
8bcf2b2
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 10, 2024
9b3275b
Add HIP Driver support for AMDGCN flavoured SPIRV.
AlexVlx Jun 10, 2024
5b764ec
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 10, 2024
ba3fb6f
Fix formatting.
AlexVlx Jun 10, 2024
3719c3b
Revert changing the HIPAMD default to SPIR-V; tweak some tests.
AlexVlx Jun 12, 2024
7ca1c87
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 13, 2024
f3e5145
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 17, 2024
089bb9b
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 18, 2024
b60e753
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 19, 2024
8741e7c
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 20, 2024
5f775b8
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 20, 2024
4aa60c7
Fix warning.
AlexVlx Jun 20, 2024
1c2d0fa
Fix broken test.
AlexVlx Jun 20, 2024
e8a78a2
Reorder check.
AlexVlx Jun 21, 2024
294cd9c
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 21, 2024
f712c53
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 22, 2024
fe927e0
Do not allow mixing SPIR-V & concrete `offload-arch`s for now.
AlexVlx Jun 22, 2024
5ce5497
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 22, 2024
2220d37
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 24, 2024
83ec34c
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 24, 2024
887df00
Merge branch 'main' of https://github.com/llvm/llvm-project into amdg…
AlexVlx Jun 25, 2024
d281831
Add preliminary documentation for HIPAMD support for AMDGCN flavoured…
AlexVlx Jun 25, 2024
a3d42cb
Fix typo.
AlexVlx Jun 26, 2024
1fdcd9b
Correct the bundle id.
AlexVlx Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions clang/docs/HIPSupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,48 @@ Example Usage
Base* basePtr = &obj;
basePtr->virtualFunction(); // Allowed since obj is constructed in device code
}

SPIR-V Support on HIPAMD ToolChain
==================================

The HIPAMD ToolChain supports targetting
`AMDGCN Flavoured SPIR-V <https://llvm.org/docs/SPIRVUsage.html#target-triples>`_.
The support for SPIR-V in the ROCm and HIPAMD ToolChain is under active
development.

Compilation Process
-------------------

When compiling HIP programs with the intent of utilizing SPIR-V, the process
diverges from the traditional compilation flow:

Using ``--offload-arch=amdgcnspirv``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- **Target Triple**: The ``--offload-arch=amdgcnspirv`` flag instructs the
compiler to use the target triple ``spirv64-amd-amdhsa``. This approach does
generates generic AMDGCN SPIR-V which retains architecture specific elements
without hardcoding them, thus allowing for optimal target specific code to be
generated at run time, when the concrete target is known.

- **LLVM IR Translation**: The program is compiled to LLVM Intermediate
Representation (IR), which is subsequently translated into SPIR-V. In the
future, this translation step will be replaced by direct SPIR-V emission via
the SPIR-V Back-end.

- **Clang Offload Bundler**: The resulting SPIR-V is embedded in the Clang
offload bundler with the bundle ID ``hip-spirv64-amd-amdhsa--amdgcnspirv``.

Mixed with Normal ``--offload-arch``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**Mixing ``amdgcnspirv`` and concrete ``gfx###`` targets via ``--offload-arch``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to play with this with my driver code. I'm guessing it's because it needs to generate an entirely separate toolchain? The OpenMP path basically does that by inferring the toolchain from the string value, so we can support --offload-arch=sm_89,gfx90a for example.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need HIPAMD toolchain instead of HIPSPIRV toolchain because we want to locate the tools and device libraries on ROCm platform and do argument translation using amdgpu information like we are compiling for any amdgpu processors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yxsamliu is correct, the HIPSPIRV toolchain is matched to a different downstream ecosystem.

is not currently supported; this limitation is temporary and will be removed in
a future release**

Architecture Specific Macros
----------------------------

None of the architecture specific :doc:`AMDGPU macros <AMDGPUSupport>` are
defined when targeting SPIR-V. An alternative, more flexible mechanism to enable
doing per target / per feature code selection will be added in the future.