A Multi‐GPU
Implementation
of
aParallel
Solver for
Incompressible
Navier‐Stokes
Equations
Discretized
by
Stabilized Finite Element Formulations
HUYNH
Quang Huy Viet,
SUITO
HiroshiGraduate
School of
Environmental and LifeScience,
Okayama
University
E‐‐mail: hqhviet\emptysetokayama−u.ac.jp, suito@okayama‐u.ac.jp
1
Introduction
For
solving partial
differentialequationsproblems
inComputational
FluidDynamics
(CFD),
finite ele‐ment methodsareconventional numerical methods thatare
particularly
used because of theiraccuracy.In
solving
the Navier‐Stokes(NS)
equationsusing
finite element methods for simulation ofincompress‐ible
flows,
some instabilitiesarise fromthepresenceof advectionterms or thehigh Reynolds
number.Hughes
andTezduyar
etal.[1,
2, 3,4]
proposed
stabilized finite element formulations forincompressible
flows. Stabilizationin
solving
Navier‐Stokesequations isachievedby adding
twostabilizationterms to the Galerkin formulations of the Navier‐Stokes equations. The first stabilizationtermis the streamlineupwind
/\mathrm{P}\mathrm{e}\mathrm{t}\mathrm{r}\mathrm{o}\mathrm{v}
‐Galerkin(SUPG)
term. The second stabilizationtermisthepressurestabilizing/Petrov‐
Galerkin
(PSPG)
term. This stabilizedfiniteelement method has been showntobeveryeffective for the simulationofincompressibleflows.Inengineering
applications,
whencomputational
conditions becomestiff,
NS solversmight
not con‐verge tosolutions withinanallowed time limitation. Thereforeit is necessaryto
develop
fast andaccurate NS solversusing
parallel processing techniques. Traditionally, parallel
NS solvers aredeveloped
usingsupercomputersorPC clusters with
parallel programming platforms
suchasOpenMP
andMPI.Recently,
because modern
graphics processing
units(GPUs)
havemany processorsorcores, GPUcomputing
hasbeen
recognized
as apowerful platform
to achievehigh performance
insimulation andmodeling
intheCFD. GPU
computing
istheuseof GPUsin associationwith theuseof CPUstospeed
upcomputations.
A
desktop
machineor aworkstation withapowerful
GPU inside canachieveextremely high
levels ofperformance
forcomputationand simulation. Thenecessityexiststodevelop parallel
NS solversonGPUsforvarious
engineering applications.
In arecentreport
[5],
webriefly
described ourimplementation
of asolver based onthe GPBi‐CGalgorithm
for 3\mathrm{D}unsteady
Navier‐Stokes equations discretizedby
the SUPG/
PSPG stabilized finiteelementformulationusinga
single
GPU.In this paper, wereporta newmulti‐GPUimplementation
of the solver and showsperformance
results.2
Stabilized
Finite Element Formulations
2.1
Governing Equations
We consider the
following
dimensionless form of the Navier‐Stokesequationsinaspatial
domain$\Omega$\subset \mathrm{R}^{3}
:\displaystyle \frac{\partial u_{i}}{\partial t}+u_{j}\frac{\partial u_{i}}{\partial x_{j}}=-\frac{\partial p}{\partial x_{i}}+\frac{1}{Re}\frac{\partial}{\partial x_{j}}(\frac{\partial u_{i}}{\partial x_{j}}+\frac{\partial u_{j}}{\partial x_{i}})
in $\Omega$,(1)
\displaystyle \frac{\partial u_{i}}{\partial x_{i}}=0
in $\Omega$.(2)
Here,
weadopt
the summation conventiononrepeated
indices that have values 1, 2, and 3. Thex,y,z axesinthe Cartesian coordinatesystemare
designated
asx_{i}, i = 1,
2,
3. Here,u_{i} representsthecomponentof the
velocity
vectorfield\mathrm{u}in thei^{th} dimension,
pstands for the scalarpressurefield,
andRe denotes the
Reynolds
number.Letus discretize the
spatial
domain $\Omega$by
elements$\Omega$^{e},
e= 1,2\ldots,n_{\mathrm{e}l}. Let
S_{\mathrm{u}},
\mathcal{V}_{\mathrm{u}} be the trial andtestfunctionspacesfor
velocity
andS_{p}, \mathcal{V}_{p}
(\mathcal{V}_{p}=S_{p})
be trial andtest functionspacesforpressure. The stabilized finite element formulation of theequations(1)-(2)
with the SUPG/
PSPG stabilizationtermscanbe
expressed
asfollows[1]:
Find\mathrm{u}\in S_{\mathrm{u}} andp\in S_{p}
such that\forall \mathrm{w}\in \mathcal{V}_{\mathrm{u}}and\forall q\in \mathcal{V}_{p}
:数理解析研究所講究録
\displaystyle \int_{ $\Omega$}w_{i}(\frac{\partial u_{i}}{\partial t}+\overline{u}_{j}\frac{\partial u_{i}}{\partial x_{j}})d $\Omega$-\int_{ $\Omega$}\frac{\partial w_{i}}{\partial x_{i}}pd $\Omega$+\int_{ $\Omega$}\frac{1}{Re}\frac{\partial w_{i}}{\partial x_{j}}(\frac{\partial u_{i}}{\partial x_{j}}+\frac{\partial u_{j}}{\partial x_{i}})d $\Omega$
+\displaystyle \sum_{e=1}^{n_{\mathrm{e}1}}\int_{$\Omega$_{\mathrm{e}}} $\tau$\overline{u}_{k}\frac{\partial w_{i}}{\partial x_{k}}(\frac{\partial u_{i}}{\partial t}+\overline{u}_{j}\frac{\partial u_{i}}{\partial x_{j}}+\frac{\partial p}{\partial x_{i}})d $\Omega$=0
,(3)
\displaystyle \int_{ $\Omega$}q\frac{\partial u_{i}}{\partial x_{i}}d $\Omega$+\sum_{\mathrm{e}=1}^{n_{\mathrm{e}1}}\int_{$\Omega$_{\mathrm{e}}} $\tau$\frac{\partial q}{\partial x_{i}}(\frac{\partial u_{i}}{\partial t}+\overline{u}_{j}\frac{\partial u_{i}}{\partial x_{j}}+\frac{\partial p}{\partial x_{i}})d $\Omega$=0
,(4)
where $\tau$isthe SUPG
/
PSPG stabilizationparameter. The formulationtocalculate theparameter $\tau$is
given
indetailsinthepaper[1].
3
GPBi‐CG
Algorithm
Algorithm
1 TheUnpreconditioned
GPBi‐CGx_{0} isaninitialguess,
r_{0}=b-Ax_{o}
;Set
r_{0}^{*}=r_{0},
t_{-1}=w_{-1}=0,$\beta$_{-1}=0
;forn=0,1, until
||r_{n}||\leq $\epsilon$||b||
dop_{n}=r_{n}+$\beta$_{n-1}(p_{n-1}-u_{n-1})
,$\alpha$_{n}=\displaystyle \frac{(r_{\dot{\mathrm{o}}},r_{n})}{(r_{\mathrm{o}}^{*},Ap_{n})},
y_{n}=t_{n-1}-r_{n}-$\alpha$_{n}w_{n-1}+$\alpha$_{n}Ap_{n},
t_{n}=r_{n}-$\alpha$_{n}Ap_{n},
$\zeta$_{n}=\displaystyle \frac{(y_{n},' y_{n})(At_{n},t_{n})-(y_{n},t_{n})(At_{n},y_{n})}{(At_{n}At_{n})(y_{n},y_{n})-(y_{n},At_{n})(At_{n},y_{n})},
$\eta$_{n}=\displaystyle \frac{(At_{n},' At_{n})(y_{n},' t_{n})-(y_{n},At_{n})(At_{n},t_{\mathfrak{n}})}{(At_{n}At_{n})(y_{n}y_{n})-(y_{n},At_{n})(At_{n},y_{n})},
(if
n=0, then$\zeta$_{n}=\displaystyle \frac{(At_{n},t_{n})}{(At_{n},At_{n})},
$\eta$_{n}=0
),
\mathrm{u}_{n}=$\zeta$_{n}Ap_{n}+$\eta$_{n}(t_{n-1}-r_{n}+$\beta$_{n-1}u_{n-1})
,z_{n}=$\zeta$_{n}r_{n}+$\eta$_{n}z_{n-1}-$\alpha$_{n}u_{n},
x_{n+1}=x_{n}+ $\alpha$ p_{n}+z_{n},r_{n+1}=t_{n}-$\eta$_{n}y_{n}-$\zeta$_{n}At_{n},
$\beta$_{n}=\displaystyle \frac{$\alpha$_{n}}{$\zeta$_{n}}\frac{(r_{0}^{*},r_{n+1})}{(r_{\dot{0}},r_{n})},
w_{n}=At_{n}+$\beta$_{n}Ap_{n}
; end forstabilized finite element method leadstoa
large
andThis linear
equation
systemis solvedby using
theTo
implement
the GPBi‐CGalgorithm
onthe GPUplatform,
weused the Nvidias GPU linearalgebra
libraries cuSPARSE
[7]
and cuBLAS[8]
toimplement
four basic vector operationsof thealgorithm:
SpMV, DOT,
AXPY and SCALasdescribed below.\bullet
\mathrm{S}\mathrm{p}\mathrm{M}\mathrm{V}
:the sparse matrix‐vectorproduct,
. DOT: the inner
product,
\bullet AXPY: adda
multiple
ofonevector toanother,
\bullet SCAL:
scaling
avectorby
aconstant.The
SpMV operation
isimplemented by using
thecuSPARSElibrary.
TheDOT,
AXPY and SCALoperationsare
implemented by using
thecuBLASlibrary.
4
Multi‐GPU
Implementation
To extendto multi‐GPU implementation of theGPBi‐CG
algorithm,
we implemented themulti‐GPUversionof
SpMV,
DOT,AXPY,
andSCALoperationsby
usingthe MPIlibrary,
thecuSPARSElibrary
and the cuBLAS
library.
It is trivialtoimplement
themulti‐GPU version of the DOT,AXPY,
andSCALoperations by using the MPI
library
andcuBLASlibrary.
However, theimplementation ofthemulti‐GPUversion of the
SpMV
operationisnotstraightforward.
It is carriedoutby subdividing
thecomputationaldomain into subdomains thataredistributedovertheGPUsby usingthe MPI
library.
Toreduce communicationcost,we
develop
anefficientprocedurethat eachGPUreceives from other GPUsonly
data eachGPUneeds. We consider theproblemof matrix‐vectormultiplicationofasparse matrixAandadensevector b. Wepartitionthe matrix Ainto groups ofadjacent completerowsand assign
onesuch grouptooneGPU. EachGPUis now
obligated
tocomputeentriesof the resultvectorAbthat match with thepartitioned rowsof the matrixAto formapartialresultof the resultvectorAb. Thissubmatrix‐vectorcomputationcanbe carriedoutaftereachGPUreceivesthe entries of thevectorb that
correspondtonon‐zeroentries intherowsof the submatrixAwhichare
assigned
toeachGPU. Asimpleimplementation
forthisproblemistoimplement
acode that all the GPUsreceivesall the entries of theentirevectorb. However,thisimplementationisnotefficientbecause the number ofnon‐zeroentries per
a rowofasparsematrix
generated by
fimite elementmethodsis small. To solve thisproblem,
wedevelop
an efficientprocedurethat each GPU receives from other GPUs
only
the entries of the vector b which eachGPUneedstocomputesubmatrix‐vectormultiplications.
5
Performance Results
Figure 1: Computationaldomain of the testproblem
We consideratestproblemwhichconsistsofan
object
immersed inafluid domainasshowninFig.
1.Starting
fromasurfacemesh,wecreatedthreetetrahedral mesheswith differentresolutions. We carriedoutthecomputationby usingaGPUsystemwith the
following
specification:\bullet Intel XeonCPUE5630,2.
53\mathrm{G}\mathrm{H}\mathrm{z},
\bullet 2GPUs‐Tesla
C2070,
\bullet 24GB
System Memory.
Thble 1: Speed‐upratiosandexecution times
We measured thetimeof theexecutionontwoGPU devices and thatoftwoCPU threads. As shown inTab. 1,theGPUexecution is1.8 timesfaster than the CPUexecutionfor the
large
mesh with 638447 elements. Thespeedup
ratioincreasesasthe number of elements of meshes increases.6
Conclusions
Weproposeanefficient
implementation
ofamulti‐GPUparallel
solver basedontheGPBi‐CGalgorithm
for 3\mathrm{D}
unsteady
Navier‐Stokesequationsdiscretizedby
the stabilized finite element formulations. Wedevelop
ahybrid
CPU‐GPUstrategythat distributes thecomputation
acrossGPUsby using
the MPIlibrary.
In futureresearch,weplan
toevaluate thescalability
of theprogram(speedup
factorversusthenumber of GPU
devices)
inmulti‐GPUhigh‐performance computing
systems. We alsoplan
toimprove
thecurrentimplementation by using multigrid‐ preconditioners.
Acknowledgment
This workwas
supported by Japan
Science andTechnology Agency,
Core Research for Evolutional Scienceand
Technology
(JST‐CREST).
The first author would liketoacknowledge
Mr.Ryota
Yamane(Okayama
University)
forproviding
the STL file used fortest computations.References
[1]
T. E.Tezduyar,
Stabilized fimite element formulations forincompressible
flowcomputations,Advancesin
Applied
Mechanics28(1992)
1‐44.[2]
T. E.Tezduyar,
S.Mittal,
S. E.Ray,
R.Shih, Incompressible
flow computationswith stabilized bilinear and linearequal
orderinterpolation velocity
pressureelements, Computer
MethodsinApplied
Mechanics andEngineering
95(1992)
221‐242.[3]
$\Gamma$.Shakib,
T. J. R.Hughes,
Z.Johan,
A new finite element formulation forcomputational
fluiddynamics:
X. thecompressible
Euler and Navier‐Stokesequations,Computer
MethodsinApplied
lMechanics
andEngineering
89(1991)
141‐219.[4]
L. P.Franca,
S. L.Fhey,
T. J. R.Hughes,
Stabilized finite element methods: I.application
tothe advective‐diffusivemodel, Computer
MethodsinApplied
Mechanics andEngineering
95(1992)
235‐ 276.[5]
V.Huynh,
H.Suito,
A GPU Parallel Solver for 3DIncompressible
Navier‐StokesEquations
Dis‐cretized
by
the SUPG/
PSPG Stabilized Finite ElementFormulation,
GPUTechnology
Confer‐ ence 2016, http://\mathrm{o}\mathrm{n}‐demand.gputechconf.$\Gamma$ 1\mathrm{u}\mathrm{i}\mathrm{d}_{-}Dynamic\mathrm{s}_{-}\mathrm{C} $\Gamma$ \mathrm{D}_{-}01_{-}\mathrm{P}6160_{-}\mathrm{W}\mathrm{E}\mathrm{B}.pdf
(Accessed
Oct.2016).
[6]
S. L.Zhang,
GPBi‐CG: Generalizedproduct‐type
methods basedonUi‐CG forsolving nonsymmetric
linearsystems,SIAM J. Sci.