Page MenuHomec4science

Report.tex
No OneTemporary

File Metadata

Created
Thu, Sep 5, 05:19

Report.tex

\documentclass[aps,pra,amssymb,amsmath,superscriptaddress,reprint]{revtex4-1}
\input{structure.tex} % Specifies the document structure and loads requires packages
%----------------------------------------------------------------------------------------
\begin{document}
\title{PHPC : Theoretical analysis - Shallow Water Wave Equation with a finite volume solver}
\author{Arnaud Pannatier - \url{https://c4science.ch/source/phpctsunamiproject/}}
\date{\today}
\maketitle
%----------------------------------------------------------------------------------------
% ARTICLE CONTENTS
%----------------------------------------------------------------------------------------
\section{Introduction}
This project proposes a way to increase the performance of a sequential code using classical parallelism technic. It is based on a Matlab code of \textit{Nicolas Richart} that simulates the evolution of a tsunami. The purpose of this report is to describe the state of the current project and to describe how the sequential code will parallelized. It also gives the expected results for the speed up, as well as the strong scaling of the problem.
\section{Description of the Code}
The code is arranged in the following way. The algorithm will compute the evolution of the height of the wave $H(x,y)$, based on the knowledge of the topography and the evolution of the speed of the wave in the direction $x$ and $y$. In order to start the computation, the algorithm first read the initial conditions for the different values ($H$,$HU$,$HV$, $Zdx$, $Zdy$) in binary files. The duration of the evolution $T_{end}$ is specified by the user. While this time is not reached, the algorithm will compute the next variable time step and the evolution of the height and the speed : $H$,$HU$,$HV$. The update of the variables only needs information of the direct neighbor of a point (x,y). When the simulation is over the height of the wave at the final time step is stored in a file.
\section{Parallelization}
The sequential code will be parallelized using \texttt{MPI}. The reader, writer and time step computation as well as the update of the height and the speed $H,HU,HV$ will be implemented.
The parallelization of the reader and writer will make use of the Parallel I/O of MPI. Computing the next time step implies that the max over a grid should be found. This can be done in a parallel fashion using the following design : as \texttt{C++} is a row major language, the grid will be split between nodes in a block of $\frac{N}{P}$ complete row. Each processor will then return the max over his subgrid and the final max will be computed at the end, this final computation will be done on a single node. The parallelization of the update of $H$, $HU$, $HV$ will be approached in a similar manner. The grid will be split as before. Before and after each subgrid (except the first one and the last one) a row of ghost cells will be added, in order to allow the computation. Most of the code will therefore be parallelized.
\section{Performance}
Translating the code from \texttt{Matlab} to \texttt{C++} allows us to compute the solution approximately 5 times faster. This performance will be improved drastically using parallelism technic.
\begin{center}
\begin{table}[h]
\begin{tabular}{l*{3}{r}r}
& Matlab [s] & C++ [s]& \\
\hline
2001x2001 & 1233.068 & 226.741 &\\
4001x4001 & 10625.835 & 2003.880 & \\
\end{tabular}
\caption{Total time in seconds for a run on a 3.1 GHz Intel i5}
\label{Table1}
\end{table}
\end{center}
\section{Theorethical results}
\subsection{Amdahl's Law - Strong scaling}
The speed up of a parallelism problem depends mostly on the percentage of sequential code that can be parallelized. In the case of this problem, most of the code can be parallelized. A first estimation can be deduced from the profiling table [TAB. \ref{Table2}]. Summing up the three main functions that can be parallelized (\texttt{compute\_step, compute\_mu\_and\_set\_dt} and \texttt{imposeTolerances}) gives a value of 98.06\% of code parallelizable. The speed up is given by Amdahl's Law :
\begin{equation}
S_p = \frac{1}{\alpha + \frac{1-\alpha}{p}}
\end{equation}
Where $\alpha$ is the fraction of non-parallelizable code, in this case 1.94\%, and $p$ is the number of cores that is used to compute the simulation.
\subsection{Expected Speed Up}
Computing the speed up using strong scaling for this problem gives the following curve [FIG. \ref{SpeedUp}]. This theoretical result will be compared with the real one when the problem is parallelized.
\onecolumngrid
\newpage
\appendix
\section{Profiling}
\begin{center}
\begin{table}[h]
\begin{tabular}{l*{7}{r}r}
\% & cumulative & self & & self & total & \\
time & seconds & seconds & calls & ms/call & ms/call & name \\
\hline
76.47 & 113.37 & 113.37 & 352 & 322.07 & 335.59 & \texttt{Simulation::compute\_step} \\
19.19 & 141.82 & 28.45 & 352 & 80.82 & 80.82 & \texttt{Simulation::compute\_mu\_and\_set\_dt} \\
2.40 & 145.37 & 3.55 & 1056 & 3.36 & 3.36 & \texttt{ Grid::imposeTolerances} \\
1.58 & 147.71 & 2.34 & 4219780580 & 0.00 & 0.0 & \texttt{ DoubleBuffer::current } \\
0.30 & 148.16 & 0.45 & 3 & 150.04 & 150.04 & \texttt{DoubleBuffer::DoubleBuffer} \\
0.04 & 148.22 & 0.06 & 5 & 12.00 & 12.00 & \texttt{Reader::readGridFromFile} \\
0.03 & 148.27 & 0.05 & 1056 & 0.05 & 0.05 & \texttt{ Grid::applyBoundaryConditions } \\
0.01 & 148.29 & 0.02 & 1 & 20.01 & 20.01 & \texttt{Reader::writeGridInFile } \\
0.00 & 148.29 & 0.00 & 2115 & 0.00 & 0.00 & \texttt{ DoubleBuffer::old } \\
0.00 & 148.29 & 0.00 & 1056 & 0.00 & 0.00 & \texttt{ DoubleBuffer::swap } \\
\end{tabular}
\caption{Profiling on Deneb1}
\label{Table2}
\end{table}
\end{center}
\section{Strong scaling}
\begin{figure}[h]
\includegraphics[scale=0.6]{figure1.eps}
\caption{Theorethical speed up following the parallelization of the problem}
\label{SpeedUp}
\end{figure}
\end{document}

Event Timeline