Now You C It. Now You Dont! Rob Ennals Intel Research Cambridge.

Slides:



Advertisements
Similar presentations
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Advertisements

Chapter 6 Writing a Program
Software Re-engineering
Chapter 26 Legacy Systems.
Chapter 11 Separate Compilation and Namespaces. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Separate Compilation.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Chapter 11 Introduction to Programming in C
Bounded Model Checking of Concurrent Data Types on Relaxed Memory Models: A Case Study Sebastian Burckhardt Rajeev Alur Milo M. K. Martin Department of.
Chao Liu, Chen Chen, Jiawei Han, Philip S. Yu
Software Transactional Objects Guy Eddon Maurice Herlihy TRAMP 2007.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Design and Implementation Issues for Atomicity Dan Grossman University of Washington Workshop on Declarative Programming Languages for Multicore Architectures.
CSE 105 Structured Programming Language (C)
The creation of "Yaolan.com" A Site for Pre-natal and Parenting Education in Chinese by James Caldwell DAE Interactive Marketing a Web Connection Company.
© 1998, Progress Software Corporation 1 Migration of a 4GL and Relational Database to Unicode Tex Texin International Product Manager.
0 - 0.
Addition Facts
Lesson 6 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
1 Automating Auto Tuning Jeffrey K. Hollingsworth University of Maryland
Linked Lists.
Eiffel: Analysis, Design and Programming Bertrand Meyer (Nadia Polikarpova) Chair of Software Engineering.
Concurrency Issues Motivation, Problems, Directions Dennis Kafura - CS Operating Systems1.
Introduction to Compilation of Functional Languages Wanhe Zhang Computing and Software Department McMaster University 16 th, March, 2004.
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
Addition 1’s to 20.
Test B, 100 Subtraction Facts
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 15 Programming and Languages: Telling the Computer What to Do.
Week 1.
Chapter 9 Interactive Multimedia Authoring with Flash Introduction to Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 14: More About Classes.
Introduction to Programming G51PRG University of Nottingham Revision 1
Languages for IT & CS Pseudo-code What HTML isn’t Early history Compiling & interpreting Classifying languages The process of programming.
Threads Cannot be Implemented As a Library Andrew Hobbs.
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
The Interface Definition Language for Fail-Safe C Kohei Suenaga, Yutaka Oiwa, Eijiro Sumii, Akinori Yonezawa University of Tokyko.
Concurrency The need for speed. Why concurrency? Moore’s law: 1. The number of components on a chip doubles about every 18 months 2. The speed of computation.
CSI 3125, Preliminaries, page 1 Programming languages and the process of programming –Programming means more than coding. –Why study programming languages?
Concurrency 101 Shared state. Part 1: General Concepts 2.
1 New Architectures Need New Languages A triumph of optimism over experience! Ian Watson 3 rd July 2009.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
UPC Runtime Layer Jason Duell. The Big Picture The Runtime layer handles everything that is both: 1) Platform/Environment specific —So compiler can output.
An Integrated Hardware-Software Approach to Transactional Memory Sean Lie Theory of Parallel Systems Monday December 8 th, 2003.
OSE 2013 – synchronization (lec3) 1 Operating Systems Engineering Locking & Synchronization [chapter #4] By Dan Tsafrir,
PROGRAMMING LANGUAGES The Study of Programming Languages.
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.
Java Programming Introduction & Concepts. Introduction to Java Developed at Sun Microsystems by James Gosling in 1991 Object Oriented Free Compiled and.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
C Hints and Tips The preprocessor and other fun toys.
COMP 111 Threads and concurrency Sept 28, Tufts University Computer Science2 Who is this guy? I am not Prof. Couch Obvious? Sam Guyer New assistant.
Dr Jekyll and Mr C Rob Ennals Intel Research Cambridge.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow.
CoreDet: A Compiler and Runtime System for Deterministic Multithreaded Execution Tom Bergan Owen Anderson, Joe Devietti, Luis Ceze, Dan Grossman To appear.
CSCI-383 Object-Oriented Programming & Design Lecture 25.
December 1, 2006©2006 Craig Zilles1 Threads & Atomic Operations in Hardware  Previously, we introduced multi-core parallelism & cache coherence —Today.
The architecture of the P416 compiler
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
PROGRAMMING LANGUAGES
What, Where and Why Swift
Atomic Operations in Hardware
Atomic Operations in Hardware
C# and the .NET Framework
CS 536 / Fall 2017 Introduction to programming languages and compilers
Introduction to C Programming Language
Object Oriented Practices
Threads and Memory Models Hal Perkins Autumn 2011
2011/11/10: Lecture 21 CMSC 104, Section 4 Richard Chang
Explaining issues with DCremoval( )
CISC 7120X Programming Languages and Compilers
Presentation transcript:

Now You C It. Now You Dont! Rob Ennals Intel Research Cambridge

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)2 The World has Changed ThenNow Parallelism an exotic curiosity Slow inter-chip communication Parallel chunks must be large Uni-processor performance increasing rapidly Not worthwhile for languages, tools, or programmers to pay attention to parallel hardware Multicore chips the norm Fast on-die communication Parallel chunks can be tiny Uni-processor performance stalling, multicore storming Essential that languages, tools and programmers pay attention to multicore

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)3 An Opportunity for Declarative Languages Parallelisability is more important than straight line performance –Number of cores set to double every 18 months Declarative languages make parallelism easier –Easier to isolate parallel threads (pure functions, effect systems, etc) –Easier to express parallel algorithms (closures, combinators, etc) ImperativeDeclarative Very fast in a single core Hard to express parallelism Widely known and used Often slower on a single core Easier to express parallelism Little known or used

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)4 A Problem: Language Switching Costs Much important software is currently written in C –Even if not the most lines of code, probably most of the cycles Moving to a new language incurs high switching costs –Programmers, tools, libraries, and existing code, all tied to C C Programmers Trust Libraries Existing CodeTools

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)5 A Solution: Lossless Round Tripping Jekyll is a high level functional programming language –Featuring most of the features of Haskell + more Jekyll can be translated losslessly to and from C –Preserving layout, formatting, comments, everything –C code is readable and editable C File Jekyll File C Programmer Jekyll Programmer

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)6 Another View of C Authoritative source code can stay as C But programmers and tools can also view it as Jekyll C Programmers need not know Jekyll is even being used. Repository C File Jekyll File C File Jekyll Programmer or Tool C Programmer or Tool

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)7 Switching Costs are Reduced Programmers and Tools can still use the C version. Existing C code can stay in C –Although there may be benefit to be had from modifying it If Jekyll ceases to be maintained, just use the C Jekyll C Programmers C Trust C Libraries Existing C CodeC Tools

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)8 Jekyll Features Parallel features still in progress. Other features largely implemented. Use of unsafe features causes a warning unless marked as unsafe All of C Unsafe Features Imperative Features Low-Level Features C Types C Expressions Pre-processor Most of Haskell Algebraic Types Type Classes Lambda Expressions Pattern Matching Generic Types Type Safety Optional GC Parallel Parallel Combinators Effect Typing Atomic Blocks Jekyll

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)9 Jekyll Parallel Features (in progress) Parallel Combinators- express parallelism at a higher level –Use high level concepts such as parallel map, reduce, pipeline, etc –Easily write new combinators –Write tools that understand and manipulate combinators –Relies on Jekylls lambda expressions Effect Typing- ensure threads are cleanly separated –Use linear types + regions + effect types –Determine what a thread can touch –Relies on Jekylls type-safe foundation Atomic Blocks- avoid the mess of locks –Simple, blocking semantics (no STM required, can be just a global lock) –Translate to locking, or use hardware

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)10 Encoding Jekyll Features into C - Example List * multlist(List * l, int x){ return par_map (l) { int* n: ret new (*n) * x;}; } _localfunenv struct multlist_lam_env {int *x}; _localfun int* multlist_lam(struct multlist_lam_env* _cenv, int* n){ _temp int *_tmp; _tmp0 = (int*)GC_malloc(sizeof(int)); (*_tmp0) = (*n) * *_cenv->x; return _tmp; } List _p(int)* multlist(List _p(int)* l, int x){ _temp struct multlist_lam_env _f0_env = {&x}; return List_par_map(_env NULL,l,_localfun (*(*)(void*,a*))multlist_lam); }

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)11 Jekyll Features Encoded using C Macros Ignored by C compilers Tell the Jekyll translator when Jekyll features are being used All macros are very simple (most are defined to nothing) #define unsafe /* nothing */ #define _fwd /* nothing */ #define _temp /* nothing */ #define _localfun /* nothing */ #define _localfunenv /* nothing */ #define _env /* nothing */ … Jekyll_1.h

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)12 A Language with Two Syntaxes Translation allow Jekyll to sit on both sides of the fence Jekyll with transparent to C compilers, but also has an elegant syntax Compatible with C Tools Understood by C Programmers Compatible with existing code Annotated C SyntaxJekyll Syntax Elegant Concise Better fit with new features Translation

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)13 Common Syntax Tree Representation AST Jekyll File C File Parse Print Check Transform

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)14 Lossless Translation by Twinned Printing Every Jekyll token is twinned with a C token Twinned tokens always have the same whitespace –Thus allowing whitespace to be preserved during translation Some C tokens may be un-twinned (see next slide) –Some Jekyll-only features need more C tokens than Jekyll tokens AST C Tokens Jekyll Tokens Twins

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)15 An Issue: Untwinned C tokens Problem: Whitespace is NOT preserved for untwinned C tokens But: Untwinned tokens only appear when Jekyll-only features are used. Whitespace is only lost when a C programmer edits such code. Thus this is ok, since: All existing C code is unaffected. Jekyll -> C -> Jekyll is always lossless Only edited lines of source code will change. The programmer is warned in such circumstances.

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)16 Demo

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)17 Conclusions Multicore is a great opportunity for declarative languages But many developers are tied into C Jekyll overcomes switching costs through lossless translation Download Jekyll now:

1/16/06Now you C it. Now you Don't! (Dec Langs for Multicore)18