34
ET E.T. International, Inc. X-Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013 DynAX Innovations in Programming Models, Compilers and Runtime Systems for Dynamic Adaptive Event-Driven Execution Models

X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

  • Upload
    parley

  • View
    61

  • Download
    0

Embed Size (px)

DESCRIPTION

DynAX Innovations in Programming Models, Compilers and Runtime Systems for Dynamic Adaptive Event-Driven Execution Models. X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013. Objectives. Brandywine Xstack Software Stack. - PowerPoint PPT Presentation

Citation preview

Page 1: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

ET

E.T. International, Inc.

X-Stack: Programming Challenges, Runtime Systems, and Tools

Brandywine TeamMarch 2013

DynAXInnovations in Programming Models, Compilers and Runtime Systems for

Dynamic Adaptive Event-Driven Execution Models

Page 2: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

2

ObjectivesScalability Expose, express, and exploit O(1010) concurrencyLocality Locality aware data types, algorithms, and

optimizationsProgrammability

Easy expression of asynchrony, concurrency, locality

Portability Stack portability across heterogeneous architecturesEnergy Efficiency

Maximize static and dynamic energy savings while managing the tradeoff between energy efficiency, resilience, and performance

Resilience Gradual degradation in the face of many faultsInteroperability

Leverage legacy code through a gradual transformation towards exascale performance

Applications Support NWChem

Page 3: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

3

Brandywine Xstack Software Stack

SWARM(Runtime System)

SCALE(Compiler)

HTA (Library)

R-Stream(Compiler)

NWChem + Co-Design Applications

Rescinded Primitive Data Types .

E.T. International, Inc.

E.T. International, Inc.

Page 4: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

SWARMMPI, OpenMP, OpenCL SWARM

Asynchronous Event-Driven Tasks Dependencies Resources Active Messages Control Migration

VS.

Communicating Sequential Processes Bulk Synchronous Message Passing

Tim

e Time

Active threads

Waiting

4

Page 5: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

5

SCALE• SCALE: SWARM Codelet Association LangaugE

Extends C99Human readable parallel intermediate representation for

concurrency, synchronization, and localityObject model interfaceLanguage constructs for expressing concurrency (codelets)Language constructs to association codelets (procedures

and initiators)Object constructs for expressing synchronization

(dependencies, barriers, network registration)Language constructs for expressing locality (planned)

• SCALECC: SCALE-to-C translator

Page 6: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

6

Rstream Compiler

Compiler Infrastructure

PolyhedralMapperISO

C Front End

Code Gen/Back End

API

Low-Level Com

pilersR-Stream

RaisingLowering

.C

Different APIsand execution

models (AFL, OpenMP, DMA, pthreads,

CUDA…)

Loop + data optimizations,locality, parallelism, communication

and synchronization generation

Machine

Model

Page 7: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

7

Hierarchical Tiled Arrays• Abstractions for parallelism and locality

• Recursive data structure• Tree structured representation of memory

Across cores

Tiling for locality

Distributedacross nodes

Page 8: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

8

NWChem

• DOE’s Premier computational chemistry software• One-of-a-kind solution scalable with respect to scientific

challenge and compute platforms• From molecules and nanoparticles to solid state and

biomolecular systems• Distributed under Educational Community License• Open-source has greatly expanded user and developer base • Worldwide distribution (70% is academia)

QM-CC QM-DFT AIMD QM/MM MM

Page 9: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

9

Rescinded Primitive Data Type Access• Prevents actors (processors, accelerators, DMA) from accessing

data structures as built-in data types, making these data structures opaque to the actors

• Redundancy removal to improve performance/energy• Communication• Storage

• Redundancy addition to improve fault tolerance• High Level fault tolerant

error correction codes and their distributed placement

• Placeholder representation for aggregated data elements • Memory

allocation/deallocation/copying

• Memory consistency models

Page 10: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

10

Approach1. Study codesign application2. Map application (by hand) to asynchronous dynamic

event-driven runtime system [codelets]3. Determine how to improve runtime based on

application learnings.4. Define key optimizations for compiler and library

team members.5. Rinse, wash, repeat.

Page 11: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

11

Progress• Applications

Cholesky DecompositionNWChem: Self Consistent Field Module

• CompilersHTA: Initial design draft of PIL (Parallel Intermediate

Language)HTA: PIL -> SCALE compilerR-Stream: Codelet generation, redundant dependence

• RuntimePriority SchedulingMemory ManagementData Placement

Page 12: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Cholesky DAG•POTRF → TRSM•TRSM → GEMM, SYRK•SYRK → POTRF• Implementations:

