-
-
-
\documentclass[conference]{IEEEtran}
-
\usepackage[ruled,vlined]{algorithm2e}
-
-
\hyphenation{op-tical net-works semi-conduc-tor}
-
\bibliographystyle{IEEEtran}
-
-
\usepackage{amsfonts}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\todo[color=orange!10,#1]{\sffamily\textbf{AS:} #2}\xspace}
-
-
\begin{document}
\title{Two parallel implementations of Ehrlich-Aberth algorithm for root-finding of polynomials on multiple GPUs with OpenMP and MPI}
\LZK{Pas d'autres contributions possibles? J'ai supprimé les deux premiers points proposés précédemment.}
The paper is organized as follows. In Section~\ref{sec2} we present three different parallel programming models OpenMP, MPI and CUDA. In Section~\ref{sec3} we present the implementation of the Ehrlich-Aberth algorithm on a single GPU. In Section~\ref{sec4} we present the parallel implementations of the Ehrlich-Aberth algorithm on multiple GPUs using the OpenMP and MPI approaches. In section~\ref{sec5} we present our experiments and discuss them. Finally, Section~\ref{sec6} concludes this paper and gives some hints for future research directions in this topic.
-%\LZK{A revoir toute cette organization: je viens de la revoir}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Initialize the polynomial $P$ and its derivative $P'$\;
Set the initial values of vector $Z$\;
Copy $P$, $P'$ and $Z$ from CPU to GPU\;
-\While{\emph{not convergence}}{
+\While{$\Delta Z_{max} > \epsilon$}{
$Z^{prev}$ = KernelSave($Z,n$)\;
$Z$ = KernelUpdate($P,P',Z,n$)\;
$\Delta Z$ = KernelComputeError($Z,Z^{prev},n$)\;
$\Delta Z_{max}$ = CudaMaxFunction($\Delta Z,n$)\;
- TestConvergence($\Delta Z_{max},\epsilon$)\;
}
Copy $Z$ from GPU to CPU\;
\label{alg1-cuda}
-\LZK{J'ai modifié l'algo. Sinon, est ce qu'on doit mettre en paramètre
- $Z^{prev}$ ou $Z$ tout court (dans le cas où on exploite
- l'asynchronisme des threads cuda!) pour le Kernel\_Update? }
-\RC{Le $Z_{prev}$ sert à calculer l'erreur donc j'ai remis Z. La ligne
-avec TestConvergence ca fait une ligne de plus.}
+\RC{La ligne avec TestConvergence ca fait une ligne de plus.\LZK{Oui j'ai hésité à l'ajouter. On peut faire le test dans la condition de while mais quelle est la valeur initiale de $\Delta Z_{max}$?! Ou bien on s'en fiche?}}
\end{algorithm}
$n_{loc}$ = $n/ngpu$ (local size)\;
%$idx$ = $id_{gpu}\times n_{loc}$ (local offset)\;
Copy $P$, $P'$ from CPU to GPU\;
-\While{\emph{not convergence}}{
+\While{$max > \epsilon$}{
Copy $Z$ from CPU to GPU\;
$Z^{prev}$ = KernelSave($Z,n$)\;
- $Z_{loc}$ = KernelUpdate($P,P',Z^{prev},n_{loc}$)\;
+ $Z_{loc}$ = KernelUpdate($P,P',Z,n_{loc}$)\;
$\Delta Z_{loc}$ = KernelComputeError($Z_{loc},Z^{prev}_{loc},n_{loc}$)\;
$\Delta Z_{max}[id_{gpu}]$ = CudaMaxFunction($\Delta Z_{loc},n_{loc}$)\;
Copy $Z_{loc}$ from GPU to $Z$ in CPU\;
- $max$ = MaxFunction($\Delta Z_{max},ngpu$)\;
- TestConvergence($max,\epsilon$)\;
+ $max$ = MaxFunction($\Delta Z_{max},ngpu$)\;
}
\label{alg2-cuda-openmp}
\LZK{J'ai modifié l'algo. Le $P$ est mis shared. Qu'en est-il pour
-\subsection{an MPI-CUDA approach}
+\subsection{a MPI-CUDA approach}
+
+Our parallel implementation of EA to find root of polynomials using a
+CUDA-MPI approach follows a similar computing approach to the one used
+in CUDA-OpenMP. Each process is responsible to compute its own part of
+roots using all the roots computed by other processors at the previous
+iteration. The difference between both approaches lies in the way
+processes communicate and exchange data. With MPI processors need to
+send and receive data explicitely. So in
+Algorithm~\ref{alg2-cuda-mpi}, after the initialization all the
+processors have the same $Z$ vector. Then they need to compute the
+parameters used by the $MPI\_AlltoAll$ routines (line 4). In practise,
+each processor needs to compute its offset and its local size. Then
+processors need to allocate memory on their GPU (line 5). At the
+beginning of each iteration, a processor starts by transfering the
+whole vector Z from the CPU to the GPU (line 7). Then only the local
+part of $Z^{prev}$ is saved (line 8). After that, a processor is able
+to compute its own roots (line 9). Next, the local error can be
+computed (ligne 10) and the global error (line 11). Then the local
+roots are transfered from the GPU memory to the CPU memory (line 12)
+before being exchanged between all processors (linge 13) in order to
+give to all processors the last version of the roots. If the
+convergence is not statisfied, an new iteration is executed.
-Our parallel implementation of EA to find root of polynomials using a CUDA-MPI approach is a data parallel approach. It splits input data of the polynomial to solve among MPI processes. In Algorithm \ref{alg2-cuda-mpi}, input data are the polynomial to solve $P$, the solution vector $Z$, the previous solution vector $ZPrev$, and the value of errors of stop condition $\Delta z$. Let $p$ denote the number of MPI processes on and $n$ the degree of the polynomial to be solved. The algorithm performs a simple data partitioning by creating $p$ portions, of at most $\lceil n/p \rceil$ roots to find per MPI process, for each $Z$ and $ZPrec$. Consequently, each MPI process of rank $k$ will have its own solution vector $Z_{k}$ and $ZPrec$, the error related to the stop condition $\Delta z_{k}$, enabling each MPI process to compute $\lceil n/p \rceil$ roots.
-Since a GPU works only on data already allocated in its memory, all local input data, $Z_{k}$, $ZPrec$ and $\Delta z_{k}$, must be transferred from CPU memories to the corresponding GPU memories. Afterwards, the same EA algorithm (Algorithm \ref{alg1-cuda}) is run by all processes but on different polynomial subset of roots $ p(x)_{k}=\sum_{i=1}^{n} a_{i}x^{i}, k=1,...,p$. Each MPI process executes the loop \verb=(While(...)...do)= containing the CUDA kernels but each MPI process computes only its own portion of the roots according to the rule ``''owner computes``''. The local range of roots is indicated with the \textit{index} variable initialized at (line 5, Algorithm \ref{alg2-cuda-mpi}), and passed as an input variable to $kernel\_update$ (line 10, Algorithm \ref{alg2-cuda-mpi}). After each iteration, MPI processes synchronize (\verb=MPI_Allreduce= function) by a reduction on $\Delta z_{k}$ in order to compute the maximum error related to the stop condition. Finally, processes copy the values of new computed roots from GPU memories to CPU memories, then communicate their results to other processes with \verb=MPI_Alltoall= broadcast. If the stop condition is not verified ($error > \epsilon$) then processes stay withing the loop \verb= while(...)...do= until all the roots sufficiently converge.
\begin{algorithm}[htpb]
\label{alg2-cuda-mpi}
-%\LinesNumbered
+\LinesNumbered
\caption{CUDA-MPI Algorithm to find roots with the Ehrlich-Aberth method}
\KwIn{$Z^{0}$ (Initial root's vector), $\varepsilon$ (Error tolerance
- threshold), P (Polynomial to solve), Pu (Derivative of P), $n$ (Polynomial degrees), $\Delta z$ ( error of stop condition), $num_gpus$ (number of MPI processes/ number of GPUs), Size (number of roots)}
+ threshold), P (Polynomial to solve), P' (Derivative of P), $n$ (Polynomial degrees), $\Delta z$ ( error of stop condition)}
-\KwOut {$Z$ (Solution root's vector), $ZPrec$ (Previous solution root's vector)}
+\KwOut {$Z$ (Solution root's vector)}
\BlankLine
Initialization of P\;
Initialization of Pu\;
Initialization of the solution vector $Z^{0}$\;
-Distribution of Z\;
+Computation of the parameters for the $MPI\_AlltoAll$\;
Allocate memory to GPU\;
\While {$error > \epsilon$}{
copy Z from CPU to GPU\;
-$ZPrec_{loc}=kernel\_save(Z_{loc})$\;
-$Z_{loc}=kernel\_update(Z,P,Pu)$\;
-$\Delta z=kernel\_testConv(Z_{loc},ZPrec_{loc})$\;
+$Z^{Prev}_{loc}=kernel\_save(Z_{loc})$\;
+$Z_{loc}=kernel\_update(Z,P,P')$\;
+$\Delta z=kernel\_testConv(Z_{loc},Z^{prev}_{loc})$\;
$error=MPI\_Reduce(\Delta z)$\;
Copy $Z_{loc}$ from GPU to CPU\;
$Z=MPI\_AlltoAll(Z_{loc})$\;
}
+\RC{A uniformiser avec les autres algos, mais les grandes lignes sont là}
\end{algorithm}