Whole program compilation for embedded software: the ADSL experiment

Slides:



Advertisements
Similar presentations
Transition from C to C++ …and a Review of Basic Problem Solving.
Advertisements

Android architecture overview
Overview Motivations Basic static and dynamic optimization methods ADAPT Dynamo.
Code Compaction of an Operating System Kernel Haifeng He, John Trimble, Somu Perianayagam, Saumya Debray, Gregory Andrews Computer Science Department.
1 Objects and ClassesStefan Kluth 1.6Objects and Classes 1.6What is an Object? 1.7Objects and Classes 1.8Object Interface, Class Inheritance, Polymorphism.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
Method Manipulation in an Object-Oriented Processor.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Template class Wrapper { public: T* operator->() { return &myT; } private: T myT; }; int main() { Wrapper wThing; wThing- >Foo(); // calls Thing::Foo()...
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Themes and Variations abstraction -- the object metaphor modeling -- understanding.
Composing Dataflow Analyses and Transformations Sorin Lerner (University of Washington) David Grove (IBM T.J. Watson) Craig Chambers (University of Washington)
Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.
Software Development and Software Loading in Embedded Systems.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
COMPUTER PROGRAMMING. Introduction to C++ History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed.
Types(2). 2 Recursive Problems  One or more simple cases of the problem have a straightforward, nonrecusive solution  The other cases can be redefined.
Chapter 3 Memory Management: Virtual Memory
Programming Languages and Paradigms Object-Oriented Programming.
Polymorphism in C++ 24th Aug Overview Polymorphism means “Many forms” OO Purists – “Only virtual methods” Liberal C++ guys – Either virtual methods.
1 Virtual Functions and Polymorphism Chapter What You Will Learn What is polymorphism? How to declare and use virtual functions for abstract classes.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014 Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
JAVA Introduction ● One of the main JAVA design goal is reducing complexity for programmer – Development time is half or less comparing to equivalent C++
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
1 Efficient Type and Memory Safety for Tiny Embedded Systems John Regehr Nathan Cooprider Will Archer Eric Eide University of Utah School of Computing.
1 Memory Management Requirements of memory management system to provide the memory space to enable several processes to execute concurrently to provide.
Generative Programming. Automated Assembly Lines.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Object Oriented Software Development 4. C# data types, objects and references.
Introduction to OOP CPS235: Introduction.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 20 - Virtual Functions Outline 20.1Introduction 20.2Type Fields and switch Statements 20.3Virtual.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Eine By: Avinash Reddy 09/29/2016.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
CSC 427: Data Structures and Algorithm Analysis
What Do Computers Do? A computer system is
Programming paradigms
Visit for more Learning Resources
Persistent Contextual Values as Inter-process Layers
Chapter 1 Introduction.
Understanding Operating Systems Seventh Edition
Process Management Process Concept Why only the global variables?
7. Inheritance and Polymorphism
Chapter 9: Virtual Memory – Part I
Chapter 1 Introduction.
Object Oriented Programming in Java
JAVA Introduction ការណែនាំពី Java
Workshop in Nihzny Novgorod State University Activity Report
Lecture 2 of Computer Science II
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Types of Programming Languages
Object-Oriented Principles and Implementations
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
CMPE419 Mobile Application Development
UML Class Diagrams: Basic Concepts
Inlining and Devirtualization Hal Perkins Autumn 2011
Inlining and Devirtualization Hal Perkins Autumn 2009
Yikes! Why is my SystemVerilog Testbench So Slooooow?
José A. Joao* Onur Mutlu‡ Yale N. Patt*
The Challenge of Cross - Language Interoperability
HPC User Forum: Back-End Compiler Technology Panel
CMPE419 Mobile Application Development
Presentation transcript:

Whole program compilation for embedded software: the ADSL experiment SCOPES’2001 Whole program compilation for embedded software: the ADSL experiment Johan Cockx johan.cockx@imec.be

Embedded software dilemma: flexible&reusable or fast&small? flat design-specific optimizations C / assembly modular object-oriented C++ How much overhead? Can it be removed?

The ADSL experiment ARM processor ADSL software 130,000 lines C/C++ & preprocessor modular + OO traces multi-thread, dyn. allloc. Manually optimized footprint (code+data) Virtuoso RTOS interrupts memory-mapped I/O ADSL hardware (data path + controllers)

=> local optimization is not good enough Where is the overhead? Code written for the general case Many small procedures Polymorphic (virtual) calls => local optimization is not good enough

Optimization techniques: a whole-program approach 1. Aggressive use of inter-procedural techniques 2. OO-specific optimization 3. Data allocation optimization

Example: removing polymorphic calls Abstract Abstract* a; … a->foo(); foo() replace call via function pointer by direct calls enable inlining Concrete1 foo() { … } Concrete2 foo() { … } Abstract* a; … switch (a->type_tag) { case CONCRETE1: a->Concrete1::foo(); case CONCRETE2: a->Concrete2::foo(); } The initial approach starts from the runtime objects and is typical for an “Object-Based” approach. There’s no use of “Object-Oriented” features like polymorphism. The OO approach, although it looks more elaborate, has identical runtime objects. There will be only one “Button” object and one “Lamp” object instantiated, just as for the object-based design. The concept (some kind of switch that controls a switchable object) is hidden in the object-based design. This concept is lifted from the specific instances and made explicit, I.e. becomes reusable. It also clarifies the designers intend. In an object-based design there’s a close coupling between the Button and the Lamp. Eventually we end up with a “Button_For_Lamp”, “Button_For_Ventilator”, …etc. The situation gets worse when we want to add different “kinds” of buttons like a remote control, GUI button, … The OO approach allows for any Switch to control any switchable. Initially the designer needs less “lines” to code the object-based design compared to the OO design. Reusing is not possible without duplication of code in an object-based design while the OO design offers automatic reuse of high-level algorithms. Duplication is of course a nightmare when for instance a bug is solved in the algorithm. We need to track all duplications and apply the changes by hand. In the OO design the algorithm is defined once so any solved bug is automatically propagated.

Example: data inlining Eliminate: dynamic allocation pointer de-reference polymorphic calls class A B* b; A() { b = new B; } ~A() { delete b; } void f() { b->g();} class B class A’ C b; A(): b() {} ~A() {} void f() { b.g();} class C

Example: dynamic allocation removal Eliminate dynamic allocation Re-use stack memory already needed for other call tree branches void teq(…,short size,…) { float* Ryy; Ryy = new float[size]; … teq computation … delete Ryy; } void teq(…,…) { float Ryy[64]; … teq computation … } teq(…,64,…); … teq(…,…); …

ADSL result: footprint -33% Unoptimized ARM C++ optimized (-O2 -Ospace) Inlining, dead code, const. prop. Virtual call elimination 400kB Data alloc. optim. 200kB 106% 100% 83% 82% 67% Total memory footprint (code + data)

Main benefit: modular & reusable embedded software Conclusions Whole program optimization is worthwhile ADSL: footprint -33%, traditional compiler -6% Manual optimization ruins modularity a compiler is desirable Compiler must be RTOS-aware dynamic allocation, stack sizes Main benefit: modular & reusable embedded software