-
Notifications
You must be signed in to change notification settings - Fork 31
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
Switch to XCode's Metal compiler? #7
Labels
Comments
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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: