McLab Tutorial www.sable.mcgill.ca/mclab Part 6 – Introduction to the McLab Backends MATLAB-to-MATLAB MATLAB-to-Fortran90 (McFor) McVM with JIT 6/4/2011Backends-

Slides:



Advertisements
Similar presentations
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Advertisements

McLab Tutorial Part 8 – Wrap Up Summary Ongoing and Future Work Further Sources 6/4/2011Wrap Up- 1McLab Tutorial, Laurie Hendren,
McLab Tutorial Part 2 – Introduction to MATLAB Functions and Scripts Data and Variables Other Tricky "Features" 6/4/2011Matlab-
The Analytical Engine Module 6 Program Translation.
Program Flow Charting How to tackle the beginning stage a program design.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
Data Flow Analysis Compiler Design October 5, 2004 These slides live on the Web. I obtained them from Jeff Foster and he said that he obtained.
Context-sensitive Analysis, II Ad-hoc syntax-directed translation, Symbol Tables, andTypes.
From Cooper & Torczon1 Implications Must recognize legal (and illegal) programs Must generate correct code Must manage storage of all variables (and code)
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Programming Concepts and Languages Chapter 12 – Computers: Understanding Technology, 3 rd edition 1November
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Compiled by Benjamin Muganzi 3.2 Functions and Purposes of Translators Computing 9691 Paper 3 1.
LLVM Developed by University of Illinois at Urbana-Champaign CIS dept Cisc 471 Matthew Warner.
McLab Tutorial Laurie Hendren, Rahul Garg and Nurudeen Lameed Other McLab team members: Andrew Casey, Jesse Doherty, Anton Dubrau,
Introduction to Shell Script Programming
McLab Tutorial Part 4 – McLab Intermediate Representations High-level McAST Lower-level McLAST Transforming McAST to McLAST 6/4/2011IR-
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
McLab Tutorial Part 5 – Introduction to the McLab Analysis Framework Exploring the Main Components Creating a Simple Analysis.
Cosc 2150: Computer Organization
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
Programming With C.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Joey Paquet, 2000, 2002, 2007, Concordia University Department of Computer Science COMP 442/6421 Compiler Design.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
BUILD ON THE POLYGLOT COMPILER FRAMEWORK MIHAL BRUMBULLI 7th Workshop “SEERE” Montenegro-Risan 9-14 September 2007 SimJ Programming Language.
COP4020 Programming Languages Names, Scopes, and Bindings Prof. Xin Yuan.
McLab Tutorial Part 3 – McLab Frontend Frontend organization Introduction to Beaver Introduction to JastAdd 6/4/2011 Frontend-1McLab.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Introduction CPSC 388 Ellen Walker Hiram College.
Vineet Kumar and Laurie Hendren McGill University MiX10 First steps to compiling MATLAB to X10.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt1 Topic 2b High-Level languages and System Software (Languages) Introduction to Computer Systems Engineering.
LLVM Compiler Katie Dew. Lectures High-level overview of LLVM (Katie) Walkthrough of LLVM in context of our project (Jason) –Input requirements –Configuration.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
Structured Programming (4 Credits)
1 Compiler & its Phases Krishan Kumar Asstt. Prof. (CSE) BPRCE, Gohana.
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
R-Verify: Deep Checking of Embedded Code James Ezick † Donald Nguyen † Richard Lethin † Rick Pancoast* (†) Reservoir Labs (*) Lockheed Martin The Eleventh.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
CSC 8505 Compiler Construction
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Introduction to Computer Programming using Fortran 77.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Compiler Design (40-414) Main Text Book:
The architecture of the P416 compiler
Matlab.
Introduction to Compiler Construction
McLAB: Compiler Tools for MATLAB
Introduction to MATLAB
McLAB: A toolkit for static and dynamic compilers for MATLAB
Data Flow Analysis Compiler Design
Simulation And Modeling
IS 135 Business Programming
Presentation transcript:

