Skip to content

Commit

Permalink
Update the docs of the MPI interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoemi09 committed Nov 15, 2024
1 parent 9ca8967 commit 29c5870
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion c++/nda/mpi/broadcast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace nda {
* @endcode
*
* @tparam A nda::basic_array or nda::basic_array_view type.
* @param a Array or view to be broadcasted from/into.
* @param a Array/view to be broadcasted from/into.
* @param comm `mpi::communicator` object.
* @param root Rank of the root process.
*/
Expand Down
6 changes: 3 additions & 3 deletions c++/nda/mpi/gather.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ namespace nda {
* these methods, all ranks in the communicator need to call the same method. Otherwise, the program will deadlock.
*
* @tparam A nda::basic_array or nda::basic_array_view type with C-layout.
* @param a Array or view to be gathered.
* @param a Array/view to be gathered.
* @param comm `mpi::communicator` object.
* @param root Rank of the root process.
* @param all Should all processes receive the result of the gather.
* @return An mpi::lazy<mpi::tag::gather, A> object modelling an nda::ArrayInitializer.
*/
template <typename A>
requires(is_regular_or_view_v<A> and std::decay_t<A>::is_stride_order_C())
ArrayInitializer<std::remove_reference_t<A>> auto lazy_mpi_gather(A &&a, mpi::communicator comm = {}, int root = 0, bool all = false) {
auto lazy_mpi_gather(A &&a, mpi::communicator comm = {}, int root = 0, bool all = false) {
return mpi::lazy<mpi::tag::gather, A>{std::forward<A>(a), comm, root, all};
}

Expand Down Expand Up @@ -239,7 +239,7 @@ namespace nda {
* Here, the array `B` has the shape `(3 * comm.size(), 4)` on the root process and `(0, 0)` on all other processes.
*
* @tparam A nda::basic_array or nda::basic_array_view type with C-layout.
* @param a Array or view to be gathered.
* @param a Array/view to be gathered.
* @param comm `mpi::communicator` object.
* @param root Rank of the root process.
* @param all Should all processes receive the result of the gather.
Expand Down
14 changes: 7 additions & 7 deletions c++/nda/mpi/reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ namespace nda {
* nda::array<int, 2> B = nda::lazy_mpi_reduce(A);
* @endcode
*
* The behavior is otherwise identical to nda::mpi_reduce and nda::mpi_reduce_in_place. The reduction is performed
* in-place if the target and input array/view are the same (if the underlying data pointer is the same), e.g.
* The behavior is otherwise identical to nda::mpi_reduce and nda::mpi_reduce_in_place.
*
* The reduction is performed in-place if the target and input array/view are the same, e.g.
*
* @code{.cpp}
* A = mpi::reduce(A);
Expand All @@ -220,7 +221,7 @@ namespace nda {
* ranks in the communicator need to call the same method. Otherwise, the program will deadlock.
*
* @tparam A nda::basic_array or nda::basic_array_view type.
* @param a Array or view to be reduced.
* @param a Array/view to be reduced.
* @param comm `mpi::communicator` object.
* @param root Rank of the root process.
* @param all Should all processes receive the result of the reduction.
Expand All @@ -229,8 +230,7 @@ namespace nda {
*/
template <typename A>
requires(is_regular_or_view_v<A>)
ArrayInitializer<std::remove_reference_t<A>> auto lazy_mpi_reduce(A &&a, mpi::communicator comm = {}, int root = 0, bool all = false,
MPI_Op op = MPI_SUM) {
auto lazy_mpi_reduce(A &&a, mpi::communicator comm = {}, int root = 0, bool all = false, MPI_Op op = MPI_SUM) {
return mpi::lazy<mpi::tag::reduce, A>{std::forward<A>(a), comm, root, all, op};
}

Expand Down Expand Up @@ -259,7 +259,7 @@ namespace nda {
* before the MPI call on all other processes.
*
* @tparam A nda::basic_array or nda::basic_array_view type.
* @param a Array or view to be reduced.
* @param a Array/view to be reduced.
* @param comm `mpi::communicator` object.
* @param root Rank of the root process.
* @param all Should all processes receive the result of the reduction.
Expand Down Expand Up @@ -303,7 +303,7 @@ namespace nda {
* Here, the array `B` has the shape `(3, 4)` on the root process and `(0, 0)` on all other processes.
*
* @tparam A nda::basic_array or nda::basic_array_view type.
* @param a Array or view to be reduced.
* @param a Array/view to be reduced.
* @param comm `mpi::communicator` object.
* @param root Rank of the root process.
* @param all Should all processes receive the result of the reduction.
Expand Down
6 changes: 3 additions & 3 deletions c++/nda/mpi/scatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ namespace nda {
* these methods, all ranks in the communicator need to call the same method. Otherwise, the program will deadlock.
*
* @tparam A nda::basic_array or nda::basic_array_view type.
* @param a Array or view to be scattered.
* @param a Array/view to be scattered.
* @param comm `mpi::communicator` object.
* @param root Rank of the root process.
* @return An mpi::lazy<mpi::tag::scatter, A> object modelling an nda::ArrayInitializer.
*/
template <typename A>
requires(is_regular_or_view_v<A> and std::decay_t<A>::is_stride_order_C())
ArrayInitializer<std::remove_reference_t<A>> auto lazy_mpi_scatter(A &&a, mpi::communicator comm = {}, int root = 0) {
auto lazy_mpi_scatter(A &&a, mpi::communicator comm = {}, int root = 0) {
return mpi::lazy<mpi::tag::scatter, A>{std::forward<A>(a), comm, root, true};
}

Expand Down Expand Up @@ -225,7 +225,7 @@ namespace nda {
* `comm.size()`).
*
* @tparam A nda::basic_array or nda::basic_array_view type.
* @param a Array or view to be scattered.
* @param a Array/view to be scattered.
* @param comm `mpi::communicator` object.
* @param root Rank of the root process.
* @return An nda::basic_array object with the result of the scattering.
Expand Down
11 changes: 4 additions & 7 deletions doc/groups.dox
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@
* The following example demonstrates some of these features:
*
* @code{.cpp}
* #include <mpi/mpi.hpp>
* #include <nda/mpi.hpp>
* #include <nda/nda.hpp>
*
* #include <iostream>
* #include <mpi/mpi.hpp>
*
* int main(int argc, char **argv) {
* // initialize MPI environment
Expand All @@ -178,14 +178,11 @@
* nda::array<int, 2> A(2, 2);
* A() = comm.rank();
*
* // reduce the array over all processes, which returns an mpi::lazy proxy object
* auto lazy_sum = mpi::reduce(A);
*
* // since it satisfies the nda::ArrayInitializer concept, we can use it to initialize an nda::array
* nda::array<int, 2> sum(lazy_sum);
* // reduce the array over all processes
* auto A_sum = mpi::reduce(A);
*
* // print the result
* if (comm.rank() == 0) std::cout << sum << std::endl;
* if (comm.rank() == 0) std::cout << A_sum << std::endl;
* }
* @endcode
*
Expand Down

0 comments on commit 29c5870

Please sign in to comment.