programming challenges of intermittent energy-harvesting ......nv for( i = 1) call hicost() call...

77
Programming Challenges of Intermittent Energy-harvesting Devices Brandon Lucia | Assistant Professor, CMU ECE ABSTRACT Research Group - https:// intermittent.systems with PhD Students: Alexei Colin, Kiwan Maeng, Emily Ruppel, Vignesh Balaji Graham Gobieski, Milijana Surbatovich MS Students: Preeti Murthy, Amanda Marano, Neil Ryan, Devon White, Chris Meredith BS Students: Graham Harvey, Mark McElwaine, Hannah Tomio Industry Collaborators: Zac Manchester (Harvard/KickSat) Alanson Sample (Disney Research Pittsburgh)

Upload: others

Post on 12-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Programming Challenges of Intermittent Energy-harvesting DevicesBrandon Lucia | Assistant Professor, CMU ECEABSTRACT Research Group - https://intermittent.systemswith PhD Students: Alexei Colin, Kiwan Maeng, Emily Ruppel, Vignesh Balaji

Graham Gobieski, Milijana SurbatovichMS Students: Preeti Murthy, Amanda Marano, Neil Ryan, Devon White, Chris MeredithBS Students: Graham Harvey, Mark McElwaine, Hannah TomioIndustry Collaborators: Zac Manchester (Harvard/KickSat)

Alanson Sample (Disney Research Pittsburgh)

Page 2: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 2

Wearables, sensors, “Internet of Things”, tiny satellites, medical

implants, environmental monitoring, security, computational art,

interactive clothing, smart furniture, smart carpets, smart toilet paper

Emerging Hardware/Software Devices Everywhere

Page 3: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 5

computer (microcontroller)

energy buffer (capacitor)

energy receiver (antenna)

energy source

Energy harvesting untethers devices

empty space

Page 4: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 6

Page 5: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 7

computer (microcontroller)

energy buffer (capacitor)

energy receiver (antenna)

energy source

empty space

…but energy is intermittentsoftware becomes inherently unreliable.

—and as a result—

Page 6: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 8

Designing for IntermittenceSystem Support for Reliable Intermittence

The Intermittent Execution ModelReasoning About Intermittently-powered Devices

Debugging IntermittenceToolchain Support for Understanding Intermittence

Page 7: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 9

RF Available!

Running on intermittent energy

Available

Energy

Time

Charging, dead.

Page 8: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 10

Running on intermittent energy

Available

Energy

Time

“Life Line”

Operating!

Page 9: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 11

Running on intermittent energy

Available

Energy

Time

“Death Line”Not charging, dead.

Page 10: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 12

Running on intermittent energy

RF Available!

Available

Energy

Time

Charging, dead.

Page 11: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 13

Running on intermittent energy

RF Available!

Available

Energy

Time

“Life Line”

Operating!

Page 12: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 14

Available

Energy

Time

“Death Line”

Computer

shuts down

Computer

reboots

“Life Line”

Page 13: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 15

Available

Energy

Time

Compute ComputeRebootReboot

Page 14: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 16

Time

Compute Reboot Compute

The Intermittent Execution Model[PLDI ’15]

Page 15: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 17

Time

The Intermittent Execution Model

Goal: Run programs that take longer than one green box

[PLDI ’15]

Page 16: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 18

void main(void){

for( i = 1 .. 10)

append()

}

void append(){

sz++

buf[sz] = ‘a’

}

Page 17: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 19

void main(void){

for( i = 1 .. 10)

append()

}

void append(){

sz++

buf[sz] = ‘a’

}

for( i = 1 )

append()sz++

buf[sz] = ‘a’

for( i = 2 )

append()sz++

buf[sz] = ‘a’

REBOOT

Page 18: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 20

void main(void){

for( i = 1 .. 10)

append()

}

void append(){

sz++

buf[sz] = ‘a’

}

for( i = 1 )

append()

for( i = 1 )

append()sz++

buf[sz] = ‘a’

