Efficient Embedded Runtime Systems through Optimization of Port
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 20 Hz Periodic I/O From other Partitions Pr 2 20 Hz To other Navigation Sensor Processing Partitions Pr 3 Shared data area 10 Hz Integrated Navigation Pr 4 Data flow determined by execution order of write & read Preemption and concurrency affect read/write order 20 Hz Guidance Processing 5 Hz Pr 6 Flight Plan Processing Pr 9 2 Hz 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 2 X: n, n+2, n+4 (2, 2, 2, …) • Worst-case sampling pattern: n, n+1, n+4 (1, 3, …) 20 Hz 10 Hz Nav. Sensor Processing Integrated Navigation Read Write Thread Integrated. Navigation Thread Nav. Sensor. Processing Timeline Port Communication Optimization Feiler, April 2008 © 2008 Carnegie Mellon University 4
Port-based AADL Model 20 Hz Nav signal data Navigation Sensor Processing From Partitions Periodic Partitions sensor data Integrated Navigation data Input-compute-output AADL thread semantics Nav data 20 Hz Guidance Processing Guidance FP data 5 Hz Flight Plan Processing Immediate and delayed data port connections for deterministic sampling Nav data Fuel Flow To Nav 10 Hz Nav sensor I/O Aircraft Performance Calculation 2 Hz 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 Xfer MSj Consumer/Producer MRj • Send/receive with or without copy • Transfer with or without copy • Processing with or without copy MCk MPk Send MSk Receive Xfer MRk 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 buffer Xfer TP, Mi+1 E MPi DP, Mi+1 MPi+1 SMi MSi XMi MSi+1 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 S Mi < X Mi < R Mi 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+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+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 T P P S P D P 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 Single buffer • IMT: Sj-1 = Xj-1 < Tj < Rj < Sj = Xj • 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 P ; C MF: 1 B C ; P DMT PD: 2 B MF: 1 B S X R R S X/R PD: 1 B PD: 1 B P C ND: 1 B PD: 2 B ND: 1 B X R X/R P | C ND: 3 B PD: 2 B NDI: 2 B S/XC RC X R X/R S/X/RC MF: Mid-Frame 1 B: Single buffer S, X, R : data copy PD: Period Delay 2 B: Two buffers S/X : IMT combined send/xfer ND: Non-Deterministic 3 B: Three buffers S/X/R : DMT combined S, X, R NDI: No Data Integrity 4 B: Four buffers X/R: DSR/PMT combined X, R o 1 o 2 : 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 phf@sei. cmu. edu
- Slides: 19