JuliaGPU / JuliaGPU/GPUArrays.jl
Better error for map! misuse
- Dominant language
- Julia
- Stars
- 450
- Forks
- 104
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 10
Description
```
julia> map!(sqrt, rand(1))
ERROR: ArgumentError: map! requires at least one "source" argument
Stacktrace:
[1] map!(::typeof(sqrt), ::Vector{Float64})
@ Base ./abstractarray.jl:3353
[2] top-level scope
@ REPL[17]:1
[3] top-level scope
@ ~/Julia/pkg/Metal/src/initialization.jl:51
```
vs
```
julia> map!(sqrt, Metal.rand(1))
ERROR: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#map_kernel#27"{Int64})(::Metal.mtlKernelContext, ::MtlDeviceVector{Float32, 1}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(sqrt), Tuple{}}, ::Int64) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to sqrt)
Stacktrace:
[1] _broadcast_getindex_evalf
@ ./broadcast.jl:683
[2] _broadcast_getindex
@ ./broadcast.jl:656
[3] getindex
@ ./broadcast.jl:610
[4] map_kernel
@ ~/Julia/pkg/GPUArrays/src/host/broadcast.jl:118
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the two map! examples and compare the errors. Start at GPUArrays/src/host/broadcast.jl:118 and trace the map! entry point to understand where the invalid LLVM IR is produced. Done means the Metal misuse reports a clear argument or invocation error instead of the current compiler failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100