Presentation is loading. Please wait.

Presentation is loading. Please wait.

ESP: A Language for Programmable Devices Sanjeev Kumar, Yitzhak Mandelbaum, Xiang Yu, Kai Li Princeton University.

Similar presentations


Presentation on theme: "ESP: A Language for Programmable Devices Sanjeev Kumar, Yitzhak Mandelbaum, Xiang Yu, Kai Li Princeton University."— Presentation transcript:

1 ESP: A Language for Programmable Devices Sanjeev Kumar, Yitzhak Mandelbaum, Xiang Yu, Kai Li Princeton University

2 Sanjeev KumarESP: A Language for Programmable Devices2 Programmable Devices Network Card Bus CPU D Mem R Disk CPU D D D Mem R Main CPUMain Memory Move functionality from main CPUs to devices

3 Sanjeev KumarESP: A Language for Programmable Devices3 Programming Devices in C WaitReq WaitNet WaitDMA Low-overhead concurrency –Threads vs. Event-Driven State Machines A state machine event DmaFree execute event UserReq execute processUser() event KernelReq execute processKernel() event NetFree execute

4 Sanjeev KumarESP: A Language for Programmable Devices4 Programming devices in C Contd. Programming is hard –Sequential code split into handlers Difficult for C Compiler to Optimize –Explicitly save values in global variables Hand optimizations make it worse –Fast paths (Violate modularity) –Ad-hoc Scheduling

5 Sanjeev KumarESP: A Language for Programmable Devices5 Case Study: VMMC Firmware Used Myrinet network cards –Gigabit network, 33 MHz CPU, 1 MB Event-Driven State Machines in C –Hard to program VMMC: 15,600 lines of C code –Hard to debug Complicated race conditions Trusted by the OS –Achieves good performance Requires hand optimizations Data OS VMMC Firmware Application Network High-Performance Communication Network Card

6 Sanjeev KumarESP: A Language for Programmable Devices6 Outline Motivation ESP overview ESP language Verifying ESP programs Performance of ESP programs Conclusions

7 Sanjeev KumarESP: A Language for Programmable Devices7 ESP: Event-driven State-machines Programming Domain-specific language Goals –Easy to program Concise, modular programs –Allow extensive testing Existing software verification tools –Performance Low overhead Case Study: VMMC firmware

8 Sanjeev KumarESP: A Language for Programmable Devices8 ESP Approach pgm.spinpgm.C ESP Compiler pgm.ESP help.C Generate Firmware Develop and Test test.spin

9 Sanjeev KumarESP: A Language for Programmable Devices9 Outline Motivation ESP overview ESP language Verifying ESP programs Performance of ESP programs Conclusions

10 Sanjeev KumarESP: A Language for Programmable Devices10 The ESP Language Message passing style concurrency (like CSP) Processes & Synchronous channels –in : Receive a message on a channel –out : Send a message on a channel –alt : Wait on multiple in/out operations Processes communicate only using channels –No shared mutable data structure Static Design

