1 / 38

The Regiment Macroprogramming System

The Regiment Macroprogramming System. Ryan Newton (MIT) Greg Morrisett, Matt Welsh (Harvard). Sensor Network Programming. ... is hard low level resource management, debugging embedded devices Macroprogramming - one proposed solution Program at the global level

quail-johns
Download Presentation

The Regiment Macroprogramming System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Regiment Macroprogramming System • Ryan Newton (MIT) • Greg Morrisett, Matt Welsh (Harvard)

  2. Sensor Network Programming • ... is hard • low level resource management, debugging embedded devices • Macroprogramming - one proposed solution • Program at the global level • Implicitly distribute program onto network • Compiler/runtime maps global to local

  3. Why Regiment? • Some Macroprogramming approaches: • TinyDB: send SQL query to the network • Kairos: focused on synchronizing shared state • And many others... + middleware layers (Hoods, Abstract Regions) • When to use Regiment? • Long-running stream-processing computations • Significant spatial component to processing (regions) • Need efficient compiled node-program

  4. Regiment: spatio-temporal macroprogramming • Stream-processing dataflow language • Streams of sensor data • Regions group streams, capture subsets of interest • Filter regions, map functions over them,fold (reduce) to produce results • Compiler: convert source to custom intermediate language [IPSN ‘05] • This paper: app case study + evaluation • Collaborative sensing: detect chemical plumes

  5. Outline • Regiment Language • Regiment Compiler • Application Case Study

  6. S sfilter(p, smap(f, S)) For this talk: assume epochs. Basic Datatypes • Nodes are modeled as streams of tuples • Streams can be processed by user functions or filtered with user predicates • Regions are bundles of streams • Accessible only through region operators

  7. R’= rmap(f, R) Outputs a region! Basic Operators • rmap: apply a function to all data elements of all streams in a region region R R’= rmap(f, R)

  8. Basic Operators • rmap: apply a function to all data elements of all streams in a region • rfilter: reduce membership in a region by applying a predicate region R R’= rmap(f, R) R’’= rfilter(p, R’)

  9. Basic Operators • rmap: apply a function to all data elements of all streams in a region • rfilter: reduce membership in a region by applying a predicate • rfold: aggregate a region into a single stream using associative, commutative function region R R’= rmap(f, R) R’’= rfilter(p, R’) rfold(avg, (0,0), R’’)

  10. Region Formation • world: a special region containing all nodes in the network • rmap/rfilter output new region values (but don’t construct regions) • neighborhood formation primitives • find the nodes near a given node • by hops, distance, etc • For example khood(k-hop-neighborhood) ‘world’ khood(1,N1)

  11. Composable Operators! • Regiment’s operators produce and consume regions • Can construct nested regions (region of regions) • Enables collaborative sensing • Together with user-defined functions this makes the language expressive world rmap( khood(1), world)

  12. Example Query: Average temperature More involved thanSELECT AVG(TEMP) but much more general... fun dosum(temp, (sumtemp, count)) { (sumtemp+temp, count+1) } tempreg = rmap( sense("temp"), world); sumstrm = rfold( dosum, (0,0), tempreg); avgstrm = smap( (/), sumstrm); BASE ← avgstrm User-Defined Functions are integrated Can map/filter/fold an arbitrary number of times, use nested regions, etc.

  13. Different communication strategies Local Filtering Collaborative Filtering • Regiment is high level • these programs are simple and short • but not TOO high level • still expressive enough to take control of the comm strategy! Collaborative w/Gossip Gossip w/ suppression

  14. Second Variant: Collaborative Filtering fun localthresh(nd) { sense("concentration", nd) > CHEM_THRESHOLD } detects = rfilter(localthresh, world); hoods = rmap( fun(nd){ khood(1,nd) }, detects); fun sum(r) {rfold((+), 0, r)} sums = rmap(sum, hoods); BASE ← rfilter( fun(cnt){cnt > CLUSTER_THRESH}, sums)

  15. Aggregates data from neighbors into tableindexed by node id Third Variant: Gossip fun sum(tbl) { fold( fun((id,t), acc) {t + acc}, 0, r) } detects = rfilter(abovethresh, rmap(read,world)); tables = table_gossip(detects); sums = rmap(sum, tables); BASE ← rfilter(fun(t) {t>CLUSTER THRESH}, sums)

  16. How much understanding of the underlying compiler and runtime system do you think is needed to develop an efficient application in Regiment? Discussion ?

  17. Outline • Regiment Language • Regiment Compiler • Application Case Study

  18. Strawman Proposal • What would a “direct” implementation look like? • How do you implement a variable that stores a region? • Or a function that takes and returns regions? • A region would be manifest as a table of nodes/data • A central base station would manage region tables • Runtime messages would task & query regions • Extremely inefficient! • Requires constant communication with base station during steady state operation Instead we generate a distributed, node-level program

  19. The Regiment Compiler • Regiment Source • Region dataflow • Node dataflow • Token machine [IPSN ‘05] • Token encapsulates state and handler method • Event driven • Atomic, asynchronous event handlers rmap(project, rfilter(abovethresh, world) No heavyweight query-engine or runtime required

  20. Architecture • Regiment Compiler: • Simplify source • Partial evaluate to produce aRegion Dataflow normal form • Convert to Node Dataflow(Switch POV) • Convert to Token Machine • General-purpose Spanning tree implementation used to implement regions • Also in the paper:Compiling programs with nested regions

  21. Compiling Regiment Programs • Regiment walks a thin line • We can’t implement (at runtime): • region values stored in data structures • if x then R1 else R2 • Thus: partial evaluate at compile-time • ‘x’ above must evaluate at compile time • Essentially: write script to generate fixed Region dataflow • (But still with nested regions, much generality)

  22. Outline • Regiment Language • Regiment Compiler • Application Case Study

  23. Application: chemical plume detection • Event (chemical plume) starts at a point • Spreads outward uniformly • Nodes sense event proportional to distance from edge of affected area • Data-fusion from multiple nodes allows extraction of signal from noise (Image from Glenn Nofsinger)

  24. RED LED: Reading exceeds local threshold Expanding Circle:Chemical Plume GREEN LED: node within plume

  25. Different communication strategies Local Filtering Collaborative Filtering Collab w/ gossip & suppression Collaborative w/Gossip

  26. Expressiveness:Make the easy program easy and the hard possible Simulation: 250 nodes avg degree ~7.2 network diameter ~13 ETX-based trees Simple probabalistic connectivity model Communication savings through program refinement • Local chem threshold 12ppmnoise stddev 4ppm

  27. Current and Future Work • Regiment 2.0 == WaveScript • Added signal processing libraries • Using for several applications currently • acoustic localization, pipeline leak detection • C++ backend, runs on ARM class or better • We hope to replace our incomplete NesC backend with a better solution using a third party virtual machine • Looking for users! Download at http://regiment.us

  28. Conclusion • Regiment converts global program to node behaviors • Carefully designed operator set + partial evaluation rules • Partial evaluation strategy enables abstraction, reusability in the source, w/out loss of efficiency in the generated code • Productivity tool • Allows rapid prototyping of applications • Tool support for debugging (simulator)

  29. Extra Slides

  30. Unraveling Nested Regions • For nested regions • Trace new data flow • Splice operators in • Generate node dataflow • Hooks into spanning tree service

  31. First Variant: Local Filtering fun abovethresh((chem,id)) { chem > THRESHOLD } fun projectfields(node) { (sense("concentration", node), nodeid(node)) } BASE ← rfilter(abovethresh, rmap(projectfields, world)) Now we rapidly prototype several solution variants

  32. Thershold vs. Detection Latency

  33. Communication Overhead

  34. Local Filter

  35. Collaborative Filter

  36. Collaborative (gossip) Filtering

  37. Gossip with Suppression

  38. Operating systems (TinyOS) Resource (device) management Basic primitives Protocols (MAC, routing) {covered in many previous lectures} Programming languages and runtime environments Low level (C, nesC) Very high level abstractions (Regiment) Services needed Synchronization of clocks (RBS) Propagation of new code to all nodes (Trickle) Localization {not today} Software Development Infrastructure for Sensor Networks

More Related