hetroomp: openmp for hybrid load balancing across...

29
HetroOMP: OpenMP for Hybrid Load Balancing Across Heterogeneous Processors Vivek Kumar 1 , Abhiprayah Tiwari 1 , Gaurav Mitra 2 1 IIIT Delhi, New Delhi, India 2 Texas Instruments, Sugarland, Texas, USA

Upload: others

Post on 11-Oct-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

HetroOMP: OpenMP for Hybrid Load Balancing Across

Heterogeneous Processors

Vivek Kumar1, Abhiprayah Tiwari1, Gaurav Mitra2

1 IIIT Delhi, New Delhi, India 2 Texas Instruments, Sugarland, Texas, USA

Page 2: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Outline

•  Introduction •  Contributions •  Motivating analysis •  Insights and approach •  Implementation •  Experimental Evaluation •  Summary

2 HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Page 3: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Accelerator Programming

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Introduction

3

Directive-based

Language-based

Page 4: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Accelerator Programming

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Introduction

4

Pragmas for multicore programming

Supported on wide range of processors and accelerators

Supports both data and task parallelism

Pragmas for accelerator

programming

Can I use both multicore and accelerator together?

Page 5: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Hybrid Parallelism

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Introduction

5

Mergesort: recursive call with divide-and-concur parallelism

Mergesort – can I use both multicore

and accelerator together?

Multicore Accelerator

