From: couturie Date: Fri, 26 Jul 2013 14:02:53 +0000 (+0200) Subject: new X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/book_gpu.git/commitdiff_plain/a79be71669f1b6fa38df1cc606be8e2b39fc4428?ds=sidebyside new --- diff --git a/BookGPU/BookGPU.tex b/BookGPU/BookGPU.tex index 90baace..d96b4e9 100755 --- a/BookGPU/BookGPU.tex +++ b/BookGPU/BookGPU.tex @@ -173,14 +173,14 @@ \author{Raphaël Couturier} \maketitle - +\cleardoublepage \frontmatter %\include{frontmatter/Foreword} -\include{frontmatter/preface} \tableofcontents \listoffigures \listoftables +\include{frontmatter/preface} \mainmatter diff --git a/BookGPU/Chapters/chapter1/ch1.tex b/BookGPU/Chapters/chapter1/ch1.tex index c69a60e..fc891b5 100755 --- a/BookGPU/Chapters/chapter1/ch1.tex +++ b/BookGPU/Chapters/chapter1/ch1.tex @@ -5,7 +5,7 @@ \label{chapter1} \section{Introduction}\label{ch1:intro} - +``test" "test" ``test'' This chapter introduces the Graphics Processing Unit (GPU) architecture and all the concepts needed to understand how GPUs work and can be used to speed up the execution of some algorithms. First of all this chapter gives a brief history of @@ -113,7 +113,7 @@ Threads are used to benefit from the large number of cores of a GPU. These threads are different from traditional threads for a CPU. In Chapter~\ref{chapter2}, some examples of GPU programming will explain the details of the GPU threads. Threads are gathered into blocks of 32 -threads, called warps. These warps are important when designing an algorithm +threads, called ``warps''. These warps are important when designing an algorithm for GPU. diff --git a/BookGPU/Chapters/chapter14/biblio14.bib b/BookGPU/Chapters/chapter14/biblio14.bib index ec060bc..8ad0aaa 100644 --- a/BookGPU/Chapters/chapter14/biblio14.bib +++ b/BookGPU/Chapters/chapter14/biblio14.bib @@ -1,14 +1,14 @@ @Book{succi-book, author = {Succi, S.}, - title = {The lattice Boltzmann equation and beyond}, + title = {The lattice {B}oltzmann {E}quation and {B}eyond}, publisher = {Oxford University Press, Oxford}, year = {2001}, } @Article{desplat, author = {Desplat, J.-C. and Pagonabarraga, I. and Bladon P.}, - title = {LUDWIG: A parallel lattice-Boltzmann code for complex fluids}, + title = {LUDWIG: A parallel lattice-{B}oltzmann code for complex fluids}, journal = {Comput. Phys. Comms.}, year = {2001}, volume = {134}, @@ -17,7 +17,7 @@ @Article{aidun2010, author = { Aidun, C. K. and Clausen, J. R.}, - title = {Lattice Boltzmann method for complex flows}, + title = {Lattice {B}oltzmann method for complex flows}, journal = {Ann. Rev. Fluid Mech.}, year = {2010}, volume = {42}, @@ -27,7 +27,7 @@ @Article{stratford2008, author = {Stratford, K. and Pagonabarraga, I.}, - title = {Parallel domain decomposition for lattice Boltzmann with moving particles}, + title = {Parallel domain decomposition for lattice {B}oltzmann with moving particles}, journal = {Comput. Math. with Applications}, year = {2008}, volume = {55}, @@ -36,7 +36,7 @@ @Article{wei2004, author = {Wei, X. and Li, W. and M\"uller, K. and Kaufman, A. E.}, - title = {The lattice Boltzmann method for simulating gaseous phenomena}, + title = {The lattice {B}oltzmann method for simulating gaseous phenomena}, journal = {IEEE Transactions on Visualization and Computer Graphics}, year = {2004}, volume = {10}, @@ -45,7 +45,7 @@ @Article{zhu2006, author = {Zhu, H. and Liu, X. and Liu, Y. and Wu, E.}, - title = {Simulation of miscible binary mixtures based on lattice Boltzmann method}, + title = {Simulation of miscible binary mixtures based on lattice {B}oltzmann method}, journal = {Comp. Anim. Virtual Worlds}, year = {2006}, volume = {17}, @@ -54,7 +54,7 @@ @Article{zhao2007, author = {Zhao, Y.}, - title = {Lattice Boltzmann based PDE solver on the GPU}, + title = {Lattice {B}oltzmann based {PDE} solver on the {GPU}}, journal = {Visual Comput.}, year = {2008}, volume = {24}, @@ -63,7 +63,7 @@ @Article{toelke2010, author = {T\"olke, J.}, - title = {Implementation of a lattice Boltzmann kernel using the compute unified device architecture developed by nVIDIA}, + title = {Implementation of a lattice {B}oltzmann kernel using the compute unified device architecture developed by {NVIDIA}}, journal = {Comput. Visual Sci.}, year = {2010}, volume = {13}, @@ -73,7 +73,7 @@ @InProceedings{fan2004, author = { Fan, Z. and Qiu, F. and Kaufman, A. and Yoakum-Stover, S.}, - title = {GPU cluster for high performance computing}, + title = {{GPU} cluster for high performance computing}, booktitle = {Proceedings of ACM/IEEE Supercomputing Conference}, pages = {47--59}, year = {2004}, @@ -84,7 +84,7 @@ @Article{myre2011, author = { Myre, J. and Walsh, S. D. C. and Lilja, D. and Saar, M. O.}, - title = {Performance analysis of single-phase, multiphase, and multicomponent lattice Boltzmann fluid flow simulations on GPU clusters}, + title = {Performance analysis of single-phase, multiphase, and multicomponent lattice {B}oltzmann fluid flow simulations on {GPU} clusters}, journal = {Concurrency Computat.: Pract. Exper.}, year = {2011}, volume = {23}, @@ -94,7 +94,7 @@ @Article{obrecht2011, author = { Obrecht, C. and Kuznik, F. and Tourancheau, B. and Roux, J.-J.}, - title = {Multi-GPU implementation of the lattice Boltzmann method}, + title = {Multi-{GPU} implementation of the lattice {B}oltzmann method}, journal = {Comput. Math. with Applications}, year = {2013}, volume = {65}, @@ -103,7 +103,7 @@ @Article{bernaschi2010, author = {Bernaschi, M. and Fatica, M. and Melchionna, S. and Succi, S. and Kaxiras, E.}, - title = {A flexible high-performance lattice Boltzmann GPU code for the + title = {A flexible high-performance lattice {B}oltzmann {GPU} code for the simulations of fluid flow in complex geometries}, journal = {Concurrency Computat.: Pract. Exper.}, year = {2010}, @@ -113,8 +113,8 @@ simulations of fluid flow in complex geometries}, @Article{xian2011, author = { Xian, W. and Takayuki, A.}, - title = {Multi-GPU performance of incompressible flow computation by -lattice Boltzmann method on GPU cluster}, + title = {Multi-{GPU} performance of incompressible flow computation by +lattice {B}oltzmann method on {GPU} cluster}, journal = {Parallel Comput.}, year = {2011}, volume = {37}, @@ -125,7 +125,7 @@ lattice Boltzmann method on GPU cluster}, @Article{feichtinger2011, author = {Feichtinger, C. and Habich, J. and K\"ostler, H. and Hager, G. and R\"ude, U. and Wellein, G.}, - title = {A flexible patch-based lattice Boltzmann parallelization approach for heterogeneous GPU-CPU clusters}, + title = {A flexible patch-based lattice {B}oltzmann parallelization approach for heterogeneous {GPU-CPU} clusters}, journal = {Parallel Computing}, year = {2011}, volume = {37}, @@ -134,7 +134,7 @@ lattice Boltzmann method on GPU cluster}, @Article{wellein2006, author = {Wellein, G. and Zeiser, T. and Hager, G. and Donath, S.}, - title = {On the single processor performance of simple lattice Boltzmann kernels}, + title = {On the single processor performance of simple lattice {B}oltzmann kernels}, journal = {Computers and Fluids}, year = {2006}, volume = {35}, @@ -143,7 +143,7 @@ lattice Boltzmann method on GPU cluster}, @Article{pohl2003, author = { Pohl, T. and Kowarschik, M. and Wilke, J. and Igelberger, K. and R\"ude, U.}, - title = {Optimization and profiling of the cache performance of parallel lattice Boltzmann code}, + title = {Optimization and profiling of the cache performance of parallel lattice {B}oltzmann code}, journal = {Parallel Process Lett.}, year = {2003}, volume = {13}, @@ -152,7 +152,7 @@ lattice Boltzmann method on GPU cluster}, @Article{mattila2007, author = {Mattila, K. and Hyv\"aluoma, J. and Rossi, T. and Aspn\"as M. and Westerholm, J.}, - title = {An efficient swap algorithm for the lattice Boltzmann method}, + title = {An efficient swap algorithm for the lattice {B}oltzmann method}, journal = {Comput. Phys. Comms.}, year = {2007}, volume = {176}, @@ -163,7 +163,7 @@ lattice Boltzmann method on GPU cluster}, @Article{wittmann2012, author = {Wittmann, M. and Zeiser, T. and Hager, G. and Wellein, G.}, - title = {Comparison of different propagation steps for lattice Boltzmann methods}, + title = {Comparison of different propagation steps for lattice {B}oltzmann methods}, journal = {Comput. Math with Appl.}, year = {2012}, note = {doi:10.1016/j.camwa.2012.05.002}, @@ -171,7 +171,7 @@ lattice Boltzmann method on GPU cluster}, @Article{walshsaar2012, author = {Walsh, S. D. C. and Saar, M. O.}, - title = {Developing extensible lattice Boltzmann simulators for general-purpose graphics-processing units}, + title = {Developing extensible lattice {B}oltzmann simulators for general-purpose graphics-processing units}, journal = {Comm. Comput. Phys.}, year = {2013}, volume = {13}, @@ -181,7 +181,7 @@ lattice Boltzmann method on GPU cluster}, @InProceedings{williams2011, author = {Williams, S. and Oliker, L. and Carter, J. and Shalf, J.}, - title = {Extracting ultra-scale lattice Boltzmann performance via + title = {Extracting ultra-scale lattice {B}oltzmann performance via hierarchical and distributed auto-tuning}, booktitle = {International Conference for High Performance Computing, Networking, Storage and Analysis (SC) }, pages = {1--12}, @@ -194,7 +194,7 @@ hierarchical and distributed auto-tuning}, @Article{ch14:stratford-jsp2005, author = {Stratford, K. and Adhikari, R. and Pagonabarraga, I. and Desplat, J.-C.}, - title = {Lattice Boltzmann for Binary Fluids with Suspended Colloids}, + title = {Lattice {B}oltzmann for Binary Fluids with Suspended Colloids}, journal = {J. Stat. Phys.}, year = {2005}, volume = {121}, @@ -204,7 +204,7 @@ hierarchical and distributed auto-tuning}, @Article{ladd1994, author = {Ladd, A. J. C.}, - title = {Numerical simulations of particle suspensions via a discretized Boltzmann equation. Part 1. Theoretical foundation and Part II. Numerical results}, + title = {Numerical simulations of particle suspensions via a discretized {B}oltzmann equation. {P}art 1. Theoretical foundation and {P}art II. {N}umerical results}, journal = {J. Fluid Mech.}, year = {1994}, volume = {271}, @@ -215,7 +215,7 @@ hierarchical and distributed auto-tuning}, @Article{nguyen2002, author = {Nguyen, N.-Q. and Ladd, A. J. C.}, - title = {Lubrication corrections for lattice Boltzmann simulations of particle suspensions}, + title = {Lubrication corrections for lattice {B}oltzmann simulations of particle suspensions}, journal = {Phys. Rev. E}, year = {2002}, volume = {66}, @@ -244,7 +244,7 @@ hierarchical and distributed auto-tuning}, @Article{ch14:immersed-lb, author = {Feng, Z.-G. and Michaelides, E. E}, - title = {The immersed boundary-lattice Boltzmann method for solving + title = {The immersed boundary-lattice {B}oltzmann method for solving fluid-particles interaction problem}, journal = {J. Comp. Phys.}, year = {2004}, diff --git a/BookGPU/Chapters/chapter14/ch14.tex b/BookGPU/Chapters/chapter14/ch14.tex index 1acb080..2ce9331 100755 --- a/BookGPU/Chapters/chapter14/ch14.tex +++ b/BookGPU/Chapters/chapter14/ch14.tex @@ -13,14 +13,14 @@ The lattice Boltzmann (LB) method \index{Lattice Boltzmann method} (for an overv dynamics problems. It provides a way to solve the incompressible isothermal Navier-Stokes equations and has the attractive features of being both explicit in time and local in space. This makes the LB -method wellsuited to parallel computation. Many efficient parallel +method well suited to parallel computation. Many efficient parallel implementations of the LB method have been undertaken, typically using a combination of distributed domain decomposition and the Message Passing Interface (MPI). However, the potential performance benefits offered by GPUs has motivated a new ``mixed-mode'' approach to address very large problems. Here, fine-grained parallelism is implemented on the GPU, while MPI is reserved for -largerscale parallelism. This mixed mode is of increasing interest +larger scale parallelism. This mixed mode is of increasing interest to application programmers at a time when many supercomputing services are moving toward clusters of GPU accelerated nodes. The design questions which @@ -156,9 +156,9 @@ site, may be thought of as follows. A matrix-vector multiplication ${\cal M}_{ij}f_j$ is used to transform the distributions into the hydrodynamic quantities, where ${\cal M}_{ij}$ is a constant 19x19 matrix related to the choice of -$\mathbf{c}_i$. The nonconserved hydrodynamic quantities are then +$\mathbf{c}_i$. The non-conserved hydrodynamic quantities are then relaxed toward their (known) equilibrium values and are transformed -back to new postcollision distributions via the inverse transformation +back to new post-collision distributions via the inverse transformation ${\cal M}^{-1}_{ij}$. This gives rise to the need for a minimum of $2\times 19^2$ floating point multiplications per lattice site. (Additional operations are required to implement, for example, the force $\mathbf{f}(\mathbf{r})$.) @@ -193,12 +193,13 @@ Listing~\ref{ch14:listing1}: the fact that consecutive loads are from consecutive memory addresses allows the prefetcher to engage fully. (The temporary scalar \texttt{a\_tmp} allows caching of the intermediate accumulated value in the innermost loop.) A variety of -standard sequential optimisations are relevant for the collision stage +standard sequential optimizations are relevant for the collision stage (loop unrolling, inclusion of SIMD operations, and so on \cite{wellein2006}). For example, the collision stage in \textit{Ludwig} includes explicit SIMD code, which is useful if the -compiler on a given platform cannot identify it. The propagation -stage is separate and is organised as a ``pull'' (again, various +compiler on a given platform cannot identify the appropriate vectorization. +The propagation +stage is separate and is organized as a ``pull'' (again, various optimizations have been considered, e.g., \cite{pohl2003,mattila2007,wittmann2012}). No further optimization is done here beyond ensuring that the ordering of the discrete velocities @@ -206,7 +207,7 @@ allows memory access to be as efficient as possible. While these optimizations are important, it should be remembered that for some complex fluid problems, the hydrodynamics embodied in the LB calculation is a relatively small part of the total computational cost -(at the 10\%level in some cases). This means optimization effort may +(at the 10\% level in some cases). This means optimization effort may be better concentrated elsewhere. @@ -249,7 +250,7 @@ involving relevant data can take place, and so on. We note that only For the D3Q19 model, this reduces the volume of data traffic from 19 to 5 of the $f_i(\mathbf{r};t)$ per lattice site at each edge. In the CPU version, the necessary transfers are implemented in place using -a vector of appropriately strided MPI datatypes for each direction. +a vector of MPI datatypes with appropriate stride for each direction. \section{Single GPU implementation}\label{ch14:sec:singlegpu} @@ -301,7 +302,7 @@ of CUDA threads. As the matrix ${\cal M}_{ij}$ is constant, it is assigned to the fast {\it constant} on-chip device memory. For the propagation stage, the GPU implementation adds a second time -level of distribution values. The datadependencies inherent in the +level of distribution values. The data dependencies inherent in the propagation mean that the in-place propagation of the CPU version cannot be parallelized effectively without the additional time level. As both time levels may remain resident on the GPU, this is not a @@ -350,7 +351,8 @@ complication is that halo transfers between GPUs must be staged through the host (in the future, direct GPU-to-GPU data transfers via MPI may be possible, obviating the need for these steps). This means host MPI sends must be preceded by appropriate device-to-host -transfers and host MPI receives must be followed by corresponding host-to-device transfers. +transfers and host MPI receives must be followed by corresponding +host-to-device transfers. %To execute on multiple GPUs in parallel we decompose the problem using %the existing high-level parallelisaton framework: each MPI task acts @@ -393,7 +395,7 @@ retrieved by the host, these can be exchanged using MPI between hosts at the same time as kernels for packing and retrieving of data for the second coordinate direction are executed. This -overlapping must respect the synchronisation required to ensure +overlapping must respect the synchronization required to ensure that data values at the corners of the subdomain are transferred correctly. We use a separate CUDA stream for each coordinate direction: @@ -503,7 +505,7 @@ scaling for the larger systems. \begin{figure}[t] \centering %\includegraphics[width=10cm]{Chapters/chapter14/figures/bbl} -\includegraphics[width=10cm]{Chapters/chapter14/figures/colloid_new} +\includegraphics[width=10cm]{Chapters/chapter14/figures/colloid_new_gray} \caption[A two-dimensional schematic picture of spherical particles on the lattice.]{ A two-dimensional schematic picture of spherical particles on the lattice. Left: a particle is allowed @@ -541,11 +543,11 @@ to efficient GPU implementation of an LB code such as \textit{Ludwig}. In this section, we give a brief overview of the essential features of the CPU implementation, and how the considerations raised in the previous sections---maximizing parallelism and minimising both -host-to-device and GPU to GPU data movement---shape the design decisions +host-to-device and GPU-to-GPU data movement---shape the design decisions for a GPU implementation. We restrict our discussion to a simple fluid in this section; additional solid-fluid boundary conditions (e.g., wetting at a fluid-fluid-solid contact line) usually arise elsewhere -in the calculation broadly independent of the hydrodynamic boundary +in the calculation and are broadly independent of the hydrodynamic boundary conditions which are described in what follows. Moving solid particles (here, spheres) are defined by a center position @@ -556,7 +558,7 @@ where a discrete velocity propagation $\mathbf{c}_i \Delta t$ would intercept or cut the spherical shell (see Fig.~\ref{ch14:fig:bbl}). Hydrodynamic boundary conditions are then implemented via the standard approach of bounce-back on links \cite{ladd1994, nguyen2002}, where the -relevant postcollision distribution values are reversed at the +relevant post-collision distribution values are reversed at the propagation stage with an appropriate correction to allow for the solid body motion. The exchange of momentum at each link must then be accumulated around the entire particle surface to provide the net @@ -565,8 +567,8 @@ and torque on the sphere. The particle motion can then be updated in a molecular dynamics-like step. For the CPU implementation, a number of additional MPI communications -are required: (1) to exchange the center position, radius, etc of each -particle as it moves and (2), to allow the accumulation of the force +are required: (1) to exchange the center position, radius, etc.\ of each +particle as it moves and (2) to allow the accumulation of the force and torque for each particle (the links of which may be distributed between up to 8 MPI tasks in three dimensions). Appropriate marshaling of these data can provide an effective parallelization for relatively @@ -579,7 +581,7 @@ With these features in mind, we can identify a number of competing concerns which are relevant to a GPU implementation: \begin{enumerate} \item -Minimisation of host-device data transfer would argue for moving the +Minimization of host-device data transfer would argue for moving the entire particle code to the GPU. However, the code in question involves largely conditional logic (e.g., identifying cut surface links) and irregular memory accesses (e.g., access to distribution elements around @@ -603,10 +605,11 @@ particle information. We have implemented the second option as follows. For each subdomain, -a list of boundary-cutting links is assembled on the CPU which includes -the identity of the relevant element of the distribution. This list, +a list of boundary-cutting links is assembled on the CPU; the list includes +the identity of the relevant element of the distribution in each case. +This list, together with the particle information required to compute the correct -bounce-back term, are transferred to the GPU. The updates to the relevant +bounce-back term, is transferred to the GPU. The updates to the relevant elements of the distribution can then take place on the GPU. The corresponding information to compute the update of the particle dynamics is returned @@ -741,7 +744,7 @@ we have tried to maintain the modular structure of the CPU where possible. For each data structure, such as the distribution, a separate analogue is maintained in both the CPU and GPU memory spaces. However, the GPU copy does not include the complete CPU structure: in -particular, nonintrinsic datatypes such as MPI datatypes are not +particular, non-intrinsic datatypes such as MPI datatypes are not required on the GPU. Functions to marshal data between CPU and GPU are provided for each data structure, abstracting the underlying CUDA implementation. (This reasonably lightweight abstraction layer @@ -934,7 +937,7 @@ complex fluid problems. % use section* for acknowledgement -\section*{Acknowledgments} +\section{Acknowledgments} AG was supported by the CRESTA project, which has received funding from the European Community's Seventh Framework Programme (ICT-2011.9.13) under Grant Agreement no. 287703. KS was supported diff --git a/BookGPU/Chapters/chapter14/figures/colloid_new.pdf b/BookGPU/Chapters/chapter14/figures/colloid_new.pdf deleted file mode 100644 index 55e8022..0000000 Binary files a/BookGPU/Chapters/chapter14/figures/colloid_new.pdf and /dev/null differ diff --git a/BookGPU/Chapters/chapter14/figures/colloid_old.pdf b/BookGPU/Chapters/chapter14/figures/colloid_old.pdf deleted file mode 100644 index b884a42..0000000 Binary files a/BookGPU/Chapters/chapter14/figures/colloid_old.pdf and /dev/null differ