-
Notifications
You must be signed in to change notification settings - Fork 367
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
Add TypeMultiplier, MakeZeroTuple and IdentityTuple #3718
Add TypeMultiplier, MakeZeroTuple and IdentityTuple #3718
Conversation
Any ideas on having something similar to MakeZeroTuple but suitable for reduce min and max also, like |
That would be a better version of MakeZeroTuple. I did not make it that way because the reductions in HiPACE++ don’t need it. It does seem a bit difficult to get the ReduceOps template list into a device lambda in user code, without capturing the ReduceOps object. I think an additional object such as a TypeList is necessary to store all the ReduceOpMax, ReduceOpSum etc so they don’t have the be manually given to the Tuple init function. |
Actually, maybe it would be fine to capture the ReduceOps object in a device lambda. |
Could something like this work? (Not tested).
|
I guess it cannot be constexpr because for_each_init is not. |
But we probably could make |
I made the function use the GpuTuple and ReduceOps to make it more convenient in a typical reduce op use case. The following code now compiles for CPU and CUDA:
|
LGTM |
Summary
This PR adds TypeMultiplier and MakeZeroTuple from Hi-PACE/hipace#1052 to AMReX.
TypeMultiplier can be used to shorten ReduceOps and ReduceData definitions where the same type is used many times.
MakeZeroTuple can be used to initialize a GpuTuple to zero (the default constructor would leave the values uninitialized).
IdentityTuple can be used to initialize a GpuTuple to the identity elements of each operation in a ReduceOps.
Additional background
Checklist
The proposed changes: