Skip to content

Commit e2eda09

Browse files
committed
Update 03-mpi-api
- Remove mention of Boost MPI - Update AllGather operation slide\ - Update references
1 parent e76d45d commit e2eda09

File tree

3 files changed

+21
-71
lines changed

3 files changed

+21
-71
lines changed

03-mpi-api/03-mpi-api.tex

Lines changed: 18 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -64,61 +64,6 @@
6464
\tableofcontents
6565
\end{frame}
6666

67-
\section{Boost.MPI}
68-
69-
\begin{frame}{Boost.MPI}
70-
Boost.MPI is a part of the Boost C++ libraries that provides C++ bindings for the Message Passing Interface (MPI).
71-
72-
Boost.MPI makes it easier to write distributed applications in C++ by wrapping the complex MPI API with C++-friendly abstractions, improving safety and reducing the amount of boilerplate code.
73-
74-
Key Features of Boost.MPI:
75-
\begin{itemize}
76-
\item Simplified use of MPI with C++ bindings.
77-
\item Supports complex data types through Boost.Serialization.
78-
\item Easier management of distributed tasks and communication.
79-
\item Compatible with common MPI implementations like MPICH, OpenMPI, MS MPI, etc.
80-
\end{itemize}
81-
82-
Note: C API mappting ot Boost.MPI: \href{https://www.boost.org/doc/libs/1_86_0/doc/html/mpi/c_mapping.html}{link}
83-
84-
{\footnotesize For more details see Boost.MPI docs: \href{https://www.boost.org/doc/libs/1_86_0/doc/html/mpi.html}{link}}
85-
\end{frame}
86-
87-
\begin{frame}[fragile]{Boost.MPI example}
88-
\lstset{style=CStyle, caption=Hello World example with Boost MPI}
89-
\begin{lstlisting}
90-
#include <boost/mpi.hpp>
91-
#include <iostream>
92-
93-
// Namespace alias for convenience
94-
namespace mpi = boost::mpi;
95-
96-
int main(int argc, char* argv[]) {
97-
// Initialize the MPI environment
98-
mpi::environment env(argc, argv);
99-
mpi::communicator world;
100-
101-
// Get the rank (ID) of the current process and the total number of processes
102-
int rank = world.rank();
103-
int size = world.size();
104-
105-
if (rank == 0) {
106-
// If this is the root process (rank 0), send a message to another process
107-
std::string message = "Hello from process 0";
108-
world.send(1, 0, message); // Send to process 1
109-
std::cout << "Process 0 sent: " << message << std::endl;
110-
} else if (rank == 1) {
111-
// If this is process 1, receive the message
112-
std::string received_message;
113-
world.recv(0, 0, received_message); // Receive from process 0
114-
std::cout << "Process 1 received: " << received_message << std::endl;
115-
}
116-
117-
return 0;
118-
}
119-
\end{lstlisting}
120-
\end{frame}
121-
12267
\section{Advanced Send/Receive API}
12368

12469
\begin{frame}{Why Using \texttt{MPI\_Send} and \texttt{MPI\_Recv} Is Not Enough?}
@@ -137,7 +82,6 @@ \section{Advanced Send/Receive API}
13782
{
13883
\footnotesize
13984
\texttt{int MPI\_Isend(const void *buf, int count, MPI\_Datatype datatype, int dest, int tag, MPI\_Comm comm, MPI\_Request *request);} \\
140-
\texttt{boost::mpi::request boost::mpi::communicator::isend(int dest, int tag, const T* values, int n);}
14185
}
14286

14387
Parameters:
@@ -160,7 +104,6 @@ \section{Advanced Send/Receive API}
160104
{
161105
\footnotesize
162106
\texttt{int MPI\_Irecv(void *buf, int count, MPI\_Datatype datatype, int source, int tag, MPI\_Comm comm, MPI\_Request *request);} \\
163-
\texttt{boost::mpi::request boost::mpi::communicator::irecv(int source, int tag, T\& value);}
164107
}
165108

166109
Parameters:
@@ -203,7 +146,6 @@ \section{Synchronization}
203146
{
204147
\footnotesize
205148
\texttt{int MPI\_Barrier(MPI\_Comm comm);} \\
206-
\texttt{void boost::mpi::communicator::barrier();}
207149
}
208150

209151
Usage:
@@ -245,7 +187,6 @@ \section{Collective operations}
245187
{
246188
\footnotesize
247189
\texttt{int MPI\_Bcast(void *buffer, int count, MPI\_Datatype datatype, int root, MPI\_Comm comm);} \\
248-
\texttt{void broadcast(const communicator\& comm, T\& value, int root);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
249190
}
250191

251192
\begin{minipage}[t]{0.6\textwidth}
@@ -275,7 +216,6 @@ \section{Collective operations}
275216
{
276217
\footnotesize
277218
\texttt{int MPI\_Reduce(const void *sendbuf, void *recvbuf, int count, MPI\_Datatype datatype, MPI\_Op op, int root, MPI\_Comm comm);} \\
278-
\texttt{void reduce(const communicator\& comm, const T\& in\_value, T\& out\_value, Op op, int root);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
279219
}
280220

281221
\begin{minipage}[t]{0.2\textwidth}
@@ -302,7 +242,6 @@ \section{Collective operations}
302242
{
303243
\footnotesize
304244
\texttt{int MPI\_Gather(const void *sendbuf, int sendcount, MPI\_Datatype sendtype, void *recvbuf, int recvcount, MPI\_Datatype recvtype, int root, MPI\_Comm comm);} \\
305-
\texttt{void gather(const communicator\& comm, const T\& in\_value, std::vector<T>\& out\_values, int root);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
306245
}
307246

308247
\begin{minipage}[t]{0.6\textwidth}
@@ -327,7 +266,6 @@ \section{Collective operations}
327266
{
328267
\footnotesize
329268
\texttt{int MPI\_Scatter(const void *sendbuf, int sendcount, MPI\_Datatype sendtype, void *recvbuf, int recvcount, MPI\_Datatype recvtype, int root, MPI\_Comm comm);} \\
330-
\texttt{void scatter(const communicator\& comm, const std::vector<T>\& in\_values, T\& out\_value, int root);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
331269
}
332270

333271
\begin{minipage}[t]{0.6\textwidth}
@@ -352,11 +290,25 @@ \section{Collective operations}
352290
{
353291
\footnotesize
354292
\texttt{int MPI\_Allgather(const void *sendbuf, int sendcount, MPI\_Datatype sendtype, void *recvbuf, int recvcount, MPI\_Datatype recvtype, MPI\_Comm comm);} \\
355-
\texttt{void all\_gather(const communicator\& comm, const T\& in\_value,
356-
std::vector<T>\& out\_values);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
357293
}
358294

359-
Usage of this function reduces the need for separate gather and broadcast operations.
295+
\begin{minipage}[t]{0.6\textwidth}
296+
Parameters:
297+
\begin{itemize}
298+
\item sendbuf: Starting address of send buffer
299+
\item sendcount / sendtype: Number and type of elements contributed by each process
300+
\item recvbuf: Starting address of receive buffer
301+
\item recvcount / recvtype: Number and type of elements received from each process
302+
\end{itemize}
303+
\end{minipage}
304+
\hfill
305+
\begin{minipage}[t]{0.35\textwidth}
306+
\begin{figure}[h]
307+
\includegraphics[scale=0.6]{images/allgather.png}
308+
\end{figure}
309+
\end{minipage}
310+
311+
{\footnotesize Source: \href{https://mpitutorial.com/tutorials/mpi-scatter-gather-and-allgather/}{https://mpitutorial.com/tutorials/mpi-scatter-gather-and-allgather/}}
360312
\end{frame}
361313

362314
\begin{frame}{All-to-All (\texttt{MPI\_Alltoall})}
@@ -365,7 +317,6 @@ \section{Collective operations}
365317
{
366318
\footnotesize
367319
\texttt{int MPI\_Alltoall(const void *sendbuf, int sendcount, MPI\_Datatype sendtype, void *recvbuf, int recvcount, MPI\_Datatype recvtype, MPI\_Comm comm);} \\
368-
\texttt{void all\_to\_all(const communicator\& comm, const std::vector<T>\& in\_values, std::vector<T>\& out\_values);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
369320
}
370321

371322
Note: This operation is communication-intensive.
@@ -396,8 +347,8 @@ \section{Collective operations}
396347
\begin{frame}{References}
397348
\begin{enumerate}
398349
\item MPI Standard \href{https://www.mpi-forum.org/docs/}{https://www.mpi-forum.org/docs/}
399-
\item Boost.MPI Chapter in Boost documentation \href{https://www.boost.org/doc/libs/1_86_0/doc/html/mpi.html}{https://www.boost.org/doc/libs/1\_86\_0/doc/html/mpi.html}
400350
\item Open MPI v4.0.7 documentation: \href{https://www.open-mpi.org/doc/v4.0/}{https://www.open-mpi.org/doc/v4.0/}
351+
\item MPI Scatter, Gather, and Allgather: \href{https://mpitutorial.com/tutorials/mpi-scatter-gather-and-allgather/}{https://mpitutorial.com/tutorials/mpi-scatter-gather-and-allgather/}
401352
\end{enumerate}
402353
\end{frame}
403354

03-mpi-api/03-mpi-api.toc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
\beamer@sectionintoc {1}{Boost.MPI}{3}{0}{1}
2-
\beamer@sectionintoc {2}{Advanced Send/Receive API}{5}{0}{2}
3-
\beamer@sectionintoc {3}{Synchronization}{8}{0}{3}
4-
\beamer@sectionintoc {4}{Collective operations}{10}{0}{4}
1+
\beamer@sectionintoc {1}{Advanced Send/Receive API}{3}{0}{1}
2+
\beamer@sectionintoc {2}{Synchronization}{6}{0}{2}
3+
\beamer@sectionintoc {3}{Collective operations}{8}{0}{3}

03-mpi-api/images/allgather.png

8.03 KB
Loading

0 commit comments

Comments
 (0)