From: Kahina Date: Fri, 29 Apr 2016 07:21:47 +0000 (+0200) Subject: Quelques modifications dans la partie implemention X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/kahina_paper2.git/commitdiff_plain/9412dbfad35f07dcf24d6ddf498533bd3d959afe Quelques modifications dans la partie implemention --- diff --git a/paper.tex b/paper.tex index 8cb7ff3..b453915 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]{% @@ -275,24 +275,40 @@ where \verb=DBL_MAX= stands for the maximum representable \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 +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 @@ -310,19 +326,26 @@ 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.4\textwidth]{code1} +\caption{The Kernel Update code} +\label{fig:00} +\end{figure} - +%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 +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} \subsection{An OpenMP-CUDA approach} @@ -447,12 +470,13 @@ 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 +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 degrees. All experimental results obtained are performed with double -precision float data and the convergence threshold of the EA method is +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}.