You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using this project to circumvent the world age problems when generating functions and it has worked great so far.
Now I'm trying to also generate functions to run on the GPU, CUDA for now to be specific. There are two ways that I've tried to do that. The first is simply broadcasting the function on a CuVector, however, this does not work because RuntimeGeneratedFunctions are not isbits, which CUDA.jl does not like:
julia>func.(cu_inputs)
ERROR: GPU compilation of MethodInstance for (::GPUArrays.var"#34#36")(::CUDA.CuKernelContext, ::CuDeviceVector{ComplexF64, 1}, ::Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{…}, Tuple{…}, RuntimeGeneratedFunction{…}, Tuple{…}}, ::Int64) failed
KernelError: passing and using non-bitstype argument
Argument 4 to your kernel function is of type Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{1, CUDA.Mem.DeviceBuffer}, Tuple{Base.OneTo{Int64}}, RuntimeGeneratedFunction{(:data_input,), ComputableDAGs.var"#_RGF_ModTag", var"#_RGF_ModTag", (0x3d86ea6b, 0x46940344, 0xf0c50769, 0x501ce261, 0x5c3fa2fa), Expr}, Tuple{Base.Broadcast.Extruded{CuDeviceVector{<LongArgumentType...>, 1}, Tuple{Bool}, Tuple{Int64}}}}, which is not isbits:.f is of type RuntimeGeneratedFunction{(:data_input,), ComputableDAGs.var"#_RGF_ModTag", var"#_RGF_ModTag", (0x3d86ea6b, 0x46940344, 0xf0c50769, 0x501ce261, 0x5c3fa2fa), Expr} which is not isbits.
.body is of type Expr which is not isbits.
.head is of type Symbol which is not isbits.
.args is of type Vector{Any} which is not isbits.
The other option is to use @cuda and call a (generated) kernel. However, this also does not work as RuntimeGeneratedFunctions seem to always return an Any, and GPU kernels are not allowed to return anything:
julia>@cudakernel(cu_inputs, cu_outputs, 1000)
ERROR: GPU compilation of MethodInstance for (::RuntimeGeneratedFunction{(:input_vector, :output_vector, :n), CUDAExt.var"#_RGF_ModTag", var"#_RGF_ModTag", (0x26ea8e24, 0xf73e2d2a, 0xb1e0f07e, 0x53860e81, 0xc0771049), Expr})(::CuDeviceVector{PhaseSpacePoint{…}, 1}, ::CuDeviceVector{Float64, 1}, ::Int64) failed
KernelError: kernel returns a value of type `Any`
Make sure your kernel function ends in`return`, `return nothing` or `nothing`.
It would be great if compatibility for GPU broadcasting and kernels could be added. Looking at the code in this package, I don't understand how it is doing what it is doing so I don't think I can add support myself. It seems that fixing the return nothing problem with kernels might not be too hard though.
The text was updated successfully, but these errors were encountered:
I've been using this project to circumvent the world age problems when generating functions and it has worked great so far.
Now I'm trying to also generate functions to run on the GPU, CUDA for now to be specific. There are two ways that I've tried to do that. The first is simply broadcasting the function on a
CuVector
, however, this does not work becauseRuntimeGeneratedFunction
s are not isbits, which CUDA.jl does not like:The other option is to use
@cuda
and call a (generated) kernel. However, this also does not work as RuntimeGeneratedFunctions seem to always return anAny
, and GPU kernels are not allowed to return anything:It would be great if compatibility for GPU broadcasting and kernels could be added. Looking at the code in this package, I don't understand how it is doing what it is doing so I don't think I can add support myself. It seems that fixing the
return nothing
problem with kernels might not be too hard though.The text was updated successfully, but these errors were encountered: