Rollback by Reverse Computation

17
Rollback by Reverse Computation Kevin Hamlen CS717: Fault-Tolerant Computing

description

Rollback by Reverse Computation. Kevin Hamlen CS717: Fault-Tolerant Computing. Research on Reversible Computation. Quantum Computing Quantum Computation (Nielsen & Chuang) Nanocomputers Ralph Merkle @ Zyvex (http://www.merkle.com) Low-power processor design - PowerPoint PPT Presentation

Transcript of Rollback by Reverse Computation

Page 1: Rollback by Reverse Computation

Rollback byReverse Computation

Kevin Hamlen

CS717: Fault-Tolerant Computing

Page 2: Rollback by Reverse Computation

Research onReversible Computation

• Quantum Computing– Quantum Computation (Nielsen & Chuang)

• Nanocomputers– Ralph Merkle @ Zyvex (http://www.merkle.com)

• Low-power processor design– http://www.ai.mit.edu/~cvieri/reversible.html

• Computational Complexity Theory– Time and Space Bounds for Reversible Simulation (Buhrman, Tromp, and

Vitányi)

• Parallel Programs & Fault Tolerance– Carothers (RPI), Perumalla (Georgia Tech), and Fujimoto (Georgia Tech)

Page 3: Rollback by Reverse Computation

Georgia Tech Time Warp (GTW)

• General purpose simulator– telecommunication network simulations– commercial air traffic simulations

• Parallel– Shared memory– Message passing

• Event-based– Each computation and each event associated with a

stimulus event

• Executes programs written in C/C++ w/API calls

“General purpose parallel discrete event simulation executive”

Page 4: Rollback by Reverse Computation

Optimistic Synchronization

• Incorrect computations permitted– Roll back when error detected

• Direct cancellation

Page 5: Rollback by Reverse Computation

State-Saving• Copy state-saving – copy of entire state

saved before every event• Periodic state-saving – copy of entire state

saved before every pth event• Incremental state-saving – copy of only

modified state saved before every event• Reversible Computing – copy of only

destroyed state data saved before every event

Page 6: Rollback by Reverse Computation

Advantages of Reversible Computing

• Lower space overhead for saved state

• Lower time overhead in non-rollback case

• Cost of state-saving amortized over duration of computation

• Advantages most pronounced in fine-grained settings (i.e. many events each associated with small computations)

Page 7: Rollback by Reverse Computation

Reversing C ProgramsOriginal

int x=0, y=1;

f(){ if (x>y) y += x; else x += y;}

Reversible

int x=0, y=1;bit b;

f’(){ b = (x>y); if (b) y += x; else x += y;}

Reverse

int x=0, y=1;bit b;

rf’(){ if (b) y -= x; else x -= y;}

Note: If S is the state, then we need rf’(f’(S))==S. However we don’t care about the result of f’(rf’(S)).

Page 8: Rollback by Reverse Computation

RCC: Reverse C Compiler

• Transforms arbitrary C programs

• Each function made reversible

• A reverse of each function is generated

• GTW Executive modified to call function reverses during rollback

Page 9: Rollback by Reverse Computation

Saving Destroyed State Data:The Tape Driver Abstraction

SAVE_BYTES(var) – push var onto the tape and increment the tape pointer by sizeof(var)*8

RESTORE_BYTES(var) – pop var from the tape and decrement the tape pointer by sizeof(var)*8

SAVE_BITS(var, n) – push the n low-order bits of var onto the tape; increment the tape pointer by n

RESTORE_BITS(var, n) – pop n bits from the tape and store them in the n low-order bits of var; decrement the tape pointer by n

Page 10: Rollback by Reverse Computation

RCC’s Transformation

Original

int x=0, y=1;

f(){ if (x>y) y += x; else x += y;}

Reversible

int x=0, y=1;

f’(){ char c=!!(x>y); if (c) y += x; else x += y; SAVE_BITS(c,1);}

Reverse

rf’(){ char c; RESTORE_BITS(c,1); if (c) y -= x; else x -= y;}

Page 11: Rollback by Reverse Computation

RCC Compilation Procedure

Normalize Transform Optimize

OriginalC Program

ReversibleC Programw/reverses

Page 12: Rollback by Reverse Computation

Normalization Post-conditions• Only one assignment per expression. No

other side-effects in such an expression except possibly a single function call.

• for() loops replaced by equivalent while()’s.

• Conditional expressions are side-effect free.• Only one return statement per function. It

has the form “return;” or “return var;”• break’s and continue’s replaced by goto’s.

Page 13: Rollback by Reverse Computation

Two Unusual Normalizations

• All floating point datatypes promoted to strictly higher precision types– Software emulation of a new highest-precision

datatype may be necessary.

• Abnormal exit (via goto) from a block requires saving all variables which are about to go out of scope.– Analogous to how C++ handles implicit

destructor calls

Page 14: Rollback by Reverse Computation

Transformation Phase:Block Scopes

Original

{ int x, y; s1 s2 s3}

Reversible

{ int x, y; s1 s2 s3 SAVE(x); SAVE(y);}

Reverse

{ int x, y; RESTORE(y); RESTORE(x); rs3 rs2 rs1}

Page 15: Rollback by Reverse Computation

Interesting Transformations

• Function pointer calls – maintain a hash table of the reverses of functions

• Labeled join points – introduce a variable to record the source of the jump

• Loops – introduce a counter variable to record the number of iterations

Page 16: Rollback by Reverse Computation

Optimization Phase

• Irreversible operations ignored (e.g. output, network message sends)

• Kernel-reversible operations are special cases (e.g. message cancellation)

• Dataflow analysis on reverses (esp. initializer expressions)

• Invariant detection (esp. conditionals)• Tape compression (esp. loops)

Page 17: Rollback by Reverse Computation

References

C. Carothers, K. S. Perumalla, R. M. Fujimoto. “Efficient Optimistic Parallel Simulations using Reverse Computation.” In Proceedings of 13th Workshop on Parallel and Distributed Simulation, May 1999.

K.S. Perumalla and R. M. Fujimoto. “Source code transformations for efficient reversibility.” Technical Report, GIT-CC-99-21, College of Computing, Georgia Institute of Technology.