23
20th Euromicro International Conference on Parallel, Distributed and Network-Based Special Session on Energy-aware Systems Saving Energy in the LU Factorization with Partial Pivoting on Multi-Core Processors Pedro Alonso 1 , Manuel F. Dolz 2 , Francisco D. Igual 2 , Rafael Mayo 2 , Enrique S. Quintana-Ort 2 1 2 February 15–17, 2012, Garching bei M¨ unchen (Germany)

Saving Energy in the LU Factorization with Partial

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Saving Energy in the LU Factorization with Partial

20th Euromicro International Conference onParallel, Distributed and Network-Based

Special Session on Energy-aware Systems

Saving Energy in the LU Factorization with Partial Pivotingon Multi-Core Processors

Pedro Alonso1, Manuel F. Dolz2, Francisco D. Igual2,Rafael Mayo2, Enrique S. Quintana-Ort2

1 2

February 15–17, 2012, Garching bei Munchen (Germany)

Page 2: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Motivation

High performance computing:

Optimization of algorithms applied to solve complex problems

Technological advance ⇒ improve performance:

Higher number of cores per socket (processor)

Large number of processors and cores ⇒ High energy consumption

Methods, algorithms and techniques to reduce energy consumptionapplied to high performance computing

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 3: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Outline

1 Introduction

2 LU Factorization with Partial PivotingThe right-looking algorithmParallelization

3 Accommodating Energy-Aware Techniques into SuperMatrixEA1: Reduce operation frequency when there are no ready tasksEA2: Remove polling when there are no ready tasks

4 Experimental resultsEnvironment setupResults

5 Summary and conclusions

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 4: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Introduction

Scheduling tasks of dense linear algebra algorithms

Examples: Cholesky, QR and LU factorizations

Energy saving tools available for multi-core processors

Example: Dynamic Voltage and Frequency Scaling (DVFS)

Scheduling tasks + DVFS

⇓Power-aware scheduling on multi-core processors

Current strategies:

“Slack Reduction”: Reduce the frequency of cores that will execute non-critical tasksto decrease idle times without sacrifying total performance of the algorithm

“Race-to-idle”: Execute all tasks at highest frequency to “enjoy” longer inactiveperiods

⇓Energy savings

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 5: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Introduction

Scheduling tasks of dense linear algebra algorithms

Examples: Cholesky, QR and LU factorizations

Energy saving tools available for multi-core processors

Example: Dynamic Voltage and Frequency Scaling (DVFS)

Scheduling tasks + DVFS

⇓Power-aware scheduling on multi-core processors

Current strategies:

“Slack Reduction”: Reduce the frequency of cores that will execute non-critical tasksto decrease idle times without sacrifying total performance of the algorithm

“Race-to-idle”: Execute all tasks at highest frequency to “enjoy” longer inactiveperiods

⇓Energy savings

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 6: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

The right-looking algorithmParallelization

Dense linear algebra operations

LU factorization with partial pivoting

PA = LU

A ∈ Rn×n nonsingular matrixP ∈ Rn×n permutation matrix

L/U ∈ Rn×n unit lower/upper triangular matrices

We consider a partitioning of matrix A into blocks of size b × b

For numerical stability, permutations are introduced to prevent operationwith small pivot elements

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 7: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

The right-looking algorithmParallelization

LU factorization using FLAME notation

n(·) stands for the number of columns of itsargument

trilu(·) denotes the matrix consisting to theelements in lower triangular with diagonalreplaced by ones

pivoting omitted for simplicity

Some cost details

Blocked algorithm performs 2n3/3 +O(n2) flops

Most of them cast in terms of gemm operations

Algorithm: A := LUP blk(A)

Partition A →(

ATL ATRABL ABR

)where ATL is 0 × 0

while n(ATL) < n(A) doDetermine block size bRepartition

(ATL ATRABL ABR

)→

A00 A01 A02A10 A11 A12A20 A21 A22

where A11 is b × b(A11A21

):= LUP unb

(A11A21

)A12 := trilu(A11)

−1A12 (trsm)A22 := A22 − A21A12 (gemm)

Continue with

(ATL ATRABL ABR

)←

A00 A01 A02A10 A11 A12A20 A21 A22

endwhile

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 8: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

The right-looking algorithmParallelization

Parallelization

Parallelization not trivial at code level!

We use SuperMatrix runtime to execute libflame routines:

Operations are not executed in the order they appear in code ⇒ Control-flow Parallelism

SuperMatrix schedules execution respecting data dependencies ⇒ Data-flow parallelism

SuperMatrix proceeds in two stages:

1 A symbolic execution produces a DAG containing dependencies

2 DAG dictates the feasible orderings in which task can be executed

T 43

G 22T 21

M 54

M 51

M 53

M 43

T 52

T 42

M 31

M 32T 32

T 51

T 54 G 55

M 41

M 21T 53

M 42

T 41

T 31

M 52

G 11 G 33

G 44

Figure: DAG with a matrix consisting of 5× 5 blocks

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 9: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

The right-looking algorithmParallelization

SuperMatrix runtime:

Queue of ready

tasks (no dependencies)

Queue of pending

tasks + dependencies

(DAG)

......

Algorithm

Symbolic

Analysis

Dispatch

Worker Th. 1

Worker Th. 2

Worker Th. p

Core 1

Core 2

Core p

Basic scheduling:1 Initially only one a task in ready queue

2 A thread acquires a task of the ready queue and runs the corresponding job

3 Upon completion checks tasks which were in the pending queue moving to ready if theirdependencies are satisfied.

Problem!

Idle threads (one per core) continuously check the ready list for workBusy-wait or polling ⇒ Energy consumption!

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 10: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

The right-looking algorithmParallelization

SuperMatrix runtime:

Queue of ready

tasks (no dependencies)

Queue of pending

tasks + dependencies

(DAG)

......

Algorithm

Symbolic

Analysis

Dispatch

Worker Th. 1

Worker Th. 2

Worker Th. p

Core 1

Core 2

Core p

Basic scheduling:1 Initially only one a task in ready queue

2 A thread acquires a task of the ready queue and runs the corresponding job

3 Upon completion checks tasks which were in the pending queue moving to ready if theirdependencies are satisfied.

Problem!

Idle threads (one per core) continuously check the ready list for workBusy-wait or polling ⇒ Energy consumption!

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 11: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

EA1: Reduce operation frequency when there are no ready tasksEA2: Remove polling when there are no ready tasks

Energy-Aware Techniques into SuperMatrix

Modern Linux distributions leverage DVFS: “cpufreq-utils”

Increase/reduce operation frequency of cores

Governors: control operation frequency

performance frequency is always fixed to the highest

ondemand frequency is controlled by cpufreq kernel module, sets the highestfrequency when core is loaded and the lowest when core is idle

userspace frequency is controlled by user

Basic idea:

Dependencies between tasks ⇒ idle periods

Idle periods ⇒ can be exploited to save energy

We consider Race-to-idle Algorithm. Why?

Current processors are quite efficient at saving power when idle

Power of idle core is much smaller than power in working periods

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 12: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

EA1: Reduce operation frequency when there are no ready tasksEA2: Remove polling when there are no ready tasks

EA1: Reduce operation frequency when there are no ready tasks

Objective ⇒ Do a more efficient Race-to-Idle technique

Is there a ready task for a polling thread in the ready list?

No: runtime immediately sets the operation frequency of the associated core to the lowestpossible

Yes: frequency is raised back to the highest and task is executed by the thread

Settings:

Linux governor is set to userspace: frequency is controlled by SuperMatrix

Experiments on an 6128 AMD (8-core):

DVFS AMD PowerNow! technology allows to control frequency at core level!

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 13: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

EA1: Reduce operation frequency when there are no ready tasksEA2: Remove polling when there are no ready tasks