for( i = 2 )

append()sz++

buf[sz] = ‘a’

REBOOT

REBOOT

Page 19: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 21

void main(void){

for( i = 1 .. 10)

append()

}

void append(){

sz++

buf[sz] = ‘a’

}

for( i = 1 )

append()

for( i = 2 )

append()

for( i = 3 )

append()

sz++

buf[sz] = ‘a’

sz++

buf[sz] = ‘a’

sz++

buf[sz] = ‘a’

for( i = 1 )

append()

for( i = 1 )

append()sz++

buf[sz] = ‘a’

for( i = 2 )

append()sz++

buf[sz] = ‘a’

REBOOT

REBOOT

REBOOT

Page 20: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 22

void main(void){

for( i = 1 .. 10)

append()

}

void append(){

sz++

buf[sz] = ‘a’

}

main()append()

for( i = …)

call append()

<loop>

end of main()

Control-flow Graph

buf[sz] = ‘a’

sz++

We can model intermittence as a control-flow problem

Page 21: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 23

main()append()

for( i = …)

call append()

<loop>

end of main()

Control-flow Graph

Failure Induces

Implicit Control-flow

Intermittent Programming

Challenge:

Implicit control-flow

“back in time” on reboot.

buf[sz] = ‘a’

sz++

Back in time!

Page 22: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 24

Mixture of Volatile & Non-volatile State

volatile memory (e.g.,

DRAM, SRAM registers)

non-volatile memory

(e.g., Flash, FRAM)

Access latencies growing

similar w/ new technology

Page 23: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 25

Time

Reboots clear volatile state and

preserve non-volatile state

Persists!

Volatile

State

Non-volatile

State

Clear! Clear! Clear! Clear!

Page 24: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 26

Prior work (e.g., Mementos) overlooked the need

to version non-volatile memory with checkpoints

main()append()

for( i = …)

call append()

<loop>

end of main()

Control-flow Graph

buf[sz] = ‘a’

sz++

Checkpoint Volatile State

Use NV memory to capture values of

registers, stack, and global variables

Page 25: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 27

main()append()

for( i = …)

call append()

<loop>

end of main()

Control-flow Graph

Checkpoint introduce more

complex implicit control-flow

Intermittent Programming

Challenge:

Implicit control-flow

“back in time” on reboot.

buf[sz] = ‘a’

sz++

Checkpoint Volatile State

Page 26: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 28

void main(void){

for( i = 1 .. 10)

append()

}

void append(){

sz++

buf[sz] = ‘a’

}

for( i = 1 )

append()

for( i = 2 )

append()

for( i = 3 )

append()

sz++

buf[sz] = ‘a’

sz++

buf[sz] = ‘a’

sz++

buf[sz] = ‘a’

for( i = 1 )

append()

for( i = 1 )

append()sz++

buf[sz] = ‘a’

for( i = 2 )

append()sz++

buf[sz] = ‘a’

REBOOT

REBOOT

REBOOT

The way we think about programming doesnot match the intermittent execution model

The Big Idea

Page 27: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 29

void main(void){

for( i = 1 .. 10)

append()

}

void append(){

sz++

buf[sz] = ‘a’

}

for( i = 1 )

append()

for( i = 2 )

append()

for( i = 3 )

append()

sz++

buf[sz] = ‘a’

sz++

buf[sz] = ‘a’

sz++

buf[sz] = ‘a’

for( i = 1 )

append()

for( i = 1 )

append()sz++

buf[sz] = ‘a’

for( i = 2 )

append()sz++

buf[sz] = ‘a’

REBOOT

REBOOT

REBOOT

Software that is correct with continuous power

can be incorrect due to intermittent execution

especially when we combine non-volatileand volatile memory!

Challenge: Intermittence Bugs

+

Page 28: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 30

Page 29: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 31

main()append()

for( i = …)

call append()

<loop>

end of main()

buf[sz] = ‘a’

sz++

Intermittence Bug: Out-of-thin-air Values

sz

buf

