programming heterogeneous, manycore machines: a runtime system's...

30
Programming heterogeneous, manycore machines: a runtime system's perspective Raymond Namyst University of Bordeaux Journées scientifiques SEPIA November 12 th , 2015 STORM INRIA Group INRIA Bordeaux Sud-Ouest

Upload: others

Post on 20-May-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Programming heterogeneous, manycore machines:

a runtime system's perspective Raymond Namyst

University of Bordeaux

Journées scientifiques SEPIA November 12th, 2015 STORM

INRIA Group INRIA Bordeaux Sud-Ouest

Page 2: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Evolution of Parallel Hardware

Raymond Namyst - 2

Multicore is a solid trend

•  Multicore chips are commonplace -  More performance = more cores -  Complex memory hierarchies -  Clusters can no longer be

considered as “flat sets of processors”

•  Designing scalable multicore architectures -  Non-coherent cache architectures?

•  Intel SCC •  IBM Cell/BE

-  Different memory technologies •  Intel KNL

High throughput (smaller) memory for stream processing

Page 3: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

What Programming Models for such machines?

Raymond Namyst - 3

Widely used, standard programming models

•  MPI -  Communication Interface -  Scalable implementations

exist already •  Was actually designed with

scalability in mind

•  OpenMP -  Directive-based, incremental

parallelization -  Well suited to symmetric

machines

•  Several efforts to make these models multicore-ready -  MPI

•  NUMA-aware buffer management

•  Efficient collective operations

•  Memory footprint

-  OpenMP •  NUMA-awareness, memory

affinity •  Tasks

Page 4: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Mixing OpenMP with MPI

Raymond Namyst - 4

Makes sense even on shared-memory machines

•  MPI address spaces must fit the underlying topology

•  Experimental platforms for tuning hybrid applications -  Topology-aware process

allocation

-  Customizable core/process ratio

-  # of OpenMP tasks independent from # of cores

•  MPC software (CEA/DAM) -  “Threadization” of MPI

+OpenMP programs

0 10 20 30 40 50 60

BT-MZ.C.32 SP-MZ.C.32

Exec

utio

n tim

e (s

ecs)

Impact of Thread distribution

Optimum Worst Default

0

20

40

60

80

64 32 16 8

Exec

utio

n tim

e (s

econ

ds)

Number of MPI processes

Impact of thread/process ratio

Page 5: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Then came heterogeneous computing

Raymond Namyst - 5

And it seems to be a solid trend…

•  Accelerators -  Nvidia & AMD GPUs

•  De facto adoption •  Concrete success stories

Speedups > 50 -  Intel Xeon Phi -  ARM Mali

•  Accelerators get more integrated -  Intel Ivy Bridge, Haswell -  AMD APUs

•  They all raise the same issues -  Cost of moving data

•  Even for so-called APUs -  Programming model

Page 6: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

The Quest for Programming Models

Raymond Namyst - 6

How shall we program hybrid machines?

•  Use well-known libraries when available -  BLAS routines, FFT kernels, stencils

•  Use directive-based languages -  OpenACC, HMPP, OpenMP 4.0 -  They can save you from:

•  Learning which type of memory coalescing is supported by a given card

•  Thinking about setting some arrays dimensions to 17 instead of 16

•  Searching for tradeoffs between cluster occupancy and register usage

•  Otherwise, fall back to CUDA, OpenCL, …

Page 7: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

The Quest for Programming Models

Raymond Namyst - 7

How shall we program heterogeneous clusters?

•  The hard hybrid way -  Combine different paradigms by

hand •  MPI +

{OpenMP/TBB} + {OpenCL/OpenACC}

-  Portability is hard to achieve •  Work distribution depends on

#GPU & #CPU per node… •  Needs aggressive autotuning

-  Currently used for building distributed parallel numerical kernels •  MAGMA, D-PLASMA, FFT

kernels M.

CPU

CPU

CPU

CPU M. *PU

M. *PU

Multicore

OpenMP TBB

Accelerators

MPI Cilk ?

OpenACC CUDA

OpenCL Ct ?

Page 8: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

The Quest for Programming Models

Raymond Namyst - 8

How shall we program heterogeneous clusters?

•  The uniform way -  Use high-level programming

languages to deal with network + multicore + accelerators

-  Increasing number of directive-based languages •  Use simple directives… and

good compilers! •  XcalableMP

PGAS approach •  OpenACC, OpenMP 4.0, OmpSs

-  Much better potential for composability… •  If compiler is clever!

M.

CPU

CPU

CPU

CPU M. *PU

M. *PU

Multicore

OpenMP

Accelerators

?

HMPP

OpenACC OpenMPC

XMP

Page 9: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

The Quest for Programming Models

Raymond Namyst - 9

Current trend: directive-based programming

•  OpenMP 4.0 introduces new directives for accelerators -  Task-based parallelism

•  But -  We start from a sequential code, and ask the compiler to generate

efficient parallel code… -  Data transfers and tasks’ targets are mostly explicit

•  A clever runtime system could do much better

#pragma omp target device(0) map(tofrom:A)

#pragma omp parallel for

for (i=0; i<N; i++)

A[i] = f(A[i]);

Page 10: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Parallel Compilers

HPC Applications

Runtime system

Operating System

CPU

Parallel Libraries

What dynamic runtime systems can do for you

Raymond Namyst - 10

Toward “portability of performance”

•  Do dynamically what can’t be done statically -  Load balance -  React to hardware feedback -  Autotuning, self-organization

•  Extract knowledge from upper layers -  Structure of parallelism -  Let the runtime system take

control! GPU …

Page 11: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Illustration of a widespread approach: StarPU

Raymond Namyst - 11

A runtime system for heterogeneous architectures

•  Rational -  Dynamically schedule tasks

on all processing units •  See a pool of

heterogeneous processing units

-  Avoid unnecessary data transfers between accelerators •  Software VSM for

heterogeneous machines

A = A+B

M.

CPU

CPU

CPU

CPU M. GPU

M. GPU

CPU

CPU

CPU

CPU

M. A

B B

M. GPU

M. GPU

Page 12: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

CPU

Parallel Compilers

HPC Applications

StarPU

Drivers (CUDA, OpenCL)

Parallel Libraries

Overview of StarPU

Raymond Namyst

Maximizing PU occupancy, minimizing data transfers

•  Accept tasks that may have multiple implementations -  Potential inter-dependencies

•  Leads to a directed acyclic graph of tasks

•  Data-flow approach

•  Open, general purpose scheduling platform -  Scheduling policies = plugins

GPU MIC

(ARW, BR, CR)

f cpu gpu spu

- 12

Page 13: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Dealing with heterogeneous architectures

Raymond Namyst - 13

Performance prediction

•  Task completion time estimation -  History-based -  User-defined cost function -  Parametric cost model

•  Can be used to improve scheduling -  E.g. Heterogeneous Earliest

Finish Time

time

cpu #3

gpu #1

cpu #2

cpu #1

gpu #2

Page 14: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Dealing with heterogeneous architectures

Raymond Namyst - 14

Performance prediction

•  Data transfer time estimation -  Sampling based on off-line

calibration

•  Can be used to -  Better estimate overall exec

time -  Minimize data movements

time

cpu #3

gpu #1

cpu #2

cpu #1

gpu #2

Page 15: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Mixing PLASMA and MAGMA with StarPU

Raymond Namyst - 15

With University of Tennessee & INRIA HiePACS

•  Cholesky decomposition -  5 CPUs (Nehalem) + 3 GPUs

(FX5800) -  Efficiency > 100%

0 100 200 300 400 500 600 700 800 900

1000

5120 15360 25600 35840 46080

Perfo

rman

ce (G

flop/

s)

Matrix order

4 GB

3 GPUs + 5 CPUs3 GPUs2 GPUs1 GPU

Page 16: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Mixing PLASMA and MAGMA with StarPU

Raymond Namyst - 16

With University of Tennessee & INRIA HiePACS

•  QR decomposition -  16 CPUs (AMD) + 4 GPUs (C1060)

0

200

400

600

800

1000

0 5000 10000 15000 20000 25000 30000 35000 40000

Gflo

p/s

Matrix order

4 GPUs + 16 CPUs4 GPUs + 4 CPUs3 GPUs + 3 CPUs2 GPUs + 2 CPUs1 GPUs + 1 CPUs

MAGMA

+12 CPUs ~200 GFlops

(although 12 CPUs alone ~150 Gflops)

Page 17: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Mixing PLASMA and MAGMA with StarPU

Raymond Namyst - 17

« Super-Linear » efficiency in QR? •  Kernel efficiency

-  sgeqrt •  CPU: 9 Gflops GPU: 30 Gflops Ratio: x3

-  stsqrt •  CPU: 12 Gflops GPU: 37 Gflops Ratio: x3

-  somqr •  CPU: 8.5 Gflops GPU: 227 Gflops Ratio: x27

-  Sssmqr •  CPU: 10 Gflops GPU: 285 Gflops Ratio: x28

•  Task distribution observed on StarPU -  sgeqrt: 20% of tasks on GPUs -  Sssmqr: 92.5% of tasks on GPUs

•  Heterogeneous architectures are cool! J

Page 18: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Scheduling for Power Consumption

Raymond Namyst 18

FP7 project

•  Power consumption information can be retrieved from OpenCL devices -  clGetEventProfilingInfo

•  CL_PROFILING_POWER_CONSUMED

-  Implemented by Movidius multicore accelerator

•  Autotuning of power models similar to performance

•  Scheduling heuristic inspired by MCT -  Actually, a subtle mix with MCT

is possible Consumption

cpu #3

gpu #1

cpu #2

cpu #1

gpu #2

Task consumption

idle consumption

Page 19: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Theoretical bound Can we perform a lot better?

