chia-chiao ho t oward optimized code generation through model - based optimization 2010/9/24 1 ccu...

Post on 18-Jan-2018

218 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

I NTRODUCTION Model-based Development (MBD) Using model to design systems Offer an higher level of abstraction 2010/9/24 3 CCU CSIE ESL Group Meeting Presentation

TRANSCRIPT

CCU CSIE ESL Group Meeting Presentation

1

Chia-Chiao Ho

TOWARD OPTIMIZED CODE GENERATION THROUGH MODEL-BASED OPTIMIZATION

2010/9/24

Authors:Asma Charfi *Chokri Mraidha *Sébastien Gérard *François Terrier *Pierre Boulet ***CEA, LIST, Laboratory of model driven engineering for embedded systems** Université Lille 1, Sciences et TechnologiesPublished on Design, Automation & Test in Europe Conference & Exhibition (DATE), 2010

2

CCU CSIE ESL Group Meeting Presentation

OUTLINE Introduction Model-based Development For RTES Design Experimental Studies Exploiting UML Semantics For Optimization Conclusion

2010/9/24

3

CCU CSIE ESL Group Meeting Presentation

INTRODUCTION Model-based Development (MBD)

Using model to design systemsOffer an higher level of abstraction

2010/9/24

4

CCU CSIE ESL Group Meeting Presentation

INTRODUCTION (CONT.) Real-Time and Embedded System (RTES)

become more complex and along with limited resources.

With automatic code generation tools, MBD brings: Increasing productivityEnhancing source code consistency Intending to improving the performance

In this paper, we are going to examine the possibility of model-based optimization

2010/9/24

5

CCU CSIE ESL Group Meeting Presentation

OUTLINE Introduction Model-based Development For RTES Design Experimental Studies Exploiting UML Semantics For Optimization Conclusion

2010/9/24

6

CCU CSIE ESL Group Meeting Presentation

MODEL-BASED DEVELOPMENT FOR RTES DESIGN 3 Steps to develop a RTES1. Building models

Design with Unified Model Language (UML)2. Code generation

Compile models to C/C++, Java, etc.3. Code Compilation and Optimization

Use GCC Compiler and it’s Optimization Options.

2010/9/24

7

CCU CSIE ESL Group Meeting Presentation

RAISING THE LEVEL OF ABSTRACTION IN RTES DESIGN With UML, we can describe a basic system

model. But RTES needs more specific descriptions for

modeling and analysis. Modeling and Analysis of Real-Time and

Embedded (MARTE) is an extended profile for UML, using for annotating models with required information

Thus, it’s possible for automatic code generation.

2010/9/24

8

CCU CSIE ESL Group Meeting Presentation

GENERATING CODE FROM UML MODELS Before adding Activities and Actions

packages into UML2, Designer need to complete the code or it can’t

be compiled. Now it’s possible to make code generation

from UML2 models a fully automatable step.

2010/9/24

9

CCU CSIE ESL Group Meeting Presentation

COMPILATION AND OPTIMIZATION GCC provides –O1, -O2, -O3 and other

optimization options. In this paper, code size is the optimized

target for RTES. –Os option is used here. Before GCC 4.0, Register transfer language

(RTL) optimization is used. Low level optimization

GCC 4.0 now using Static single assignment (SSA) optimization. High level optimization

2010/9/24

10

CCU CSIE ESL Group Meeting Presentation

OUTLINE Introduction Model-based Development For RTES Design Experimental Studies Exploiting UML Semantics For Optimization Conclusion

2010/9/24

11

CCU CSIE ESL Group Meeting Presentation

EXPERIMENTAL STUDIES For showing relying only on compiler

optimizations is not enough. There are two examples later demonstrate

the shortages of compiler optimizations.

2010/9/24

12

CCU CSIE ESL Group Meeting Presentation

BUILDING STATE MACHINE DIAGRAM This paper uses Papyrus as their tool to

