Rollback by Reverse Computation
description
Transcript of Rollback by Reverse Computation
Rollback byReverse Computation
Kevin Hamlen
CS717: Fault-Tolerant Computing
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)
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”
Optimistic Synchronization
• Incorrect computations permitted– Roll back when error detected
• Direct cancellation
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
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)
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)).
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
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
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;}
RCC Compilation Procedure
Normalize Transform Optimize
OriginalC Program
ReversibleC Programw/reverses
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.
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
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}
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
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)
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.