X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/kahina_paper2.git/blobdiff_plain/b89095f023b142fe1421d966acc4382cb936360a..HEAD:/paper.tex diff --git a/paper.tex b/paper.tex index 7819f18..e90eac4 100644 --- a/paper.tex +++ b/paper.tex @@ -9,7 +9,7 @@ \usepackage[textsize=footnotesize]{todonotes} \usepackage{amsmath} \usepackage{amssymb} - +\usepackage{float} \newcommand{\LZK}[2][inline]{% \todo[color=red!10,#1]{\sffamily\textbf{LZK:} #2}\xspace} \newcommand{\RC}[2][inline]{% @@ -90,7 +90,7 @@ convergence. Many authors have proposed parallel simultaneous methods~\cite{Freeman89,Loizou83,Freemanall90,bini96,cs01:nj,Couturier02}, using several paradigms of parallelization (synchronous or asynchronous computations, mechanism of shared or distributed memory, -etc). However, so fat until now, only polynomials not exceeding +etc). However, so far until now, only polynomials not exceeding degrees of less than 100,000 have been solved. %The main problem of the simultaneous methods is that the necessary @@ -115,13 +115,21 @@ degrees of less than 100,000 have been solved. %roots of sparse polynomials of degree 10,000. The authors showed an interesting %speedup that is 20 times as fast as the sequential implementation. -With the recent advent of the Compute Unified Device Architecture -(CUDA)~\cite{CUDA15}, a parallel computing platform and a programming -model invented by NVIDIA had revived parallel programming interest for +The recent advent of the Compute Unified Device Architecture +(CUDA)~\cite{CUDA15}, a programming +model and a parallel computing architecture developed by NVIDIA, has revived parallel programming interest in this problem. Indeed, the computing power of GPUs (Graphics Processing -Units) has exceeded that of traditional CPUs processors, which makes it very appealing to the research community to investigate new parallel implementations for a whole set of scientific problems in the reasonable hope to solve bigger instances of well known computationally demanding issues such as the one beforehand. However, CUDA adopts a totally new computing architecture to use the hardware resources provided by the GPU in order to offer a stronger computing ability to the massive data computing. Ghidouche et al.~\cite{Kahinall14} proposed an implementation of the Durand-Kerner method on a single GPU. Their main results showed that a parallel CUDA implementation is about 10 times faster than the sequential implementation on a single CPU for sparse polynomials of degree 48,000. - -In this paper we propose the parallelization of the Ehrlich-Aberth (EA) method which has a cubic convergence rate which is much better than the quadratic rate of the Durand-Kerner method which has already been investigated in \cite{Kahinall14}. In the other hand, EA is suitable to be implemented in parallel computers according to the data-parallel paradigm. In this model, computing elements carry computations on the data they are assigned and communicate with other computing elements in order to get fresh data or to synchronise. Classically, two parallel programming paradigms OpenMP and MPI are used to code such solutions. But in our case, computing elements are CUDA multi-GPU platforms. This architectural setting poses new programming challenges but offers also new opportunities to efficiently solve huge problems, otherwise considered intractable until recently. To the best of our knowledge, our CUDA-MPI and CUDA-OpenMP codes are the first implementations of EA method with multiple GPUs for finding roots of polynomials. Our major contributions include: +Units) has exceeded that of traditional CPUs processors, which makes +it very appealing to the research community to investigate new +parallel implementations for a whole set of scientific problems in the +reasonable hope to solve bigger instances of well known +computationally demanding issues such as the one beforehand. However, +CUDA provides an efficient massive data computing model which is +suited to GPU architectures. Ghidouche et al.~\cite{Kahinall14} proposed an implementation of the Durand-Kerner method on a single GPU. Their main results showed that a parallel CUDA implementation is about 10 times faster than the sequential implementation on a single CPU for sparse polynomials of degree 48,000. + +In this paper we propose the parallelization of the Ehrlich-Aberth +(EA) method which has a much better cubic convergence rate than the +quadratic rate of the Durand-Kerner method that has already been investigated in \cite{Kahinall14}. In the other hand, EA is suitable to be implemented in parallel computers according to the data-parallel paradigm. In this model, computing elements carry computations on the data they are assigned and communicate with other computing elements in order to get fresh data or to synchronize. Classically, two parallel programming paradigms OpenMP and MPI are used to code such solutions. But in our case, computing elements are CUDA multi-GPU platforms. This architectural setting poses new programming challenges but offers also new opportunities to efficiently solve huge problems, otherwise considered intractable until recently. To the best of our knowledge, our CUDA-MPI and CUDA-OpenMP codes are the first implementations of EA method with multiple GPUs for finding roots of polynomials. Our major contributions include: \begin{itemize} \item The parallel implementation of EA algorithm on a multi-GPU platform with a shared memory using OpenMP API. It is based on threads created from the same system process, such that each thread is attached to one GPU. In this case the communications between GPUs are done by OpenMP threads through shared memory. @@ -222,7 +230,7 @@ initial roots are all distinct from each other. In step 3, the iterative function based on the Newton's method~\cite{newt70} and Weiestrass operator~\cite{Weierstrass03} is applied. In our case, the Ehrlich-Aberth is applied as in~(\ref{Eq:EA1}). Iterations of the -Ehrlich-Aberth method will converge to the roots of the considered +EA method will converge to the roots of the considered polynomial. In order to stop the iterative function, a stop condition is applied, this is the 4th step. This condition checks that all the root modules are lower than a fixed value $\epsilon$. @@ -233,13 +241,13 @@ root modules are lower than a fixed value $\epsilon$. \end{equation} \subsection{Improving Ehrlich-Aberth method} -With high degree polynomials, the Ehrlich-Aberth method suffers from floating point overflows due to the mantissa of floating points representations. This induces errors in the computation of $p(z)$ when $z$ is large. +With high degree polynomials, the EA method suffers from floating point overflows due to the mantissa of floating points representations. This induces errors in the computation of $p(z)$ when $z$ is large. In order to solve this problem, we propose to modify the iterative function by using the logarithm and the exponential of a complex and -we propose a new version of the Ehrlich-Aberth method. This method +we propose a new version of the EA method. This method allows us to exceed the computation of the polynomials of degree -100,000 and to reach a degree up to more than 1,000,000. The reformulation of the iteration~(\ref{Eq:EA1}) of the Ehrlich-Aberth method with exponential and logarithm operators is defined as follows, for $i=1,\dots,n$: +100,000 and to reach a degree up to more than 1,000,000. The reformulation of the iteration~(\ref{Eq:EA1}) of the EA method with exponential and logarithm operators is defined as follows, for $i=1,\dots,n$: \begin{equation} \label{Log_H2} @@ -257,34 +265,54 @@ Using the logarithm and the exponential operators, we can replace any multiplications and divisions with additions and subtractions. Consequently, computations manipulate lower values in absolute values~\cite{Karimall98}. In practice, the exponential and -logarithm mode is used when a root is outisde the circle unit represented by the radius $R$ evaluated in C language with: +logarithm mode is used when a root is outside the circle unit represented by the radius $R$ evaluated in C language with: \begin{equation} \label{R.EL} R = exp(log(DBL\_MAX)/(2*n) ); \end{equation} where \verb=DBL_MAX= stands for the maximum representable -\verb=double= value and $n$ is the degree of the polynimal. +\verb=double= value and $n$ is the degree of the polynomial. \subsection{The Ehrlich-Aberth parallel implementation on CUDA} -The code is organized as kernels which are parts of codes that are run -on GPU devices. Algorithm~\ref{alg1-cuda} describes the CUDA -implementation of the Ehrlich-Aberth on a GPU. This algorithms starts -by initializing the polynomial and its derivative (line 1). The -initialization of the roots is performed (line 2). Data are transferred -from the CPU to the GPU (after the allocation of the required memory on -the GPU) (line 3). Then at each iteration, if the error is greater -than the threshold, the following operations are performed. The previous -roots are saved using a kernel (line 5). Then the new roots with the +%\KG{ + The algorithm ~\ref{alg1-cuda} shows sketch of the Ehrlich-Aberth method using CUDA. +The first steps consist in the initialization of the input data like, the polynomial P,derivative of P and the vector solution Z. Then, all data of the root finding problem +must be copied from the CPU memory to the GPU global memory,because +the GPUs only work on the data filled in their memories. +Next, all the data-parallel arithmetic operations inside the main loop +\verb=(while(...))= are executed as kernels by the GPU. The +first kernel named \textit{Kernelsave} in line 5 of Algorithm~\ref{alg1-cuda} consists in saving the vector of polynomial roots found at the previous time-step in GPU memory, in +order to check the convergence of the roots after each iteration (line +7, Algorithm~\ref{alg1-cuda}). Then the new roots with the new iterations are computed using the EA method with a Gauss-Seidel iteration mode in order to use the latest updated roots (line 6). This improves the convergence. This kernel is, in practice, very long since it performs all the operations with complex numbers with -the normal mode of the EA method but also with the -logarithm-exponential one. Then the error is computed with a final -kernel (line 7). Finally when the EA method has converged, the roots -are transferred from the GPU to the CPU. - +the normal mode of the EA method as in Eq.~\ref{Eq:EA1} but also with the logarithm-exponential one as in Eq.(~\ref{Log_H1},~\ref{Log_H2}). The last kernel checks the convergence of the roots after each update of $Z^{k}$, according to formula Eq.~\ref{eq:Aberth-Conv-Cond} line (7). We used the functions of the CUBLAS Library (CUDA Basic Linear Algebra Subroutines) to implement this kernel. + +The algorithm terminates its computations when all the roots have +converged. +%} + + + %The code is organized as kernels which are parts of codes that are run +%on GPU devices. Algorithm~\ref{alg1-cuda} describes the CUDA +%implementation of the Ehrlich-Aberth on a GPU. This algorithms starts +%by initializing the polynomial and its derivative (line 1). The +%initialization of the roots is performed (line 2). Data are transferred +%%from the CPU to the GPU (after the allocation of the required memory on +%the GPU) (line 3). Then at each iteration, if the error is greater +%%than the threshold, the following operations are performed. The previous +%roots are saved using a kernel (line 5). Then the new roots with the +%new iterations are computed using the EA method with a Gauss-Seidel +%iteration mode in order to use the latest updated roots (line +%6). This improves the convergence. This kernel is, in practice, very +%long since it performs all the operations with complex numbers with +%the normal mode of the EA method but also with the +%logarithm-exponential one. Then the error is computed with a final +%kernel (line 7). Finally when the EA method has converged, the roots +%are transferred from the GPU to the CPU. \begin{algorithm}[htpb] \label{alg1-cuda} \LinesNumbered @@ -302,21 +330,29 @@ Copy $P$, $P'$ and $Z$ from CPU to GPU\; } Copy $Z$ from GPU to CPU\; \end{algorithm} +\ \\ +This figure shows the second kernel code +\begin{figure}[htbp] +\centering +\includegraphics[angle=+0,width=0.5\textwidth]{code} +\caption{The Kernel Update code} +\label{fig:00} +\end{figure} - -The development of this code is a rather long task, as the development -of corresponding kernels with CUDA is longer than on a CPU host. This -comes in particular from the fact that it is very difficult to debug -CUDA running threads like threads on a CPU host. In the following -section the GPU parallel implementation of the Ehrlich-Aberth method with -OpenMP and MPI is presented. - - - - +%We noticed that the code is executed by a large number of GPU threads organized as grid of to dimension (Number of block per grid (NbBlock), number of threads per block(Nbthread)), the Nbthread is fixed initially, the NbBlock is computed as fallow: +%$ NbBlocks= \frac{N+Nbthreads-1}{Nbthreads} where N: the number of root$ +%the such that each thread in grid is in charge of the computation of one root. +The development of this code is a rather long task due to the +development of all the kernels that compute the parts ported on the +GPU. This comes in particular from the fact that it is very difficult +to debug CUDA running threads like threads on a CPU host. In the +following section the GPU parallel implementation of the +Ehrlich-Aberth method with OpenMP and MPI is presented. + \section{The Ehrlich-Aberth algorithm on multiple GPUs} \label{sec4} +\KG{we remind that to manage the CUDA contexts of different GPUs, We investigate two parallel paradigms: OpenMP and MPI. In this section we present the both \textit{OpenMP-CUDA} approach and the \textit{MPI-CUDA} approach} used to implement the Ehrlich-Aberth algorithm on multiple GPUs. \subsection{An OpenMP-CUDA approach} Our OpenMP-CUDA implementation of EA algorithm is based on the hybrid OpenMP and CUDA programming model. This algorithm is presented in @@ -395,7 +431,7 @@ its own roots (line 9) with the EA method. The local error is computed the local roots are transferred from the GPU memory to the CPU memory (line 12) before being exchanged between all processors (line 13) in order to give to all processors the last version of the roots (with -the MPI\_AlltoAll routine). If the convergence is not satisfied, a +the $MPI\_AlltoAll$ routine). If the convergence is not satisfied, a new iteration is executed. \begin{algorithm}[htpb] @@ -439,12 +475,14 @@ We study two categories of polynomials: sparse polynomials and full polynomials. {\Large \forall \alpha_{i} \in \mathbb{C}, i\in \mathbb{N}; p(x)=\sum^{n}_{i=0} \alpha_{i}.x^{i}} \end{equation} -For our tests, 4 GPU cards Tesla Kepler K40 are used. In order to -evaluate both the GPU and Multi-GPU approaches, we performed a set of +\KG{For our tests, a CPU Intel(R) Xeon(R) CPU +X5650@2.40GHz and 4 GPUs cards Tesla Kepler K40,are used with CUDA version 7.5}. + + In order to evaluate both the GPU and Multi-GPU approaches, we performed a set of experiments on a single GPU and multiple GPUs using OpenMP or MPI with the EA algorithm, for both sparse and full polynomials of different -sizes. All experimental results obtained are performed with double -precision float data and the convergence threshold of the EA method is +degrees. All experimental results obtained are performed with double +precision floating-point data and the convergence threshold of the EA method is set to $10^{-7}$. The initialization values of the vector solution of the methods are given by the Guggenheimer method~\cite{Gugg86}. @@ -502,7 +540,7 @@ In the previous section we saw that both approaches are very efficient to reduce \label{fig:06} \end{figure} -In Figure~\ref{fig:05} there is one curve for CUDA-OpenMP and another one for CUDA-MPI. We can see that the results are quite similar between OpenMP and MPI for the polynomial degree of 200K. For the degree of 800K, the MPI version is a little bit slower than the OpenMP version but for the degree of 1,4 million, there is a slight advantage for the MPI version. In Figure~\ref{fig:06}, we can see that when it comes to full polynomials, both approaches are almost equivalent. +In Figure~\ref{fig:05} there is one curve for CUDA-OpenMP and another one for CUDA-MPI for each polynomial investigated. We can see that the results are quite similar between OpenMP and MPI for the polynomial degree of 200K. For the degree of 800K, the MPI version is a little bit slower than the OpenMP version but for the degree of 1,4 million, there is a slight advantage for the MPI version. In Figure~\ref{fig:06}, we can see that when it comes to full polynomials, both approaches are almost equivalent. \subsection{Solving sparse and full polynomials of the same degree on multiple GPUs} @@ -544,9 +582,9 @@ These experiments report the execution times of the EA method for sparse and ful \section{Conclusion} \label{sec6} -In this paper, we have presented parallel implementations of the Ehrlich-Aberth algorithm to solve full and sparse polynomials, on a single GPU with CUDA and on multiple GPUs using two parallel paradigms: shared memory with OpenMP and distributed memory with MPI. These architectures were addressed by a CUDA-OpenMP approach and CUDA-MPI approach, respectively. Experiments show that, using parallel programming model like (OpenMP or MPI), we can efficiently manage multiple graphics cards to solve the same problem and accelerate the parallel execution with 4 GPUs and solve a polynomial of degree up-to 5,000,000 four times faster than on a single GPU. +In this paper, we have presented parallel implementations of the Ehrlich-Aberth algorithm to solve full and sparse polynomials, on a single GPU with CUDA and on multiple GPUs using two parallel paradigms: shared memory with OpenMP and distributed memory with MPI. These architectures were addressed by a CUDA-OpenMP approach and CUDA-MPI approach, respectively. Experiments show that, using parallel programming model like OpenMP or MPI, we can efficiently manage multiple graphics cards to solve the same problem and accelerate the parallel execution with 4 GPUs and solve a polynomial of degree up-to 5,000,000 four times faster than on a single GPU. -Our next objective is to extend the model presented here to clusters of GPU nodes, with a three-level scheme: inter-node communications via MPI processes (distributed memory), management of multi-GPU nodes by OpenMP threads (shared memory). Actual platforms may probably also contain purely multi-core nodes without any GPU. This heterogeneous setting may lead to the integration of load balancing algorithms so as to allow an optimal use of hardware ressources. +Our next objective is to extend the model presented here to clusters of GPU nodes, with a three-level scheme: inter-node communications via MPI processes (distributed memory), management of multi-GPU nodes by OpenMP threads (shared memory). Actual platforms may probably also contain purely multi-core nodes without any GPU. This heterogeneous setting may lead to the integration of load balancing algorithms so as to allow an optimal use of hardware resources. \section*{Acknowledgment}