-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make allocator more flexible with domain sizes #34
Conversation
Yes, I think that can be neat. How I see it implemented is to have all the bound remapping handled by the We should be able to call Other idea would be to have a |
Another option, which could have some safety benefits for other areas of code would be to encode this in types, something like type data_block
real(dp), dimension(:), allocatable :: data
end type
type extends(data_block) :: x_block
end type The user code would then look like type(x_block) :: u_x
type(y_block) :: u_y
! ...
! Allocator allocates appropriate sizes based on type
call allocator%get_block(u_x)
call allocator%get_block(u_y) This would be a wide-ranging change, and require something like call rotate_xy(u_x, u_z) ! Can't compile due to types The specific rotation could even be determined by the type if we wanted call rotate(u_x, u_y) ! Must be an X->Y rotation |
We extend the base allocator in CUDA backend so that we can have a device array member. I don't think we can do extends you recommend and have x directional cuda field and base field under the same class. And then it will be hard to use allocator in solver class. Maybe we can have a brand new type that has base field as a member, then extend this so that there are one for each direction
But then we'll have a select type for figuring out the direction, then another for resolving down to exact field type and this will make things complicated I think. |
@pbartholomew08 We can get best of both worlds by storing the orientation (XYZ, YZX, ZXY) in the field, so that could be checked at runtime in e.g. a debug block. No catch by the compiler but seems less complex than playing with the type system. |
Yes, much less intrusive, I prefer that. |
I think I figured out a nice way to fix this problem. A summary of changes: We used to have a
Allocated memory is addessed by this private data member, and then to play with different shapes we use We can discuss this in our meeting today, so please have a look if you have time. The only remaning part is actually setting the padding in the |
Discussion to have during our next meeting: |
I think we covered most of the technical parts in the meeting, if there is any point not clear I'll be happy to explain. I just removed the padding in the z-direction as the current pencil group ordering strategy doesn't require any padding in z. And it looks like there are a lot of changes but most of it is just A review will be helpful if you have time, please let me know if you want to review but can't do today so we can wait, but otherwise I think its in good shape and can be merged at the end of the day. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beside these minor comments, this looks good to me. I think it should be merged before #68 and I will adapt it there to make it work (specially the tests).
The problem is described in #24. I wanted to have a draft PR here so that we can plan ahead how to make this transition in both backends.
In the CUDA backend we always type check and assing a pointer to the
%data_d
component offield_t
. Fortran allows a bounds remapping with pointer assignments and we can use this to have a 3D pointer pointing a 1Ddata_d
array. My plan is to move all the type selection bits into a subroutine in CUDA backend like @pbartholomew08 suggested in a previous PR, and sort the bounds remapping there.With the OpenMP backend the current way allocator works is very handy, but obviously we need to support different nx, ny, and nz and currently it is not possible. I think currently the
%data
component infield_t
is passed directly into the kernels and it doesn't allow fixing the dimensions ofdata
array when switching form x, y, and z orientations. My suggestion is again using bounds remapping and pointing to the 1Ddata
array with the right dimensions based on the x, y, z orientations we're at. What do you think, @Nanoseb?Alternative to this bounds remaping strategy is using assumed shape arrays in kernels but I think it might be more complicated especially with different velocity grid dimensions and pressure grid dimensions. I think padding is a good strategy to deal with this and assumed shape arrays would't mix well with with padding I believe.