Expert answer:I need a full two pages report of the following paper 12 font size and double spaced. with apa citation.
oopsla12_long.pdf
Unformatted Attachment Preview
Energy Types
Michael Cohen
Haitao Steve Zhu
Senem Ezgi Emgin
Yu David Liu
Department of Computer Science
SUNY Binghamton
Binghamton NY 13902, USA
{mcohen3,hzhu1,semgin1,davidL}@binghamton.edu
Abstract
This paper presents a novel type system to promote and
facilitate energy-aware programming. Energy Types is built
upon a key insight into today’s energy-efficient systems and
applications: despite the popular perception that energy and
power can only be described in joules and watts, real-world
energy management is often based on discrete phases and
modes, which in turn can be reasoned about by type systems
very effectively. A phase characterizes a distinct pattern of
program workload, and a mode represents an energy state
the program is expected to execute in.
This paper describes a programming model where phases
and modes can be intuitively specified by programmers or inferred by the compiler as type information. It demonstrates
how a type-based approach to reasoning about phases and
modes can help promote energy efficiency. The soundness
of our type system and the invariants related to inter-phase
and inter-mode interactions are rigorously proved. Energy
Types is implemented as the core of a prototyped objectoriented language ET for smartphone programming. Preliminary studies show ET can lead to significant energy savings
for Android Apps.
Categories and Subject Descriptors D.3.3 [Programming
Languages]: Language Constructs and Features; C.0 [Computer Systems Organization]: General—Hardware/Software
Interfaces
Keywords Energy Efficiency, Energy-Aware Software, Type
Systems
1.
Introduction
There is a long history of designing type systems to improve
software quality, such as robustness, reliability, and security.
Permission to make digital or hard copies of all or part of this work for personal or
classroom use is granted without fee provided that copies are not made or distributed
for profit or commercial advantage and that copies bear this notice and the full citation
on the first page. To copy otherwise, to republish, to post on servers or to redistribute
to lists, requires prior specific permission and/or a fee.
OOPSLA’12, October 19–26, 2012, Tucson, Arizona, USA.
Copyright © 2012 ACM 978-1-4503-1561-6/12/10. . . $10.00
As we look forward, energy efficiency is increasingly looming large as a critical software metric. From cloud computing servers, to sensor networks, to iPads and Droids, new
hardware platforms redefine what “acceptable software” is
– occasional crashes may be tolerated, but unacceptable are
electricity bills in an astronomical amount for a data center,
or battery life of just a few hours for a smartphone. Prior research on energy efficiency concentrates on innovations in
VLSI (e.g. [7]), architectures (e.g. [17]), operating systems
(e.g. [38]), and compiler optimizations (e.g. [18]). A much
less explored path is how innovations on programming models [4, 30, 34] can help build energy-friendly software, and
in particular, how programming language technologies can
help reason about energy management.
To some extent, the lack of development in reasoning
energy-aware software is understandable. First, energy is
measured in joules and watts – continuous values (or their
floating-point number representations) that are often unfriendly to reasoning techniques. Second, energy consumption is a combined effect of many hardware components –
such as CPUs, caches, DRAMs, I/O devices – and they often interact in complex ways so that energy consumption is
impossible to precisely estimate. Third, unlike lower-layer
solutions where effectiveness can be quantified unambiguously – e.g. “this CMOS circuit contributes to an energy
saving of 0.31 µW .” – innovations on language designs assume a rational programmer, and the effectiveness depends
on the programmer and the nature of the program.
This paper presents Energy Types, a practical type system to reason about energy-aware software. Instead of directly reasoning about joules and watts over complex hardware – an ambitious task perhaps impossible to get perfectly
right and practical – Energy Types reasons about phases and
modes, two recurring motifs in modern energy-aware software.
1.1
Phases as Types
An established fact in architecture research is that a program
usually demonstrates phased behaviors of energy consumption ([8, 17]): the rate of energy consumption (i.e. power)
flows and ebbs in phases, steady within but drastically differ-
ent across. Intuitively, program fragments with different logical goals have distinct workloads, which yield distinct patterns of CPU usage, memory accesses, cache misses, and I/O
operations, and eventually lead to a distinct pattern of energy
consumption. Program phase characterization – determining
the number of phases, and the boundary of each – provides
important insight into understanding program energy consumption behaviors, and further guides energy management
techniques for better decision-making. Existing phase prediction techniques (e.g. [16, 31]) usually combine dynamic
monitoring and profiling with sophisticated classification or
prediction algorithms.
Phase Support in Energy Types Energy Types brings the
knowledge of programmers into the equation. We argue that
a programmer often intuitively knows the logical sub-goals
of her program, which often corresponds to phases with
distinct patterns of energy consumption. For example, it
is not difficult for a programmer to realize that her Mars
landing game is composed of a (CPU-intensive) physics
calculation phase and an (I/O-intensive) 3D rendering phase.
Programmers in Energy Types can label data and operations with phase type qualifiers, directly specifying phased
behaviors by relating computational elements to phases of
energy consumption. Energy Types helps programmers preserve a consistent view of phase placement by enforcing
phase distinction: each data or operation must commit to –
i.e. be typed with – one and only one phase. The type system
further enforces phase isolation: any cross-phase interaction
must be accompanied with explicit type coercion.
There are two important energy efficiency benefits that
result from building phases into an energy-aware programming language. First, hardware-level energy management
procedures often need to adjust the status of hardware (to
save energy) based on the status of the software runtime.
Phase type qualifiers are invaluable at this software/hardware interface:
E NERGY M ANAGEMENT B ENEFIT 1 (Guiding Hardware
through Types). Phase type information can be used to
guide hardware-level energy management, because it taps
both the knowledge of the programmer through type declaration, and the ability of a type system to propagate phase
information.
Concretely, the host language of Energy Types – ET – is
equipped with a dynamic semantics that supports CPU dynamic voltage and frequency scaling (DVFS) [29] directed
by phase type information. As one of the most time-honored
hardware-level energy management strategies, DVFS is a
trade-off between energy and speed. It is most advantageous
to scale down the CPU frequency, so that energy can be
saved, but only at a time when the CPU is least busy, so that
performance degrades the least. Its effectiveness is largely
dependent upon choosing the right scaling point (“where to
scale”) and the right scaling factor (“what frequency/voltage
to scale to”). We offer a language design, accompanied by an
experimental validation, to demonstrate phases as types can
provide answers to both questions that yield energy savings.
Thanks to the type system enforcement of phase distinction and phase isolation, phases as types further promote
phased behaviors. In Energy Types, intra-phase object interaction – say messaging – is supported in the same syntax
as in the familiar Java model, whereas any inter-phase interaction requires explicit type coercion, an inconvenience
programmers would rather avoid. Given the requirement of
phase isolation, the programmer is motivated to re-factor the
code to cluster calculation operations separately from rendering operations, instead of intertwining code with distinct
patterns of system usages. To summarize:
E NERGY M ANAGEMENT B ENEFIT 2 (Promoting Phased
Behaviors). Phase distinction and phase isolation promote
the construction of programs with more stable power consumption within phases and fewer phase changes, both beneficial for phase-based energy management.
1.2
Modes as Types
Application-specific energy savings are another important
source for software energy efficiency. It has been observed
that [4, 26, 30, 34] applications can often be programmed
in different ways. All are acceptable, but different choices
may consume different levels of energy and be best used
in different energy states. For example, a programmer may
decide to render a high-fidelity Mars lander image when her
smartphone is fully charged, and only a low-fidelity image
when the battery level of the phone is below 20%.
Mode Support in Energy Types Energy Types builds on
this insight, and offers programmers the capability to associate data and operations with mode type qualifiers. Each
mode is a programmer-defined and typed energy state, indicating the expected energy usage context associated with
specific data or operations, such as “battery high” and “battery low.” Allowing for programmer mode declarations is
in sync with our philosophy on constructing a practical
static reasoning system for energy management: instead of
painstakingly determining why rendering a high-fidelity image consumes more energy than a low-fidelity image through
advanced static analysis, we believe programmers intuitively
know. The goal of Energy Types is thus to assist rational yet
imperfect programmers to consistently assign energy consumption expectations to program elements.
Building modes into an energy-aware programming language leads to two benefits toward energy efficiency:
E NERGY M ANAGEMENT B ENEFIT 3 (Encouraging Application-Specific Energy Savings). The process of thinking
how many modes should be supported, and how data and
operations should be assigned to each mode is the same as
designing application-specific energy-saving strategies.
E NERGY M ANAGEMENT B ENEFIT 4 (Regulating Energy
States). The type-based approach regulates what program
fragments can be used under different energy states, which
on the high level is aligned with the programmer intuition
of constructing energy-aware programs friendly to distinct
energy states.
1
2
3
4
5
6
7
To achieve Benefit 4, our type system enforces a waterfall invariant: a program element associated with a “higher”
energy state – one with more availability for energy consumption – may access an element with a “lower” energy
state, but not vice versa. This design decision is driven by
the requirement of energy-aware programming: invoking a
function associated with a “higher” energy state – often more
energy-consuming – when the system is in a low energy state
may drain the system energy source, an energy error.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1.3
Energy Types
Energy Types is a foundational study of the fabrics of
energy-aware software, abstracting the recurring themes of
energy management as the reasoning of phases and modes.
The type system and its host language ET are one of the
first efforts to build common energy management strategies
directly into a programming language, and guarantee the
consistency of the programmers’ energy management intentions during their practice of energy-aware programming.
In addition to Benefits 1-4, Energy Types inherits some
benefits from type system solutions which may be appealing for energy-efficient computing in general: it is portable
and platform independent; it promotes compositional reasoning of energy management behaviors; and it serves as
lightweight and consistent documentation throughout the often iterative process of energy optimization.
This paper makes the following contributions:
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
• It introduces one of the first systematic studies on static
49
reasoning for energy-aware software, in the shape of a
type system that has been proven sound;
51
• It formulates invariants related to recurring themes of
54
energy management as properties of phases and modes,
with their enforcement on the language level formally
proved;
56
50
52
53
55
57
58
59
60
• It provides a small-step semantics that demonstrates how
traditional energy-saving strategies such as DVFS can
be type-directed, and a formal illustration on type-based
scaling factor selection;
61
62
63
64
65
66
• It offers an easy-to-use programming model that has been
67
implemented as a prototyped compiler, and evaluated
through programming Android Apps.
69
68
70
71
72
The rest of the paper is organized as follows. Sec.2 is an
informal discussion on Energy Types and ET. The formal
Energy Types system is presented in Sec. 3 and the implementation of ET and its evaluation is presented in Sec. 4.
The last sections describe related work and future work.
73
74
p h a s e s { g r a p h i c s 0.3)
return h i f i
else
return l o f i ;
}
}
c l a s s M a t c h e r @phase ( math ) {
double p r e c i s i o n ;
G e s t u r e [ ] ps = . . . ; / / r e c o g n i z a b l e p a t t e r n s
Matcher ( double p r e c i s i o n )
{ this . precision = precision ; }
i n t match ( G e s t u r e g , D i s t C a l dc ) {
G e s t u r e gs = sampling ( g , p r e c i s i o n ) ;
f o r ( i n t i = 0 ; i< p s . l e n g t h ; i ++)
{ i f ( dc . compute ( gs , p s [ i ] ) < THRES )
return i ;
}
}
...
}
c l a s s View@phase ( g r a p h i c s ) {
Gesture [ ] p = . . . ; / / recognizable patterns
void p a i n t O v e r l a y ( Gesture g , i n t r e s u l t ) {
paint (g );
paint (p[ result ]);
}
void p a i n t ( Gesture g ) {
U t i l . draw ( g . C o o r d i n a t e s ( ) ) ;
}
}
class DistCal {...}
c l a s s Cosine extends DistCal { . . . }
c l a s s Euclidean extends DistCal { . . . }
class Gesture { . . . }
static class Util {
boolean b a t t e r y c h a r g e d ( ) { . . . }
double b a t t e r y l e v e l ( ) { . . . }
v o i d draw ( i n t co ) { }
}
Figure 1. A Gesture Recognition Program in ET
2.
Energy-Aware Programming in ET
ET is a Java-like object-oriented language for smartphone
programming – an immediate testing ground we choose for
Energy Types. A sample ET program is illustrated in Fig. 1.
Key language features are highlighted in red.
This program, inspired by android.gesture APIs,
applies pattern recognition techniques to determine what
“gesture” the fingers of a smartphone user perform on the
touch screen. The core program logic follows the predictable
“input-recognize-render” sequence, in L. 8 - 10. The recognition logic is encapsulated in the Recognizer class,
which selects different recognition algorithms based on the
battery state of the smartphone (L. 25 - 29). The mathematical core of the recognition is implemented by class
Matcher, which can be instantiated with different recognition precision settings and different mathematical routines to compute distances in a vector space, such as either
in Cosine distance or in Euclidean distance.
The Pre-ET Era To motivate the need for ET, let us imagine what a green-conscious Android Java programmer would
do in her attempt of energy-aware programming.
First, an informed programmer – especially one from architecture/VLSI/OS communities – might know that programs of different workloads often react to CPU scaling differently, in that scaling down CPU frequency/voltage of a “I/O-bound” part of the program such as the
paintOverlay method, may lead to energy savings with
little performance penalty. Her plan thus is to insert a pair of
DVFS system calls in the source code, one before the messaging on L. 10 to scale down the CPU (say she decides to
use 300Mhz) and then the other right after the messaging to
scale the CPU back up to the previous level. The ensuing
program might be faced with a number of usability, efficiency, and robustness issues, in that such DVFS calls might
be:
• platform-dependent, e.g. the same program might be de-
ployed to a machine that does not support 300Mhz
• redundant, e.g. both the message sender and the receiver
insert the same DVFS calls to “err on the safe side”
• unbalanced, e.g. DVFS is used to scale the CPU down
before paintOverlay messaging, but forgotten to be
used afterwards to scale the CPU back up
• inconsistent e.g. the View object is thought to be I/O in-
tensive at some program point, but may flow to a variable
used as if it were CPU-intensive
Second, a green-conscious programmer may also apply
to application-specific savings, such as creating different
Matcher objects – similar to L. 19 - L.21 but without
the qualifiers – each for a different battery level. What is
required for her is to memorize the energy consumption
traits for individual program fragments – m1, m2, m3 in the
program – and hopefully not accidentally use a m1 or m2
object when the system is low on battery. This task may
appear to be simple for a program as short as Fig. 1, but not
obviously so when the program grows larger, where objects
references are routinely passed around, stored on the heap,
and aliased.
This is not to mention the fact that the difficulties described above are indeed the privileges of advanced Android
programmers. The majority of Apps programmers are not
even aware of the options of energy-aware programming
in the first place. It is these kinds of problems that ET addresses.
Phases and Modes The most noticeable features of ET are
the optional type qualifiers of phases and modes.
Instead of thinking how low-level CPU frequencies should
be scaled, ET programmers are encouraged to think how
CPU-intensive each program fragment is. Either a class
(L. 56) or an object (L. 15) can be associated with a phase
qualifier to characterize such intensity. In addition, ET programmers can declare a partial order
Purchase answer to see full
attachment
You will get a plagiarism-free paper and you can get an originality report upon request.
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more