EA2: Remove polling when there are no ready tasks

Objective ⇒ Replace busy-waits by idle-waits

Is there a ready task for a polling thread in the ready list?

No: the thread blocks/suspends itself in a POSIX semaphore by calling to sem wait()

Yes:1 Thread acquires and executes the task2 Updates dependencies: moves k tasks from pending queue to ready queue3 Thread activates k − 1 sleeping threads to attend ready tasks by calling k − 1 times

to sem post()

Settings:

Linux governor is set to ondemand: highest frequency when working, and lowest when idle

POSIX semaphores to allow suspension states for non working threadsIdle-wait ⇒ Low energy consumption

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 14: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

EA1: Reduce operation frequency when there are no ready tasksEA2: Remove polling when there are no ready tasks

40

50

60

70

80

90

100

110

120

0 5 10 15 20 25 30

Pow

er(W

att

s)

Time (s)

Power for different thread activities

MKL dgemm at 2.0 GHzPolling at 2.0 GHz

Polling at 800 MHzBlocking at 800 MHz

MKL dgemm at 2.0 GHz: 97-100 W

Polling at 2.0 GHz: 93-97 W

Polling at 800 MHz: 83-88 W

Blocking at 800 MHz: 49-55 W

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 15: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Environment setupResults

Experimental results

Environment setup:

8-core AMD 6128 processor (2.0 GHz) with 24 Gbytes of RAM

Discrete collection of frequencies: {2.0, 1.5, 1.2, 1.0, 0.8} GHz

Linux Ubuntu 10.04

BLAS and LAPACK implementations from MKL 10.2.4

SuperMatrix runtime in libflame v5.0-r5587

Two energy saving techniques: EA1+EA2

Benchmark algorithm:

LU with partial pivoting

FLASH LU piv routine ⇒ blocked right-looking variant of LU factorization

Block size: b = 512

Matrix size ranges from 2,048 to 12,288

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 16: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Environment setupResults

Environment setup

Power measurements:

Internal DC powermeter

ASIC directly attached to the lines connecting the power supply unit and the motherboards(chipset+processors)

Operation frequency 25 Hz ⇒ 25 samples/sec.

PowerSupplyUnit

GPU

PCI−Express

Motherboard

ComputerUSB

Measurement

SoftwareInternal

Power Meter

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 17: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Environment setupResults

Experiments

Evaluation:

1 We evaluate the existence and length of idle periods during the computation of the LUfactorization

2 We measure the actual gains that can be attained by our energy-aware approaches with 3

versions of the SuperMatrix runtime:

Original runtime (performance)

EA1: Reduces operation frequency during polling periods (userspace)

EA2: Integrates semaphores to block idle threads and avoid polling (ondemand)

EA1+EA2 (userspace)

⇒ Each experiment was repeated 30 times and average values of energy consumption werereported

⇒ Maximum coefficient of variation was lower than 0.8 %

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 18: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Environment setupResults

Thread activity during the execution of the LU factorization with partial pivoting

0

20

40

60

80

100

20

48

30

72

40

96

51

20

61

44

71

68

81

92

92

16

10

24

0

11

26

4

12

28

8

%o

fto

tal

tim

e

Matrix size (n)

#Threads running concurrently

8

7

6

5

4

3

2

1

For small problem sizes, 53 % of time there is a single active thread and only 9 % of time allthreads are performing work

For large problem sizes, 26 % of time there is a single active thread and only 74 % of time allthreads are performing work

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 19: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Environment setupResults

Impact on and relative execution time of LU factorizationwith partial pivoting using the energy-aware techniques

0

5

10

15

20

25

30

35

20

48

30

72

40

96

51

20

61

44

71

68

81

92

92

16

10

24

0

11

26

4

12

28

8

Tim

e(s

)

Matrix size (n)

Absolut time

SuperMatrixSuperMatrix with EA1SuperMatrix with EA2

SuperMatrix with EA1+EA2

0.8

0.85

0.9

0.95

