Hi all! I’m exploring ways to pass a mutable struct as an argument to a CUDA kernel. For example,
# Define a custom struct here
mutable struct MyStruct
field1::Float32
field2::Float32
field3::Float32
...
end
# Pass the custom struct as argument of a kernel
function MyKernel!(arg1, arg2, arg3, arg4::MyStruct)
# Use arg4 to do something
return nothing
end
The mutable struct
always gave errors like passing and using non-bitstype argument
. But if the struct is defined as immutable, the CUDA kernel can run successfully. My problem is that I really have to make this struct mutable for other purposes, so is there any way to make it work?
Also, I tried the Adapt
package and the example from here Using custom structs · CUDA.jl, but unfortunately I found that this example did not work for mutable struct Interpolate{A}
. It caused the same errors like passing and using non-bitstype argument
. Hope someone can provide suggestions on how to handle mutable structures within CUDA kernels. Thanks a lot!