-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible elegant solution for compiling kernels with fields as arguments #722
Comments
Hmmm, do we know why we can't adapt the full The definition is struct Field{X, Y, Z, A, G, B} <: AbstractField{X, Y, Z, A, G}
data :: A
grid :: G
boundary_conditions :: B where the Note: If we can't adapt If we can adapt X-Ref: #298 |
I'm not sure why my attempt failed. It's worth documenting an attempt. |
If you are looking to pass structs with CuArray members into kernels, I think that you might be looking for something like https://github.com/sandreza/Learning/blob/master/nla/gmres.jl#L50 |
@sandreza thanks! We utilize this functionality for many of our objects, eg: For some reason, during an undocumented attempt to apply this logic to fields back in October, we were unsuccessful to get code to work on the GPU. Back then, the field consisted of an OffsetArray wrapped around a CuArray, and a grid. Both of those objects can be adapted to GPU kernels, so it should have worked, I think. So I'm not 100% sure why our attempt to use |
Without knowing what you tried to do, not really. |
Yes, that's not surprising. I regret not being more careful. |
I've documented an attempt to adapt |
One solution for compiling kernels with fields as arguments is to define
and
This approach will automatically unwrap fields when they are passed to GPU kernels (I think).
The disadvantage of this approach is that the code is a little bit harder to interpret, because if you miss the definition of this function, you might be confused why
field.boundary_conditions
andfield.grid
were not accessible from inside GPU kernels.On the other hand, this only affects the lowest-level kernels, and GPU programmers probably know that an
adapt_structure
method must be defined somewhere for an exotic object likeField
to be passed into a kernel. If we document what we are doing clearly, we may solve this problem.Doing this means we would no longer have to unwrap fields manually prior to passing them to GPU kernels.
Are there any other issues that I'm not seeing?
The text was updated successfully, but these errors were encountered: