Scien&fic ¡Simula&ons ¡on ¡ Thousands ¡of ¡GPUs ¡with ¡ Performance ¡Portability ¡
Alan Gray and Kevin Stratford EPCC, The University of Edinburgh
Scien&fic Simula&ons on Thousands of GPUs with - - PowerPoint PPT Presentation
Scien&fic Simula&ons on Thousands of GPUs with Performance Portability Alan Gray and Kevin Stratford EPCC, The University of Edinburgh CORAL procurement Three
Alan Gray and Kevin Stratford EPCC, The University of Edinburgh
2
3
4
Stratford, K., A. Gray, and J. S. Lintuvuori. "Large Colloids in Cholesteric Liquid Crystals." Journal of Statistical Physics 161.6 (2015): 1496-1507. Gray, A., Hart, A., Henrich, O. & Stratford, K., Scaling soft matter physics to thousands of graphics processing units in parallel, IJHPCA (2015)
5
¡ including ¡LaVce ¡QCD ¡component, ¡
¡ h_p://www.prace-‑ri.eu/ueabs/ ¡
¡ |rgb|rgb|rgb|rgb| ¡ ¡(Array ¡of ¡Structs ¡AoS) ¡ ¡ |rrrr|gggg|bbbb| ¡ ¡(Struct ¡of ¡Arrays ¡SoA) ¡ ¡ Most ¡general ¡case ¡is ¡Array ¡of ¡Structs ¡of ¡(short) ¡Arrays ¡(AoSoA) ¡ ¡ E.g. ¡||rr|gg|bb|||rr|gg|bb|| ¡ ¡has ¡SA ¡length ¡of ¡2 ¡ ¡ Major ¡effect ¡on ¡bandwidth. ¡Best ¡layout ¡architecture-‑specific ¡
¡ De-‑couple ¡memory ¡layout ¡from ¡applica&on ¡source ¡code ¡ ¡ Can ¡simply ¡be ¡done ¡with ¡macro, ¡e.g. ¡ ¡
6
¡ With ¡some ¡opera&on ¡… ¡at ¡each ¡point ¡
7
int iSite; for (iSite = 0; iSite < N; iSite++) { ... }
8
int iSite; #pragma omp parallel for for (iSite = 0; iSite < N; iSite++) { ... } __global__ void scale(double* field) { int iSite; iSite=blockIdx.x*blockDim.x+threadIdx.x if(iSite<N) { ... } return; }
__targetEntry__ void scale(double* field){ int iSite; __targetTLP__(iSite, N) { ... } return; }
9
loops ¡to ¡create ¡vector ¡instruc&ons. ¡ ¡
laVce ¡sites ¡ ¡
¡ VVL ¡must ¡be ¡1 ¡for ¡above ¡example ¡to ¡work ¡ ¡ But ¡we ¡can ¡set ¡VVL>1, ¡and ¡add ¡a ¡new ¡innermost ¡loop ¡
__targetEntry__ void scale(double* t_field) {
int index; __targetTLP__(iSite, N) { int iDim; for (iDim = 0; iDim < 3; iDim++) { t_field[INDEX(iDim,iSite)] = t_a*t_field[INDEX(iDim,iSite)]; } } return; }
10
direc&ve ¡
IMCI ¡instruc&on ¡for ¡8-‑way ¡DP ¡vector ¡unit ¡on ¡Xeon ¡Phi ¡
¡ Without ¡this, ¡performance ¡is ¡several ¡&mes ¡worse ¡on ¡Xeon ¡Phi ¡
__targetEntry__ void scale(double* t_field) { int baseIndex; __targetTLP__(baseIndex, N) { int iDim, vecIndex; for (iDim = 0; iDim < 3; iDim++) { __targetILP__(vecIndex) \ t_field[INDEX(iDim,baseIndex+vecIndex)] = \ t_a*t_field[INDEX(iDim,baseIndex+vecIndex)]; } } return; }
¡ That ¡can ¡alterna&vely ¡map ¡to ¡regular ¡CPU ¡(malloc, ¡memcpy ¡etc) ¡
11
targetMalloc((void **) &t_field, datasize); copyToTarget(t_field, field, datasize); copyConstDoubleToTarget(&t_a, &a, sizeof(double)); scale __targetLaunch__(N) (t_field); targetSynchronize(); copyFromTarget(field, t_field, datasize); targetFree(t_field);
12
¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡CPU ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡Xeon ¡Phi ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPU ¡
13
0" 100" 200" 300" 400" 500" 600" 700" Intel"Ivy1 bridge"121 core"CPU" Intel"Haswell" 81core"CPU" AMD" Interlagos" 161core"CPU" Intel"Xeon" Phi"" NVIDIA"K20X" GPU" NVIDIA"K40" GPU" !me$(s)$
Full$Ludwig$Liquid$Crystal$128x128x128$Test$Case$$
Ludwig"Remainder" Advect."Bound." AdvecPon" LC"Update" Chemical"Stress" Order"Par."Grad." Collision" PropagaPon" AoSoA,%% VVL=4% %%AoS,%% VVL=1% %%AoS,%% VVL=1% AoSoA,%% VVL=8% %%SoA,%% VVL=1% %%SoA,%% VVL=1% Best%% Config:%
" "" " " "" " " "" "
14
0" 100" 200" 300" 400" 500" 600" 700" Intel"Ivy1 bridge"121 core"CPU" Intel"Haswell" 81core"CPU" AMD" Interlagos" 161core"CPU" Intel"Xeon" Phi"" NVIDIA"K20X" GPU" NVIDIA"K40" GPU" !me$(s)$
Full$MILC$Conjugate$Gradient$64x64x32x8$Test$Case$$
MILC"Remainder" ShiN" Scalar"Mult."Add" Insert" Insert"&"Mult." Extract"&"Mult." Extract" AoSoA,%% VVL=4% %%AoS,%% VVL=1% %%AoS,%% VVL=1% AoSoA,%% VVL=8% %%SoA,%% VVL=1% %%SoA,%% VVL=1% Best%% Config:%
" "" " " "" " " "" "
¡ ¡
¡ Compare ¡kernel ¡bandwidth ¡with ¡STREAM ¡benchmark ¡
15
0" 20" 40" 60" 80" 100" 120" 140" Propaga.on"(0.00)" Collision"(1.08)" Order"Par."Grad."(0.15)" Chemical"Stress"(2.97)" LC"Update"(0.79)" Advec.on"(0.13)" Advect."Bound."(0.05)" Extract"(0.07)" Extract"and"Mult."(0.38)" Insert"and"Mult."(0.38)" Insert"(0.10)" Scalar"Mult."Add"(0.07)" ShiN"(0.00)" Percentage)of)STREAM) Intel"IvyPbridge"(Es.mated)" Intel"Xeon"Phi"(Es.mated)" NVIDIA"K40"GPU"(Actual)"
Ludwig" MILC"
16
17
1000" Titan"CPU"" (One"160core" Interlagos"per"node)""" Archer"CPU"" (Two"120core"Ivy0 bridge"per"node)" Titan"GPU"" (One"K20X"per"node)" 1" 10" 100" 1000" 1" 10" 100" 1000" !me$(s)$ nodes$
Ludwig$Liquid$Crystal:$128x128x128$
18
1000" Titan"CPU"" (One"160core" Interlagos"per"node)""" Archer"CPU"" (Two"120core"Ivy0 bridge"per"node)" Titan"GPU"" (One"K20X"per"node)" 10# 100# 1000# 100# 1000# 10000# !me$(s)$ nodes$
Ludwig$Liquid$Crystal:$1024x1024x512$
19
1000" Titan"CPU"" (One"160core" Interlagos"per"node)""" Archer"CPU"" (Two"120core"Ivy0 bridge"per"node)" Titan"GPU"" (One"K20X"per"node)" 1" 10" 100" 1000" 1" 10" 100" 1000" !me$(s)$ nodes$
MILC$Conjugate$Gradient:$64x64x32x8$
20
1000" Titan"CPU"" (One"160core" Interlagos"per"node)""" Archer"CPU"" (Two"120core"Ivy0 bridge"per"node)" Titan"GPU"" (One"K20X"per"node)" 1" 10" 100" 1000" 10" 100" 1000" 10000" !me$(s)$ nodes$
MILC$Conjugate$Gradient:$64x64x64x192$
mul&/many-‑core ¡CPUs ¡as ¡well ¡as ¡GPUs ¡
¡ By ¡abstrac&ng ¡parallelism ¡and ¡memory ¡spaces ¡ ¡ Express ¡TLP ¡and ¡ILP. ¡We ¡can ¡see ¡that ¡exposing ¡ILP ¡is ¡crucial ¡on ¡Xeon ¡Phi ¡today, ¡and ¡
vector ¡units ¡will ¡con&nue ¡to ¡get ¡wider ¡on ¡future ¡CPUs ¡
¡ It ¡is ¡also ¡crucial ¡to ¡de-‑couple ¡memory ¡layout ¡by ¡abstrac&ng ¡ ¡memory ¡accesses. ¡
bandwidth ¡
¡ GPUs ¡have ¡advantage ¡over ¡Xeon ¡Phi ¡
¡ NVLINK ¡should ¡help ¡with ¡strong ¡mul&-‑GPU ¡scaling ¡ ¡
¡ be ¡fruimul ¡for ¡other ¡areas ¡
¡ h_p://ccpforge.cse.rl.ac.uk/svn/ludwig/trunk/targetDP/README ¡
¡ ¡
21
22