You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed on Slack (#gpu), the LLVM code output shown after pressing L in an Cthulhu interactive session is run through the wrong pipeline, resulting in host-side optimisations/… being applied to it.
Real-world example
For instance, consider this
using Metal
@metal (() -> (rand(Float32); nothing))()
which fails, as scalar rand() is not implemented on Metal yet. The error message is
ERROR: InvalidIRError: compiling MethodInstance for (::var"#3#4")() resulted in invalid LLVM IR
Reason: unsupported call to an unknown function (call to julia.get_pgcstack)
Hint: catch this exception as `err` and call `code_typed(err; interactive = true)` to introspect the erronous code with Cthulhu.jl
[…]
and running the suggested code
julia>try@metal (() -> (rand(Float32); nothing))()
catch err
code_typed(err; interactive=true)
end
which seems to have been run through the host-side pipeline, as the julia.get_pgcstack call has been lowered into an extra argument, etc. This is obviously not desirable in any case, but here it is particularly confusing, as the host-side pipeline has removed the offending code.
The text was updated successfully, but these errors were encountered:
maleadt
changed the title
LLVM output in InvalidIRError-suggested Cthulhu call uses host instead of device pipeline
Cthulhu uses InteractiveUtils.code_llvm instead of GPUCompiler.jl
Nov 15, 2024
As discussed on Slack (#gpu), the LLVM code output shown after pressing
L
in an Cthulhu interactive session is run through the wrong pipeline, resulting in host-side optimisations/… being applied to it.Real-world example
For instance, consider this
which fails, as scalar rand() is not implemented on Metal yet. The error message is
and running the suggested code
initally gives the correct
code_typed()
output(here, the RNG tries to access TLS state, hence the reference to
jl_get_current_task
, which gets lowered to the offendingjulia.get_pgcstack
).However, pressing
L
to look at the actual LLVM IR gives the following (debug info turned off):which seems to have been run through the host-side pipeline, as the
julia.get_pgcstack
call has been lowered into an extra argument, etc. This is obviously not desirable in any case, but here it is particularly confusing, as the host-side pipeline has removed the offending code.@vchuravy has identified the root cause for this in the
code_llvm
for the host pipeline being called here: https://github.com/JuliaDebug/Cthulhu.jl/blob/3cd0baf586ab07f18ecf9c6f040e6764e8155322/src/codeview.jl#L26The text was updated successfully, but these errors were encountered: