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
We're currently using a custom metallib-as to downgrade LLVM IR and generate a metallib containing LLVM 5 bitcode, however, it's possible to just re-use XCode's Clang-based metal compiler for this:
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/metal/macos/bin/metal kernel.(ll|bc)
warning: overriding the module target triple with air64-apple-macosx12.0.0 [-Woverride-module]
1 warning generated
The problem is that we still need to downgrade the LLVM IR (this is more obvious when using textual bitcode inputs, in which case metal will complain about unsupported deferencerable arguments, spFlags MDNode contents, etc), but a tool for that could be more valuable, e.g., to support NVIDIA's NVVM compiler.
Another disadvantage is that we'd then require users to have Xcode installed, and the full thing at that (the metal compiler isn't part of the command line xcode tools). That's a multi-gigabyte download and installation, since presumably Apple doesn't allow us to redistribute those parts of the SDK.
The text was updated successfully, but these errors were encountered:
diff --git a/src/metal.jl b/src/metal.jl
index b314899..922e9be 100644
--- a/src/metal.jl+++ b/src/metal.jl@@ -708,18 +708,34 @@ end
If you think this is a bug, please file an issue and attach $(input).""")
end
end
+ cp(translated, "/tmp/ours.metallib"; force=true)++ input_alternative = tempname(cleanup=false) * ".ll"+ translated_alternative = tempname(cleanup=false) * ".reference.metallib"+ strip_debuginfo!(mod) # quick hack to support some more IR without downgrading+ write(input_alternative, string(mod))+ let+ proc = run(ignorestatus(`/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/metal/macos/bin/metal -o $translated_alternative $input_alternative`))+ if !success(proc)+ error("""Failed to translate LLVM code to MetalLib.+ If you think this is a bug, please file an issue and attach $(input_alternative).""")+ end+ end+ cp(translated_alternative, "/tmp/theirs.metallib"; force=true)
output = if format == LLVM.API.LLVMObjectFile
- read(translated)+ read(translated_alternative)
else
# disassemble
Metal_LLVM_Tools_jll.metallib_dis() do disassembler
- read(`$disassembler -o - $translated`, String)+ read(`$disassembler -o - $translated_alternative`, String)
end
end
rm(input)
rm(translated)
+ rm(input_alternative)+ rm(translated_alternative)
return output
end
We're currently using a custom
metallib-as
to downgrade LLVM IR and generate a metallib containing LLVM 5 bitcode, however, it's possible to just re-use XCode's Clang-based metal compiler for this:The problem is that we still need to downgrade the LLVM IR (this is more obvious when using textual bitcode inputs, in which case
metal
will complain about unsupporteddeferencerable
arguments,spFlags
MDNode contents, etc), but a tool for that could be more valuable, e.g., to support NVIDIA's NVVM compiler.Another disadvantage is that we'd then require users to have Xcode installed, and the full thing at that (the metal compiler isn't part of the command line xcode tools). That's a multi-gigabyte download and installation, since presumably Apple doesn't allow us to redistribute those parts of the SDK.
The text was updated successfully, but these errors were encountered: