Skip to content
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

@device_code_agx errors when Metal Shader Validation is enabled #463

Open
christiangnrd opened this issue Oct 17, 2024 · 1 comment
Open

Comments

@christiangnrd
Copy link
Contributor

christiangnrd commented Oct 17, 2024

MWE
julia> using Metal

julia> Metal.versioninfo()
macOS 15.0.1, Darwin 24.0.0

Toolchain:
- Julia: 1.11.1
- LLVM: 16.0.6

Julia packages: 
- Metal.jl: 1.4.0
- GPUArrays: 10.3.1
- GPUCompiler: 1.0.0
- KernelAbstractions: 0.9.28
- ObjectiveC: 3.1.0
- LLVM: 9.1.2
- LLVMDowngrader_jll: 0.3.0+1

Environment:
- MTL_SHADER_VALIDATION: 1
- MTL_DEBUG_LAYER: 1

2024-10-17 16:40:59.867 julia[17424:9358094] Metal API Validation Enabled
2024-10-17 16:40:59.867 julia[17424:9358094] Metal GPU Validation Enabled
1 device:
- Apple M2 Max (192.000 KiB allocated)

julia> dummy() = return
dummy (generic function with 1 method)

julia> @device_code_agx @metal dummy()
; GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams}(MethodInstance for dummy(), CompilerConfig for GPUCompiler.MetalCompilerTarget, 0x0000000000006845)

ERROR: Expected a universal binary, got a Vector{ObjectFile.MachO.MachOHandle{IOStream}}
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] extract_gpu_code(f::Metal.var"#188#191"{String, Base.TTY}, binary::String)
    @ Metal ~/.julia/dev/Metal/src/compiler/reflection.jl:96
  [3] #187
    @ ~/.julia/dev/Metal/src/compiler/reflection.jl:69 [inlined]
  [4] mktempdir(fn::Metal.var"#187#190"{Metal.MTL.MTLBinaryArchiveInstance, Base.TTY}, parent::String; prefix::String)
    @ Base.Filesystem ./file.jl:819
  [5] mktempdir (repeats 2 times)
    @ ./file.jl:815 [inlined]
  [6] macro expansion
    @ ~/.julia/dev/Metal/src/compiler/reflection.jl:61 [inlined]
  [7] (::Metal.var"#186#189"{Base.TTY, GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams}})()
    @ Metal ~/.julia/packages/ObjectiveC/C7BVt/src/foundation.jl:637
  [8] macro expansion
    @ ~/.julia/packages/ObjectiveC/C7BVt/src/foundation.jl:565 [inlined]
  [9] macro expansion
    @ ./lock.jl:273 [inlined]
 [10] ObjectiveC.Foundation.NSAutoreleasePool(f::Metal.var"#186#189"{Base.TTY, GPUCompiler.CompilerJob{…}})
    @ ObjectiveC.Foundation ~/.julia/packages/ObjectiveC/C7BVt/src/foundation.jl:557
 [11] code_agx
    @ ~/.julia/packages/ObjectiveC/C7BVt/src/foundation.jl:636 [inlined]
 [12] (::Metal.var"#hook#203"{…})(job::GPUCompiler.CompilerJob{…}; io::Base.TTY, kwargs::@Kwargs{})
    @ Metal ~/.julia/dev/Metal/src/compiler/reflection.jl:216
 [13] (::Metal.var"#hook#203"{…})(job::GPUCompiler.CompilerJob{…})
    @ Metal ~/.julia/dev/Metal/src/compiler/reflection.jl:213
 [14] var"#4#outer_hook"(job::GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams})
    @ Main ~/.julia/packages/GPUCompiler/QCNA0/src/reflection.jl:174
 [15] compile(target::Symbol, job::GPUCompiler.CompilerJob; kwargs::@Kwargs{})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/QCNA0/src/driver.jl:76
 [16] compile
    @ ~/.julia/packages/GPUCompiler/QCNA0/src/driver.jl:74 [inlined]
 [17] (::Metal.var"#155#163"{GPUCompiler.CompilerJob{…}})(ctx::LLVM.Context)
    @ Metal ~/.julia/dev/Metal/src/compiler/compilation.jl:108
 [18] JuliaContext(f::Metal.var"#155#163"{GPUCompiler.CompilerJob{…}}; kwargs::@Kwargs{})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/QCNA0/src/driver.jl:34
 [19] JuliaContext(f::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/QCNA0/src/driver.jl:25
 [20] macro expansion
    @ ~/.julia/dev/Metal/src/compiler/compilation.jl:107 [inlined]
 [21] macro expansion
    @ ~/.julia/packages/ObjectiveC/C7BVt/src/os.jl:264 [inlined]
 [22] compile(job::GPUCompiler.CompilerJob)
    @ Metal ~/.julia/dev/Metal/src/compiler/compilation.jl:105
 [23] actual_compilation(cache::Dict{…}, src::Core.MethodInstance, world::UInt64, cfg::GPUCompiler.CompilerConfig{…}, compiler::typeof(Metal.compile), linker::typeof(Metal.link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/QCNA0/src/execution.jl:237
 [24] cached_compilation(cache::Dict{…}, src::Core.MethodInstance, cfg::GPUCompiler.CompilerConfig{…}, compiler::Function, linker::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/QCNA0/src/execution.jl:151
 [25] macro expansion
    @ ~/.julia/dev/Metal/src/compiler/execution.jl:189 [inlined]
 [26] macro expansion
    @ ./lock.jl:273 [inlined]
 [27] mtlfunction(f::typeof(dummy), tt::Type{Tuple{}}; name::Nothing, kwargs::@Kwargs{})
    @ Metal ~/.julia/dev/Metal/src/compiler/execution.jl:184
 [28] mtlfunction(f::typeof(dummy), tt::Type{Tuple{}})
    @ Metal ~/.julia/dev/Metal/src/compiler/execution.jl:182
 [29] macro expansion
    @ ~/.julia/dev/Metal/src/compiler/execution.jl:85 [inlined]
 [30] top-level scope
    @ ~/.julia/packages/GPUCompiler/QCNA0/src/reflection.jl:185
 [31] top-level scope
    @ ~/.julia/dev/Metal/src/initialization.jl:72
Some type information was truncated. Use `show(err)` to see complete types.
@maleadt
Copy link
Member

maleadt commented Oct 18, 2024

Hah, interesting. I've considered removing this functionality, though, as the disassembler doesn't work on my M3, isn't actively maintained, and drags along several annoying dependencies (like Python_jll).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants