From: Kahina Guidouche Date: Wed, 16 Sep 2015 06:54:28 +0000 (+0200) Subject: MAJ X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/kahina_paper1.git/commitdiff_plain/22285cf247eb5754cde0cd2568dfd8c0f8ee3d4d?ds=inline;hp=-c MAJ --- 22285cf247eb5754cde0cd2568dfd8c0f8ee3d4d diff --git a/Root.tex b/Root.tex index c845ba8..b4edff1 100644 --- a/Root.tex +++ b/Root.tex @@ -425,9 +425,9 @@ Let Nbr\_iter the number of iteration necessary to compute all the roots,so the \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. +The execution time increase with the increasing of the polynomial's root, which take necessary to parallelize 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 } +\subsubsection{Parallelize 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. @@ -440,7 +440,7 @@ Total\_time_{exe}=\left[\frac{N}{nbr\_thread}\left(T_{i}(N)+T_{j}\right)+O(n)\ri 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: +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 Aberth algorithm on GPU: \begin{algorithm}[H] \LinesNumbered @@ -455,20 +455,43 @@ tolerance threshold),P(Polynomial to solve)} Initialization of the parameter of the polynomial to solve\; Initialization of the solution vector $Z^{0}$\; +Allocate and fill the data in the global memory GPU\; \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});$ +$ kernel\_save(d\_Z^{k-1})$\; +$ kernel\_update(d\_z^{k})$\; +$kernel\_testConverge (d_?z_{max},d_Z^{k},d_Z^{k-1})$\; } \end{algorithm} ~\\ +After the initialization step, all data of the root finding problem to be solved 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=(do ... while(...))= are executed as kernels by the GPU. The first kernel \textit{save} in line( 6, Algorithm 2) consist to save the vector of polynomial's root found at the previous time step on GPU memory, in order to test the convergence of the root at each iteration in line (8, Algorithme2). + +The second kernel executes the iterative function and update Z(k),as formula (), we notice that the kernel update are called in two forms, separated with the value of R which determines the radius beyond which we apply the logarithm formula like this: + +\begin{algorithm}[H] +\LinesNumbered +\caption{A global Algorithm for the iterative function} + +\eIf{$(\left|Z^{(k)}\right|<= R)$}{ +$kernel\_update(d\_z^{k})$\;} +{ +$kernel\_update\_Log(d\_z^{k})$\; +} +\end{algorithm} + +The first form execute the formula(8) if all the module's $( |Z(k)|<= R)$, else the kernel execute the formulas(13,14).the radius R was computed like: + +$$R = \exp( \log(DBL\_MAX) / (2*(double).N) )$$ + +where N the degree of the polynomial,DBL\_MAX is the maximum value of a double. +The last kernel verify the convergence of the root after each update of $Z^{(k)}$, as formula(), we used the function of the CUBLAS Library (CUDA Basic Linear Algebra Subroutines) to implement this kernel. + +The kernels terminates its computations when all the root are converged. Finally, the solution of the root finding problem is copied back from the GPU global memory to the CPU memory. We use the communication functions of CUDA for the memory allocations in the GPU \verb=(cudaMalloc())= and the data transfers from the CPU memory to the GPU memory \verb=(cudaMemcpyHostToDevice)= +or from the GPU memory to the CPU memory \verb=(cudaMemcpyDeviceToHost))=. -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 }