-1

ckpt

[MSPC ’14; PLDI ‘15]

Page 30: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 32

main()append()

for( i = …)

call append()

<loop>

end of main()

buf[sz] = ‘a’

sz++

for( i = 1)

sz

buf

0

call append()sz++buf[sz] = ‘a’

‘a’

Intermittence Bug: Out-of-thin-air Values[MSPC ’14; PLDI ‘15]

Page 31: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 33

main()append()

for( i = …)

call append()

<loop>

end of main()

buf[sz] = ‘a’

sz++

sz

buf

1

‘a’

Error: ’a’ is appended to buf

twice on the i = 1 iteration

for( i = 1)

call append()sz++buf[sz] = ‘a’

for( i = 1)

call append()sz++buf[sz] = ‘a’

‘a’

Intermittence Bug: Out-of-thin-air Values[MSPC ’14; PLDI ‘15]

Page 32: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 34

for( i = 1)

call append()sz++buf[sz] = ‘a’

for( i = 1)

call append()sz++buf[sz] = ‘a’

Stuck in an implicit

loop for i = 1

for( i = 1)

call append()sz++buf[sz] = ‘a’

for( i = 1)

call append()sz++buf[sz] = ‘a’

for( i = 1)

call append()sz++buf[sz] = ‘a’

call append()

buf[sz] = ‘a’

sz++

for( i = 1)

Intermittence Bug: Out-of-thin-air Values[MSPC ’14; PLDI ‘15]

Page 33: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 35

sz

buf

11

‘a’‘a’ ‘a’‘a’‘a’‘a’ ‘a’‘a’ ‘a’‘a’ ‘a’‘a’

Stuck in an implicit

loop for i = 1

call append()

buf[sz] = ‘a’

sz++

for( i = 1)

Application failures can depend solely on the

availability of wireless power and capacitor behavior!

sz & buf contain corrupt values.

“Out of thin air” value not permitted by any

continuous execution!

Intermittence Bug: Out-of-thin-air Values[MSPC ’14; PLDI ‘15]

Page 34: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 36

main()append()

for( i = …)

call append()

<loop>

end of main()

buf[sz] = ‘a’

sz++

for( i = 1)

sz

buf

1

call append()

sz++

for( i = 1)

call append()

sz++

buf[sz] = ‘a’

‘a’Reboot violates atomicity ofsz++; buf[sz] = ‘a’

causing update to wrong entry in buf.

Intermittence Bug: Structural Inconsistency

Corrupt buffer state impossible

in a continuous execution!

[MSPC ’14; PLDI ’15; Colin OOPSLA ‘16]

Page 35: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 37

main()

checkpoint

Sense_pressure()

end of main()

Checkpoint between I/O operations that should

execute together leaves I/O inconsistent

Intermittence Bug: I/O Atomicity & Timeliness

Inconsistent data read at different moments in time

No atomicity control w/ automatic checkpoints

Sense_temp()

checkpoint

Sense_pressure()restore

Sense_temp()

A very long time …

[Colin OOPSLA ’16, Maeng OOPSLA ‘17, Hester et al SenSys ‘17]

Useless, stale data read a long time ago

Page 36: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 38

main()hicost()

for( i = …)

call hicost()

<loop>

end of main()

bar()

foo()

NV

for( i = 1)

call hicost()

call foo()

call bar()

Energy cost atomic span exceeds energy

capacity

Intermittence Bug: Livelock, Non-termination, and Energy-Provisioning

Affected code need not even

modify NV storage!

[Colin, et al. CASES ’15, ASPLOS ‘16]

Code that is correct with continuous power

reboots indefinitely on intermittent power.

If energy cost exceeds

full capacitor charge:

never completes 1 iteration

for( i = 1)

call hicost()call foo()

call bar()

Page 37: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 39

Different operations have different energy

requirements because of different hardware

activation

Intermittence "Bug": Reactive vs. Burst Operation

If( temp > T )

Sense_temp()

TransmitBLE()

Need sampling coverage for sensing, long burst

for BLE, reactive operation for asynchronous

events.

Page 38: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 41

Reliable Intermittent ExecutionIntermittent Programming Models

Page 39: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 42

DinoArbitrary Task-based Intermittent Programming [PLDI’16]

ChainTask-based Intermittence w/ Static Data Duplication [OOPSLA’16]

AlpacaTask-based Intermittence w/ Dynamic Privatization [OOPSLA’17]

Page 40: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 43

Task-atomic Execution in DINO

Task Boundary

Task Boundary

Task Boundary

Task

Task Task

Task

Tasks have atomic all-or-

nothing semantics

Task boundaries selectively

checkpoint volatile and

non-volatile state

No implicit control-flow!

[PLDI ’15]

Page 41: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 44

for( i = 1)

call append()buf[sz] = ‘a’

sz++

task_boundary

for( i = 2)

task_boundary

call append()

sz++

task_boundary

-1sz

buf

0sz

-1sz

buf

‘a’

0sz

buf

buf[sz] = ‘a’‘a’buf Implicit Loop!

Checkpoint

Correctly Updated

Only Once!

DINO Eliminates OoTA Values

Checkpoint captures

buf and sz

Restore buf and sz!

[PLDI ’15]

Implicit flow target

made explicit

Page 42: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 45

int NV_Array[1000000];

task_boundary

for( i = 0; i < 1000000; i++){

NV_Array[i] = i;

}

task_boundary

Key Question in DINO:

What non-volatile data must we checkpoint?

Page 43: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 46

task_boundary

for( i = … )

NV_Array[i] = i;

task_boundary

NV_Array[1000000] = {0};

NV_Array[1000000] = {…};

int NV_Array[1000000];

task_boundary

for( i = 0; i < 1000000; i++){

NV_Array[i] = i;

}

task_boundary

No NV-data

flow!

Insight: No versioning! “future”

write not observed in “past”

Selective Versioning Makes Tasks Idempotent

Page 44: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 47

task_boundary

for( i = … )

NV_Array[i]++;

task_boundary

NV_Array[1000000] = {0};

NV_Array[1000000] = {…};

int NV_Array[1000000];

task_boundary

for( i = 0; i < 1000000; i++){

NV_Array[i]++;

}

task_boundary

NV-data flow!

Insight: Must version data! Task

reads & writes same NV data

NV-data flow!

Selective Versioning Makes Tasks Idempotent

Page 45: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 48

for( i = … )

t = NV_Array[i];

Insight: Write-After-Read dependences violate idempotence

Alternative Scheme: Idempotent Checkpointing

Ratchet [Hicks

2016]

Ratchet inserts checkpoints

To break WAR

dependencest++;

NV_Array[i] = t;

<checkpoint>

What to checkpoint here?

Assumptions about

memory?

Page 46: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 49

task_boundary

i = rand(…)

NV_Array[i]++;

task_boundary

NV_Array[1000000] = {0};

NV_Array[1000000] = {…};

int NV_Array[1000000];

task_boundary

i = rand(1000000);

NV_Array[i]++;

}

task_boundary

NV-data flow!

Fundamental limitation of checkpointing:

Checkpoints must keep volatile and possibly

updated NV state consistent across reboots.

NV-data flow!

…1,000,000

Compiler cannot know i in advance! Must version all of NV_Array.

Page 47: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 50

Task size (# memory updates)

Checkpointing Overhead

Task Size Limitation

Page 48: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 51

task_boundary

i = rand(…)

NV_Array[i]++;

task_boundary

NV_Array[1000000] = {0};

NV_Array[1000000] = {…};

int NV_Array[1000000];

task_boundary

i = rand(1000000);

NV_Array[i]++;

}

task_boundary

NV-data flow!

Programming Challenge:

"How much checkpointing overhead will I

have?”

breaks the compiler abstraction boundary

NV-data flow!

…1,000,000

Compiler cannot know i in advance! Must version all of NV_Array.

Page 49: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 52

Chain: Static data multi-versioning

out in in

Task

Channels statically multiversion data

separating inputs from outputs

[Colin, et al OOPSLA ’16]

Tasks exchange data via abstract

channels of non-volatile memory

out

Task

Task

Task

Programmer explicitly defines tasks

and task-flow graph in code

Page 50: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 53

[Colin, et al OOPSLA ’16]

More complex task structures

possible to support complex dataflow

Self-channels allow a future task instance

to consume updates from past instances

Chain: Static data multi-versioning

Page 51: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing

task Alert(){

int s = ChIn S, CmpAvg

int cnt = ChIn Cnt, self

report(s, cnt);

ChOut {Cnt <- cnt+1}, self

NextTask Sense }

54

[Colin, et al OOPSLA ’16]

origin task Sense(){

int s=sensor()

ChOut {S <- s}, CmpAvg

NextTask CmpAvg }

S

task CmpAvg(){

int s = ChIn S, Sense

int head = ChIn HEAD, self

for(int i=0; i < 5; i++){

sum += ChIn a[i], self }

avg = sum / 5

ChOut {a[head] <- s}, self

head = (head+1)%5

ChOut {HEAD <- head}, self

if( s > avg*2 ){

ChOut {S <- s}, Alert

NextTask Alert

}

NextTask Sense }

HEAD,a[5]S

Cnt

Chain: Static data multi-versioning

Page 52: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing

task Alert(){

report(S, Cnt);

Cnt++

NextTask Sense }

55

[Maeng, et al OOPSLA ’17]

origin task Sense(){

S=read_sensor()

NextTask CmpAvg }

task CmpAvg(){

for(int i=0; i < 5; i++){

sum += A[i] }

avg = sum / 5

A[head] = S

head = (head+1)%5

if( S > avg*2 ){

NextTask Alert

}

NextTask Sense }

Alpaca: Tasks with Dynamic Privatization

Shared S, Cnt,

A[5],headAlpaca selectively privatizes task-shared variables

Function-as-task

means no need to

checkpoint

stack & regs

Page 53: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing

task Alert(){

priv_Cnt = Cnt

report(S, Cnt);

priv_Cnt++

2PCommit(Cnt) && NextTask

Sense }

56

[Maeng, et al OOPSLA ’17]

origin task Sense(){

S=read_sensor()

NextTask CmpAvg }

task CmpAvg(){

priv_head = head

for(int i=0; i < 5; i++){

sum += A[i] }

avg = sum / 5

priv_A[priv_head] = A[head]

markDirty(A[priv_head])

priv_A[priv_head] = S

priv_head = (priv_head+1)%5

if( S > avg*2 ){

2PCommit(dirty(A), head)

&& NextTask Alert

}

2PCommit(dirty(A), head)

&& NextTask Sense }

Alpaca: Tasks with Dynamic Privatization

Shared S, Cnt,

A[5],head

Array entries

privatized on use

Only privatize data

read then written

(e.g., S not privatized)

Page 54: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing

task Moist(){

moist=moisture_sensor()

}

57

[Hester, et al SenSys ’17]

origin task Light(){

light=light_sensor()

NextTask CmpAvg }

task isWet(light,moist,…){

//Decide if the device

//is wet

}

Mayfly: Timely Intermittent Execution

Light->isWet (expires 10s)

Moist->isWet (expires 4m)

New idea: Timely

Execution requiring

stale inputs to expire

Requires intermittence-

safe time-keeping

(remanance

timekeeping)

Page 55: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 58

Dino

Chain

Alpaca

Ratchet [Hicks ‘16]

Mementos [Ransford, et al ‘11]

Intermittence Bug: Out-of-thin-air Values

Intermittence Bug: Structural Inconsistency

Intermittence Bug: IO Atomicity/Timeliness

Intermittence Bug: Livelock/Progress

Intermittence Bug: Reactivity/Bursts

Mayfly [Hester et al ‘17]

Hardware

assumptions?

Page 56: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 59

Prototype Implementations

DINO, Chain, Alpaca

Programming

Model

Task-aware

Compiler

Task Data-flow Analysis

Link to Task Runtime

Channels, Versioning,

Privatization

Task, Channel Definitions

Runtime Library

DINO: Checkpoint & Recovery

Chain: Task Management

Alpaca: Privatization/Commit

Page 57: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 60

Energy-harvesting

Platform Prototypes

WISP5 Energy-harvesting Device

RF Power

Setup

ApplicationsActivity Recognition

(accelerometer+ML)

Cold-chain Equipment Monitor

Multi-granular Sensor Log

Key Result:Applications suffer errors & failures

without our system support for tasks

MIDI Natural User Interface

Custom PCBs

Page 58: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 61

0

2

4

6

8

10

12

14

16

18

CEM AR RSA CF BF BC

No

rma

lize

d R

un

Tim

e (

Lo

we

r is

Be

tte

r)

Alpaca Chain DINO

Page 59: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 65

[Lucia, et al PLDI ’15]

Use Alpaca, Chain and DINO for your research!

http://intermittent.systems | http://github.com/CMUAbstract

https://cmuabstract.github.io/alpaca-

landing-page/

Page 60: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 66

Debugging IntermittenceToolchain Support for Understanding

Intermittence

Page 61: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 67

sz

buf

11

‘a’‘a’ ‘a’‘a’‘a’‘a’ ‘a’‘a’ ‘a’‘a’ ‘a’‘a’

Stuck in an implicit

loop for i = 1

call append()

buf[sz] = ‘a’

sz++

for( i = 1)

sz & buf are corrupted by the reboot.

“Out of thin air” value not permitted by any

continuous execution!

Failure manifests on

intermittent power

Reboot… …bug!

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Intermittence Bugs Lead to Application Errors

Page 62: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 68

sz

buf

11

‘a’‘a’ ‘a’‘a’‘a’‘a’ ‘a’‘a’ ‘a’‘a’ ‘a’‘a’

call append()

buf[sz] = ‘a’

sz++

for( i = 1)

Reboot…

…data

corrupt!

call append()

buf[sz] = ‘a’

sz++

for( i = 1)

Key Need: Correlate program events

with the device’s energy state.

“What was happening when the power

failed that led to weird behavior?”

