static energy prediction in software · building the energy model • path-independent: • execute...

21
Marco Couto [email protected] STATIC ENERGY PREDICTION IN SOFTWARE: A WORST-CASE SCENARIO APPROACH

Upload: others

Post on 17-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

Marco Couto

[email protected]

STATIC ENERGY PREDICTION IN SOFTWARE:

A WORST-CASE SCENARIO APPROACH

Page 2: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

MOTIVATION

Marco Couto @ GSL - HASLab/INESC TEC 2

Page 3: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

ENERGY VS. POWER

3

• Power (w) – rate (or effort) at which that work is done

• Energy (J) – amount of work done

• Power can change constantly while Energy is the accumulation

Energy = Power x Seconds

Power

Energy

100W360,000 J = x 3,600s

Page 4: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

ENERGY EFFICIENT SOFTWARE

• Programmers problems:

• How to analyze

• How to interpret

• How to improve

• Researchers problem:

• How to provide information to developers

4

Mining questions about software energy consumption

- [MSR’14]Integrated energy-directed test suite optimization

- [ISTA’14]Seeds: A software engineer’s energy-optimization decision

support framework - [ICSE’14]

Page 5: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

THE CHALLENGE

Marco Couto @ GSL - HASLab/INESC TEC 5

Page 6: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

STATIC ENERGY ANALYSISWHY?

• Dynamic can be too costly

1. Build application + tests

2. Intrument app and/or tests

3. Run tests

4. Gather measurements and analyze them

5. Repeat N times

• ‘M’ apps -> Repeat all ‘M’ times

• Are all cases covered?

6Marco Couto @ GSL - HASLab/INESC TEC

‘M’ times

Page 7: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

STATIC ENERGY ANALYSISHOW?

• How is it done for execution time?

• WCET – Worst Case Execution Time

• Can we do the same for energy?

7Marco Couto @ GSL - HASLab/INESC TEC

Page 8: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

STATIC ENERGY EXECUTION TIME ANALYSISHOW?

8Marco Couto @ GSL - HASLab/INESC TEC

How exactly does WCET works?

</>

Source Code CFG

Machine Behavior

Dataflow

Bound Computation

Analysis Steps

1

53

2

Bounded CFG

TExecution Time

Model

ILP Solver

x1 > C0x1+x2 = C1x1+x3 = C2...

max(∑ xi.ti)

IPET Constraints

Page 9: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

IPET – IMPLICIT PATH ENUMERATION TECHNIQUEA.K.A CONSTRAINT GENERATOR

• Each node has:

• A count variable, ‘x’

• A cost variable, ‘t’

• Each edge has:

• A count variable, ‘x’

• 4 Simple but strong premises:

1. Start and end nodes accessed exactly 1 time

2. #x of node i = sum (#x of all pred. of i)

3. #x of node i = sum (#x of all succ. of i)

4. Loops must have na upper bound

9Marco Couto @ GSL - HASLab/INESC TEC

Page 10: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

STATIC ENERGY ANALYSISHOW?

10Marco Couto @ GSL - HASLab/INESC TEC

How exactly does WCEC works?

</>

Source Code CFG

Machine Behavior

Dataflow

Bound Computation

Analysis Steps

1

53

2

Bounded CFG

EEnergy Model

ILP Solver

x1 > C0x1+x2 = C1x1+x3 = C2...

max(∑ xi.ti)

IPET Constraints

Page 11: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

ENERGY MODEL

HOW TO BUILD IT?

Marco Couto @ GSL - HASLab/INESC TEC 11

Page 12: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

BUILDING THE ENERGY MODEL

• Two types of instructions:

• Path-Independent:

• x=1;

• i++;

• a=2*b;

• return 0;

• Path-Dependent:

• Allocations: malloc(sizeof(int)) ≠ malloc(sizeof(double))

• System calls: scanf(“%d”, &a) ≠ scanf(“%f”, &a)

• Other functions: strcmp(...), atoi(...), sizeof(...), ...

• Some instructions depend on others:

• ‘int x = z;’ depends on the declaration of z

• ‘printf(“%d”, a);’ assumes a has a previous assigned value

12Marco Couto @ GSL - HASLab/INESC TEC

Estimating Mobile Application Energy Consumption using

Program Analysis - [ICSE’13]

Page 13: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

BUILDING THE ENERGY MODEL

• Path-Independent:

• Execute N times

• Repeat M times, measure each time and sum all

• At the end: energy = (sum/M/N) – dependencies

• Path-Dependent:

• Execute N times

• Repeat M times, measure each time

• At the end: energy = max(all measures) – dependencies

13Marco Couto @ GSL - HASLab/INESC TEC

Estimating Mobile Application Energy Consumption using

Program Analysis - [ICSE’13]

Page 14: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

SOFTWARE PRODUCT LINES

THE CASE STUDY

Marco Couto @ GSL - HASLab/INESC TEC 14

Page 15: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

SOFTWARE PRODUCT LINE

15Marco Couto @ GSL - HASLab/INESC TEC

“(…) a set of related software products (…)

generated from reusable assets.”

A B

CORE

D E

C

A B

CORE

D E

C{B, C, D}

A B

CORE

D E

C{A, E}

A B

CORE

D E

C{A, B, C, D}

Feature

Product

configuration

Page 16: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

STATIC ENERGY ANALYSISTHIS TIME, FOR SPL!

16Marco Couto @ GSL - HASLab/INESC TEC

C

Source Code CFG

Machine Behavior

Dataflow

Bound Computation

Analysis Steps

1

53

2

Bounded CFG

EEnergy Model

ILP Solver

x1 > C0x1+x2 = C1x1+x3 = C2...

max(∑ xi.ti)

IPET ConstraintsCFG(feature-oriented)

1

53

2

Bounded CFG(feature-oriented)(feature-oriented)

Intraprocedural Dataflow Analysis for Software Product Lines

- [AOSD '12]

Page 17: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

RESULTS

Marco Couto @ GSL - HASLab/INESC TEC 17

Page 18: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

PRELIMINARY RESULTS

• A SPL with 7 (exclusive) features

Results submited to SPLC’17 – Software Product Lines Conference, 21st edition:

“Products go green: Worst-Case Energy Consumption in Software Product Lines”

18Marco Couto @ GSL - HASLab/INESC TEC

Page 19: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

WHAT NOW?

• This work was focused on accuracy

• Technique’s performance could be improved...

• Main reason: shared constraints are re-calculated for every product

19Marco Couto @ GSL - HASLab/INESC TEC

A B

CORE

D E

C{B, C, D}

A B

CORE

D E

C{A, B, C, D}

...#Constraints for B...#Constraints for C...#Constraints for D...

Constraint

Generator

...#Constraints for B...#Constraints for C...#Constraints for D...

Constraint

Generator

*

*

*Constraints solved more than once!

Page 20: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

WHAT NOW?

• Accuracy can also be improved!

• Include a machine behavior analysis

• -> different energy consumptions per instruction

• Consider lower abstraction level

• For now, we analyzed C code

• Apply technique to different contexts

• Mobile?

• Embedded?

• ???

20Marco Couto @ GSL - HASLab/INESC TEC

Page 21: STATIC ENERGY PREDICTION IN SOFTWARE · BUILDING THE ENERGY MODEL • Path-Independent: • Execute N times • Repeat M times, measure each time and sum all • At the end: energy

Marco Couto

[email protected]

STATIC ENERGY PREDICTION IN SOFTWARE:

A WORST-CASE SCENARIO APPROACH