Title: Mehwish Nagda, Christo Frank Devaraj, Indranil Gupta, Gul Agha
1- Mehwish Nagda, Christo Frank Devaraj, Indranil
Gupta, Gul Agha - University of Illinois (Urbana-Champaign)
2Motivation
- Many scientific disciplines express ideas,
results and phenomena through differential
equations - From competition in ecosystems to Schroedingers
Wave Equation - Can we translate the scalability and reliability
inherent in non-Computer distributed systems into
protocols for distributed systems? - Can we generate code for such distributed
protocols? - Can we do this rigorously, rather than
hand-wavily?
3Approach
- DiffGen Toolkit to systematically translate a
subset of differential equation systems into
equivalent distributed protocol code in C so that
the protocols are guaranteed to - show equivalent stochastic behavior as original
equation system - be probabilistically scalable
- be probabilistically reliable
- have low and scalable bandwidth at each process
- have low convergence times
- DiffGen internals are backed by rigorous
translation methodologies, that guarantee
provable properties of generated code.
4Internals Input Semantics
Dx 0.3x2z2 - 0.3x2y2 Dy
0.3y2z2 - 0.3x2y2 Dz -0.3x2z2
-0.3y2z2 0.3x2y2 0.3x2y2
- The above is a sample input into the toolkit for
a system of 3 equations. - Each equation has to be in the form Dxi f(x1,
x2, ..., xi, ..., xn) where xi is the variable
that is differentiated. - 0.3x2z2 is a term in the first equation for
variable x. - Each term in the equation starts with a positive
or negative constant value. - Variables in the term are separated by .
- Exponents for each variable follow the '
character. A variable with no exponent defined
has an exponent of 1.
sample input (diffsys) file
5Intermediate Representation, diffIR
- Input system is converted to diffIR, the
intermediate representation of the differential
equation system - The differential system contains a list of
differential equations in the system. - The differential equation contains a list of
positive and negative terms as well as the
differential equation variable. - The equation term contains the constant in the
term, the set of variables involved in the term
and their exponents, and a reference to the
matching negative or positive term in the
differential equation system.
equation variable
negative terms
positive terms
positive terms
negative terms
differential equation
constant
match term
differential equation
variable
exp
variable
exp
equation term
differential system
6Science of Protocol Design
- The toolkit then maps the equation system to a
state machine which contains - One state per basic variable in the original
equation system - Actions mapped onto these states by mapping terms
to one of three actions
Term T
flipping
Periodically toss coin with probability p.c If
heads, switch state to state y with c.x term
7Term T
one time sampling
with
Periodically toss coin with probability p.c If
heads, sample
other processes uniformly at random from
across the group If first target
choices are in state x and for all j,
the jth process sampled
is in the same state as the jth variable in
(when ordered
lexicographically), then switch state to
state y with the T term
Term T
tokenizing
with
A variable w in X is chosen such that Flipping
or one time sampling actions are created for
processes in state w with actions modified so
that instead of switching state a token is sent
to a random process known to be in state x that
transitions into the state of the variable with
the corresponding T term on receiving the token
8Template files
- The diffIR is mapped to the above actions and the
code is generated into template files. Template
files implement - Alarm System Timer events are used to wake nodes
up to carry out protocol actions every protocol
period. A node in a particular state will set a
timer for each negative term in the corresponding
differential equation. - Core Probabilistic Functions Code for flipping,
one time sampling and tokenizing are written in
the form of four parameterized C functions
(flipping, ots, tok_flipping and tok_ots). - Communication The messaging subsystem is built
out of an interface that has two methods send_msg
and receive_msg. We provide both a simulator
implementation and a UDP sockets implementation. - Server The server is used to register each
client and to stop the protocol.
9Generated Code
- Code generated is for the Lotka Volterra model.
The output protocol is for majority selection in
a distributed system - Code generated consists of the header snippet (in
fixedclient.h and common.h) and the
initialize_states and schedule_timer_event
functions (in fixedclient.c) - The header snippet defines the number of states
(equations) in the input system and constants for
each state - The initialize_states function initializes the
number of negative terms in each equation
Dx 0.3xz - 0.3xy Dy 0.3yz -
0.3xy Dz -0.3xz -0.3yz 0.3xy
0.3xy
sample input
define STATES 3 int state_termsSTATES defi
ne ST_x 0 define ST_y 1 define ST_z 2
header snippet fixedclient.h common.h
void initialize_states() state_termsST_x
1 state_termsST_y 1
state_termsST_z 2
Initialize_states snippet fixedclient.c
10Generated Code
void schedule_timer_event (int nodeid, struct
pp_payload payload) int curr_term,
to_state, prev_state int curr_state
float p curr_state get_state()
prev_state curr_state if (curr_state !
payload-gtstate) return curr_term
payload-gtterm if (curr_state ST_x
curr_term 0) int
num_states int states, exponents
num_states 2 states
(int)malloc(num_statessizeof(int))
exponents (int)malloc(num_states sizeof(int)
) states0 ST_ystates1 ST_x
exponents0 1exponents1 0
ots (ST_z, 0.5, num_states, states,
exponents) if (curr_state ST_y
curr_term 0)
- The schedule_timer_event function chooses which
of the four core probabilistic functions should
be called depending on the process current state
and the term associated with the current alarm.
The function is written using the three mapping
techniques for flipping, one time sampling and
tokenizing.
schedule_timer_event snippet fixedclient.c
11Additional DiffGen Capabilities
- Simple lightweight Internal Simulator for testing
and performance evaluation that is - synchronous
- based on a discrete event simulation model
- assumes a FIFO message queue
12This is Continuing Work
- Internal
- New rewriting techniques Develop graphical
simulator - Automated Debugging helped by emergent
knowledge of common bug classes among
differential equation-based protocols - Incorporating other Diff. Eqn based methodologies
as they emerge - Graphical Simulator
- External
- Combine with auxiliary methodologies for
augmenting protocol properties, e.g., topology
awareness - Combine with IDEs?
13Alpha version Demo
- We have a (working!) version of the DiffGen
toolkit - Please ask for a demo!