How Do We Debug Intermittence Bugs?[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 63: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 69

sz

buf

10

‘a’‘a’ ‘a’‘a’‘a’‘a’ ‘a’‘a’ ‘a’‘a’

sz & buf are consistent.

The buggy, “out of thin air” value never shows

up with continuous power!

Debugger provides power,

masks intermittence

No assertionsNo break pointsNo tracingNo interactive debuggingNo energy tracingNo debug-time I/O

Energy-interference Precludes Conventional Debuggers[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 64: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 70

sz

buf

10

‘a’‘a’ ‘a’‘a’‘a’‘a’ ‘a’‘a’ ‘a’‘a’

Tracing code consumes

energy & changes behavior

Energy-interference Complicates Instrumentation

buf[sz] = ‘a’

sz++

Log Update

& Blink LED

“Energy-interference gap”

printf:UART or other I/O +

msg handling code

LED: up to 5x increase in

current draw w/ LED

Logs: eats NV storage +

high access cost

Instrumentation changes energy behavior,

can mask corruption, & is oblivious to energy state

LOG Need to know what you’re looking for to make LOG useful

Tracing instrumentation

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 65: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 71

Corrupt data is device-internal and

does not necessarily affect external signals

Oscilloscope: expensive and

limited to external signals

No assertionsNo break pointsNo tracingNo interactive debuggingNo energy tracingNo debug-time I/O

Failure… …bug!

?Invisible

to the

Oscilloscope

sz

buf

11

‘a’‘a’ ‘a’‘a’‘a’‘a’ ‘a’‘a’ ‘a’‘a’ ‘a’‘a’

Existing Energy-interference-free Tools are Inadequate

Invisible to the Oscilloscope

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 66: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 72

EDB: An Energy-interference-free Debugging Toolchain

We built energy-interference-free support for

debugging and monitoring intermittent, energy-harvesting computers.

Energy-interference-free

debugger

Reboot… …bug!

AssertionsBreakpointsTracingInteractive debuggingEnergy tracingDebug-time I/O& More!

Simultaneously monitor & manipulate program state and energy state.

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 67: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 73

call append()

buf[sz] = ‘a’

sz++

for( i = 1)

Reboot…

…data

corrupt!

call append()

buf[sz] = ‘a’

sz++

for( i = 1)

Monitoring Target Energy & Device State

Read Target Energy Level

Read Target Radio I/O

All monitoring is energy-interference-free

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 68: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 74

Manipulating Energy State of the Device

AssertionsBreakpointsTracingInteractive debuggingEnergy tracingDebug-time I/O

We charge or discharge the device to compensate for expensive debugging tasks.

Break

Arbitrary

Debugging

Tasks(that consume

the target’s energy)

Compensating

Recharge

Debugging Tasks

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 69: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 75

Case Study: Expensive Consistency Checks Can Kill You

Consistency Check

Main Loop Work

One list element to check Many list elements to check

Without EDB, checks consume energy Eventually, checks prevent progress.

insert_element()

foreach(elem e){

assert(e.next.prev == e) }

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 70: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 76

Case Study: EDB Enables Expensive Checks

One list element to check Many list elements to check

EDB provides energy for the check only Eliminating energy interference enables expensive checks

insert_element()

foreach(elem e){

assert(e.next.prev == e) }

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 71: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 77

How Energy-interference-free?

From the circuits up, EDB is energy-interference-free

Compensating charge

error: ~4.3% of total E(in a 47uF cap)

Passive monitoring E

interference:

~0.2% of active power(worst case)

?

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 72: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 78

Integrated EDB Support for Deployed Diagnostics

Integrating EDB with an application board’s design enables beta testing

& diagnostics in a realistic target environment

Program Tracing

I/O Tracing

Energy Tracing &

Manipulation

EDB can be powered

to make test

framework reliable

[Colin, et al. CASES ’15, ASPLOS ’16, IEEE Micro Top Picks

‘16]

Page 73: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 79

EDB is freely available to researchers!

Use EDB for your research! Email us for hardware!

http://intermittent.systems | http://github.com/CMUAbstract/edb-rat

Page 74: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 82

Designing for IntermittenceSystem Support for Reliable Intermittence

The Intermittent Execution ModelReasoning About Intermittently-powered Devices

Intermittence Debugging Toolchain Support for Understanding

Intermittence

Page 75: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 83

Future ChallengesIntermittent Computing Research Directions

Page 76: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Brandon Lucia - Carnegie Mellon University - Challenges of Intermittent Computing 84

?Energy Modeling:

How much energy

does my code

need?Key challenge: platform energy varies

Intermittent

Verification: Is my

program correct?Key challenge: modeling intermittent

behavior

Distributed

Coordination: Can

devices cooperate?Key challenge: communication & dist.

state

Page 77: Programming Challenges of Intermittent Energy-harvesting ......NV for( i = 1) call hicost() call foo() call bar() Energy cost atomic span exceeds energy capacity Intermittence Bug:

Solving the System Challenges ofIntermittent Energy-harvesting DevicesBrandon Lucia | Assistant Professor, CMU ECEABSTRACT Research Group - https://intermittent.systemswith PhD Students: Alexei Colin, Kiwan Maeng, Emily Ruppel, Vignesh Balaji

Graham Gobieski, Milijana SurbatovichMS Students: Preeti Murthy, Amanda Marano, Neil Ryan, Devon White, Chris MeredithBS Students: Graham Harvey, Mark McElwaine, Hannah TomioIndustry Collaborators: Zac Manchester (Harvard/KickSat)

Alanson Sample (Disney Research Pittsburgh)