Page 6: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Hybrid Parallelism in OpenMP (Attempt #1)

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Introduction

6

1. int THRESHOLD=/*some value*/;2. void mergesort(int left, int right){3.  if(right-left > THRESHOLD) {4.  int mid = left + (left+right)/2;5.  #pragma omp task untied \6.  firstprivate(left,mid) hetro(A:N)7.  mergesort(left, mid);8.  mergesort(mid+1, right);9.  #pragma omp taskwait10.  merge(left, mid, right);11.  } else {12.  sequentialSort(left, right);13.  }14. }15. void main() {16.  #pragma omp target map(to:N) \17.  map(tofrom:A[0:N]) 18.  #pragma omp parallel \19.  firstprivate(A:N) hetro20.  #pragma omp single21.  mergesort(0, size-1);22. }

No... This will run only on my

multicores

Mergesort – can I use both multicore

and accelerator together?

Multicore Accelerator

Page 7: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Hybrid Parallelism in OpenMP (Attempt #2)

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Introduction

7

1. int THRESHOLD=/*some value*/;2. void mergesort(int left, int right){3.  if(right-left > THRESHOLD) {4.  int mid = left + (left+right)/2;5.  #pragma omp task untied \6.  firstprivate(left,mid) hetro(A:N)7.  mergesort(left, mid);8.  mergesort(mid+1, right);9.  #pragma omp taskwait10.  merge(left, mid, right);11. } else {12.  sequentialSort(left, right);13.  }14. }15. void main() {16.  #pragma omp target map(to:N) \17.  map(tofrom:A[0:N]) 18.  #pragma omp parallel \19.  firstprivate(A:N) hetro20.  #pragma omp single21.  mergesort(0, size-1);22. }

Mergesort – can I use both multicore

and accelerator together?

No... This will run only on my

accelerator

Multicore Accelerator

Page 8: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Hybrid Parallelism in OpenMP (How?)

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Introduction

8

•  Manually partitioning the workload between multicore and accelerator? –  Two different kernels, one each for host and device

•  No serial elision – different behavior if directive disabled

–  What should be the optimal partition size? •  Host and accelerator have different performance •  Communication latency between host and device •  There could be several layers of parallelism (NP-hard)

I can only use either host or device.. One of the processing unit will

remain idle..

Page 9: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Research Questions

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Introduction

9

1.  Can we extend OpenMP accelerator model to support hybrid parallelism without affecting programmer’s productivity?

2.  Can we design a high performance hybrid runtime for such an extension?

Page 10: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Contributions ✔ HetroOMP programming model Extension to OpenMP accelerator model for enabling hybrid parallelism across host and device

✔ Lightweight runtime implementation That uses hybrid work-stealing runtime for dynamic load balancing over an

ARM+DSP based MPSoC

✔ Detailed performance study Using several data and task parallel benchmarks

✔ Results That demonstrates HetroOMP achieves significant speedup over OpenMP

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019 10

Page 11: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Motivating Analysis

11HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Page 12: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

MPSoC used in this Study: TI Keystone II

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Motivating Analysis

•  Architecture –  4 ARM + 8 DSP cores –  Cache coherency among ARM cores –  No cache coherency among DSPs /

between DSP and ARM –  Shared memory w/ different address spaces

•  Pointer conversion needed bw. ARM & DSP –  L1 cache line sizes different at ARM (64

bytes) and DSP (128 bytes) –  C library for DSPs doesn’t support

concurrency •  Concurrent hardware queues and hardware

semaphores

12

Page 13: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

MPSoC used in this Study: TI Keystone II

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Motivating Analysis

•  Existing programming models –  OpenMP accelerator model [1] –  HC-K2H (Habanero C) [2]

•  No serial elision •  Hybrid ARM/DSP work-stealing scheduler

0

1

2

3

4

OpenMP HC-K2H OpenMP HC-K2H HC-K2H ARM_Only DSP_Only Hybrid

MergeSort

Spe

edup

ove

r Seq

uent

ial

exec

utio

n (A

RM

)

Hybrid work-stealing performance worse

than ARM_Only

[1] Stotzer et al., OpenMP on the low-power TI Keystone-II ARM/DSP system-on-chip, IWOMP 2013 [2] Kumar et al., Heterogeneous work-stealing across ARM and DSP cores, HPEC 2015

13

Page 14: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Motivating Analysis

14

MPSoC used in this Study: TI Keystone II •  Drawbacks in HC-K2H’s hybrid work-stealing

... ARM

work-stealing runtime …

DSP work-stealing

runtime

LIFO steal – poor locality

Concurrent queues – Either of the ARM or

DSP cores could directly steal

Cache incoherent DSPs require explicit cache write backs at

each task synchronization

points

FIFO steal by double-ended queue (deque)

Page 15: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Insights

•  OpenMP should support hybrid execution across host and accelerator

•  Hybrid work-stealing runtime at DSP –  Should improve locality by supporting FIFO steals –  Should not perform costly cache writebacks at all task

synchronization points

Motivating Analysis

15HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Page 16: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

•  Hybrid programming –  HetroOMP programming model

✔ Simple extension to OpenMP accelerator model ✔ hetro clause to define the scope of hybrid execution

•  Hybrid execution using work-stealing ✔ Non-concurrent private deque [1] on L2 cache of DSP

✔ LIFO push and pop, whereas FIFO steals (improved locality) ✔ Sender initiated steal operations at DSP can keep track if thief is

cache coherent ✔ Cache writeback only if a task was sent to a cache incoherent core

Approach

16HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

[1] Acar et al., Scheduling Parallel Programs by Work-Stealing with Private Deques, PPoPP 2013

Page 17: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Implementation

17HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Page 18: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

HetroOMP Programming Model

•  Usage of the clause “hetro” 1.  #pragma omp parallel hetro

•  Indicating the scope of hybrid execution

2.  #pragma omp task hetro(Var1:Count1, ...)•  Name and count of all writable type share variables

–  Var should only be a pointer type –  Count is the number of elements (e.g., array size)

3. #pragma omp for schedule(hetro, chunks)•  Hybrid execution of loop iterations

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Implementation

18

Page 19: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

HetroOMP Programming Model

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Implementation

19

1.   2. void mergesort(int left, int right){3.  if(right-left > THRESHOLD) {4.  int mid = left + (left+right)/2;5.  #pragma omp task untied \6.  firstprivate(left,mid)7.  mergesort(left, mid);8.  mergesort(mid+1, right);9.  #pragma omp taskwait10.  merge(left, mid, right);11. } else {12.  sequentialSort(left, right);13.  }14. }15. void main() {16.  #pragma omp target map(to:N) \17.  map(tofrom:A[0:N]) 18.  #pragma omp parallel \19.  firstprivate(A:N)20.  #pragma omp single21.  mergesort(0, size-1);22. }

Task granularity to avoid false sharing between host and

device

“hetro” clause to define the scope of hybrid execution

“hetro” clause listing the shared writable variables

•  Parallel Mergesort that can perform hybrid execution over both host and device hetro(A:N)

hetro

int THRESHOLD=omp_cache_grain()/INT_SIZE;

Page 20: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

HetroOMP Programming Model •  Avoiding false sharing

between host and device

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Implementation

20

1.  int THRESHOLD=omp_cache_grain()/INT_SIZE;2. void mergesort(int left, int right){3.  if(right-left > THRESHOLD) {4.  int mid = left + (left+right)/2;5.  #pragma omp task untied \6.  firstprivate(left,mid) hetro(A:N)7.  mergesort(left, mid);8.  ......

–  Granularity • #pragma omp task

–  Loop tiling • #pragma omp for

–  Padding •  Worst case

Page 21: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Implementation

21

HetroOMP Runtime

… DSP

work-stealing runtime ...

ARM work-stealing

runtime

•  OMP-to-X [1] translator modified to generate runtime code •  Hybrid work-stealing runtime

–  ARM work-stealing runtime same as HC-K2H –  Private deque (L2 cache) based DSP work-stealing runtime

Sender initiated steals – cache

writebacks only if task was sent to cache incoherent

core

Thief requests DSP to send a task

Improved locality

[1] Grossman et al., OpenMP as a High-Level Specification Language for Parallelism, IWOMP 2016

Page 22: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Experimental Evaluation

22HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Page 23: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Methodology

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Experimental Evaluation

23

•  Benchmarks –  Nested task and taskwait

•  Fibonacci •  Matmul •  Knapsack •  MergeSort •  Heat

–  Parallel for •  Rodinia suite

–  BFS –  Hotspot –  Srad –  LUD –  B+Tree

ARM_Only (4 cores)

DSP_Only (8 cores)

Hybrid (12 cores)

OpenMP HC-K2H

HetroOMP

Runtime & Configurations

Page 24: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Speedup (MergeSort)

0

1

2

3

4

5

6

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Experimental Evaluation

24

ARM_Only DSP_Only Hybrid

Spe

edup

ove

r Seq

uent

ial

exec

utio

n (A

RM

)

Page 25: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Geomean Speedup (All Tasking Types)

0

1

2

3

4

5

6

7

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Experimental Evaluation

25

ARM_Only DSP_Only Hybrid

Geo

mea

n sp

eedu

p ov

er

Seq

uent

ial e

xecu

tion

(AR

M)

Note: we were unable to run Heat-OpenMP-DSP_Only

Page 26: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Geomean Speedup (All Parallel for)

0

1

2

3

4

5

6

7

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Experimental Evaluation

26

ARM_Only DSP_Only Hybrid

Geo

mea

n sp

eedu

p ov

er

Seq

uent

ial e

xecu

tion

(AR

M)

Note: we were unable to run LUD-OpenMP-DSP_Only

Page 27: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Summary •  OpenMP accelerator model doesn’t support

hybrid execution across host and device –  Wastage of CPU resources

•  HetroOMP –  Simple extension to OpenMP accelerator model for

supporting hybrid execution –  Uses hybrid work-stealing runtime

•  ARM work-stealing runtime built on traditional design (Cilk) •  DSP work-stealing runtime uses private deques allocated on

L2 cache instead of inbuilt hardware queues –  Better locality –  Fewer cache writebacks for task synchronization

–  Results •  HetroOMP achieves geometric mean speedup of 3.6x over

default OpenMP accelerator model

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Summary

27

Page 28: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

Backup Slides

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Page 29: HetroOMP: OpenMP for Hybrid Load Balancing Across ...vivkumar.github.io/papers/IWOMP2019_slides.pdf · • OpenMP accelerator model doesn’t support hybrid execution across host

HetroOMP Runtime

HetroOMP: OpenMP for Hybrid Load Balancing | Kumar et al. | IWOMP 2019

Implementation

29

1.  int THRESHOLD=omp_cache_grain()/INT_SIZE;2. void mergesort(int left, int right){3.  .....4.  #pragma omp task untied \5.  firstprivate(left,mid) hetro(A:N)6.  ......7.  #pragma omp taskwait8. }9. void main() {10.  ..... 11.  #pragma omp parallel \12.  firstprivate(A:N) hetro13.  ......14. }

1. int THRESHOLD= DSP_CACHE_LINE / INT_SIZE;

1. finish = new_scope(A, INT_SIZE * N);2. finish->incoherent_core_stolen = false; 3.  if (ARM_CORE) { /*push task on ARM deque*/ }4.  if (DSP_CORE) { 5.  /*push task on DSP private deque (on L2)*/ 6.  if(/*DSP sending task to DSP/ARM){7.  finish->incoherent_core_stolen = true;8.  }9. }

1.  while (/*tasks pending in current finish*/) {2.  if(/* tasks available on my deque */) {3.  if(/*DSP helping DSP/ARM || ARM helping DSP*/){4.  finish->incoherent_core_stolen = true;5.  }6.  /* pop task from my deque and execute*/ 7.  } else { /* steal tasks and execute */ }8. }9.  if(finish->incoherent_core_stolen == true) {10.  cacheWBInv(finish->writable_sharedVars()); 11. }

1. /*initialize A at device and start hybrid run*/