From 66cf7d3dc0285512215d112ffa0688b357dff7c6 Mon Sep 17 00:00:00 2001 From: Kahina Guidouche Date: Sat, 12 Sep 2015 10:38:50 +0200 Subject: [PATCH] this is the commit of the parallel Aberth algorithm --- Root.tex | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 121 insertions(+), 6 deletions(-) diff --git a/Root.tex b/Root.tex index 5134838..c845ba8 100644 --- a/Root.tex +++ b/Root.tex @@ -3,13 +3,15 @@ \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} +%%\usepackage{algorithm2e} +\usepackage[ruled,vlined]{algorithm2e} +%%\usepackage{algo} \author{ghidouche} \title{Paper1_kahina} \begin{document} \section{Root finding problem} -we consider a polynomial of degree \textit{n} having coefficients -in the complex \textit{C} and zeros $\alpha -_{i},\textit{i=1,...,n}$. \\ +We consider a polynomial of degree \textit{n} having coefficients +in the complex \textit{C} and zeros $\alpha_{i},\textit{i=1,...,n}$. \\ \begin{center} \begin{equation} {\Large p(x)=\sum{a_{i}x^{i}}=a_{n}\prod(x-\alpha_{i}),a_{0} a_{n}\neq 0} @@ -353,9 +355,122 @@ texture space, which reside in external DRAM, and are accessed via read-only caches \subsection{A parallel implementation of the Aberth's method } -\subsection{A CUDA implementation of the Aberth's method } -\subsection{A GPU implementation of the Aberth's method } -\subsubsection{the step to parallelize} +%%\subsection{A CUDA implementation of the Aberth's method } +%%\subsection{A GPU implementation of the Aberth's method } + + + +\subsubsection{A sequential Aberth algorithm} +The means steps of Aberth's method can expressed as an algorithm +like: + +\begin{algorithm}[H] +\LinesNumbered +\caption{Algorithm to find root polynomial with Aberth method} + +\KwIn{$Z^{0}$(Initial root's vector),$\varepsilon$ (error +tolerance threshold),P(Polynomial to solve)} + +\KwOut {Z(The solution root's vector)} + +\BlankLine + +Initialization of the parameter of the polynomial to solve\; +Initialization of the solution vector $Z^{0}$\; + +\While {$\Delta z_{max}\succ \epsilon$}{ + Let $\Delta z_{max}=0$\; +\For{$j \gets 0 $ \KwTo $n$}{ +$ZPrec\left[j\right]=Z\left[j\right]$\; +$Z\left[j\right]=H\left(j,Z\right)$\; +} + +\For{$i \gets 0 $ \KwTo $n-1$}{ +$c=\frac{\left|Z\left[i\right]-ZPrec\left[i\right]\right|}{Z\left[i\right]}$\; +\If{$c\succ\Delta z_{max}$ }{ +$\Delta z_{max}$=c\;} +} +} +\end{algorithm} +~\\ +~\\ +In this sequential algorithm one thread CPU execute all steps, let see the step 3 the execution of the iterative function , 2 instructions are needed, the first instruction \textit{save} the solution vector for the previous iteration, the second instruction \textit{update} or compute a new values of the roots. +We have two manner to execute the iterative function, taking a Jacobi iteration who need all the previous value $z^{(k)}_{i}$ to compute the new value $z^{(k+1)}_{i}$we have: + +\begin{equation} +H(i,z^{k+1})=\frac{p(z^{(k)}_{i})}{p'(z^{(k)}_{i})-p(z^{(k)}_{i})\sum^{n}_{j=1 j\neq i}\frac{1}{z^{(k)}_{i}-z^{(k)}_{j}}}, i=1,...,n. +\end{equation} + +Or with the Gauss-seidel iteration, we have: +\begin{equation} +H(i,z^{k+1})=\frac{p(z^{(k)}_{i})}{p'(z^{(k)}_{i})-p(z^{(k)}_{i})\sum^{i-1}_{j=1}\frac{1}{z^{(k)}_{i}-z^{(k)}_{j}}+\sum^{n}_{j=i+1}\frac{1}{z^{(k)}_{i}-z^{(k)}_{j}}}, i=1,...,n. +\end{equation} + +In formula(16) the iteration function use the $z^{k+1}_{i}$ computed in the current iteration to compute the rest of the roots, which take him to converge more quickly compare to the jacobi iteration (it's well now that the Gauss-seidel iteration converge more quickly because they used the most fresh computed root, so we used Gauss-seidel iteration.) + +The steps 4 of the Aberth's method compute the convergence of the roots, using(9) formula. +Both steps 3 and 4 use 1 thread to compute N roots on CPU, which is faster and hard, it make the algorithm faster and hard for the large polynomial's roots finding. + +\paragraph{The execution time} +Let $T_{i}(N)$: the time to compute one new root's value of the step 3,$T_{i}$ depend on the polynomial's degrees N, when N increase $T_{i}$ increase to.We need $N.T_{i}(N)$ to compute all the new root's value in one iteration on the step 3. + +Let $T_{j}$: the time to compute one root's convergence value of the step 4, we need $N.T_{j}$ to compute all the root's convergence value in one iteration on the step 4. + +The execution time for both steps 3 and 4 can see like: +\begin{equation} +T_{exe}=N(T_{i}(N)+T_{j})+O(n). +\end{equation} +Let Nbr\_iter the number of iteration necessary to compute all the roots,so the total execution time $Total\_time_{exe}$ can give like: + +\begin{equation} +Total\_time_{exe}=\left[N\left(T_{i}(N)+T_{j}\right)+O(n)\right].Nbr\_iter. +\end{equation} +The execution time increase with the increasing of the polynomial's root, which take necessary to parallilize this step to reduce the execution time. In the following paper you explain how we parrallelize this step using GPU architecture with CUDA platform. + +\subsubsection{Parralelize the steps on GPU } +On the CPU Aberth algorithm both steps 3 and 4 contain the loop \verb=for= , it use one thread to execute all the instruction in the loop N times.Here we explain how the GPU architecture can compute this loop and reduce the execution time. +The GPU architecture affect the execution of this loop to a groups of parallel threads organized as a grid of blocks each block contain a number of threads. All threads within a block are executed concurrently in parallel. the instruction are executed as a kernel. + +Let nbr\_thread be the number of threads executed in parallel, so you can easily transform the (18)formula like this: + +\begin{equation} +Total\_time_{exe}=\left[\frac{N}{nbr\_thread}\left(T_{i}(N)+T_{j}\right)+O(n)\right].Nbr\_iter. +\end{equation} + +In theory, the $Total\_time_{exe}$ on GPU is speed up nbr\_thread times as a $Total\_time_{exe}$ on CPU. We show more details in the experiment part. +~\\ +~\\ +In CUDA platform, All the instruction of the loop \verb=for= are executed by the GPU as a kernel form. A kernel is a procedure written in CUDA and defined by a heading \verb=__global__=, which means that it is to be executed by the GPU.the following algorithm see the kernels created for the step 3 and 4 of the Aberth algorithm: + +\begin{algorithm}[H] +\LinesNumbered +\caption{Algorithm to find root polynomial with Aberth method} + +\KwIn{$Z^{0}$(Initial root's vector),$\varepsilon$ (error +tolerance threshold),P(Polynomial to solve)} + +\KwOut {Z(The solution root's vector)} + +\BlankLine + +Initialization of the parameter of the polynomial to solve\; +Initialization of the solution vector $Z^{0}$\; + +\While {$\Delta z_{max}\succ \epsilon$}{ + Let $\Delta z_{max}=0$\; +$\prec DimGrid,DimBloc\succ kernel\_save(d\_Z^{k-1});$ +$\prec DimGrid,DimBloc \succ kernel\_update(d\_z^{k});$ + +$\prec DimGrid,DimBloc\succ kernel\_testConverge (d_?z_{max},d_Z^{k},d_Z^{k-1});$ +} +\end{algorithm} +~\\ + + + +here we need to create two kernel for the step 3 \textit{Kernel\_save} is used to save vector $Z^{K-1}$ and \textit{kernel\_update} is used to update the $Z^{k}$ vector. In phase 4 a kernel is created to test the convergence of the method + + \subsubsection{the kernel corresponding } \subsubsection{Comparison between sequential algorithm and GPU algorithm } \bibliographystyle{plain} -- 2.39.5