CLArrays.jl
CLArrays.jl copied to clipboard
gpu_call with @cartesian index
gpu_call does not seem to work for multidimensional grids when I run the simple following code
using CLArrays, GPUArrays
n_b = 100
n_h = 10
n_m = 100
grid = CLArray(zeros(Float32, n_m, n_h, n_b))
gpu_call(grid, (grid, UInt32(n_m), UInt32(n_h), UInt32(n_b))) do state, grid, n_m, n_h, n_b
idx3 = GPUArrays.@cartesianidx grid
idx_m = idx3[1]
idx_h = idx3[2]
idx_b = idx3[3]
return
end
gives Error in Expr rewrite! MethodError(all, (Transpiler.#27, Any[1]), 0x0000000000005845)
Expression resulting in the error: idx_m::UInt32 = (Main.getindex)(idx3::Tuple{UInt32,UInt32,UInt32}, 1)::UInt32 happening in function tree: Sugar stack trace: [1] #149(CLArrays.KernelState, CLArrays.DeviceArray{Float32,3,Transpiler.CLIntrinsics.GlobalPointer{Float32}}, UInt32, UInt32, UInt32)
Code of the context this error occured in: begin NewvarNode(:(idx3::Tuple{UInt32,UInt32,UInt32})) NewvarNode(:(i2::UInt32)) NewvarNode(:(idx_m::UInt32)) NewvarNode(:(idx_h::UInt32)) NewvarNode(:(idx_b::UInt32)) x::CLArrays.DeviceArray{Float32,3,Transpiler.CLIntrinsics.GlobalPointer{Float32}} = grid::CLArrays.DeviceArray{Float32,3,Transpiler.CLIntrinsics.GlobalPointer{Float32}} x1::CLArrays.DeviceArray{Float32,3,Transpiler.CLIntrinsics.GlobalPointer{Float32}} = x::CLArrays.DeviceArray{Float32,3,Transpiler.CLIntrinsics.GlobalPointer{Float32}} i1::UInt32 = (GPUArrays.linear_index)(state::CLArrays.KernelState)::UInt32 if (i1::UInt32 > (GPUArrays.length)(x1::CLArrays.DeviceArray{Float32,3,Transpiler.CLIntrinsics.GlobalPointer{Float32}})::UInt32)::Bool $(Expr(:return)) end::Any i2::UInt32 = i1::UInt32 idx3::Tuple{UInt32,UInt32,UInt32} = (GPUArrays.gpu_ind2sub)(x::CLArrays.DeviceArray{Float32,3,Transpiler.CLIntrinsics.GlobalPointer{Float32}}, i2::UInt32)::Tuple{UInt32,UInt32,UInt32} idx_m::UInt32 = (Main.getindex)(idx3::Tuple{UInt32,UInt32,UInt32}, 1)::UInt32 idx_h::UInt32 = (Main.getindex)(idx3::Tuple{UInt32,UInt32,UInt32}, 2)::UInt32 idx_b::UInt32 = (Main.getindex)(idx3::Tuple{UInt32,UInt32,UInt32}, 3)::UInt32 $(Expr(:return)) end::Any
any idea why this is happening and how to fix it?