Title: Towards a Static TimeAnalysis for Hume programs
1Towards a Static Time-Analysis for Hume programs
Kevin Hammond, Roy Dyckhoff,Pedro Vasconcelos,
Meng Sun, Leonid Timochouk,Edwin Brady, Steffen
Jost, Armelle Bonenfant University of St Andrews,
ScotlandGreg Michaelson, Andy Wallace,Robert
Pointon, Graeme McHale, Chunxiu Liu, Gudmund
Grov, Zenzi ChenHeriot-Watt University,
Scotland Jocelyn Sérot, Norman ScaifeLASMEA,
Clermont-Ferrand, France Martin Hofmann,
Hans-Wolfgang LoidlLudwig-Maximilians
Universität, München, Germany Christian
Ferdinand, Reinhold HeckmannAbsInt GmbH,
Saarbrücken, Germany http//www.hume-lang.orghttp
//www.embounded.org
2Hume Design Objectives
Purely Functional Expressions
Reliability, Expressibility, Controllability, Pre
dictability, Costability
- Targets embedded/critical applications
- Hard real-time target
- Formally bounded time and space
- I/O managed through low-level ports/streams
- Memory-mapped, interrupts or devices
- Asynchronous concurrency model
- Simple exception handling mechanisms
- Transparent design and implementation
correctness by construction - High level of expressiveness/productivity
- Rule-based system concise clear
- Runtime errors reduced by strong polymorphic
types - Structured reuse through higher order functions
- Thread management simplified by implicit
concurrency/parallelism - Elimination of memory errors through automatic
memory management
3Autonomous SystemsDefence Technology
Centre(Hammond,Bonenfant)
- MoD research project
- led by Bae systems, 7 industry participants, 9
universities - Systems Engineering Integrated Systems for
Defence Autonomous Semi Autonomous Vehicles - focus on sensors for autonomous vehicles
- The DTC will
- develop novel technology-based system solutions
to the understanding and advancement of
uninhabited military vehicles. - exploit Hume for sensor control using novel
computer vision algorithms - Key aspects are
- certification (in particular for safety related
issues) - validation and verification
4(FSM-)Hume Example Polling
- -- poll for input
- stream input from "std_in"
- stream output to "std_out"
- data STATUS WAITING RECEIVED
- box getinput
- in (ichar)
- out (ochar,handshakeSTATUS)
- match
- v -gt (v,RECEIVED)
- -gt (,WAITING)
- wire getinput (input) (output,timer.monitor)
std_in
i
getinput
handshake
o
timer. monitor
output
5Abstract Machine Design
- Simple Stack Heap Design
- Stack machine, higher level than JVM (about 8x
speed for naive impl.) - Supports concurrency, timeouts, exceptions, HOFs
- Formal compilation scheme
- Hume to AM compiler written in Haskell
- AM interpreter and runtime written in C
- Purpose
- Ease of costing rather than absolute speed/size
- Predictable real-time behaviour
- Real-Time ? Real Fast!
6Abstract Machine Design (2)
instructions
- One Stack One Heap per box
- No GC necessary
- small SP and HP (can be one byte)
- all values boxed (at present)
- Fixed-Size Wire Buffers
- Shared Instruction Stream
output
box
wire
input
Heap
Stack
internal
7Basic Instructions
8Match Instructions
9Coordination Instructions
10Towards a formal time cost analysis
- Approach
- Getting accurate worst-case distribution of time
costs based on empirical evidence (for each
necessary architecture) - Adding time cost model to space cost model in
operational semantics - Providing cost analysis
expression
environement
heap
location
heap
signature
(Steffen Jost)
stack and heap units available before evaluation
and unused after evaluation
11Method (after Bernat 2003)
- Individual timing execute each instruction
(identical context) a relevant number of times
and record the average/worst-case duration. - record AM state current time
- execute instruction(s) repeatedly
- restore AM state and show average time
- (n.b. some states are hard to restore!!)
- Statistical distribution execute a program that
includes each instruction a different relevant
number of times and obtaining a distribution over
time
12What is meant by Relevant?
- Figures for MkBool instruction
13Normal distribution
14(FSM-)Hume Example
- stream output to "std_out"
- box testb1
- in (nint 32)
- out (nint 32,nint 32)
- match
- 0 -gt (1,)
- 1 -gt (2,)
- 2 -gt (3,3)
- _ -gt (,4)
- wire testb1 (testb1.n) (testb1.n initially
0,stdout)
15Corresponding ham code(first match)
-
- Label "testb1_0"
- MatchRule
- MatchAvailable
- MatchInt 0
- Consume 0
- MatchedRule
- MkNone
- MkInt 1
- MkTuple 2
- Unpack
- CheckOutputs
- Write 0
- Write 1
- Schedule
16Instruction Effects(PowerBook G4 1.67GHz)
17Conclusions
- Statistic accuracy
- Portable
- ... work in progress...
18Future Work
- Larger example - parameterised instructions
- Extend Cost Analysis to Primitive Recursion and
HOFs - Introduce timing function in Semantics and
analysis
19HumeHigher-order Uniform Meta-Environment
David HumeScottish Enlightenment Philosopher
and Sceptic 1711-1776