Slides
Slides
Challenges of analysis
or
Niklas Holsti
Tidorum Ltd
www.tidorum.fi
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 1 of 31
Outline: the dark prospects
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 2 of 31
Main reason for WCET analysis problems
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 3 of 31
So why work on WCET analysis?
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 5 of 31
Would WCET analysis have helped?
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 6 of 31
Evolution in programs
Program architecture evolves
new styles and paradigms
new languages and tools
All programs
Typical
WCET programs
tool year 2020
Typical Typical
programs programs
year 2000 year 2010
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 7 of 31
What is a program?
Historically:
machine code compiled and linked from source code
burned into the (EEP)ROM, same in all units
invariant during execution, not self-modifying
understood by the programmers, at least on the source-
code level, often on the machine code level too
Now becoming:
a “model” in Matlab/Simulink, UML, or whatever
created by 5-10-100-... programmers
who do not understand how the model is converted into
machine code for execution, via C or Java, bytecode, JIT,
DLLs, etc, etc.
the final machine code may be different depending on the
unit, the external and internal conditions, and the phase of
the moon, and may change during the execution
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 8 of 31
Consequences 1: Hiding global control flow
In several ways:
virtual function calls depend on object class
table-driven routines depend on table contents
call-backs depend on call-back pointers
Present value analysis in WCET tools unsuitable
interval domain poor for object class, pointer, enum
ditto polyhedron domain
Solution?
for static (constant) data: see consequences 4
for dynamic (variable) data: see consequences 1?
apply “shape analysis” to the data?
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 10 of 31
Consequences 3: More function pointers
Reasons for it
object-oriented designs (virtual function calls)
call-backs to compose “SW components”
or to specialize “SW frameworks”
Problems
call-graph hard to recover from machine code
but the design tool probably knows it very well !
Why are function pointers so hard to analyse?
they are initialised far away from their uses
they are held in memory, subject to aliasing
over-estimation has drastic effects on the analysis
Solutions?
convince code generators not to use function pointers
or generate also the annotations to help WCET tools
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 11 of 31
Consequences 4: More initialization code
Running at SW boot:
crt0, of course, but also:
object constructors
registry calls, call-back set-ups
HW presence checks & adaptations
The linked memory image is no longer a good description of
the state of the program at execution time
analysis of a subprogram/thread must consider
the global state set up by the boot/init code
Solution?
simulate or execute the boot/init code
dump an “execution-ready” memory image for analysis
the value-analysis of a WCET tool is almost a simulator
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 12 of 31
Consequences 5: Inhuman code
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 14 of 31
What is a processor?
Historically:
a machine that executes one sequence of instructions
from a standard instruction set for this architecture
using a well-defined, stable sequence of cycles / stages
fetch, decode, execute, ...
same for many applications
Now becoming:
a system of communicating, parallel functional units
each with its internal history-dependent state
executing several instruction streams
in parallel, with dynamic scheduling and ordering
with wildly varying execution time per instruction
depending also on the implementation of the architecture
eg. ARM chips from various manufacturers
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 15 of 31
The processor race
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 16 of 31
Can it be analysed statically?
My impression:
static-analysis models exist for many “features”
caches, pipelines, branch predictors, ...
but not, in practice, for their complex combinations
State of the art: aiT from AbsInt
models the processor as communicating units (FSMs)
abstracts only:
the cache (to eg. LRU “ages”)
the values of addresses (to intervals)
no other real abstractions of the whole processor state
aiT must simulate most possible executions in a BB
does not scale to really complex processors (my opinion)
Solutions? to analysis of such processors
none, I believe :-(
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 17 of 31
Timing anomalies, why?
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 18 of 31
On greed
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 19 of 31
Sad example
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 20 of 31
Final insult...
Asynchronous processors
no clock !
each logic signal comes with a handshake
“relay race”, computations go as fast as possible
ET depends on voltage and temperature, etc.
ET depends on data values
Advantages:
low-noise operation
no clock / power transients on signals
perhaps low-energy operation
only those FF's change that need to
WCET analysis?
static analysis unsafe without large over-estimates
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 21 of 31
Special processors for hard RT?
To be predictable and analysable
Scratchpads, lockable caches, ...
static allocation limits size of fast memory
especially difficult for multi-threaded systems
easiest to analyse if different instructions for fast memory
eg. Intel 8051 “internal” and “external” memory space
but complex to program (eg. pointers to either space)
Suggestions:
multicore with predictable cores (thus rather slow)
perhaps a bit of VLIW for compile-time scheduling
plenty of local memory per core
all memory accesses can be analysed as fast
no shared caches
all use of shared or off-chip resources analysed as I/O
in the schedulability analysis (“not my problem” :-)
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 22 of 31
Turtles all the way
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 23 of 31
Measurement-based methods
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 26 of 31
Flow analysis: work to do
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 28 of 31
Infeasible paths in general
Unstructured problem
little work on classification of types of infeasible paths
attempt (A. Holsti):
local (intra-procedural) path
non-local (inter-procedural) path
over-iteration path (loop cannot repeat so many times)
intra-repeat path (within one iteration of loop)
inter-repeat path (over one or more iterations of loop)
loop-entering path
loop-exiting path
Practical importance not well known
easy to construct examples with huge effects
my experience: sometimes very important, sometimes not
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 29 of 31
Time-introspective programs
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 30 of 31
Summary
WCET analysis is practical now only for relatively simple
programs on relatively simple microcontrollers
“simple” does not imply “small”
highly critical systems: aerospace, automotive, nuclear
Static analysis of worst-case processor behaviour seems
hopeless for high-end, general processors
open: are predictable but powerful processors possible?
Msmt-based analysis is unreliable for the same reasons
but more reliable than end-to-end measurements
Flow analysis has promising problems to work on
Increased use of static analysis for bug-finding etc.
may push programs to be more analysable
Existence of WCET tools pushes the “state of the art”
may make WCET analysis required for critical SW
Tid
rum
Timing Analysis / Aalto ESG / T-106.5840, 12.5.2011 slide 31 of 31