Optimization of Port Communication

Efficient Embedded Runtime
Systems through Optimization
of Port Communication
Software Engineering Institute
Carnegie Mellon University
Pittsburgh, PA 15213
Peter H Feiler
April 2, 2008
© 2006 Carnegie Mellon University
Outline
The problem
Buffer lifespan model
Buffer optimization considerations
Property preserving transformation
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
2
Shared Variable Communication
Pr 1
20Hz
Periodic I/O
From other
Partitions
Pr 2
20Hz
To other
Navigation
Sensor
Processing
Partitions
Pr 3
Shared
data
area
10Hz
Integrated
Navigation
Pr 4
Data flow determined
by execution order of
write & read
Preemption and
concurrency affect
read/write order
20Hz
Guidance
Processing
5Hz
Pr 6
Flight Plan
Processing
Pr 9
2Hz
Aircraft
Performance
Calculation
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
3
Non-Deterministic Sampling of Data Stream
Example: Downsampling
•
Desired sampling pattern 2X: n, n+2, n+4 (2,2,2,…)
•
Worst-case sampling pattern: n, n+1, n+4 (1,3,…)
20Hz
10Hz
NavSensor
Processing
Integrated
Navigation
Read
Write
Thread IntegratedNavigation
Thread NavSensorProcessing
Timeline
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
4
Port-based AADL Model
20Hz
20Hz
Nav signal
data
Navigation
Sensor
Processing
Periodic
I/O
To
Partitions
Nav
sensor
data
From
Partitions
10Hz
Nav sensor
Integrated
Navigation
data
Input-compute-output
AADL thread semantics
Nav
data
20Hz
Guidance
Processing
FP data
5Hz
Flight Plan
Processing
Immediate and delayed
data port connections for
deterministic sampling
Nav data
Fuel Flow
Guidance
Aircraft
Performance
Calculation
2Hz
FP data
Performance
data
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
5
Outline
The problem
Buffer lifespan model
Buffer optimization considerations
Property preserving transformation
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
6
General Unqueued Port Buffer Model
Producer
MPj
MCj
Send
Receive
MCk
MPk
Send
Xfer
MSj
Consumer
Consumer/Producer
MRj
MSk
Receive
Xfer
MRk
• Send/receive with or without copy
• Transfer with or without copy
• Processing with or without copy
MP: producer copy
MS: send copy
MR: receive copy
MC: consumer copy
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
7
Message Streaming Lifespan Model
B
Producer task
Send
Send buffer
Xfer
TP, Mi+1
E
MPi
DP, Mi+1
MPi+1
SMi
MSi
MSi+1
XMi
MRi
Receive buffer
MRi+1
RMi
Receive
MCi
Consumer task
TX
TC, Mi
MCi+1
DC, Mi
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
8
Message Lifespan Properties
Message operation ordering condition
SMi < XMi < RMi
MP bounded by producer dispatches
TP, Mi  BMPi  EMPi = SMi  TP, Mi+1
MC bounded by consumer dispatches
TC, Mi  RMi = BMCi  EMCi  TC, Mi+1
MS bounded by sends and transfer
SMi = BMSi  X*Mi  EMSi < SMi+1
MR bounded by transfers and receive
X**Mi  BMRi  EMRi = R***Mi < XMi+1
* Completion of transfer
** Start of transfer
*** Latest of multiple receivers
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
9
Outline
The problem
Buffer lifespan model
Buffer optimization considerations
Property preserving transformation
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
10
Sequential Task Execution
TP ; TC
Collapse to single buffer
MPi
MPi+1
MS
MS
MR
MR
MCi-1
MCi
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
11
Overlapping Message Instances
Overlapping message instance lifespan
Send, transfer, or receive as copy operation
Copy message between 2 buffers before BMPi+1 after EMCi-1
MPi
MPi+1
MS
MS
MR
MR
MCi-1
MCi
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
12
Application-based Send and Receive (ASR)
ASR
TP  P  S  P  DP
MP
TC  C  R  C DC
P
P S&X
 : actual execution start time
MR
C
 : actual completion time
C
R
MC
ASR/IMT
P - P  C - C    non-deterministic S/R
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
13
Buffer Optimization Considerations
Periodic & aperiodic task dispatch
Send and receive execution
• As part of application (ASR)
• As part of task dispatch/completion (DSR)
Task execution order
• Concurrent: C | P
• Atomic non-deterministic: C ≠ P
• Ordered: C ; P or P ; C
Message transfer
• Immediate to consumer (IMT)
• Direct to delayed consumer (DMT)
• Period-delayed to consumer (PMT)
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
14
Consumer Before Producer
C ; P consumer before producer: C,j  P,j
• Non-preemption: P,j - P,j  C,j - C,j = 
• Deterministic S/R for ASR & DSR
• ASR
Period delayed communication
• Sj-1 < Tj < Rj < Sj < Tj+1 : Sj = SMi  Rj = RMi-1
• IMT: Sj-1 = Xj-1 < Tj < Rj < Sj = Xj
Single buffer
• PMT: Sj-1 < Tj = Xj < Rj < Sj < Tj+1 = Xj+1
•DSR
• Sj-1 = DP,j-1 < Tj = Rj < Sj < Tj+1 : Sj = SMi  Rj = RMi-1
• IMT: Sj-1 = DP,j-1 = Xj-1 < Tj = Rj < Sj = Xj
• PMT: Sj-1 < Tj = Xj = Rj < Sj < Tj+1 = Xj+1
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
15
Periodic Task Communication Summary
Periodic
ASR
DSR
Same period
IMT | PMT
IMT | PMT
P ; C
MF:1B
C ; P
DMT
PD:2B
PD:2B
PD:2B
MF:1B
SXR
R
SX/R
PD:1B
PD:1B
PD:1B
PD:1B
PD:1B
P  C
ND:1B
PD:2B
PD:2B
PD:2B
ND:1B
X
R
X/R
P | C
ND:3B
PD:2B
PD:2B
PD:2B
NDI:2B
S/XC
RC
X
R
X/R
S/X/RC
MF: Mid-Frame
1B: Single buffer
S, X, R : data copy
PD: Period Delay
2B: Two buffers
S/X : IMT combined send/xfer
ND: Non-Deterministic
3B: Three buffers
S/X/R : DMT combined S, X, R
NDI: No Data Integrity
4B: Four buffers
X/R: DSR/PMT combined X, R
o1o2 : One operation copy
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
16
Outline
The problem
Buffer lifespan model
Buffer optimization considerations
Property preserving transformation
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
17
AADL Communication Semantics
• Input frozen at dispatch time
• Copy to input buffer at dispatch if required
• Data ports & periodic threads
• Immediate connection (DMT)
• Data driven execution or offset start time
• Delayed connection (DSR/PMT)
• Transfer by dispatch in runtime system
• Sampling ports
• Double buffer for concurrency or down-sampling to
ensure data consistency during compute
Port Communication Optimization
Feiler, April 2008
© 2008 Carnegie Mellon University
18
Peter H Feiler
[email protected]