kokkos / kokkos-comm

Experimental MPI Wrapper for Kokkos
https://kokkos.org/kokkos-comm/
Other
12 stars 9 forks source link

Refactor comm modes #103

Closed dssgabriel closed 1 week ago

dssgabriel commented 2 weeks ago

Closes #83.

KokkosComm::send/isend can now be called like so, following the tag-type-as-argument approach, encouraged by ISO C++ library design guidelines:

using namespace KokkosComm;

// Send with explicit "synchronous" communication mode and execution space:
send(ReadyCommMode(), Kokkos::DefaultExecutionSpace(), view, dest, tag, comm);

// Send with implicit "default" communication mode and explicit execution space:
send(Kokkos::DefaultExecutionSpace(), view, dest, tag, comm);

// Send with explicit communication mode and implicit "default" execution space:
send(SynchronousCommMode(), view, dest, tag, comm);

// Send with implicit "default" communication mode and "default" execution space:
send(view, dest, tag, comm);

send and isend functions use a newly introduced CommunicationMode concept that enforces correct typing of the specified communication mode.


Reviews are welcome! I'm not a C++ expert, and I am not sure this is the best way to do it.

Two questions as well:

  1. is the namespace around the comm mode structures really necessary?
  2. would it be better to have function specializations instead of dispatching in the lambda (like in the previous implementation)? It may be more verbose, but as I understand, it is the preferred way to do it.

While we figure this out, I am converting the PR to a draft.


Edit: added code example.

dssgabriel commented 2 weeks ago

C++ experts' reviews welcome! 🙂

cedricchevalier19 commented 1 week ago

@dssgabriel Can you add an example of the change in the description of the PR?