McLab Tutorial Part 6 – Introduction to the McLab Backends MATLAB-to-MATLAB MATLAB-to-Fortran90 (McFor) McVM with JIT 6/4/2011Backends- 1McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen Lameed TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAAA

MATLAB-to-MATLAB 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 2 We wish to support high-level transformations, as well as refactoring tools. Keep comments in the AST. Can produce.xml or.m files from McAST or McLAST. Design of McLAST such that it remains valid MATLAB, although simplified.

MATLAB-to-Fortran90 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 3 MATLAB programmers often want to develop their prototype in MATLAB and then develop a FORTRAN implementation based on the prototype. 1 st version of McFOR implemented by Jun Li as M.Sc. thesis. – handled a smallish subset of MATLAB – gave excellent performance for the benchmarks handled – provided good insights into the problems needed to be solved, and some good initial solutions. 2 nd version of McFOR currently under development. – fairly large subset of MATLAB, more complete solutions – provide a set of analyses, transformations and IR simplifications that will likely be suitable for both the FORTRAN generator, as well as other HLL. to be put on the list of those interested in

McVM-McJIT 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 4 Whereas the other back-ends are based on static analyses and ahead-of-time compilation, the dynamic nature of MATLAB makes it more suitable for a VM/JIT. MathWorks' implementation does have a JIT, although technical details are not known. McVM/McJIT is an open implementation aimed at supporting research into dynamic optimization techniques for MATLAB.

McVM Design 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 5 A basic but fast interpreter for the MATLAB language A garbage-collected JIT Compiler as an extension to the interpreter Easy to add new data types and statements by modifying only the interpreter. Supported by the LLVM compiler framework and some numerical computing libraries. Written entirely in C++; interface with the McLab front-end via a network port.

The Structure of McVM 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 6 Interpreter Boehm GCATLAS, BLAS, LAPACKLLVM Framework IIR Types Fallback Logic Versioning Logic LLVM Emission Front-end Type Inference Live Variable Reaching Defs Bounds Check Copy Analyses Language Core McJIT Analyses Data Types Functions Func Handles Matrix Types McVM > Source m files IM Commands

Supported Types 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 7 Logical ArraysCharacter ArraysDouble-precision floating pointsDouble-precision complex number matricesCell arraysFunction Handles

McJIT: Executing a Function 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 8 Compiled code exists in the code cache? Execute function Load function Generate LLVM & Machine Code Parse function code; generate XML Send code string to the front-end; receive AST as XML Parse XML; build AST Perform analyses & transformations Mclab Front-end Code Cache yes no f(arg_types) IIR exist? no Yes

Type Inference 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 9 It is a key performance driver for the JIT Compiler: – the type information provided are used by the JIT compiler for function specialization.

Type Inference 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 10 It is a forward flow analysis: propagates the set of possible types through every possible branch of a function. Assumes that: for each input argument arg, there exist some possible types At every program point p, infers the set of possible types for each variable May generate different results for the same function at different times depending on the types of the input arguments

Lattice of McVM types 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 11 Function handle Bottom (No information inferred) Matrix-like types Top (Unknown type, could be any) Cell ArrayMatrix types Char arrayLogical arrayComplex MatrixDouble matrix

Internal Intermediate Representation 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 12 A simplified form of the Abstract Syntax Tree (AST) of the original source program It is machine independent All IIR nodes are garbage collected

IIR: A Simple MATLAB Program 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 13 function [a] = test(n) a = zeros(1, n); $t1 = 1; $t0 = 1; $t2 = $t1; $t3 = n; while True $t4 = ($t0 <= $t3); if ~$t4 break; end i = $t0; a(i) = (i * i); $t0 = ($t0 + $t2); end.m file IIR form function a = test(n) a(i) = i*i; a = zeros(1,n); end for i = 1:n end

McVM Project Class Hierarchy (C++ Classes) 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 14

Running McVM 6/4/2011McLab Tutorial, Laurie Hendren, Rahul Garg and Nurudeen LameedBackends- 15