2008 ICFP DEFUN - Functional in The Field
2008 ICFP DEFUN - Functional in The Field
Ryan Newton
+
What I’m advocating: 3 things
App2:
App2: birds
birds
Functional programming DetectEvent
Type/memory safety
Audio0
Polymorphism (generics)
Audio1
Factoring control patterns, functions/closures
sync
Audio2
Node
Locations sync4 Buffer N
>3sec?
Event Pseudo-likelihood
association Map
Evaluation
Infrastructure,
Sensors Desktop/Server
Not TCP/IP
TinyOS
iPhone SDK
+
Brew Why stream languages
Android • A big mess of hardware
JavaME Phone
Symbian • No convenient way to write
programs that use all pieces
• Def. not high perf ones (Erlang, Java)
•No phone/pc p2p services
•Would require migrating comp.
+
Vision:
A language for a streaming era
Phone
Convenience – automate what can be automated
Network transparency, scheduling, distribution (sometimes)
Execution Model
Execute!
•iterate – run code on each iterate
element
Fission / Replication
Must be
(inlining)
stateless!
Meters
Meters
100
104 105
110
Evaluation
Easy to move node/server boundary
+
Audio Sensor Node
Detect
Input
Node
Locations sync4 Buffer N
>3sec?
Event Pseudo-likelihood
association Map
+
WaveScript Speedup
C WS Speedup
VoxNet DOA 3.00s 2.18s 1.38
VoxNet Detect 87.9% 56.5% Wins
Wins for
1.56 for this
this app:
app:
•• Portable
Portable HLL
HLL
LOC / WS LOC / ••C Network
Network transparent
transparent
Detector 92 252 •• Whole
Whole program
program compile
compile
DOA 124 239 •• Stream
Stream graph
graph opts
opts
Evaluation
+
Case Study 2: background subtraction
for bird classification
+
Case Study 2: background subtraction
for bird classification
+
Case Study 2: background subtraction
for bird classification
Application in use by UCLA Sensing/Computer Vision
group
Not experts in embedded computation
pixel
}
pixel_kernel(fun(nbrhd) { nbrhd(0,0) + nbrhd(1,1) }, strm)
pixel_kernel(fun(nbrhd,st) { … }, init_state, strm)
+
Case Study: background subtraction
application
Original code – massive duplication (1300 lines of C++)
Image
+
Server side: Parallel Speedup
Wins
Wins for
for this
this app:
app:
•• Types
Types &
& higher
higher order
order
functions
functions enable
enable aa fully
fully
polymorphic
polymorphic parallel
parallel matrix
matrix
library
library
http://wavescope.csail.mit.edu