-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement MPI functions for ArborX #53
Comments
This sounds right. Would be nice to also do something about getting rank and size from a communicator, but that's not a big deal. Another pretty annoying thing that we have to do is to avoid passing // Strip "--help" and "--kokkos-help" from the flags passed to Kokkos if we
// are not on MPI rank 0 to prevent Kokkos from printing the help message
// multiply.
if (comm_rank != 0)
{
auto *help_it = std::find_if(argv, argv + argc, [](std::string const &x) {
return x == "--help" || x == "--kokkos-help";
});
if (help_it != argv + argc)
{
std::swap(*help_it, *(argv + argc - 1));
--argc;
}
}
Kokkos::initialize(argc, argv); |
Another thing that could be worth trying to address at some point is to be able to run with GPU-aware MPI implementations, rather than doing everything on the host. We have a pathway in ArborX for it (even though we never saw it running faster, but it was like 4 years ago, maybe things are better now). |
I expect GPU-aware MPI to be pretty high on the priority list once we get some of these initial functions implemented! |
GPU-aware MPI installations should be supported out of the box. Note that the communication itself is still host-triggered. |
GPU-aware communications work out of the box indeed, but a nice to have thing in my experience is a fallback mode which deep copies onto the host, sends and deep copies back upon reception, for non GPU-aware MPI installations (or badly installed supposedly GPU-aware installations which just crash in practice...). It can easily be implemented with a few |
So how do we handle this?
|
@dutkalex wrote:
We should implement this with Users will always know what to expect, and it will let us remove the fallback mechanisms from the critical path once the code is compiled. |
To me, it's as simple as: void send(device_view, ...){
#ifdef KOKKOSCOMM_GPU_AWARE
send(device_view, ...);
#else
auto mirror = Kokkos::create_mirror_view(device_view);
Kokkos::deep_copy(mirror, device_view);
send(mirror, ...);
#endif
}
void recv(device_view, ...){
#ifdef KOKKOSCOMM_GPU_AWARE
recv(device_view, ...);
#else
auto mirror = Kokkos::create_mirror_view(device_view);
recv(mirror, ...);
Kokkos::deep_copy(device_view, mirror);
#endif
} You can replace the #ifdefs by |
I would argue that GPU-aware call should be a runtime and not compile time decision. |
Why would you want to have both compiled? When linking against an mpi implementation, gpu-aware communications either work or they don't... |
A user may want to dispatch the kernel on the host or the device depending on the size of the data, or the MPI call. I think if a view is on the host, it would make sense to use host MPI routines, while if it's on the device, GPU-aware routines if available, and transfer to host if not. |
I agree, but the compile time solution already enables this: if the view is on the host you get a regular mpi host call regardless of the branch, because the pointer passed to mpi is a host pointer and because the deep copy becomes a no-op |
It is more complicated for asynchronous communications, and I am slightly annoyed by the silent extra allocation. |
Agreed. Async semantics require hooking the recv deep_copy to the
Agreed, this is suboptimal. I don't see an obvious solution to this problem, but I bet we can come up with something better. Or at the very least more transparent to the user... |
I have an ArborX branch for kokkos-comm. Currently:
|
How do you want the custom datatypes to look? Is it a Kokkos::View of things that are described by custom datatypes? |
It is |
Do you ship the whole |
The whole thing. Right now, just through |
@aprokop
probably skip these for a bare MPI wrapper
The text was updated successfully, but these errors were encountered: