Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.

Slides:



Advertisements
Similar presentations
Generative Programming and Active Libraries Krzysztof Czarnecki DaimlerChrysler Research and Technology Software Engineering Lab Ulm, Germany
Advertisements

ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Background information Formal verification methods based on theorem proving techniques and model­checking –to prove the absence of errors (in the formal.
Marko Rosenmüller - University of Magdeburg, Germany 1 Feature-oriented Refactoring of Berkeley DB Dagstuhl Seminar on Software Engineering for Tailor-made.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
CStar Optimizing a C Compiler
Software Factory Assembling Applications with Models, Patterns, Frameworks and Tools Anna Liu Senior Architect Advisor Microsoft Australia.
UML CASE Tool. ABSTRACT Domain analysis enables identifying families of applications and capturing their terminology in order to assist and guide system.
Whole Platform Tesi di Dottorato di: RICCARDO SOLMI Università degli Studi di Bologna Facoltà di scienze matematiche, fisiche e naturali Corso di Dottorato.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Domain-Specific Software Engineering Alex Adamec.
Deriving AO Software Architectures using the AO-ADL Tool Suite Luis Fernández, Lidia Fuentes, Mónica Pinto, Juan A. Valenzuela Universidad de Málaga
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse 2.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 18 Slide 1 Software Reuse.
Software Engineering Muhammad Fahad Khan
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
5.3 Machine-Independent Compiler Features
SPL: A Language and Compiler for DSP Algorithms Jianxin Xiong 1, Jeremy Johnson 2 Robert Johnson 3, David Padua 1 1 Computer Science, University of Illinois.
Software Product Families. Generative Programming Main text: Ian Sommerville, Software Engineering, 8 th edition, chapter 18 Additional readings: K. Czarnecki.
1 N Degrees of Separation: Multi-Dimensional Separation of Concern (MDSOC) HyperJ: language and concepts of general concern combination.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
A Survey of Rewriting Strategies in Program Transformation Systems Part 1 Author: Eelco Visser Speaker: Wei Zhao.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
What is “model transformation”? Distinction between source and target Source may be same as target May be multiple sources, or targets Reaching a fixed.
MathCore Engineering AB Experts in Modeling & Simulation WTC.
Grammar Variation in Compiler Design Carl Wu. Three topics Syntax Grammar vs. AST Component(?)-based grammar Aspect-oriented grammar.
1 Model Compiler Construction Based on Aspect-oriented Mechanisms Naoyasu Ubayashi (Kyushu Institute of Technology) Tetsuo Tamai (University of Tokyo)
Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton February 28th, 2003 Advisor: David G. Hannay Client:
Generative Programming. Automated Assembly Lines.
Performance Analysis Of Generics In Scientific Computing Laurentiu Dragan Stephen M. Watt Ontario Research Centre for Computer Algebra University of Western.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
1 Code optimization “Code optimization refers to the techniques used by the compiler to improve the execution efficiency of the generated object code”
The Volcano Optimizer Generator Extensibility and Efficient Search.
Towards Multi-Paradigm Software Development Valentino Vranić Department of Computer Science and Engineering Faculty of Electrical Engineering.
University of Toronto Department of Computer Science Lifting Transformations to Product Lines Rick Salay, Michalis Famelis, Julia Rubin, Alessio Di Sandro,
© Siemens AG, CT SE 2 C O R P O R A T E T E C H N O L O G Y 1 Model-Driven Development for Pluggable Collaborations Iris Groher, Stephan Bleicher, Christa.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 18 Slide 1 Software Reuse.
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
OOPSLA workshop on Domain-Specific Visual Languages 1 Juha-Pekka Tolvanen, Steven Kelly, Jeff Gray, Kalle Lyytinen.
1 Software Design Lecture What’s Design It’s a representation of something that is to be built. i.e. design  implementation.
Scalable Clone Detection and Elimination for Erlang Programs Huiqing Li, Simon Thompson University of Kent Canterbury, UK.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Advanced Software Development Karl Lieberherr CSG 260 Fall Semester
Concepts and Realization of a Diagram Editor Generator Based on Hypergraph Transformation Author: Mark Minas Presenter: Song Gu.
Component Design Elaborating the Design Model. Component Design Translation of the architectural design into a detailed (class-based or module- based)
Formal Verification. Background Information Formal verification methods based on theorem proving techniques and model­checking –To prove the absence of.
Andrey Karaulov, Alexander Strabykin Institute for System Programming Russian Academy of Sciences SYRCoSE: Spring Young Researchers Colloquium on Software.
2000 Research Overview Dr. Kim Mens Programming Technology Lab Vrije Universiteit Brussel.
CS412/413 Introduction to Compilers and Translators April 2, 1999 Lecture 24: Introduction to Optimization.
A Framework for Automated and Composable Testing of Component-based Services Miguel A. Jiménez, Ángela Villota, Norha M. Villegas, Gabriel Tamura, Laurence.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
The PLA Model: On the Combination of Product-Line Analyses 강태준.
Software Reuse. Objectives l To explain the benefits of software reuse and some reuse problems l To discuss several different ways to implement software.
Chapter 1 Introduction.
Object-Oriented Software Engineering Using UML, Patterns, and Java,
Introduction to Advanced Topics Chapter 1 Text Book: Advanced compiler Design implementation By Steven S Muchnick (Elsevier)
Software Reuse ©Ian Sommerville 2006.
Chapter 1 Introduction.
Object-Oriented Design
<PETE> Shape Programmability
ENERGY 211 / CME 211 Lecture 27 November 21, 2008.
Ponder policy toolkit Jovana Balkoski, Rashid Mijumbi
Presentation transcript:

Generative Programming

Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing families of domain concepts Generative Programming also includes the process of creating concrete instances of concepts Generative Programming also includes the process of creating concrete instances of concepts

Overview Translator Generative Component Specification in a configuration DSL Implementation components Finished Configuration

Why Generators? Raise the intentionality of system descriptions Raise the intentionality of system descriptions –E.g. using domain specific notation Produce an efficient implementation Produce an efficient implementation –Nontrivial mapping into implementation concepts Avoid the library scaling problem Avoid the library scaling problem –Library built as concrete component double in size for each new added feature

Transformation Model System Requirements Source Code (C++, Java) System Implementation High Level System Specification System Requirements compile Source Code (C++, Java) compile Source Code (C++, Java) Source in DSL System Implementation Source in DSL Manually implement Implement with tools

Type of transformations Vertical Vertical Horizontal Horizontal

Vertical Transformation Refines higher-level structure into lower level, preserving structure Refines higher-level structure into lower level, preserving structure Typical of step-wise refinement and CASE or GUI builders Typical of step-wise refinement and CASE or GUI builders

Horizontal Transformation Modifies modular structure at the same level Modifies modular structure at the same level Merges, deletes or modifies existing modules Merges, deletes or modifies existing modules

Kind of transformations Compiler transformations Compiler transformations Source to source transformations Source to source transformations

Compiler Transformations Refinements Refinements –Decomposition –Choice of representation –Choice of algorithm –Specialization –Concretization Optimizations Optimizations

Compiler Optimizations Inlining Inlining Constant folding Constant folding Data caching Data caching Loop fusion Loop fusion –Adding matrixes A+B+C Loop unrolling Loop unrolling –When number of iterations is small Code motion Code motion –Move invariant code outside of loop

Compiler Optimizations (2) Common subexpression elimination Common subexpression elimination Dead-code elimination Dead-code elimination Partial evaluation Partial evaluation –Partially evaluate a function based on knowledge of some of its parameters to be constants in a special context Finite differencing Finite differencing x = x + 2x = x + 2; y = x * 3;y = y + 6;

y = x * 3 dy/dx = 3 dx = 2 y i+1 = y i + 3 dx

Source to source Transformations Editing transformations Editing transformations Refactoring Refactoring Abstraction and generalization Abstraction and generalization Introducing new variant points Introducing new variant points Simplification Simplification

Approaches Aspect-Oriented Programming Aspect-Oriented Programming Subject-Oriented Programming Subject-Oriented Programming Software Transformation Technologies Software Transformation Technologies Intentional Programming Intentional Programming Domain Engineering Domain Engineering Generative Programming Generative Programming

Aspect Oriented Programming To improve the modularity of designs and implementations by allowing a better encapsulation of cross-cutting concerns: To improve the modularity of designs and implementations by allowing a better encapsulation of cross-cutting concerns: –synchronization, distribution, authentication, data traversal, memory allocation, tracing, caching, etc. New kind of modularity called “aspect” New kind of modularity called “aspect” Aspects represent an orthogonal parameterization concept compared to what's available in current languages Aspects represent an orthogonal parameterization concept compared to what's available in current languages

Subject Oriented Programming Related to AOP Related to AOP Focuses on capturing different subjective perspectives on a single object model Focuses on capturing different subjective perspectives on a single object model It allows composing applications out of "subjects" (partial object models) by means of declarative composition rules It allows composing applications out of "subjects" (partial object models) by means of declarative composition rules

Software Transformations aid software development activities by providing mechanized support for manipulating program representations aid software development activities by providing mechanized support for manipulating program representations Examples: Examples: –extracting views –Refinement –Refactoring –optimizations of program representations

Intentional Programming an extendible programming environment based on transformation technology and direct manipulation of active program representations an extendible programming environment based on transformation technology and direct manipulation of active program representations New programming notations and transformations can be distributed and used as plug-ins New programming notations and transformations can be distributed and used as plug-ins The system replaces parsing technology with the direct entry and editing of resolved ASTs The system replaces parsing technology with the direct entry and editing of resolved ASTs

Domain Engineering Domain engineering comprises the development of a common model and concrete components, generators, and reuse infrastructures for a family of software systems Domain engineering comprises the development of a common model and concrete components, generators, and reuse infrastructures for a family of software systems

Goals of Generative Programming Each language implements its own libraries: types are hard to match Each language implements its own libraries: types are hard to match Problem: Problem: int add(int i, int j) { return i+j; } add(1, x); int inc(int x) { return add(1, x); } class Complex { double r, i; } Complex add(Complex x, Complex y) { return Complex(x.r + y.r, x.i + y.i); }

Complex inc(Complex x) { return add(Complex(1, 0), x); } Compiler can’t optimize, since it does not know the Complex type Compiler can’t optimize, since it does not know the Complex type Class used to represent concepts in domain, but semantics of domain is not conveyed to compiler Class used to represent concepts in domain, but semantics of domain is not conveyed to compiler

Partial Evaluation Matrix A, B, C, D; D = A.add(B.add(C)); Requires allocation of temporary intermediate matrix and two loops Compiler is not capable, DSL for algebra could incorporate, e.g. write Matrix.add(A, B, C);

C++ Using template metaprogramming one can produce specialized code Using template metaprogramming one can produce specialized code BLITZ matrix library: faster than Fortran BLITZ matrix library: faster than Fortran