MKL/ACML (trivial)OpenMPSWARM

POTRF TRSM SYRK GEMM1:

2:

3:

12

Page 13: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Naïve O

penMP

Tuned OpenM

PSW

AR

M

Cholesky Decomposition: Xeon

1 2 3 4 5 6 7 8 9 101112123456789

101112

OpenMPSWARM

# Threads

Spee

dup

over

Ser

ial

13

Page 14: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Cholesky Decomposition: Xeon Phi

14

Ope

nMP

SWA

RM

Xeon Phi: 240 Threads

OpenMP fork-join programming suffers on many-core chips (e.g. Xeon Phi). SWARM removes these synchronizations.

Page 15: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Cholesky: SWARM vs ScaLapack/MKLSc

aLap

ack

SWA

RM

16 node cluster: Intel Xeon E5-2670 16-core 2.6GHz

Asynchrony is key in large dense linear algebra

2 4 8 16 32 640

2000

4000

6000

8000

10000

12000

14000

16000

ScaLapack/MKL

SWARM

# Nodes

GFLO

PS15

Page 16: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Memory and Scheduling: no prefetch

• Net – # outstanding buffers that are needed for computation but not yet consumed

• Sched – # outstanding tasks that are ready to execute but have not yet been executed

• Miss - # times a scheduler went to the task queue and found no work (since last timepoint)

• Notice that at 500s, one node runs out of memory and starves everyone else.

0 500 1000 1500 20000

5000100001500020000250003000035000400004500050000

0

2000

4000

6000

8000

10000

12000Network buffers, miss rate, and work

schedulednetmisssched

Time (s)

Out

stan

ding

Net

wor

k Bu

ffer

s

Sche

dule

d W

ork

& M

iss

Rate

16

Page 17: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Memory and Scheduling: static prefetch

• Because the receiver prefetches, he can obtain work as it is needed.

• However, there is a tradeoff between prefetching too early and risking out of memory and prefetching too late and starving.

• It turns out that at the beginning of the program we need to prefetch aggressively to keep the system busy, but prefectch less when memory is scarce.

• A prefetch scheme that is not aware of memory usage cannot balance this tradeoff.

0 100 200 300 400 500 6000

5000100001500020000250003000035000400004500050000

0

2000

4000

6000

8000

10000

12000Network buffers, miss rate, and work

schedulednetmisssched

Time(s)

Out

stan

ding

Net

wor

k Bu

ffer

s

Sche

dule

d W

ork

& M

iss

Rate

s

17

Page 18: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

0 100 200 300 400 500 6000

5000100001500020000250003000035000400004500050000

0

2000

4000

6000

8000

10000

12000Network buffers, miss rate, and work scheduled

netreqmisssched

Time (s)

Net

wor

k Bu

ffer

s

Sche

dule

d W

ork

& M

iss

Rate

Memory and Scheduling: dynamic prefetch

• Because the receiver prefetches, he can obtain work as it is needed.

• The receiver determines the most buffers it can handle (i.e. 40,000)

• It immediately requests the max and whenever a buffer is consumed, it requests more.

• Note the much higher rate of schedulable events at the beginning (5000 vs 1500) and no memory overcommital

Page 19: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

19

Key Learnings• Fork-Join model does not scale for Cholesky

Asynchronous data dependent execution needed• Scheduling is by priority is key

Not based on operation, but phase and position• Memory Management

‘pushing’ data to actor does not allow actor to control it’s memory management

Static prefetch works better but limits parallelism Prefetch based on how much memory (resource) you have

provides best balance

Page 20: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Self-Consistent Field MethodObtain variational solutions to the electronic Schrödinger Equation

20

EH

eigenvector

Wavefront Energy

By expressing the system’s one electron orbitals as the dot product of the system’s eigenvectors and some set of Gaussian basis functions

)()( rr ii C

Gaussian basis function

Page 21: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

… reduces toThe solution to the electronic Schrödinger Equation reduces to the self-consistent eigenvalue problem

21

DhF

CCD

CSCF

kk

k

kk

||221

Fock matrix

Eigenvectors

Density matrix

Overlap matrixEigenvalues

One-electron forces

Two-electron Coulomb forces

Two-electron Exchange forces

Page 22: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Logical flow

22

Initial Density Matrix

Construct Fock Matrix

a) One electronb) Two electron

Compute Orbitals

Compute Density Matrix

Damp Density Matrix

no convergence

convergence

Output

Initial Orbital Matrix

Schwarz Matrix

Page 23: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

The BIG loop

