Source-To-Source Automatic Program Transformations for GPU-Like Hardware Accelerators Mehdi Amini

Total Page:16

File Type:pdf, Size:1020Kb

Source-To-Source Automatic Program Transformations for GPU-Like Hardware Accelerators Mehdi Amini Source-to-Source Automatic Program Transformations for GPU-like Hardware Accelerators Mehdi Amini To cite this version: Mehdi Amini. Source-to-Source Automatic Program Transformations for GPU-like Hardware Ac- celerators. Other [cs.OH]. Ecole Nationale Supérieure des Mines de Paris, 2012. English. NNT : 2012ENMP0105. pastel-00958033 HAL Id: pastel-00958033 https://pastel.archives-ouvertes.fr/pastel-00958033 Submitted on 11 Mar 2014 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. INSTITUT DES SCIENCES ET TECHNOLOGIES École doctorale nO432 : Sciences des Métiers de l’Ingénieur Doctorat ParisTech THÈSE pour obtenir le grade de docteur délivré par l’École nationale supérieure des mines de Paris Spécialité « Informatique temps-réel, robotique et automatique » présentée et soutenue publiquement par Mehdi Amini le 13 décembre 2012 Transformations de programme automatiques et source-à-source pour accélérateurs matériels de type GPU ⇠⇠⇠ Source-to-Source Automatic Program Transformations for GPU-like Hardware Accelerators Directeur de thèse : François Irigoin Co-encadrement de la thèse : Fabien Coelho Co-encadrement de la thèse : Ronan Keryell Jury T M. Cédric Bastoul, Maître de Conférence, Alchemy/LRI/INRIA, Université Paris-Sud Examinateur M. Philippe Clauss, Professeur, ICPS/LSIIT, Université de Strasbourg Examinateur H M. Fabien Coelho, Maître-Assistant, CRI, MINES ParisTech Co-encadrant de la thèse M. Albert Cohen, Directeur de Recherche, PARKAS, INRIA Rocquencourt Rapporteur È M. Alain Darte, Directeur de Recherche, LIP, CNRS Rapporteur M. François Irigoin, Directeur de Recherche, CRI, MINES ParisTech Directeur de thèse S M. Ronan Keryell, Directeur Scientifique, SILKAN Co-encadrant de la thèse M. Sanjay Rajopadhye, Professeur, CS/ECE Departments, Colorado State University Rapporteur E MINES ParisTech Centre de Recherche en Informatique 35 rue Saint-Honoré, 77305 Fontainebleau, France To my beloved father. Remerciements Avant toute chose, relever ce défi personnel n’aurait pas été possible sans le soutien indéfectible de ma tendre épouse, ces trois dernières années n’ont pas été les plus reposantes et j’admire sa patience et sa tolérance vis à vis de son mari travaillant à 500km de notre domicile et s’absentant régulièrement pour toutes sortes de conférences ou formations. Mes pensées vont évidement à mon fils Tim, mon moteur principal aujourd’hui, mais aussi celui qui m’épuise à longueur de journées (du moins le peu de celles que j’ai passé avec lui à la maison ces dernières années). A croire qu’il puise son énergie qui semble infinie dans la notre. J’ai la chance d’avoir des parents formidables à qui j’ai posé beaucoup de difficultés qu’ils ont su surmonter pour me pousser à faire des études. Peut-être que Tim qui me le rend bien me fait mesurer l’ampleur de la tâche. Je les en remercie milles fois. Une aventure commence souvent avec une rencontre, et pour satisfaire ma nature nos- talgique, je vais la raconter. C’était le 4 juin 2009, lorsque mon étoile m’a conduit à assister à la Journée jeunes chercheurs sur les Multiprocesseurs et Multicoeurs àParis. Quelle chance d’être encore là à la fin de la journée lorsqu’un curieux personnage (non, je ne me risquerai pas à une description àlaZola) s’est levé pour annoncer qu’il cherchait des candidats passionnés à un projet un peu fou (ou des candidats un peu fous pour un projet passionnant, je ne sais plus très bien...). Il n’en fallait pas plus pour piquer ma curiosité et, après une description plus détaillée, j’étais fasciné par la folie apparente du projet et j’oubliais être le fou potentiel. Je repartais vers mon TGV, une carte de visite dans la poche. Peu après minuit le soir même, sitôt rentré chez moi, j’envoyais mon CV à Ronan Keryell.Ledoigtdansl’engrenage... Trois jours plus tard, j’étais invité par François Irigoin àluirendrevisiteà Fontainebleau. C’est finalement le 1er juillet que je me suis rendu dans les locaux du Centre de Recherche en Informatique (CRI) pour y rencontrer celui qui allait me proposer de diriger cette thèse. Neuf jours plus tard, Ronan me proposait de réaliser ces travaux dans une petite entreprise. Était-ce le goût du risque ? Ou peut-être le nom tellement cool de HPC Project ?Lechallengedelathèsen’étaitpasassezdifficileàreleverenluimême qu’il fallait y associer une entreprise ? A moins que Ronan n’ait simplement su employer les arguments qui font mouche pour un esprit pur: Nous sommes prêts à te prendre en thèse CIFRE entre HPC Project et CRI, histoire de combiner le fun de la thèse avec une rémunération raisonnable et de voir la vie à 2 endroits différents. Le 6 décembre j’étais encore ingénieur à l’Université de Strasbourg, le 7 décembre 2009 l’aventure commençait vraiment. Le jour même je m’envolais pour une école thématique sur le calcul hautes performances sur accélérateurs matériels et je rencontrais deux personnes dont j’ignorais l’importance de nos futurs interactions: Béatrice Creusillet et Stéphanie Even.Jenepouvaisrêvermeilleurdépart. Acesrencontress’ensontsuccédéesdenombreusesautres,etilm’estimpossiblede toutes les mentionner ici. Certaines ont été plus marquantes, ou ont eu plus d’impact dans le cadre de mes travaux, que ce soit vis-à-vis de l’orientation de mes recherches ou simplement de mes conditions de "travail". Bien sûr Ronan et François, pour m’avoir supporté, ont la plus grande part de mérites, ils ont été en quelque sorte le Yin et le Yang, le Chaud et le Froid, l’Alpha et l’Omega, enfin bref les éléments essentiels au maintient d’un équilibre pendant ces trois années. J’ai le privilège de continuer à travailler avec Ronan aujourd’hui. Fabien Coelho,quiarejoint l’aventure en cours de route (et il n’avait pas l’excuse de l’ignorance, il avait déjà eu à me supporter sur pipsdev@), a su apporter une couleur différente et compléter efficacement la direction de mes travaux. J’ai beaucoup progressé à leur contact, techniquement et humainement. Leurs relectures attentives et leur nombreux commentaires ont contribué significativement à l’amélioration de ce manuscrit, et j’atteste que tout ce qui peut em- pêcher ce dernier de répondre à l’exigence du lecteur reste de mon seul fait, que ce soit de ma paresse ou de mon incompétence (je me plais à croire au premier et à douter du second). Au rang de mes collègues, j’ai eu la chance de côtoyer des gens très brillant. Il est très facile d’être modeste quand on évolue dans un pareil environnement. Je reste admiratif devant la qualité du travail de Béatrice qui continue à m’impressionner chaque semaine par son efficacité. Je déconseille la lecture de son manuscrit de thèse à tout doctorant: la qualité (et la taille) de l’ouvrage pose une base à décourager de commencer sa propre rédaction. Si elle n’était pas si gentille, dévouée, et tellement agréable, je pourrais peut-être songer à lui trouver un défaut. Au même titre que Ronan, je suis chanceux de pouvoir continuer à la compter parmi mes collègues pour la suite de nos travaux sur Par4All. Je suis heureux d’avoir pu travailler avec Serge papillon Guelton pour la teneur nos discussions techniques, pour sa fraîcheur,etpoursonenthousiasmecommunicatif.Nos différences ont été sources d’enrichissement, que j’espère mutuel. Le choix de m’engager avec Silkan (HPC-Project à cette époque) comportait des risques, mais ce fut payant. En dehors de l’expérience intéressante qui a consister à trouver l’équilibre entre la recherche et les problématiques terre-à-terre d’une jeune entreprise, j’ai côtoyé (et continue à travailler avec) des gens brillants. Parmi eux Pierre Villalon, François-Xavier Pasquier, Thierry Porcher, Janice Onanian McMahon, Onil Nazra Per- sada Goubier, ou Yannick Langlois ; mais également notre PDG-CEO Pierre Fiorini que je remercie pour la confiance qu’il m’accorde. Le CRI est un laboratoire accueillant, situé dans un cadre magnifique pour ne rien gâcher. J’ai apprécié d’y rencontrer et d’échanger sur la compilation avec Pierre Jouvelot, Karim Barkati, Antoniu Pop, Amira Mensi, Rachid Habel, ou encore Claude Tadonki ; et d’échanger sur divers autres sujets avec Georges-André Silber, Claire Medrala, Laurent Daverio, ou Jacqueline Altimira. J’ai découvert la communauté française de compilation, grâce aux immanquable journées compilation que je soupçonne de devoir beaucoup à l’implication de Laure Gonnord parmi d’autres. J’y ai fait beaucoup de rencontre, et passé d’excellent moment. J’espère que mon éloignement géographique actuel me laissera des opportunités d’assister et de partager nos travaux lors de quelques journées futures. Je me dois de dire que je ne me serai pas lancé dans ce projet sans avoir vécu à côté l’équipe Informatique et Calcul Parallèle Scientifique (ICPS) de Strasbourg et son ambiance de travail inégalable. Les meilleurs enseignants de mon cursus universitaire en font (ou faisait) partis, parmi eux : Alain Ketterlin, Vincent Loechner, Eric Violard, Catherine Mongenet, Arnaud Giersch, ou encore Benoit Meister. J’ai vraiment apprécié l’informatique en suivant leur enseignement. J’ai une pensée particulière pour Philippe Clauss avec qui j’ai découvert la programmation parallèle, et qui, ce 4 juin 2009 dans le TGV qui nous ramenait de Paris, m’a encouragé à postuler sur ce sujet de thèse. Pour m’avoir montré une autre facette de la recherche, et m’avoir encadré (supporté ?) pendant mon stage de Master à l’Observatoire Astronomique de Strasbourg, je remercie chaleureusement Dominique Aubert.
Recommended publications
  • When Is a Microprocessor Not a Microprocessor? the Industrial Construction of Semiconductor Innovation I
    Ross Bassett When is a Microprocessor not a Microprocessor? The Industrial Construction of Semiconductor Innovation I In the early 1990s an integrated circuit first made in 1969 and thus ante­ dating by two years the chip typically seen as the first microprocessor (Intel's 4004), became a microprocessor for the first time. The stimulus for this piece ofindustrial alchemy was a patent fight. A microprocessor patent had been issued to Texas Instruments, and companies faced with patent infringement lawsuits were looking for prior art with which to challenge it. 2 This old integrated circuit, but new microprocessor, was the ALl, designed by Lee Boysel and used in computers built by his start-up, Four-Phase Systems, established in 1968. In its 1990s reincarnation a demonstration system was built showing that the ALI could have oper­ ated according to the classic microprocessor model, with ROM (Read Only Memory), RAM (Random Access Memory), and I/O (Input/ Output) forming a basic computer. The operative words here are could have, for it was never used in that configuration during its normal life­ time. Instead it was used as one-third of a 24-bit CPU (Central Processing Unit) for a series ofcomputers built by Four-Phase.3 Examining the ALl through the lenses of the history of technology and business history puts Intel's microprocessor work into a different per­ spective. The differences between Four-Phase's and Intel's work were industrially constructed; they owed much to the different industries each saw itselfin.4 While putting a substantial part ofa central processing unit on a chip was not a discrete invention for Four-Phase or the computer industry, it was in the semiconductor industry.
    [Show full text]
  • Pattern Matching
    Functional Programming Steven Lau March 2015 before function programming... https://www.youtube.com/watch?v=92WHN-pAFCs Models of computation ● Turing machine ○ invented by Alan Turing in 1936 ● Lambda calculus ○ invented by Alonzo Church in 1930 ● more... Turing machine ● A machine operates on an infinite tape (memory) and execute a program stored ● It may ○ read a symbol ○ write a symbol ○ move to the left cell ○ move to the right cell ○ change the machine’s state ○ halt Turing machine Have some fun http://www.google.com/logos/2012/turing-doodle-static.html http://www.ioi2012.org/wp-content/uploads/2011/12/Odometer.pdf http://wcipeg.com/problems/desc/ioi1211 Turing machine incrementer state symbol action next_state _____ state 0 __1__ state 1 0 _ or 0 write 1 1 _10__ state 2 __1__ state 1 0 1 write 0 2 _10__ state 0 __1__ state 0 _00__ state 2 1 _ left 0 __0__ state 2 _00__ state 0 __0__ state 0 1 0 or 1 right 1 100__ state 1 _10__ state 1 2 0 left 0 100__ state 1 _10__ state 1 100__ state 1 _10__ state 1 100__ state 1 _10__ state 0 100__ state 0 _11__ state 1 101__ state 1 _11__ state 1 101__ state 1 _11__ state 0 101__ state 0 λ-calculus Beware! ● think mathematical, not C++/Pascal ● (parentheses) are for grouping ● variables cannot be mutated ○ x = 1 OK ○ x = 2 NO ○ x = x + 1 NO λ-calculus Simplification 1 of 2: ● Only anonymous functions are used ○ f(x) = x2+1 f(1) = 12+1 = 2 is written as ○ (λx.x2+1)(1) = 12+1 = 2 note that f = λx.x2+1 λ-calculus Simplification 2 of 2: ● Only unary functions are used ○ a binary function can be written as a unary function that return another unary function ○ (λ(x,y).x+y)(1,2) = 1+2 = 3 is written as [(λx.(λy.x+y))(1)](2) = [(λy.1+y)](2) = 1+2 = 3 ○ this technique is known as Currying Haskell Curry λ-calculus ● A lambda term has 3 forms: ○ x ○ λx.A ○ AB where x is a variable, A and B are lambda terms.
    [Show full text]
  • Lambda Calculus and Functional Programming
    Global Journal of Researches in Engineering Vol. 10 Issue 2 (Ver 1.0) June 2010 P a g e | 47 Lambda Calculus and Functional Programming Anahid Bassiri1Mohammad Reza. Malek2 GJRE Classification (FOR) 080299, 010199, 010203, Pouria Amirian3 010109 Abstract-The lambda calculus can be thought of as an idealized, Basis concept of a Turing machine is the present day Von minimalistic programming language. It is capable of expressing Neumann computers. Conceptually these are Turing any algorithm, and it is this fact that makes the model of machines with random access registers. Imperative functional programming an important one. This paper is programming languages such as FORTRAN, Pascal etcetera focused on introducing lambda calculus and its application. As as well as all the assembler languages are based on the way an application dikjestra algorithm is implemented using a Turing machine is instructed by a sequence of statements. lambda calculus. As program shows algorithm is more understandable using lambda calculus in comparison with In addition functional programming languages, like other imperative languages. Miranda, ML etcetera, are based on the lambda calculus. Functional programming is a programming paradigm that I. INTRODUCTION treats computation as the evaluation of mathematical ambda calculus (λ-calculus) is a useful device to make functions and avoids state and mutable data. It emphasizes L the theories realizable. Lambda calculus, introduced by the application of functions, in contrast with the imperative Alonzo Church and Stephen Cole Kleene in the 1930s is a programming style that emphasizes changes in state. formal system designed to investigate function definition, Lambda calculus provides a theoretical framework for function application and recursion in mathematical logic and describing functions and their evaluation.
    [Show full text]
  • Purity in Erlang
    Purity in Erlang Mihalis Pitidis1 and Konstantinos Sagonas1,2 1 School of Electrical and Computer Engineering, National Technical University of Athens, Greece 2 Department of Information Technology, Uppsala University, Sweden [email protected], [email protected] Abstract. Motivated by a concrete goal, namely to extend Erlang with the abil- ity to employ user-defined guards, we developed a parameterized static analysis tool called PURITY, that classifies functions as referentially transparent (i.e., side- effect free with no dependency on the execution environment and never raising an exception), side-effect free with no dependencies but possibly raising excep- tions, or side-effect free but with possible dependencies and possibly raising ex- ceptions. We have applied PURITY on a large corpus of Erlang code bases and report experimental results showing the percentage of functions that the analysis definitely classifies in each category. Moreover, we discuss how our analysis has been incorporated on a development branch of the Erlang/OTP compiler in order to allow extending the language with user-defined guards. 1 Introduction Purity plays an important role in functional programming languages as it is a corner- stone of referential transparency, namely that the same language expression produces the same value when evaluated twice. Referential transparency helps in writing easy to test, robust and comprehensible code, makes equational reasoning possible, and aids program analysis and optimisation. In pure functional languages like Clean or Haskell, any side-effect or dependency on the state is captured by the type system and is reflected in the types of functions. In a language like ERLANG, which has been developed pri- marily with concurrency in mind, pure functions are not the norm and impure functions can freely be used interchangeably with pure ones.
    [Show full text]
  • (February 2 , 2015) If You Know Someone Who You Think Would
    (February 2nd, 2015) If you know someone who you think would benefit from being an Insider, feel free to forward this PDF to them so they can sign up here. Quick Tips for our Insider friends! Hey Insiders, It’s the 100th newsletter!! I’ve been producing these newsletters since March 2011 – wow! To celebrate this milestone, I’ve put together some cool stuff for you: A Pluralsight giveaway. The first 100 people to respond to the newsletter email asking for a Pluralsight code will get 30-days of access to all 120+ hours of SQLskills online training for free. No catches, no credit cards. Go! My top-ten books of all time as well as my regular book review 100 SQL Server (and career) hints, tips, and tricks from the SQLskills team in my Paul’s Ponderings section. And the usual demo video, by me for a change. This newsletter is *looooong* this time! Grab a cup of coffee and settle in for a great ride. We’ve done eleven remote and in-person user group presentations this year already, to a combined audience of more than 1,100 people in the SQL community, and Glenn’s presenting remotely in Israel as this newsletter is hitting your inbox. Go community! I recently won the “Person You’d Most Like to be Mentored By” community award in the annual Redgate Tribal Awards. Thanks! To celebrate, I’m offering to mentor 3 men and 3 women through March and April. See this post for how to enter to be considered. I made it to the fantastic Living Computer Museum in Seattle over the weekend, which has a ton of cool old computers, many from DEC where I worked before Microsoft.
    [Show full text]
  • Silicon Valley's Hi-Tech Heritage: Apple Park Visitor Center And
    Silicon Valley’s Hi-Tech Heritage: Apple Park Visitor Center and Three Great Museums Tell the Computer and Technology Story By Lee Foster Author’s Note: This article “Silicon Valley’s Hi-Tech Heritage: Apple Park Visitor Center and Three Great Museums Tell the Computer and Technology Story” is a chapter in my new book/ebook Northern California History Travel Adventures: 35 Suggested Trips. The subject is also covered in my book/ebook Northern California Travel: The Best Options. That book is available in English as a book/ebook and also as an ebook in Chinese. Several of my books on California can be seen on my Amazon Author Page. In Brief In California’s Silicon Valley, you can learn about the computer and technology revolution that is affecting the world today. For instance, the story comes alive at the new Apple Park Visitor Center in Cupertino. In addition you can visit three great museums located, appropriately, in this Northern California epicenter of innovation. These high-tech revolutions have altered the face of San Jose and the Silicon Valley. You find the area, which is 30-50 miles south of San Francisco. It stretches along the western and southern edge of San Francisco Bay. My Osborne Computer, 1980, a copy of which can be seen at the Computer History Museum Originally a bucolic ranching region, San Jose began as a small pueblo and Spanish mission in the 18th century. In the 19th and early 20th centuries, the valley developed as one of the most important fruit-growing areas in the United States.
    [Show full text]
  • Everything Matters
    Everything intel.com/go/responsibility Matters Global Citizenship Report 2003 Contents Executive Summary 3 Everything Adds Up Corporate Performance 4 Organizational Profile 6 Everywhere Matters 8 Stakeholder Relationships 10 Performance Summary 11 Goals & Targets 12 Ethics & Compliance 13 Economic Performance Environment, Health & Safety 14 Every Effort Contributes 16 Performance Indicators 18 Inspections & Compliance 19 Workplace Health & Safety 20 Environmental Footprint 22 Product Ecology 23 EHS Around the World Social Programs & Performance 24 Everyone Counts 26 Workplace Environment 31 Everyone Has a Say 32 Diversity 34 Education 36 Technology in the Community 37 Contributing to the Community 38 External Recognition 39 Intel: 35 Years of Innovation GRI Content Table Section # GRI Section Intel Report Reference Page # 1.1 Vision & Strategy Executive Summary 3 1.2 CEO Statement Executive Summary 3 2.1– 2.9 Organizational Profile Organizational Profile, Stakeholder Relationships 4–9 2.10– 2.16 Report Scope Report Scope & Profile 2 2.17– 2.22 Report Profile Report Scope & Profile 2 3.1– 3.8 Structure & Governance Ethics & Compliance 12 3.9– 3.12 Stakeholder Engagement Stakeholder Relationships 8–9 3.13– 3.20 Overarching Policies & Management Systems Ethics & Compliance, For More Information 12, 40 4.1 GRI Content Index GRI Content Table 2 Performance Summary 2003 Performance, 2004 Goals & Targets 10–11 5.0 Economic Performance Indicators Economic Performance 13 5.0 Environmental Performance Indicators Environment, Health & Safety 14– 23 5.0 Social Performance Indicators Social Programs & Performance 24–37 Report Scope and Profile: This report, addressing Intel’s worldwide operations, was published in May 2004. The report contains data from 2001 through 2003.
    [Show full text]
  • Computer Architectures an Overview
    Computer Architectures An Overview PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Sat, 25 Feb 2012 22:35:32 UTC Contents Articles Microarchitecture 1 x86 7 PowerPC 23 IBM POWER 33 MIPS architecture 39 SPARC 57 ARM architecture 65 DEC Alpha 80 AlphaStation 92 AlphaServer 95 Very long instruction word 103 Instruction-level parallelism 107 Explicitly parallel instruction computing 108 References Article Sources and Contributors 111 Image Sources, Licenses and Contributors 113 Article Licenses License 114 Microarchitecture 1 Microarchitecture In computer engineering, microarchitecture (sometimes abbreviated to µarch or uarch), also called computer organization, is the way a given instruction set architecture (ISA) is implemented on a processor. A given ISA may be implemented with different microarchitectures.[1] Implementations might vary due to different goals of a given design or due to shifts in technology.[2] Computer architecture is the combination of microarchitecture and instruction set design. Relation to instruction set architecture The ISA is roughly the same as the programming model of a processor as seen by an assembly language programmer or compiler writer. The ISA includes the execution model, processor registers, address and data formats among other things. The Intel Core microarchitecture microarchitecture includes the constituent parts of the processor and how these interconnect and interoperate to implement the ISA. The microarchitecture of a machine is usually represented as (more or less detailed) diagrams that describe the interconnections of the various microarchitectural elements of the machine, which may be everything from single gates and registers, to complete arithmetic logic units (ALU)s and even larger elements.
    [Show full text]
  • Deep Dive Into Programming with CAPS HMPP Dev-Deck
    Introduction to HMPP Hybrid Manycore Parallel Programming Московский государственный университет, Лоран Морен, 30 август 2011 Hybrid Software for Hybrid Hardware • The application should stay hardware resilient o New architectures / languages to master o Hybrid solutions evolve: we don‟t want to redo the work each time • Kernel optimizations are the key to get performance o An hybrid application must get the best of its hardware resources 30 август 2011 Москва - Лоран Морен 2 Methodology to Port Applications Methodology to Port Applications Hotspots Parallelization •Optimize CPU code •Performance goal •Exhibit Parallelism •Validation process •Move kernels to GPU •Hotspots selection •Continuous integration Define your Port your Hours to Days parallel application Days to Weeks project on GPU GPGPU operational Phase 1 application with known potential Phase 2 Tuning Optimize your GPGPU •Exploit CPU and GPU application •Optimize kernel execution •Reduce CPU-GPU data transfers Weeks to Months 30 август 2011 Москва - Лоран Морен 4 Take a decision • Go • Dense hotspot • Fast GPU kernels • Low CPU-GPU data transfers • Midterm perspective: Prepare to manycore parallelism • No Go o Flat profile o GPU results not accurate enough • cannot validate the computation o Slow GPU kernels • i.e. no speedup to be expected o Complex data structures o Big memory space requirement 30 август 2011 Москва - Лоран Морен 5 Tools in the Methodology Hotspots Parallelization • Profiling tools Gprof, Kachegrind, Vampir, Acumem, ThreadSpotter •HMPP Workbench •Debugging
    [Show full text]
  • The Quantum IO Monad Thorsten Altenkirch and Alexander S
    1 The Quantum IO Monad Thorsten Altenkirch and Alexander S. Green School of Computer Science, The University of Nottingham Abstract The Quantum IO monad is a purely functional interface to quantum programming implemented as a Haskell library. At the same time it provides a constructive semantics of quantum programming. The QIO monad separates reversible (i.e. unitary) and irreversible (i.e. prob- abilistic) computations and provides a reversible let operation (ulet), allowing us to use ancillas (auxiliary qubits) in a modular fashion. QIO programs can be simulated either by calculating a probability distribu- tion or by embedding it into the IO monad using the random number generator. As an example we present a complete implementation of Shor’s algorithm. 1.1 Introduction We present an interface from a pure functional programming language, Haskell, to quantum programming: the Quantum IO monad, and use it to implement Shor’s factorisation algorithm. The implementation of the QIO monad provides a constructive semantics for quantum programming, i.e. a functional program which can also be understood as a mathematical model of quantum computing. Actually, the Haskell QIO library is only a first approximation of such a semantics, we would like to move to a more expressive language which is also logically sound. Here we are thinking of a language like Agda (Norell (2007)), which is based on Martin L¨of’s Type Theory. We have already investigated this approach of functional specifications of effects in a classical context (Swierstra and Altenkirch (2007, 2008); Swierstra (2008)). At the same 1 2 Thorsten Altenkirch and Alexander S.
    [Show full text]
  • Why Functional Programming Is Good … …When You Like Math - Examples with Haskell
    Why functional programming is good … …when you like math - examples with Haskell . Jochen Schulz Georg-August Universität Göttingen 1/18 Table of contents 1. Introduction 2. Functional programming with Haskell 3. Summary 1/18 Programming paradigm imperative (e.g. C) object-oriented (e.g. C++) functional (e.g. Haskell) (logic) (symbolc) some languages have multiple paradigm 2/18 Side effects/pure functions . side effect . Besides the return value of a function it has one or more of the following modifies state. has observable interaction with outside world. pure function . A pure function always returns the same results on the same input. has no side-effect. .also refered to as referential transparency pure functions resemble mathematical functions. 3/18 Functional programming emphasizes pure functions higher order functions (partial function evaluation, currying) avoids state and mutable data (Haskell uses Monads) recursion is mostly used for loops algebraic type system strict/lazy evaluation (often lazy, as Haskell) describes more what is instead what you have to do 4/18 Table of contents 1. Introduction 2. Functional programming with Haskell 3. Summary 5/18 List comprehensions Some Math: S = fx2jx 2 N; x2 < 20g > [ x^2 | x <- [1..10] , x^2 < 20 ] [1,4,9,16] Ranges (and infinite ranges (don’t do this now) ) > a = [1..5], [1,3..8], ['a'..'z'], [1..] [1,2,3,4,5], [1,3,5,7], "abcdefghijklmnopqrstuvwxyz" usually no direct indexing (needed) > (head a, tail a, take 2 a, a !! 2) (1,[2,3,4,5],[1,2],3) 6/18 Functions: Types and Typeclasses Types removeNonUppercase :: [Char] -> [Char] removeNonUppercase st = [ c | c <- st, c `elem ` ['A'..'Z']] Typeclasses factorial :: (Integral a) => a -> a factorial n = product [1..n] We also can define types and typeclasses and such form spaces.
    [Show full text]
  • Function Programming in Python
    Functional Programming in Python David Mertz Additional Resources 4 Easy Ways to Learn More and Stay Current Programming Newsletter Get programming related news and content delivered weekly to your inbox. oreilly.com/programming/newsletter Free Webcast Series Learn about popular programming topics from experts live, online. webcasts.oreilly.com O’Reilly Radar Read more insight and analysis about emerging technologies. radar.oreilly.com Conferences Immerse yourself in learning at an upcoming O’Reilly conference. conferences.oreilly.com ©2015 O’Reilly Media, Inc. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. #15305 Functional Programming in Python David Mertz Functional Programming in Python by David Mertz Copyright © 2015 O’Reilly Media, Inc. All rights reserved. Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). See: http://creativecommons.org/licenses/by-sa/4.0/ Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected]. Editor: Meghan Blanchette Interior Designer: David Futato Production Editor: Shiny Kalapurakkel Cover Designer: Karen Montgomery Proofreader: Charles Roumeliotis May 2015: First Edition Revision History for the First Edition 2015-05-27: First Release The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Functional Pro‐ gramming in Python, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc.
    [Show full text]