A Tiling Based Programming Model and Its Suppor7ve Tools - - PowerPoint PPT Presentation

a tiling based programming model and its suppor7ve tools
SMART_READER_LITE
LIVE PREVIEW

A Tiling Based Programming Model and Its Suppor7ve Tools - - PowerPoint PPT Presentation

A Tiling Based Programming Model and Its Suppor7ve Tools Didem Unat , Burak Bastem, Nufail Farooqi Ko University, Istanbul Weiqun Zhang, Tan Nguyen,


slide-1
SLIDE 1

A ¡Tiling ¡Based ¡Programming ¡Model ¡and ¡ ¡ Its ¡Suppor7ve ¡Tools ¡

Didem ¡Unat, ¡Burak ¡Bastem, ¡Nufail ¡Farooqi ¡ ¡ Koç ¡University, ¡Istanbul ¡ Weiqun ¡Zhang, ¡Tan ¡Nguyen, ¡John ¡Shalf, ¡Ann ¡Almgren ¡ Lawrence ¡Berkeley ¡Na:onal ¡Laboratory ¡ ¡ ¡

1 ¡

25 ¡Jan ¡2016, ¡SPPEXA ¡Symposium, ¡Munich, ¡Germany ¡

slide-2
SLIDE 2

¡ Abstract ¡Machine ¡Model ¡ ¡

(for ¡emerging ¡node ¡architectures) ¡ ¡

