-
Notifications
You must be signed in to change notification settings - Fork 49
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
Introduce support of the LLVM SPIR-V Backend to translate LLVM IR to SPIR-V #3229
base: main
Are you sure you want to change the base?
Introduce support of the LLVM SPIR-V Backend to translate LLVM IR to SPIR-V #3229
Conversation
Would be interesting to see what is the functional pass rate after switching to use the official LLVM SPIRV BE. |
Just a point to remember that we will not see actual pass rates in the CI -- active development means that CI results are always outdated. |
add_mlir_translation_library(TritonSPIRV | ||
SPIRVTranslation.cpp | ||
# Check if there is the LLVM SPIR-V backend. | ||
is_llvm_target_library("SPIRV" spirv_present_result INCLUDED_TARGETS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would SPIRV backend not exists after SPIRV backend moved out of experimental?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% until I check, but I'd expect that, for example, LLVM_TARGETS_TO_BUILD
allows to narrow a list of targets and exclude any existing target from actually installed.
57c6e8f
to
51425ea
Compare
static const std::string DefaultTriple = "spirv64v1.6-unknown-unknown"; | ||
static const std::vector<std::string> Opts{ | ||
"--avoid-spirv-capabilities", "Shader", "--translator-compatibility-mode", | ||
"--spirv-ext=all", "- O3"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"--spirv-ext=all", "- O3"}; | |
"--spirv-ext=all", "-O3"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A fun fact is that "- O3" is a legit option to pass in a legacy SPIR-V Backend API call. Please see a comment in lines 22-31 of third_party/intel/lib/Target/SPIRV/SPIRVTranslation.cpp for a wider perspective of how we are going to switch to a newer API call when it's available in openai llvm build.
In brief, this "- O3" will disappear in favor of explicit CodeGenOptLevel::Aggressive. For now, though, llvm has -O
reserved for itself, so SPIR-V Backend API engaged a slightly weird spelling of - O
to be able to pass opt level into the API call in a style of command line arguments. Appreciate your attention to these details in the review!
FYI @VyacheslavLevytskyy, LLVM commit is updated in #3316, it now contains llvm/llvm-project@cda81b1. |
b529394
to
f554c4f
Compare
Thank you @whitneywhtsang , this simplifies the patch even further, updated. |
@whitneywhtsang Looks like pre-built LLVM used by failed Github Actions doesn't contain SPIRV as a target. In scripts/compile-triton.sh we are able to explicitly list targets via
@pbchekin Can you please suggest what else should be updated for the prebuilt |
We currently use LLVM prebuilt by OpenAI (https://github.com/triton-lang/triton/blob/main/.github/workflows/llvm-build.yml), not sure if they are ready to add
|
8a0a03e
to
33556bd
Compare
Good point, thank you. Then I revert back to the initial logic that doesn't rely and always checks presence of SPIR-V Backend. |
…sh and CMakeLists.txt
33556bd
to
fbb5d89
Compare
This PR is to introduce support of the LLVM SPIR-V Backend to translate LLVM IR to SPIR-V. The backend will be preferred over Khronos Translator only when both conditions are satisfied:
TRITON_USE_SPIRV_BACKEND
present and set to a non-zero integer value.Khronos Translator remains the default tool to translate LLVM IR to SPIR-V.