InvalidIRError when using integer powers
Created by: sandreza
It seems that using integer powers as in 2^11 in a kernel yields an error
MWE: In https://github.com/JuliaGPU/KernelAbstractions.jl/blob/master/examples/matmul.jl#L10 If one instead adds m=2^11 to line 10
@kernel function matmul_kernel!(a, b, c)
i, j = @index(Global, NTuple)
m = 2^11
# creating a temporary sum variable for matrix multiplication
tmp_sum = zero(eltype(c))
for k = 1:size(a)[2]
tmp_sum += a[i,k] * b[k, j]
end
c[i,j] = tmp_sum
end
one gets an invalid IRE error:
However, change m = 2^11 to m = Int(2.0^11), as in
@kernel function matmul_kernel!(a, b, c)
i, j = @index(Global, NTuple)
m = Int(2.0^11)
# creating a temporary sum variable for matrix multiplication
tmp_sum = zero(eltype(c))
for k = 1:size(a)[2]
tmp_sum += a[i,k] * b[k, j]
end
c[i,j] = tmp_sum
end
yields no error and the test passes.
Perhaps extending https://github.com/JuliaGPU/KernelAbstractions.jl/blob/e08b87dd6e89797afda2c4cf8a0c8ad4941e8a9a/lib/CUDAKernels/src/CUDAKernels.jl#L281-L285 to integers solves the issue?
Platform Info: OS: Linux (x86_64-pc-linux-gnu) CPU: Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-9.0.1 (ORCJIT, cascadelake)
The GPU is a TitanV