for (i = 0; i < nbfn; i++) { for (j = 0; j < nbfn; j++) { for (k = 0; k < nbfn; k++) { for (l = 0; l < nbfn; l++) { if (g_schwarz[i][j] * g_schwarz[k][l]) < tol2e) continue; double gg = g(i, j, k, l); g_fock[i][j] += ( gg + g_dens[k][l]); g_fock[i][k] -= (0.5 * gg * g_dens[j][l]); } } } }

23

twoel

Page 24: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

24

Serial Optimizations• Added additional sparsity tests.• Reduced calls to g by taking advantage of its 8-way

symmetry.• Replaced matrix multiplication and eigenvector solving

routines with BLAS and LAPACK.• Pre-compute lookup tables for use in g to reduce

calculations and total memory accesses.• Reduced memory accesses in inner loops of twoel by

taking advantage of input and output matrices being symmetric

• Parallelized twoel function using SWARM.

Page 25: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Serial Optimizations

Origina

l

Symmetr

y of g

()

BLAS/L

APACK

Precom

pute_x

000d

_g va

lues

Fock M

atrix S

ymmetr

y02468

1012141618

Serial Optimizations

Spee

dup

25

Page 26: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

26

Single Node Parallelization• SWARM

Create temp arrays and do a parallel array reduction• OpenMP:

Version 1: Atomic operationsVersion 2: Critical SectionVersion 3: SWARM method [not really OpenMP style]

Page 27: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

27

Single Node Parallelization

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31

02468

10121416182022

Speedup of OpenMP versions and SWARM

Dynamic,v1Dynamic,v2Dynamic,v3Guided,v1Guided,v2Guided,v3Static,v1Static,v2Static,v3SWARMIdeal

# Threads

Spee

dup

Page 28: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

Multi-Node Parallelization

16 32 64 128 256 512 1024 204810

100

1000

10000

SCF Multi-Node Execution Scaling

SWARMMPI

# Cores

Exec

utio

n Ti

me

(sec

onds

)

16 32 64 128 256 512 1024 2048

0.1

1

10

100

SCF Multinode Speedup

SWARMMPI

# Cores

Spee

dup

over

Sin

gle

Nod

e

28

Page 29: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

29

Key Learnings• Better loop scheduling/tiling needed to balance

parallelism• Better tiling needed to balance cache usage [not yet

done]• SWARM Asynchronous runtime natively supports better

scheduling/tiling than current MPI/OpenMPRstream will be used to automate the current hand-coded

decomposition• Static workload balance across nodes is not possible

[highly data dependent]Future work: Dynamic internode scheduling

Page 30: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

R-Stream• Automatic parallelization of loop codes

Takes sequential, “mappable” C (writing rules)• Has both scalar and loop + array optimizers• Parallelization capabilities

Dense: core of the DoE app codes (SCF, stencils)Sparse/irregular (planned): outer mesh computations

• Decrease programming effort to SWARMGoal: “push button” and “guided by user”User writes C, gets parallel SWARM

30

R-Stream

Loops

Parallel Distributed SWARM

Page 31: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

The Parallel Intermediate Language (PIL) Goals

An intermediate language for parallel computation Any-to-any parallel compilation

PIL can be the target of any parallel computation Once parallel computation is represented in PIL

abstraction, it can be retargeted to any supported runtime backend

Retargetable Possible Backends

SWARM/SCALE, OCR, OpenMP, C, CnC, MPI, CUDA, Pthreads, StarPU

Possible Frontends SPIL, HTAs, Chapel, Hydra, OpenMP, CnC

31

Page 32: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

PIL Recent Work Cholesky decomposition in PIL case study

Shows SCALE and OpenMP backend perform very similarly

PIL adds about 15% overhead to pure OpenMP implementation from ETI

Completed and documented the PIL API design Extended PIL to allow creation of libraries

We can provide or users can write reusable library routines Added built in tiled Array data structure

Provide automatic data movement of built in data structures

Designed new higher level language Structured PIL (SPIL)

Improves programmability of PIL32

Page 33: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

33

Information Repository• All of this information is available in more detail at the

Xstack wiki:http://www.xstackwiki.com

Page 34: X -Stack: Programming Challenges, Runtime Systems, and Tools Brandywine Team March 2013

E.T. International, Inc.

34

Acknowledgements• Co-PIs:

Benoit Meister (Reservoir)David Padua (Univ. Illinois) John Feo (PNNL)

• Other team members:ETI: Mark Glines, Kelly Livingston, Adam MarkeyReservoir: Rich LethinUniv. Illinois: Adam SmithPNNL: Andres Marquez

• DOESonia Sachs, Bill Harrod