Skip to content

Commit 5dbcc2c

Browse files
committed
Update 03-mpi-api
- Remove mention of Boost MPI - Update AllGather operation slide\ - Update references
1 parent 0aedf04 commit 5dbcc2c

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
@@ -71,61 +71,6 @@
7171
\tableofcontents
7272
\end{frame}
7373

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

13176
\begin{frame}{Why Using \texttt{MPI\_Send} and \texttt{MPI\_Recv} Is Not Enough?}
@@ -144,7 +89,6 @@ \section{Advanced Send/Receive API}
14489
{
14590
\footnotesize
14691
\texttt{int MPI\_Isend(const void *buf, int count, MPI\_Datatype datatype, int dest, int tag, MPI\_Comm comm, MPI\_Request *request);} \\
147-
\texttt{boost::mpi::request boost::mpi::communicator::isend(int dest, int tag, const T* values, int n);}
14892
}
14993

15094
Parameters:
@@ -167,7 +111,6 @@ \section{Advanced Send/Receive API}
167111
{
168112
\footnotesize
169113
\texttt{int MPI\_Irecv(void *buf, int count, MPI\_Datatype datatype, int source, int tag, MPI\_Comm comm, MPI\_Request *request);} \\
170-
\texttt{boost::mpi::request boost::mpi::communicator::irecv(int source, int tag, T\& value);}
171114
}
172115

173116
Parameters:
@@ -210,7 +153,6 @@ \section{Synchronization}
210153
{
211154
\footnotesize
212155
\texttt{int MPI\_Barrier(MPI\_Comm comm);} \\
213-
\texttt{void boost::mpi::communicator::barrier();}
214156
}
215157

216158
Usage:
@@ -252,7 +194,6 @@ \section{Collective operations}
252194
{
253195
\footnotesize
254196
\texttt{int MPI\_Bcast(void *buffer, int count, MPI\_Datatype datatype, int root, MPI\_Comm comm);} \\
255-
\texttt{void broadcast(const communicator\& comm, T\& value, int root);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
256197
}
257198

258199
\begin{minipage}[t]{0.6\textwidth}
@@ -282,7 +223,6 @@ \section{Collective operations}
282223
{
283224
\footnotesize
284225
\texttt{int MPI\_Reduce(const void *sendbuf, void *recvbuf, int count, MPI\_Datatype datatype, MPI\_Op op, int root, MPI\_Comm comm);} \\
285-
\texttt{void reduce(const communicator\& comm, const T\& in\_value, T\& out\_value, Op op, int root);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
286226
}
287227

288228
\begin{minipage}[t]{0.2\textwidth}
@@ -309,7 +249,6 @@ \section{Collective operations}
309249
{
310250
\footnotesize
311251
\texttt{int MPI\_Gather(const void *sendbuf, int sendcount, MPI\_Datatype sendtype, void *recvbuf, int recvcount, MPI\_Datatype recvtype, int root, MPI\_Comm comm);} \\
312-
\texttt{void gather(const communicator\& comm, const T\& in\_value, std::vector<T>\& out\_values, int root);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
313252
}
314253

315254
\begin{minipage}[t]{0.6\textwidth}
@@ -334,7 +273,6 @@ \section{Collective operations}
334273
{
335274
\footnotesize
336275
\texttt{int MPI\_Scatter(const void *sendbuf, int sendcount, MPI\_Datatype sendtype, void *recvbuf, int recvcount, MPI\_Datatype recvtype, int root, MPI\_Comm comm);} \\
337-
\texttt{void scatter(const communicator\& comm, const std::vector<T>\& in\_values, T\& out\_value, int root);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
338276
}
339277

340278
\begin{minipage}[t]{0.6\textwidth}
@@ -359,11 +297,25 @@ \section{Collective operations}
359297
{
360298
\footnotesize
361299
\texttt{int MPI\_Allgather(const void *sendbuf, int sendcount, MPI\_Datatype sendtype, void *recvbuf, int recvcount, MPI\_Datatype recvtype, MPI\_Comm comm);} \\
362-
\texttt{void all\_gather(const communicator\& comm, const T\& in\_value,
363-
std::vector<T>\& out\_values);} (needs \texttt{\#include <boost/mpi/collectives.hpp>})
364300
}
365301

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

369321
\begin{frame}{All-to-All (\texttt{MPI\_Alltoall})}
@@ -372,7 +324,6 @@ \section{Collective operations}
372324
{
373325
\footnotesize
374326
\texttt{int MPI\_Alltoall(const void *sendbuf, int sendcount, MPI\_Datatype sendtype, void *recvbuf, int recvcount, MPI\_Datatype recvtype, MPI\_Comm comm);} \\
375-
\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>})
376327
}
377328

378329
Note: This operation is communication-intensive.
@@ -403,8 +354,8 @@ \section{Collective operations}
403354
\begin{frame}{References}
404355
\begin{enumerate}
405356
\item MPI Standard \href{https://www.mpi-forum.org/docs/}{https://www.mpi-forum.org/docs/}
406-
\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}
407357
\item Open MPI v4.0.7 documentation: \href{https://www.open-mpi.org/doc/v4.0/}{https://www.open-mpi.org/doc/v4.0/}
358+
\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/}
408359
\end{enumerate}
409360
\end{frame}
410361

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}{6}{0}{2}
3-
\beamer@sectionintoc {3}{Synchronization}{10}{0}{3}
4-
\beamer@sectionintoc {4}{Collective operations}{13}{0}{4}
1+
\beamer@sectionintoc {1}{Advanced Send/Receive API}{3}{0}{1}
2+
\beamer@sectionintoc {2}{Synchronization}{7}{0}{2}
3+
\beamer@sectionintoc {3}{Collective operations}{10}{0}{3}

03-mpi-api/images/allgather.png

8.03 KB
Loading

0 commit comments

Comments
 (0)