Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13...
-
Upload
jaida-feild -
Category
Documents
-
view
214 -
download
1
Transcript of Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13...
![Page 1: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/1.jpg)
Types for Energy Management
Yu David Liu
State University of New York (SUNY)
at Binghamton
OOPSLA’13 PC Workshop
![Page 2: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/2.jpg)
2
Energy Efficiency in Computing
PL & SEefforts
PACT, ASPLOS
OSDI, SOSP, SenSys,
SIGCOMM
ISCA, MICRO, HPCA
VLSI, DAC
operational cost phone battery
life sensor network
usability system
reliability (overheating)
environment
![Page 3: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/3.jpg)
3
High-Level Questions
What are the principles of energy management? recurring themes of software-hardware
interactions recurring themes of static-dynamic interactions
How can the principles be abided by at software construction time (or through software lifecycle)?
What is the role of programmers in energy-efficient computing?
![Page 4: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/4.jpg)
4
This Talk
An energy-aware programming language design
Core Idea: building the principles of energy management into a type system Static Typing:
Michael Cohen, Haitao Steve Zhu, Senem Ezgi Emgin, Yu David Liu, "Energy Types," OOPSLA’12.
Hybrid Typing: ongoing work
![Page 5: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/5.jpg)
5
Energy Types
Phase• A pattern of system (CPU, memory…) utilization
• “math”, “graphics”, “audio”…
• A level of energy state
• “battery low”, “battery high”, “battery charged”…
Mode
A type system to reason about energy management based on
two concepts:
![Page 6: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/6.jpg)
6
Energy Types
Phase• A pattern of system (CPU, memory…) utilization
• “math”, “graphics”, “audio”…
• A level of energy state
• “battery low”, “battery high”, “battery charged”
Mode
A type system to reason about energy management based on
two concepts:
![Page 7: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/7.jpg)
7
CPU-bound
class Compute{
…
void doCompute(){
for(int i = 0; i < N; i++){
pi += factor/(2 * i + 1);
factor /= -3.0;
}}}
class Draw{
…
void doDraw(){
for(int i = 0; i < NUM; i++) {
canvas.drawL(x[i], y[i],);
c.draw(getImg(), rect);
}}}
I/O-bound
Phases in Programs
![Page 8: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/8.jpg)
8
Draw draw = new Draw();
Compute cmpt = new Compute();
draw.doDraw();
cmpt.doCompute();
Draw draw = new Draw();
Phases in Programs
![Page 9: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/9.jpg)
9
Draw draw = new Draw();
Compute@phase(math) cmpt = new Compute();
draw.doDraw();
cmpt.doCompute();
Draw@phase(graphics) draw = new Draw();
phases { graphics <cpu math}
Phases as Type Qualifiers
![Page 10: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/10.jpg)
10
DVFS in Energy Management
Energy = Power * Time
Dynamic Voltage & Frequency Scaling (DVFS)
Power = c * Frequency * V2
![Page 11: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/11.jpg)
11
Phase-based Energy Management
What: divide execution into distinct system utilization “phases”, and scale down CPU frequency when a phase is not CPU-bound
Why: minimum performance degradation with maximum energy savings
Energy Types Solution: use (declared or inferred) phase types to guide DVFS
A case of software-hardware
interaction for energy management
![Page 12: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/12.jpg)
12
Draw draw = new Draw();
Compute@phase(math) cmpt = new Compute();
draw.doDraw();
cmpt.doCompute();
Draw@phase(graphics) draw = new Draw();
phases { graphics <cpu math}
Phases as Type Qualifiers
CPU frequency scaled through
compiler instrumentation
CPU frequency scaled through
compiler instrumentation
Energy Management through Type-Directed DVFS:
1. tap programmer knowledge
2. tap type systems’ ability for consistency checking, type propagation and inference
![Page 13: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/13.jpg)
13
Invariants
Phase distinction: No object can commit to more than one phase
Phase isolation: an object can only send messages to an object belonging to the same phase Inter-phase messaging is only
allowed through explicit type coercion
Promoting phased behaviors
![Page 14: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/14.jpg)
14
Type System Details
Based on region types: phases are regions
Parametric polymorphism: Different objects of the same class
can have different phases Finer-grained support through
method polymorphism Explicit form: “generic” phases Implicit form: polymorphic inference
to allow for arbitrary qualifier elisionType Soundness
![Page 15: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/15.jpg)
15
Energy Types
Phase• A pattern of CPU and memory utilization
• “math”, “graphics”, “audio”
• A level of energy state expectation
• “battery low”, “battery high”, “battery charged”
Mode
A type system to reason about energy management based on
two concepts
![Page 16: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/16.jpg)
16
Renderer m1 = new Renderer(0.99);Renderer m2 = new Renderer(0.5);
Objects of different qualities
Mode-based Energy Management
class Renderer{ Renderer(double quality){ int loopNum = 1000 * quality; for(int i = 0; i < loopNum; i++){ render(canvas, i); }}}
![Page 17: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/17.jpg)
17
Renderer m1 = new Renderer(0.99);
Renderer m2 = new Renderer(0.5);
Modes as Type Qualifiers
modes { low <: hi; }
Renderer@mode(hi) m1 = new Renderer(0.99);
Renderer@mode(low) m2 = new Renderer(0.5);
Encouraging Application-Specific Energy Savings
![Page 18: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/18.jpg)
18
Invariants
waterfall Invariant: an object can only send messages to an object of the same mode, or of a “lower” mode in the partial order A program in “high” energy state can
invoke code supposed to be used in “low” energy state
The other way around requires explicit type coercion
Regulating Energy States
![Page 19: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/19.jpg)
19
Type System Details
Based on region types: modes are regions
Parametric polymorphism: Different objects of the same class
can have different modes Finer-grained support through
method polymorphism Explicit form: “generic” modes Implicit form: polymorphic inference
to allow for arbitrary qualifier elisionType Soundness
![Page 20: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/20.jpg)
20
Ongoing Effort: Hybrid Typing
class Network { void send() {…}}
class Client {…Network n = new Network();while (…) { n.send();}}
![Page 21: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/21.jpg)
21
Ongoing Effort: Hybrid Typing
class Network { void send() {…}}
class Client {…Network@mode(hi) n = new Network();while (…) { n.send();}}
Hmm..
![Page 22: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/22.jpg)
22
Ongoing Effort: Hybrid Typing
class Network { void send() {…}}
class Client {…Network@mode(low) n = new Network();while (…) { n.send();}}
Hmm..
![Page 23: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/23.jpg)
23
Dynamic Types
class Network { void send() {…}}
class Client {…Network@mode(dynamic) n = new Network();while (…) { n.send();}}
![Page 24: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/24.jpg)
24
From Dynamic to Static (One Possible Design)
class Network { void send() {…}}
class Client {…Network@mode(dynamic) n = new Network();while (…) { ((Network@mode(low))n).send();}}
Client Makes
Decision
Hmm..
![Page 25: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/25.jpg)
25
From Dynamic to Static (Our Design)
class Network { void send() {…} ~ Network () { if (…) return hi else return low; }}
class Client {…Network@mode(dynamic) n = new Network();while (…) { attribute n to low { n.send(); }}}
Bi-Directional
Decision
![Page 26: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/26.jpg)
26
Implementation and Evaluation
Prototyped compiler for Android Apps
Static typing: benchmarking results show promising energy savings with minimal performance loss For some game benchmarks, 40%
energy savings and 2% performance loss with phases; application-specific with modes
Hybrid typing: under development
![Page 27: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/27.jpg)
27
Conclusions
New language designs may capture and facilitate complex software/hardware static/dynamic interactions in energy management
Principles of energy management may be enforced by type systems
Energy-aware programming broadens the scope of energy optimization by bringing in programmer knowledge
![Page 28: Types for Energy Management Yu David Liu State University of New York (SUNY) at Binghamton OOPSLA13 PC Workshop.](https://reader035.fdocuments.in/reader035/viewer/2022062619/551799d95503460e6e8b5b9c/html5/thumbnails/28.jpg)
28
Q&A