1

1.05

1.1

1.15

1.2

20

48

30

72

40

96

51

20

61

44

71

68

81

92

92

16

10

24

0

11

26

4

12

28

8

%Im

pa

cto

nti

me

Matrix size (n)

Relative time w.r.t. the original runtime

SuperMatrix with EA1SuperMatrix with EA2

SuperMatrix with EA1+EA2

These techniques introduce a minimal overhead in execution time

Longer execution time, due to the period required to “wake-up” blocked threads

Increase of 2.5 % for the smallest problem sizes, for other sizes there is no difference

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 20: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Environment setupResults

Impact on absolute and relative consumption of LU factorizationwith partial pivoting using the energy-aware techniques

0

0.5

1

1.5

2

2.5

20

48

30

72

40

96

51

20

61

44

71

68

81

92

92

16

10

24

0

11

26

4

12

28

8

En

erg

y(W

h)

Matrix size (n)

Absolut energy

SuperMatrixSuperMatrix with EA1SuperMatrix with EA2

SuperMatrix with EA1+EA2

0.8

0.85

0.9

0.95

1

1.05

1.1

1.15

1.2

20

48

30

72

40

96

51

20

61

44

71

68

81

92

92

16

10

24

0

11

26

4

12

28

8

%Im

pa

cto

nen

erg

yMatrix size (n)

Relative energy w.r.t. the original runtime

SuperMatrix with EA1SuperMatrix with EA2

SuperMatrix with EA1+EA2

For smallest problem sizes, the number of tasks is relatively low compared with the number

of threads

Produces longer idle periods during the execution the algorithm⇒ Energy savings

EA1 potentially leads to savings of 2 % and 5 % when using EA2 for largest problem sizes

The combination of both techniques produce similarenergy-savings than as the use only of EA2

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 21: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Environment setupResults

Impact on absolute and relative execution application consumption of LU factorizationwith partial pivoting using the energy-aware techniques

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

20

48

30

72

40

96

51

20

61

44

71

68

81

92

92

16

10

24

0

11

26

4

12

28

8

En

erg

ya

pp

lica

tio

n(W

h)

Matrix size (n)

Absolut energy application

SuperMatrixSuperMatrix with EA1SuperMatrix with EA2

SuperMatrix with EA1+EA2

0.8

0.85

0.9

0.95

1

1.05

1.1

1.15

1.2

20

48

30

72

40

96

51

20

61

44

71

68

81

92

92

16

10

24

0

11

26

4

12

28

8

%Im

pa

cto

nen

erg

ya

pp

lica

tio

nMatrix size (n)

Relative energy application w.r.t. the original runtime

SuperMatrix with EA1SuperMatrix with EA2

SuperMatrix with EA1+EA2

New metric ⇒ Application consumption

To obtain energy consumption values subtract idle power (75W) for each result:

E = (P − 75) · t

Energy gains considering only application using EA2 and EA1+EA2 range from 22 % for thesmallest sizes to 7 % for the largest problem sizes.

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 22: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Summary and conclusions

Some conclusions:

Idle periods appear when executing algorithms with data dependencies

Race-to-Idle: Current processors are quite good saving power when idle, so it’s generallybetter to run as fast as possible to produce longer idle periods

Optimize idle periods for energy saving

LU with partial pivoting ⇒ Just an example of algorithm with idle periods!

Two techniques to leverage inactive periods

Results:

Reduction of energy consumption of 5 % and 22 % if we only consider applicationconsumption

Negligible increase of execution time

Basic idea to save energy: avoid active polling (busy-wait) in the runtime

Do nothing well!David E. Culler

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors

Page 23: Saving Energy in the LU Factorization with Partial

IntroductionLU Factorization with Partial Pivoting

Accommodating Energy-Aware Techniques into SuperMatrixExperimental results

Summary and conclusions

Thanks for your attention!

Questions?

Manuel F. Dolz et al Saving Energy in the LU Factorization on Multi-Core Processors