I’m trying to persuade CUDA.jl to compile a kernel function. After reducing the issue I have come to this sample code
using CUDA
x=Float32(2.0)
knots =CuArray{Float32,1}([1.2, 2.0, 3.0])
mapOp(v::Float32)::Int = v >= x ? 1 : 0
mapreduce(mapOp, + , knots)
When I run this I get this
ERROR: InvalidIRError: compiling kernel partial_mapreduce_grid(typeof(identity), typeof(+), Int64, CartesianIndices{1,Tuple{Base.OneTo{Int64}}}, CartesianIndices{1,Tuple{Base.OneTo{Int64}}}, Val{true}, CuDeviceArray{Int64,2,1}, Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{1},Tuple{Base.OneTo{Int64}},typeof(mapOp),Tuple{CuDeviceArray{Float32,1,1}}}) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to >=)
Stacktrace:
[1] mapOp at D:\steph\Google Drive\src\julia\bspline\broke2.jl:4
so it seems it can’t compile the >= function as it can’t determine the types that go into it. Hw do I address this?