11 Sanjeev KumarESP: A Language for Programmable Devices11 A Process encodes a State Machine channel chan1: int channel chan2: int process add5 { $v: int = 0; while( true) { in( chan1, v); out( chan2, v+5); } States are implicit Events are messages on channels Easy to read & optimize Initial waitChan2 waitChan1

12 Sanjeev KumarESP: A Language for Programmable Devices12 Memory Management ESP supports explicit management Explicit management is difficult –Global property of program ESP makes this a local property –Objects are not shared by processes –Objects sent over channels are “copied” Use verifiers to check correctness Safety through verification instead of GC

13 Sanjeev KumarESP: A Language for Programmable Devices13 Other Language Features Pattern Matching supports dispatch –Receivers specify patterns to match –Sender simply sends on a channel Channels support external interface –Some channels have external reader or writer –Unified mechanism (C and SPIN) –Use in/out to block on external events

14 Sanjeev KumarESP: A Language for Programmable Devices14 Case Study: VMMC Firmware Implemented VMMC using ESP –7 processes, 17 channels –500 lines ESP + 3000 lines C code Modular programs that are easy to maintain Order of magnitude less code

15 Sanjeev KumarESP: A Language for Programmable Devices15 Outline Motivation ESP overview ESP language Verifying ESP programs Performance of ESP programs Conclusions

16 Sanjeev KumarESP: A Language for Programmable Devices16 Using Model Checking Verifiers State-space exploration –Try all possible scheduling options Automatic & produces counter example Exponential: State-space explosion ESP currently uses SPIN model checker –Designed for Software Systems –Assertions, Deadlocks, Linear Temporal Logic –Supports varying levels of coverage

17 Sanjeev KumarESP: A Language for Programmable Devices17 Case Study: VMMC Firmware Develop and debug retransmission protocol –Easier to debug than on the network card –Took 2 days (10 days in earlier implementation) Check for memory safety and leaks –Each process separately –Largest process: Less than a second –Used to find bugs Find deadlocks: Need abstract models

18 Sanjeev KumarESP: A Language for Programmable Devices18 Outline Motivation ESP overview ESP language Verifying ESP programs Performance of ESP programs Conclusions

19 Sanjeev KumarESP: A Language for Programmable Devices19 ESP Code Generation Compiling state machines –Combine them [Berry et. Al, Proebsting et. al.] –Low-overhead process management C as backend –Generates one large C function –Links with external C functions ESP Compiler performs optimizations –Whole program analysis

20 Sanjeev KumarESP: A Language for Programmable Devices20 Case Study: VMMC Firmware Measure overhead of using ESP –Microbenchmarks –Applications Compare performance –Earlier Implementation (vmmcOrig) –Earlier Implementation without Fast Paths (vmmcOrigNoFastPaths) –New Implementation using ESP (vmmcESP)

21 Sanjeev KumarESP: A Language for Programmable Devices21 Microbenchmarks Message Size (in Bytes) ss M B / s Message Size (in Bytes) LatencyBandwidth

22 Sanjeev KumarESP: A Language for Programmable Devices22 Applications SPLASH2 Applications on a 16 (4 X 4) node cluster 7% Slower on average Speedup

23 Sanjeev KumarESP: A Language for Programmable Devices23 Outline Motivation ESP overview ESP language Verifying ESP programs Performance of ESP programs Conclusions

24 Sanjeev KumarESP: A Language for Programmable Devices24 Related Work Code Generation & Verification –Esterel, Teapot, Promela++ Concurrent Languages –Theory: CSP, Squeak –Practice: Java, OCCAM, CML Tools – Meta-level compilation, SLAM, Verisoft

25 Sanjeev KumarESP: A Language for Programmable Devices25 Conclusions ESP: Domain-specific language –Support for writing concise, modular programs Order of magnitude less code –Developing and Extensive testing with SPIN Including checking memory safety –Low performance overhead

26 Sanjeev KumarESP: A Language for Programmable Devices26 - The End -

27 Sanjeev KumarESP: A Language for Programmable Devices27 Esterel Synchronous programming language –Encode control of reactive systems Generate software or hardware Deterministic reaction But –Only encodes control flow –Constraints on the language –Harder to compile efficiently

28 Sanjeev KumarESP: A Language for Programmable Devices28 Teapot Domain-specific language –Implement coherence protocols Specify a state machine Use continuations to simplify programming But –Only encodes control flow –Uses handlers: Code fragmentation –Similar approach would be less modular

29 Sanjeev KumarESP: A Language for Programmable Devices29 Promela++ Language for Layered Network Protocol –Non-strict extension of promela Asynchronous communication But –Layered structure –Asynchronous: overhead, ordering –No support for memory management

30 Sanjeev KumarESP: A Language for Programmable Devices30 Fast Paths Challenges –Scheduling choices made in the fast paths Also avoid starvation –Effective fast paths –How to let programmers specify fast paths ? User annotations Expose details to implement it in C


Download ppt "ESP: A Language for Programmable Devices Sanjeev Kumar, Yitzhak Mandelbaum, Xiang Yu, Kai Li Princeton University."

Similar presentations


Ads by Google