\item In a shared memory model all data (memory) are visible to all threads (workers) in your application
\item This means that they can get required data easily but also means that one has to be careful that when updating memory only one thread is writing to a particular address
\end{description}
\item Distributed Memory:
\begin{description}
\item Here the workers only see a small part of the overall memory and if they need data that are visible to another worker they have to explicitly ask for it
\item The advantage is that, if the algorithm scales, we can use more nodes to increase the performance and/or problem size
\item All the largest HPC systems use such a distributed memory model.
\end{description}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{MPI}
\framesubtitle{MPI implementations}
MPI is a standard with many implementations
\begin{itemize}
\item MPICH2
\item MVAPICH2
\item Intel MPI
\item OpenMPI
\item Platform MPI
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{MPI}
\framesubtitle{MPI code compiler}
mpicc is really a wrapper for the standard (GCC and Intel) compilers
\item[Static libraries] Using static libraries means including the definition of the library functions in your executable file, during the link editing stage (i.e. during compilation and before launching the program)
\item[Shared libraries] Using shared libraries means telling your program where it can load these definitions into memory after the program is launched
\end{description}
\item Examples
\begin{description}
\item Static libraries are generally named in the form \cmd{lib***.a}; for example, \cmd{libc.a} is the standard \cmd{C} library (functions \cxxinline{malloc}, \cxxinline{exit}, etc.) launching the program)
\item Shared libraries are generally named in the form \cmd{lib***.so}
\end{description}
\item Use
\begin{description}
\item Let the library \cmd{libXXX.a}(or \cmd{libXXX.so}) be located in a directory whose absolute path is \cmd{path}. To compile a source \cmd{file.c} file calling functions of this library, you must type the following command line:
\begin{consoleoutput}
$ gcc file.c -Lpath -lXXX -o file
\end{consoleoutput}
\end{description}
\end{itemize}
\end{frame}
\note{
\begin{itemize}
\item The advantage of static libraries is that the resulting executable file contains, before execution, everything that is necessary for it to work
\item On the other hand, a program compiled with a static library has an executable file that is much larger than the same program compiled with a dynamic library, since the definition of the library's functions is not in the executable file
\item Finally, if a static library is updated, any program that uses it will have to be recompiled so that it can take into account the modification. In the case of a dynamic library, this update does not need to be recompiled.
\end{itemize}
}
\begin{frame}[t,fragile]
\frametitle{Compilation}
\framesubtitle{Use of library path through modules}
When using shared librairies at runtime we need to set \cmd{LD LIBRARY PATH} so the system knows where to find the library
\begin{itemize}
\item This variable tells the program where to look for dynamic libraries; if this location is changed, it is enough to modify the variable, without changing the program
\item To tell the system to look in the directory \cmd{path/to/the/library}, the variable \cmd{LD_LIBRARY_PATH} must be initialized as follows:
\begin{consoleoutput}
$ export LD_LIBRARY_PATH=/usr/local/lib
\end{consoleoutput}
\item In practice, you will never define this variable but you will add files to its definition: