JuliaGPU / JuliaGPU/GPUCompiler.jl
Reflection macros do not perform validation
- Dominant language
- Julia
- Stars
- 187
- Forks
- 68
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 28
Description
Kind of a silly error, but:
```
julia> function kernel(A)
r_rhsW[1] -= A[1]
nothing
end
kernel (generic function with 1 method)
julia> CUDA.@device_code dir="bug" @cuda kernel(CUDA.zeros(10))
ERROR: LLVM error: Cannot select: 0x96c8458: ch = AtomicStore<(store release 8 into @0, addrspace 1)> 0x96c8938:1, 0x96c7e40, 0x96c8938
0x96c7e40: i64 = NVPTXISD::Wrapper TargetGlobalAddress:i64<{}* addrspace(1)* @0> 0
0x96c8250: i64 = TargetGlobalAddress<{}* addrspace(1)* @0> 0
0x96c8938: i64,ch,glue = NVPTXISD::ProxyReg 0x96c8a70, 0x96c8590, 0x96c8a70:1
0x96c8590: i64,ch,glue = NVPTXISD::LoadParam<(load 8)> 0x96c8388, Constant:i32<1>, Constant:i32<0>, 0x96c8388:1
0x96c8118: i32 = Constant<1>
0x96c7fe0: i32 = Constant<0>
0x96c8388: ch,glue = NVPTXISD::CallArgEnd 0x96c8660, Constant:i32<1>, 0x96c8660:1
0x96c8118: i32 = Constant<1>
0x96c8660: ch,glue = NVPTXISD::LastCallArg 0x96c84c0, Constant:i32<1>, Constant:i32<1>, 0x96c84c0:1
0x96c8118: i32 = Constant<1>
0x96c8118: i32 = Constant<1>
0x96c84c0: ch,glue = NVPTXISD::CallArg 0x96c88d0, Constant:i32<1>, Constant:i32<0>, 0x96c88d0:1
0x96c8118: i32 = Constant<1>
0x96c7fe0: i32 = Constant<0>
0x96c88d0: ch,glue = NVPTXISD::CallArgBegin 0x96c8800, 0x96c8800:1
0x96c8800: ch,glue = NVPTXISD::CallVoid 0x96c89a0, 0x96c81e8, 0x96c89a0:1
0x96c81e8: i64 = NVPTXISD::Wrapper TargetGlobalAddress:i64<{}* ({}*, {}*)* @jl_get_binding_or_error> 0
0x96c8528: i64 = TargetGlobalAddress<{}* ({}*, {}*)* @jl_get_binding_or_error> 0
0x96c89a0: ch,glue = NVPTXISD::PrintCallUni 0x96c8a08, Constant:i32<1>, 0x96c8a08:1
0x96c8118: i32 = Constant<1>
0x96c8a08: ch,glue = NVPTXISD::DeclareRet 0x96c8ad8, Constant:i32<1>, Constant:i32<64>, Constant:i32<0>, 0x96c8ad8:1
0x96c8a70: ch,glue = callseq_end 0x96c8590:1, TargetConstant:i64<524>, TargetConstant:i64<525>, 0x96c8590:2
0x96c8ba8: i64 = TargetConstant<524>
0x96c7f78: i64 = TargetConstant<525>
0x96c8590: i64,ch,glue = NVPTXISD::LoadParam<(load 8)> 0x96c8388, Constant:i32<1>, Constant:i32<0>, 0x96c8388:1
0x96c8118: i32 = Constant<1>
0x96c7fe0: i32 = Constant<0>
0x96c8388: ch,glue = NVPTXISD::CallArgEnd 0x96c8660, Constant:i32<1>, 0x96c8660:1
0x96c8118: i32 = Constant<1>
0x96c8660: ch,glue = NVPTXISD::LastCallArg 0x96c84c0, Constant:i32<1>, Constant:i32<1>, 0x96c84c0:1
0x96c8118: i32 = Constant<1>
0x96c8118: i32 = Constant<1>
0x96c84c0: ch,glue = NVPTXISD::CallArg 0x96c88d0, Constant:i32<1>, Constant:i32<0>, 0x96c88d0:1
0x96c8118: i32 = Constant<1>
0x96c7fe0: i32 = Constant<0>
0x96c88d0: ch,glue = NVPTXISD::CallArgBegin 0x96c8800, 0x96c8800:1
0x96c8800: ch,glue = NVPTXISD::CallVoid 0x96c89a0, 0x96c81e8, 0x96c89a0:1
0x96c81e8: i64 = NVPTXISD::Wrapper TargetGlobalAddress:i64<{}* ({}*, {}*)* @jl_get_binding_or_error> 0
0x96c89a0: ch,glue = NVPTXISD::PrintCallUni 0x96c8a08, Constant:i32<1>, 0x96c8a08:1
In function: _Z17julia_kernel_656713CuDeviceArrayI7Float32Li1ELi1EE
```
On Julia 1.6-rc1, Silly since the verifier will just yell at me when I run the code normally.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with Julia 1.6-rc1 using the shown kernel and CUDA.@device_code/@cuda invocation. Trace the reflection macros involved and compare their behavior with normal execution, where the verifier reports the invalid code; done means invalid reflected code is rejected with a useful validation error before the LLVM failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100