design state machine diagram.

2010/9/24

13

CCU CSIE ESL Group Meeting Presentation

EXAMPLE 1: NO ENTRY TRANSITION

2010/9/24

14

CCU CSIE ESL Group Meeting Presentation

EXAMPLE 2: COMPLETION TRANSITION

2010/9/24

15

CCU CSIE ESL Group Meeting Presentation

GENERATING THE C++ CODE FROM UML STATE MACHINE State Pattern

A state is implemented as a class. State Table Transition

A 2-D table describing the relation between states and events

Nested Switch Case Statement having an outer case statement that selects the

current state and an inner case statement that selects the appropriate behavior given the type of the received event

2010/9/24

16

CCU CSIE ESL Group Meeting Presentation

COMPILING AND OPTIMIZING THE GENERATED CODE USING GCC With option –Os, GCC is not able to remove

unreachable states. The authors uses a optimization tool to

remove the unreachable states. The first example exists a state with no

incoming transition. The second example shows a completion

transition. Both can’t be optimized by the compiler in

code size

2010/9/24

17

CCU CSIE ESL Group Meeting Presentation

OPTIMIZED RESULTSRequired Optimization

Code Size(Before)

Code Size(After)

Optimization Rate

Remove unreachable state

12669 bytes 11393 bytes 10.07%

Remove transition originated from state that have a completion transition

48764 bytes 26379 bytes 45.90%

2010/9/24

18

CCU CSIE ESL Group Meeting Presentation

RESULTS INTERPRETATION The semantics lost in code generation, thus

large improvement after optimizing from model level in 3 implementations.

2010/9/24

19

CCU CSIE ESL Group Meeting Presentation

OUTLINE Introduction Model-based Development For RTES Design Experimental Studies Exploiting UML Semantics For Optimization Conclusion

2010/9/24

20

CCU CSIE ESL Group Meeting Presentation

BEFORE CODE GENERATION The model level optimization is higher than

SSA in GCC optimization. The CFG is produced twice before the code

generation and in compilation.

2010/9/24

21

CCU CSIE ESL Group Meeting Presentation

DURING CODE GENERATION The model debugging is unable to debug

with removed state.

2010/9/24

22

CCU CSIE ESL Group Meeting Presentation

AFTER CODE GENERATION The UML semantics are visible to the

compiler

2010/9/24

23

CCU CSIE ESL Group Meeting Presentation

OUTLINE Introduction Model-based Development For RTES Design Experimental Studies Exploiting UML Semantics For Optimization Conclusion

2010/9/24

24

CCU CSIE ESL Group Meeting Presentation

CONCLUSION Due to the loss of some UML semantics

during the code generation, the GCC is unable to do optimization in MBD way.

The higher model-based optimization is useful in the experiment.

The future work is to develop a complete tool to generate assembly code, instead of high level language. Avoid the unnecessary use of two high level languages.

2010/9/24

25

CCU CSIE ESL Group Meeting Presentation

THANK YOU FOR YOUR ATTENTION!

2010/9/24

26

CCU CSIE ESL Group Meeting Presentation

MARTE UML Profile for Modeling and Analysis of Real-

Time and Embedded systems http://www.omgmarte.org/

2010/9/24

27

CCU CSIE ESL Group Meeting Presentation

CODE GENERATION PATTERNS State Pattern http://en.wikipedia.org/wiki/State_pattern State Transition Table http://en.wikipedia.org/wiki/State_transition_t

able Nested Switch Case Statements http://www.iplab.is.tsukuba.ac.jp/paper/docto

r/niaz_doctor.pdf

2010/9/24

28

CCU CSIE ESL Group Meeting Presentation

RTL AND SSA Register transfer language http://en.wikipedia.org/wiki/Register_transfer

_language#RTL_in_GCC Static single assignment http://en.wikipedia.org/wiki/Static_single_assi

gnment_form

2010/9/24

top related