“Abstract ¡machine ¡models ¡and ¡proxy ¡architectures ¡for ¡exascale ¡compuGng”, ¡ In ¡Proceedings ¡of ¡the ¡1st ¡Interna:onal ¡Workshop ¡on ¡Hardware-­‑SoQware ¡Co-­‑Design ¡for ¡High ¡ Performance ¡Compu:ng ¡(Co-­‑HPC ¡'14). ¡IEEE ¡Press ¡ Download ¡the ¡CAL ¡AMM ¡doc ¡ ¡from ¡hUp://www.cal-­‑design.org/ ¡

3D Stacked Memory (Low Capacity, High Bandwidth) Fat Core Fat Core Thin Cores / Accelerators DRAM NVRAM (High Capacity, Low Bandwidth) Coherence Domain Core

slide-3
SLIDE 3

NERSC ¡new ¡system: ¡Cori ¡

  • Minimize ¡data ¡movement ¡by ¡

respecGng ¡the ¡topology ¡and ¡ hierarchy ¡ ¡

  • The ¡new ¡NERSC ¡system, ¡Cori ¡

– Mesh ¡Network ¡w/quadrants ¡ – No ¡coherence ¡domains ¡yet ¡ – Heterogeneous ¡memory ¡ subsystem ¡

¡

KNL ¡ ¡ Mesh ¡on-­‑chip ¡network ¡

Move ¡away ¡from ¡compute-­‑centric ¡to ¡data-­‑centric ¡ programming ¡model ¡

slide-4
SLIDE 4

Tiling ¡is ¡a ¡well-­‑known ¡loop ¡transformaGon ¡for ¡parallelism ¡and ¡data ¡locality ¡ – Why ¡not ¡elevate ¡it ¡to ¡the ¡programming ¡model? ¡ TiDA ¡makes ¡Gling ¡part ¡of ¡the ¡data ¡structure ¡declaraGon ¡ – Each ¡array ¡is ¡extended ¡with ¡metadata ¡to ¡manage ¡memory ¡affiniGes ¡ – Metadata ¡follows ¡the ¡array ¡through ¡the ¡code ¡ ¡ ¡

¡ ¡

TiDA: ¡Tiling ¡as ¡a ¡Durable ¡AbstracGon ¡

4 ¡ Box 2 Box 1 Box 2 Box 3

Box 4 Box 5

Tile (1,1) Tile (1,2) Tile (2,1) Tile (2,2) Tile (3,1) Tile (3,2)

Tiled Box 2

slide-5
SLIDE 5

Tiling ¡introduces ¡more ¡parallelism ¡

  • OpenMP ¡ ¡

– #pragma omp for ¡is ¡generally ¡used ¡to ¡introduce ¡data ¡parallelism ¡

  • For ¡a ¡N ¡=128^3 ¡problem ¡on ¡1000 ¡cores, ¡one ¡level ¡loop ¡parallelism ¡is ¡

not ¡sufficient ¡ ¡

– #pragma omp for collapse(2)

  • Collapse ¡clause ¡doesn’t ¡decompose ¡the ¡data ¡space ¡

– It ¡flaUens ¡the ¡iteraGon ¡space, ¡have ¡to ¡introduce ¡Gling ¡manually ¡ ¡

  • Tiling ¡allows ¡mulGdimensional ¡decomposiGon ¡of ¡data ¡ ¡

– Each ¡Gle ¡represents ¡an ¡independent ¡unit ¡of ¡work ¡ – Task ¡scheduler ¡can ¡work ¡at ¡a ¡Gle ¡granularity ¡ ¡

  • MulG-­‑level ¡parallelism ¡

– Coarse-­‑grain ¡parallelism: ¡across ¡Gles ¡ – Fine-­‑grain ¡parallelism: ¡vectorizaGon, ¡instrucGon ¡ordering ¡within ¡ Gle ¡

¡ ¡ ¡

slide-6
SLIDE 6

Tiling ¡improves ¡data ¡locality ¡

  • Horizontal ¡data ¡movement ¡

– Respect ¡Gle ¡topology ¡when ¡place ¡ Gles ¡on ¡the ¡chip ¡ – If ¡adjacent ¡Gles ¡share ¡much ¡of ¡the ¡ data, ¡we ¡need ¡to ¡schedule ¡them ¡ to ¡the ¡adjacent ¡threads ¡(threads ¡ within ¡the ¡same ¡socket) ¡ ¡

  • VerGcal ¡data ¡movement ¡
  • Tiling ¡shrinks ¡the ¡working ¡set ¡size ¡to ¡

fit ¡it ¡to ¡available ¡cache ¡

0.125& 0.25& 0.5& 1& 2& 4& 8& 16& 32& 64& 128& Bytes&per&Flop& Tile&Size&

SMC&Code&with&53&Species&

64&kB&Cache& 256&kB&Cache& 1&MB&Cache& 4&MB&Cache& Unlimited&Cache&

slide-7
SLIDE 7

Three ¡Simple ¡AbstracGons ¡in ¡TiDA ¡

  • Logical ¡Tiles ¡

– These ¡are ¡logical ¡parGGons ¡of ¡data ¡ – Their ¡size ¡can ¡be ¡different ¡for ¡each ¡loop ¡nest ¡ ¡

  • Regional ¡Tiles ¡

– Support ¡NUMA ¡architectures ¡by ¡allocaGng ¡a ¡group ¡of ¡Gles ¡ conGguously ¡in ¡memory ¡ ¡

  • Tile ¡iterator ¡

– Hides ¡traversal ¡of ¡Gles ¡from ¡the ¡user ¡ – Decouples ¡the ¡loop ¡iteraGons ¡and ¡parallelizaGon ¡from ¡the ¡ loop ¡body ¡ – Can ¡be ¡used ¡for ¡different ¡execuGon ¡models ¡ ¡

Didem ¡Unat, ¡Koç ¡University ¡ 7 ¡

slide-8
SLIDE 8

Regional ¡Tiles ¡

Didem ¡Unat, ¡Koç ¡University ¡ 8 ¡

  • Each ¡structured ¡grid ¡is ¡divided ¡into ¡regions ¡and ¡mapped ¡on ¡to ¡a ¡different ¡

NUMA ¡node ¡(or ¡cache ¡coherence ¡domains) ¡

– TiDA ¡uses ¡HWLOC ¡to ¡discover ¡NUMA ¡nodes ¡and ¡distribute ¡regions ¡to ¡different ¡ NUMA ¡nodes ¡

  • A ¡programmer ¡can ¡set ¡the ¡region ¡geometry ¡using ¡an ¡env ¡var ¡or ¡in ¡the ¡

program ¡

– export ¡TiDA_REGIONS=x,y,z ¡

slide-9
SLIDE 9

Logical ¡Tiles ¡

Didem ¡Unat, ¡Koç ¡University ¡ 9 ¡

  • Logically ¡Gles ¡regions ¡

– No ¡memory ¡allocaGon ¡is ¡required ¡ – Only ¡how ¡the ¡data ¡traversed ¡differs ¡ ¡

  • Designed ¡for ¡improving ¡cache ¡reuse ¡within ¡a ¡NUMA ¡node ¡
slide-10
SLIDE 10

Regional ¡Tiles ¡and ¡Ghost ¡Cells ¡

Didem ¡Unat, ¡Koç ¡University ¡ 10 ¡

  • Regions ¡represent ¡disjoint ¡memory ¡locaGons ¡
  • They ¡introduce ¡ghost ¡cells ¡that ¡keep ¡data ¡needed ¡from ¡other ¡regions ¡
  • TiDA ¡provides ¡fill_5leboundary() ¡rouGne ¡to ¡update ¡the ¡ghost ¡cells ¡in ¡a ¡
  • program. ¡
  • The ¡programmer ¡is ¡responsible ¡for ¡where ¡to ¡call ¡this ¡rouGne ¡but ¡TiDA ¡

handles ¡communicaGon ¡between ¡regions ¡

slide-11
SLIDE 11

¡Dynamic ¡Tile ¡and ¡StaGc ¡Region ¡Sizes ¡

  • Tile ¡Size ¡

– Tile ¡size ¡is ¡parameterized ¡and ¡local ¡ – Tile ¡size ¡is ¡dynamic ¡with ¡the ¡help ¡of ¡the ¡Gle ¡iterator ¡

  • Requires ¡no ¡reallocaGon ¡
  • Some ¡loops ¡do ¡not ¡benefit ¡from ¡Gling ¡(element-­‑wise ¡updates, ¡no ¡reuse) ¡

¡ ¡ ¡

  • Region ¡Size ¡ ¡

– Region ¡size ¡is ¡parameterized ¡and ¡global, ¡can ¡be ¡set ¡at ¡the ¡launch ¡Gme ¡ – Different ¡arrays ¡can ¡have ¡different ¡region ¡sizes ¡ – Region ¡size ¡is ¡sta5c ¡otherwise ¡it ¡would ¡require ¡reallocaGon ¡of ¡data ¡

slide-12
SLIDE 12

Tile ¡Iterator ¡

  • Loop ¡traversal ¡construct ¡to ¡abstract ¡

the ¡Gle ¡traversal ¡order ¡and ¡parallelism ¡

  • Applies ¡the ¡loop ¡body ¡on ¡every ¡Gle ¡
  • Takes ¡Glesize ¡to ¡logically ¡Gle ¡the ¡array ¡

– It ¡creates ¡logical ¡Gles ¡on ¡the ¡fly ¡ ¡

  • Allows ¡dynamic ¡Gle ¡sizes ¡for ¡logical ¡

Gling ¡ ¡ – Different ¡Gle ¡size ¡per ¡nested ¡loop ¡ ¡ ¡

Didem ¡Unat, ¡Koç ¡University ¡ 12 ¡

We ¡have ¡both ¡C++ ¡and ¡Fortran ¡implementaGons ¡and ¡API ¡for ¡TiDA ¡ ¡

slide-13
SLIDE 13

InteracGon ¡with ¡AMR ¡libraries ¡

AMR ¡library ¡(e.g. ¡Boxlib, ¡Chombo) ¡ TiDA ¡library ¡ ¡

AMR ¡Level ¡ ¡ ¡ ¡ ¡ ¡ ¡ Grid ¡ ¡ ¡ ¡ ¡ ¡ Region ¡ ¡ ¡ ¡ ¡ Tile ¡ ¡ ¡ ¡ ¡ Cell ¡

  • Regions ¡and ¡Gles ¡are ¡light-­‑weight ¡

data ¡structures, ¡compared ¡to ¡Grid ¡

  • Construct ¡messages ¡directly ¡from ¡

Regions ¡

slide-14
SLIDE 14

Building ¡TiDA ¡Arrays ¡

type(tileArray) :: A, B type(absTileArray) :: abstractAB abstractAB = absTileArray_build(lb, ub, regionsizes, tilesizes) A= tilearray_build(abstractAB, ghosts) B= tilearray_build(abstractAB, ghosts) . . . call tilearray_destroy(A) call tilearray_destroy(B) lower ¡bound ¡ upper ¡bound ¡ Integer ¡vector ¡

  • f ¡regionsize ¡

We ¡have ¡both ¡C++ ¡and ¡Fortran ¡implementaGons ¡and ¡API ¡for ¡TiDA ¡ ¡

slide-15
SLIDE 15

!$OMP PARALLEL PRIVATE(ti, tlo, thi, reglo, reghi, i, j, ptrA) ti = tileItr_build(abstractAB, logtilesize) do while(next_tile(ti)) ptrA =>dataptr(A, ti) tlo = get_lwb(ti) thi = get_upb(ti) !Option 1: process a tile within a loop do j = tlo(2), thi(2) do i = tlo(1), thi(1) ptrA(i,j) = compute(i,j) ... end do end do !Option 2: process a tile within a function reglo = get_lwb(get_region(A, ti)) 
 reghi = get_upb(get_region(A, ti)) ! call compute_a_tile(ptrA, tlo, thi, reglo, reghi) end do !$OMP END PARALLEL

OperaGon ¡on ¡TiDA ¡Arrays ¡

Original ¡loop ¡ nest ¡

Tiling ¡iterator ¡and ¡ its ¡loop ¡ Get ¡Gle ¡ and ¡its ¡ range ¡

slide-16
SLIDE 16

MulG-­‑grid ¡with ¡TiDA ¡

Didem ¡Unat, ¡Koç ¡University ¡ 16 ¡

0" 2" 4" 6" 8" 10" 12" 14" 16"

6" 12" 18" 24"

Speedup&

#&of&Cores&

MiniMG&Speedup&over&1&Thread&(Hopper)&

OMP+Naïve" OMP" TiDA"

slide-17
SLIDE 17

15.4%& 12.4%& 11.1%& 10.1%& 8.5%& 23.3%& 25.3%& 40.4%& 31.3%& 30.9%&

0%& 5%& 10%& 15%& 20%& 25%& 30%& 35%& 40%& 45%&

192& 384& 768& 1536& 3072& Speedup& #&of&Cores& Improvement&of&MPI+TiDA&over&MPI+OMP&

MPI+TiDA& MPI+TiDA&(nocomm)&

MPI ¡ ¡+ ¡TiDA ¡

Didem ¡Unat, ¡Koç ¡University ¡ 17 ¡

TiDA ¡provides ¡15% ¡improvement ¡with ¡192 ¡cores ¡but ¡the ¡performance ¡gain ¡ drops ¡to ¡8.5% ¡on ¡3072 ¡due ¡to ¡the ¡inter-­‑node ¡communicaGon ¡overhead. ¡ We ¡need ¡an ¡asynchronous ¡runGme ¡ system ¡and ¡region ¡scheduler ¡

slide-18
SLIDE 18

TiDA API TiDA-Acc TiDA Fortran TiDA C++ Asynchronous Execution

  • Region Scheduler
  • Runtime for TiDA

Slow/Fast Memory

  • Prefetching of

Regions

  • Cori Machine

NUMA-Aware Mapping

  • HWLOC
  • Tile or Thread

migration for load balancing Compiler Support

  • GPU support
  • Optimizations

within a tile

Applications: AMR Frameworks : Boxlib and Chombo from LBL Combustion, Cardiac Modeling, Multi-phase Flow Simulations

Big ¡Picture: ¡Summary ¡

slide-19
SLIDE 19

Thank ¡you! ¡

  • Acknowledgements: ¡ ¡
  • This ¡work ¡is ¡supported ¡by ¡the ¡Marie ¡Sklodowska ¡Curie ¡ReintegraGon ¡Grant ¡

by ¡the ¡European ¡Commission. ¡ ¡ ¡

  • This ¡work ¡was ¡supported ¡by ¡the ¡SciDAC ¡Program ¡and ¡the ¡Exascale ¡Co-­‑

Design ¡Program ¡of ¡the ¡DOE ¡Office ¡of ¡Advanced ¡ScienGfic ¡CompuGng ¡ Research ¡under ¡the ¡U.S. ¡Department ¡of ¡Energy ¡under ¡contract ¡DE-­‑ AC02-­‑05CH11231. ¡ ¡ ¡

  • This ¡research ¡used ¡resources ¡of ¡the ¡NaGonal ¡Energy ¡Research ¡ScienGfic ¡

CompuGng ¡Center, ¡which ¡is ¡supported ¡by ¡the ¡Office ¡of ¡Science ¡of ¡the ¡U.S. ¡ Department ¡of ¡Energy ¡under ¡Contract ¡No. ¡DE-­‑AC02-­‑05CH11231. ¡ ¡

Didem ¡Unat, ¡Koç ¡University ¡ 19 ¡