•  Express set of tasks (and dependencies) as Linear Problem -  With heterogeneous task durations, and heterogeneous resources

Raymond Namyst - 19

Page 20: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Theoretical bound Can we perform a lot better?

•  Express set of tasks (and dependencies) as Linear Problem -  With heterogeneous task durations, and heterogeneous resources

Raymond Namyst - 20

Page 21: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

So, is there room for improvement?

Raymond Namyst - 21

•  The quest for “good” granularity -  Adaptive granularity

•  Divisible tasks •  Autotuning

•  Automatic selection of code variants -  Database of various algorithms -  Different algorithms for different problem sizes

•  All the magic done by the scheduler (scheduling, prefetching, flushing) makes it harder to understand (bad) performance -  Where does this disappointing behavior come from?

•  Need for tighter compiler/runtime system integration!

Page 22: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Integrating runtime systems in languages

Raymond Namyst - 22

Directive-based languages

•  Directive-based languages on top of dynamic runtime systems -  OpenMP 4

•  Via KaStar Inria initiative -  OpenACC

•  Idea -  Use a compiler to generate

accelerator code -  Use runtime system to

achieve dynamic load balancing

Adaptation layer

StarPU

CPU GPU …

OpenACC/OpenMP Application

// Get rid of such explicit data transfers! // #pragma acc region copy(A[0:N-1][0:M-1]) { for (int i=0; i<N;++i) { … } }

Page 23: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Evolution of Parallel Hardware

Raymond Namyst - 23

Exascale Parallel Machines

•  SuperComputers expected to reach Exascale (1018 flop/s) by 2020

•  From the programmer point of view, the biggest change will probably come from node architecture -  High number of cores -  Powerful SIMD units -  Hybrid systems will be commonplace

•  Extreme parallelism -  Total system concurrency is estimated to reach O(109)

•  Including O(10) to O(100) to hide latency -  Embarrassingly parallel hardware

•  Do we really want to assign different tasks to each individual computing unit?

Page 24: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

How will we program these machines?

Raymond Namyst - 24

From a programming point of view

•  Billions of threads will be necessary to occupy exascale machines -  Express massive parallelism -  SIMD/vectorization is essential

-  Toward new extreme programming models? •  Note: OpenCL-like approaches are good at expressing extreme

parallelism Start from pure, extreme parallelism…

then map over a restricted set of resources E.g. cores, vector units, streaming processors

•  Reflects constraints of manycore architectures No global synchronization Need to feed large vectorization units/numerous HW threads

Page 25: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

How will we program these machines?

Raymond Namyst - 25

From a runtime system’s perspective

•  No global, consistent view of node’s state -  Local algorithms -  Hierarchical coordination/load balance -  Spawn coarse grain tasks over subsets of cores

•  Reuse and couple existing codes/algorithms -  Multi-scale, Multi-physics applications are welcome!

•  Great opportunity to exploit multiple levels of parallelism

•  It’s all about composability! -  Probably the biggest upcoming challenge for runtime systems

•  Hybridization will mostly be indirect (linking libraries)

Page 26: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

How will we program these machines?

Raymond Namyst - 26

From a pragmatic point of view

•  Cluster nodes will contain many cores… -  But not every algorithm/problem resolution can scale that far L

•  Co-scheduling parallel tasks simultaneously can help

Page 27: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Co-scheduling multiple parallel tasks

Raymond Namyst - 27

•  Code composability and tasks co-scheduling raise similar issues

•  Libraries are typically not aware of each other -  Resource over-subscription

•  Each library typically allocates and binds one thread per core •  Inter-thread cache interference

•  Even if a common runtime system is used underneath -  Resource negotiation between libraries is not a trivial task

Page 28: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Context B

Scheduling contexts

Raymond Namyst - 28

Toward code composability

•  Lightweight virtualization -  Multiple parallel libraries can

run simultaneously -  Each context features its own

scheduler

•  Contexts may expand and shrink -  Hypervised approach

•  Maximize overall throughput •  Minimize completion time

•  Successfully used inside linear algebra solvers -  QR-MUMPS

Context A

CPU GPU

Page 29: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Towards a common BASIS for runtime systems?

Raymond Namyst - 29

•  There is currently no consensus on a common runtime system… -  Seen from outer space, many runtime systems offer similar

functionalities! •  OCR initiative, INTERTWINE EU Project

•  But we could certainly agree on a common “micro-runtime” basis

Common Runtime System Basis

Topology Discovery

Memory Management I/O

OpenMP Intel TBB StarPU

MKL MAGMA

MPI OpenCL PGAS

FFTW

Resource Negociation

Page 30: Programming heterogeneous, manycore machines: a runtime system's …Jean-Marc.Pierson/cariboost_files/... · 2015-11-25 · Programming heterogeneous, manycore machines: a runtime

Major Challenges are ahead…

We are living exciting times!

more information at http://www.inria.fr/en/teams/storm