From 54dcca0c93547130a381d05f6566199d6751d557 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Sun, 22 Sep 2024 23:03:42 +0300 Subject: [PATCH] Update 03-mpi-api slides - Add information about isend/irecv, synchronization and MPI_Barrier specifically - Extend 03-mpi-api lecture plan --- 03-mpi-api/03-mpi-api.tex | 88 ++++++++++++++++++++++++++++++++++++++- 03-mpi-api/03-mpi-api.toc | 4 +- 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/03-mpi-api/03-mpi-api.tex b/03-mpi-api/03-mpi-api.tex index 9c30516..a47f17b 100644 --- a/03-mpi-api/03-mpi-api.tex +++ b/03-mpi-api/03-mpi-api.tex @@ -64,7 +64,90 @@ \tableofcontents \end{frame} -\section{MPI collective operations} +\section{Advanced Send/Receive API} + +\begin{frame}{Why Using \texttt{MPI\_Send} and \texttt{MPI\_Recv} Is Not Enough?} + Blocking Operations \texttt{MPI\_Send} and \texttt{MPI\_Recv} are blocking, causing processes to wait until communication completes. + So they are the reason of: + \begin{itemize} + \item \textbf{Performance Bottlenecks:} Blocking calls can lead to idle CPU time, reducing parallel efficiency. + \item \textbf{Lack of Overlap:} Cannot overlap computation with communication, limiting optimization opportunities. + \item \textbf{Scalability Issues:} As the number of processes increases, blocking operations can significantly degrade performance. + \end{itemize} +\end{frame} + +\begin{frame}{\texttt{MPI\_Isend}} + Non-Blocking Send function. Initiates a send operation that returns immediately. + + \texttt{int MPI\_Isend(const void *buf, int count, MPI\_Datatype datatype, int dest, int tag, MPI\_Comm comm, MPI\_Request *request);} + + Parameters: + + \begin{itemize} + \item buf: Initial address of send buffer + \item count: Number of elements to send + \item datatype: Data type of each send buffer element + \item dest: Rank of destination process + \item tag: Message tag + \item comm: Communicator + \item request: Communication request handle + \end{itemize} + Usage: Allows the sender to proceed with computation while the message is being sent. +\end{frame} + +\begin{frame}{\texttt{MPI\_Irecv}} + Non-Blocking Receive function. Initiates a receive operation that returns immediately. + \texttt{int MPI\_Irecv(void *buf, int count, MPI\_Datatype datatype, int source, int tag, MPI\_Comm comm, MPI\_Request *request);} + + Parameters: + + \begin{itemize} + \item buf: Initial address of receive buffer + \item count: Maximum number of elements to receive + \item datatype: Data type of each receive buffer element + \item source: Rank of source process or \texttt{MPI\_ANY\_SOURCE} + \item tag: Message tag or \texttt{MPI\_ANY\_TAG} + \item comm: Communicator + \item request: Communication request handle + \end{itemize} + Usage: Allows the receiver to proceed with computation while waiting for the message. +\end{frame} + +\section{Synchronization} + +\begin{frame}{What is synchronization in MPI?} + Synchronization mechanisms are essential to coordinating processes. + Sometimes we need to ensure that particular action has been already completed. + + Synchronization facts: + + \begin{itemize} + \item Process Coordination: Mechanism to ensure processes reach a certain point before proceeding + \item Data Consistency: Ensures all processes have consistent data before computations + \item Types of Synchronization: + \begin{itemize} + \item Point-to-point synchronization: It involves explicit sending and receiving of messages between two processes using functions like \texttt{MPI\_Send} and \texttt{MPI\_Recv} + \item Collective synchronization: Collective operations (see next slides) are used, where all processes must participate + \end{itemize} + \item Importance: Prevents race conditions and ensures program correctness + \end{itemize} +\end{frame} + +\begin{frame}{\texttt{MPI\_Barrier}} + Global Synchronization function. It blocks processes until all of them have reached the barrier. + + \texttt{int MPI\_Barrier(MPI\_Comm comm);} + + Usage: + + \begin{itemize} + \item Ensures all processes have completed preceding computations + \item Commonly used before timing code segments for performance measurement + \item Typical use case: Synchronize before starting a collective operation + \end{itemize} +\end{frame} + +\section{Collective operations} \begin{frame}{Collective operations} \end{frame} @@ -87,6 +170,9 @@ \section{MPI collective operations} \begin{frame}{Reduction} \end{frame} +\begin{frame}{All API have not blocking versions} +\end{frame} + \begin{frame} \centering \Huge{Thank You!} diff --git a/03-mpi-api/03-mpi-api.toc b/03-mpi-api/03-mpi-api.toc index c012bb9..597ca8b 100644 --- a/03-mpi-api/03-mpi-api.toc +++ b/03-mpi-api/03-mpi-api.toc @@ -1 +1,3 @@ -\beamer@sectionintoc {1}{MPI collective operations}{3}{0}{1} +\beamer@sectionintoc {1}{Advanced Send/Receive API}{3}{0}{1} +\beamer@sectionintoc {2}{Synchronization}{6}{0}{2} +\beamer@sectionintoc {3}{Collective operations}{8}{0}{3}