Multiplication of some types with `Rational` causes compiler error
- Dominant language
- Julia
- Stars
- 463
- Forks
- 68
- Avg merge
- 1d 19m
- Merged PRs (30d)
- 32
Description
This seems to be separate from #550 since this is a compiler rather than type error?
When multiplying integers or rationals with a `Rational`, the function fails to compile.
```Julia-repl
julia> using Metal
julia> map(y -> y * 3 // 2, MtlArray([1f0]))
1-element MtlVector{Float32, Metal.PrivateStorage}:
1.5
julia> map(y -> y * 3 // 2, MtlArray([1]))
ERROR: Compilation to native code failed; see below for details.
If you think this is a bug, please file an issue and attach the following files:
- /var/folders/hw/bycsc7f52zvfzlh61rydj85r0000gn/T/jl_NQBgVejWPY.ll
- /var/folders/hw/bycsc7f52zvfzlh61rydj85r0000gn/T/jl_jIh6FyNozc.air
- /var/folders/hw/bycsc7f52zvfzlh61rydj85r0000gn/T/jl_FgjsvGhG72.metallib
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] macro expansion
@ ~/.julia/packages/Metal/N2ABH/src/compiler/compilation.jl:205 [inlined]
[3] macro expansion
@ ~/.julia/packages/ObjectiveC/TgrW6/src/os.jl:264 [inlined]
[4] macro expansion
@ ~/.julia/packages/Metal/N2ABH/src/compiler/compilation.jl:182 [inlined]
[5] (::Metal.var"#173#174"{GPUCompiler.CompilerJob{…}, @NamedTuple{…}})()
@ Metal ~/.julia/packages/ObjectiveC/TgrW6/src/foundation.jl:644
[6] macro expansion
@ ~/.julia/packages/ObjectiveC/TgrW6/src/foundation.jl:572 [inlined]
[7] macro expansion
@ ./lock.jl:273 [inlined]
[8] ObjectiveC.Foundation.NSAutoreleasePool(f::Metal.var"#173#174"{GPUCompiler.CompilerJob{…}, @NamedTuple{…}})
@ ObjectiveC.Foundation ~/.julia/packages/ObjectiveC/TgrW6/src/foundation.jl:564
[9] link(job::GPUCompiler.CompilerJob, compiled::@NamedTuple{…})
@ Metal ~/.julia/packages/ObjectiveC/TgrW6/src/foundation.jl:643
[10] actual_compilation(cache::Dict{…}, src::Core.MethodInstance, world::UInt64, cfg::GPUCompiler.CompilerConfig{…}, compiler::typeof(Metal.compile), linker::typeof(Metal.link))
@ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/execution.jl:262
[11] cached_compilation(cache::Dict{…}, src::Core.MethodInstance, cfg::GPUCompiler.CompilerConfig{…}, compiler::Function, linker::Function)
@ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/execution.jl:151
[12] macro expansion
@ ~/.julia/packages/Metal/N2ABH/src/compiler/execution.jl:189 [inlined]
[13] macro expansion
@ ./lock.jl:273 [inlined]
[14] mtlfunction(f::Metal.var"#broadcast_linear#204", tt::Type{Tuple{…}}; name::Nothing, kwargs::@Kwargs{})
@ Metal ~/.julia/packages/Metal/N2ABH/src/compiler/execution.jl:184
[15] mtlfunction
@ ~/.julia/packages/Metal/N2ABH/src/compiler/execution.jl:182 [inlined]
[16] macro expansion
@ ~/.julia/packages/Metal/N2ABH/src/compiler/execution.jl:85 [inlined]
[17] _copyto!
@ ~/.julia/packages/Metal/N2ABH/src/broadcast.jl:95 [inlined]
[18] copyto!
@ ~/.julia/packages/Metal/N2ABH/src/broadcast.jl:47 [inlined]
[19] copy(bc::Base.Broadcast.Broadcasted{Metal.MtlArrayStyle{…}, Tuple{…}, var"#9#10", Tuple{…}})
@ GPUArrays ~/.julia/packages/GPUArrays/uiVyU/src/host/broadcast.jl:29
[20] materialize
@ ./broadcast.jl:872 [inlined]
[21] map(f::Function, xs::MtlVector{Int64, Metal.PrivateStorage})
@ GPUArrays ~/.julia/packages/GPUArrays/uiVyU/src/host/broadcast.jl:88
[22] top-level scope
@ REPL[9]:1
[23] top-level scope
@ ~/.julia/packages/Metal/N2ABH/src/initialization.jl:79
caused by: NSError: Compiler encountered an internal error (AGXMetalG16X, code 3)
Stacktrace:
[1] Metal.MTL.MTLComputePipelineState(dev::Metal.MTL.MTLDeviceInstance, fun::Metal.MTL.MTLFunctionInstance)
@ Metal.MTL ~/.julia/packages/Metal/N2ABH/lib/mtl/compute_pipeline.jl:60
[2] macro expansion
@ ~/.julia/packages/Metal/N2ABH/src/compiler/compilation.jl:187 [inlined]
[3] macro expansion
@ ~/.julia/packages/ObjectiveC/TgrW6/src/os.jl:264 [inlined]
[4] macro expansion
@ ~/.julia/packages/Metal/N2ABH/src/compiler/compilation.jl:182 [inlined]
[5] (::Metal.var"#173#174"{GPUCompiler.CompilerJob{…}, @NamedTuple{…}})()
@ Metal ~/.julia/packages/ObjectiveC/TgrW6/src/foundation.jl:644
[6] macro expansion
@ ~/.julia/packages/ObjectiveC/TgrW6/src/foundation.jl:572 [inlined]
[7] macro expansion
@ ./lock.jl:273 [inlined]
[8] ObjectiveC.Foundation.NSAutoreleasePool(f::Metal.var"#173#174"{GPUCompiler.CompilerJob{…}, @NamedTuple{…}})
@ ObjectiveC.Foundation ~/.julia/packages/ObjectiveC/TgrW6/src/foundation.jl:564
[9] link(job::GPUCompiler.CompilerJob, compiled::@NamedTuple{…})
@ Metal ~/.julia/packages/ObjectiveC/TgrW6/src/foundation.jl:643
[10] actual_compilation(cache::Dict{…}, src::Core.MethodInstance, world::UInt64, cfg::GPUCompiler.CompilerConfig{…}, compiler::typeof(Metal.compile), linker::typeof(Metal.link))
@ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/execution.jl:262
[11] cached_compilation(cache::Dict{…}, src::Core.MethodInstance, cfg::GPUCompiler.CompilerConfig{…}, compiler::Function, linker::Function)
@ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/execution.jl:151
[12] macro expansion
@ ~/.julia/packages/Metal/N2ABH/src/compiler/execution.jl:189 [inlined]
[13] macro expansion
@ ./lock.jl:273 [inlined]
[14] mtlfunction(f::Metal.var"#broadcast_linear#204", tt::Type{Tuple{…}}; name::Nothing, kwargs::@Kwargs{})
@ Metal ~/.julia/packages/Metal/N2ABH/src/compiler/execution.jl:184
[15] mtlfunction
@ ~/.julia/packages/Metal/N2ABH/src/compiler/execution.jl:182 [inlined]
[16] macro expansion
@ ~/.julia/packages/Metal/N2ABH/src/compiler/execution.jl:85 [inlined]
[17] _copyto!
@ ~/.julia/packages/Metal/N2ABH/src/broadcast.jl:95 [inlined]
[18] copyto!
@ ~/.julia/packages/Metal/N2ABH/src/broadcast.jl:47 [inlined]
[19] copy(bc::Base.Broadcast.Broadcasted{Metal.MtlArrayStyle{…}, Tuple{…}, var"#9#10", Tuple{…}})
@ GPUArrays ~/.julia/packages/GPUArrays/uiVyU/src/host/broadcast.jl:29
[20] materialize
@ ./broadcast.jl:872 [inlined]
[21] map(f::Function, xs::MtlVector{Int64, Metal.PrivateStorage})
@ GPUArrays ~/.julia/packages/GPUArrays/uiVyU/src/host/broadcast.jl:88
[22] top-level scope
@ REPL[9]:1
[23] top-level scope
@ ~/.julia/packages/Metal/N2ABH/src/initialization.jl:79
Some type information was truncated. Use `show(err)` to see complete types.
```
Here's the additional files the error message asks for:
https://drive.google.com/drive/folders/1ipHy4p6DEiKgCJWbTHtqcf1vGKNzQxqq?usp=sharing
```Julia-repl
julia> Metal.versioninfo()
macOS 15.3.1, Darwin 24.3.0
Toolchain:
- Julia: 1.11.4
- LLVM: 16.0.6
Julia packages:
- Metal.jl: 1.5.1
- GPUArrays: 11.2.2
- GPUCompiler: 1.2.0
- KernelAbstractions: 0.9.34
- ObjectiveC: 3.4.1
- LLVM: 9.2.0
- LLVMDowngrader_jll: 0.6.0+0
1 device:
- Apple M4 Max (464.000 KiB allocated)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.