-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libclc] Add an option to build SPIR-V targets with the LLVM backend #151347
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
Conversation
This removes the dependency on an external tool to build the SPIR-V files. It may be of interest to projects such as Mesa. Note that the option is off by default as using the SPIR-V backend, at least on my machine, uses a *lot* of memory and the process is often killed in a parallelized build. It does complete, however. Fixes llvm#135327.
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.
LGTM, thanks!
I see the same behavior, goes up to something like 30GB. The input is not particularly large (just 300k lines of IR). From a quick run through massif, it looks like MachineInstrs in SPIRVGlobalRegistry are the memory hog? |
) | ||
if ( LIBCLC_USE_SPIRV_BACKEND ) | ||
add_custom_command( OUTPUT ${libclc_builtins_lib} | ||
COMMAND ${clang_exe} --target=${ARG_TRIPLE} -x ir -o ${libclc_builtins_lib} ${builtins_link_lib} |
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.
should -c
be added to clang command line? It avoids spirv-link step.
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.
Good question! I'm not sure, to be honest. I tried using -c
and it generates a slightly larger file (6900 vs 6792). It seems to take a few fewer seconds to do so, which is an upside. I haven't looked into what exactly it's doing.
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.
perhaps spirv-link does optimization, but obviously there is only one file to link. LGTM as the final size is smaller, so this is not meant to be a blocker.
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.
sorry, not meant to be
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.
LGTM
Can this be backported to 21? |
I don't think it makes sense to backport this. At least at the time it landed it only worked in the sense of "does not crash during compilation". I'm not sure if the big compile-time and memory usage issue has been resolved since, or anyone has checked whether the produced SPIRV actually works. |
Yeah, it looks like at least 638383c is needed on 21 to make it work Just that infact |
This removes the dependency on an external tool to build the SPIR-V files. It may be of interest to projects such as Mesa.
Note that the option is off by default as using the SPIR-V backend, at least on my machine, uses a lot of memory and the process is often killed in a parallelized build. It does complete, however.
Fixes #135327.