Prototyping Parallel Functional Intermediate Languages
Total Page:16
File Type:pdf, Size:1020Kb
Prototyping parallel functional intermediate languages by Andrew David Ben-Dyke A thesis submitted to the Faculty of Science of The University of Birmingham for the degree of DOCTOR OF PHILOSOPHY School of Computer Science Faculty of Science The University of Birmingham United Kingdom October 1999 University of Birmingham Research Archive e-theses repository This unpublished thesis/dissertation is copyright of the author and/or third parties. The intellectual property rights of the author or third parties in respect of this work are as defined by The Copyright Designs and Patents Act 1988 or as modified by any successor legislation. Any use made of information contained in this thesis/dissertation must be in accordance with that legislation and must be properly acknowledged. Further distribution or reproduction in any format is prohibited without the permission of the copyright holder. Abstract Non-strict higher-order functional programming languages are elegant, concise, math ematically sound and contain few environment-specific features, making them obvious candidates for harnessing high-performance architectures. The validity of this approach has been established by a number of experimental compilers. However, while there have been a number of important theoretical developments in the field of parallel functional programming, implementations have been slow to materialise. The myriad design choices and demands of specific architectures lead to protracted development times. Furthermore, the resulting systems tend to be monolithic entities, and are difficult to extend and test, ultimatly discouraging experimentation. The traditional solution to this problem is the use of a rapid prototyping framework. However, as each existing systems tends to prefer one specific platform and a particular way of expressing parallelism (including implicit specification) it is difficult to envisage a general purpose framework. Fortunately, most of these systems have at least one point of commonality: the use of an intermediate form. Typically, these abstract representations explicitly identify all parallel components but without the background noise of syntactic and (potentially arbitrary) implementation details. To this end, this thesis outlines a framework for rapidly prototyping such intermediate languages. Based on the traditional three-phase compiler model, the design process is driven by the development of various semantic descriptions of the language. Executable versions of the specifications help to both debug and informally validate these models. A number of case studies, covering the spectrum of modern implementations, demonstrate the utility of the framework. Acknowledgements Firstly, I thank my supervisor, Dr Tom Axford, for his assistance throughout this re search project. I also acknowledge the members of my thesis group. Dr Lydia Kronsjo, and Dr Marta Kwiatkowska, for their helpful and timely advice. Furthermore, I acknowledge my examiners, Dr Antoni Diller of the University of Birmingham, and Dr Mike Joy of the University of Warwick, for their advice, in accordance with which this thesis has been modified. I am also grateful to my fellow research students for providing a relaxed and friendly working environment in addition. Dr Howard Goodman must take the credit for the improvement in my grammar, punctuation, and general writing style. Finally, I would like to thank all of my family and friends for their patience and understanding, though special recognition must go to Claire for her dedicated support of my academic pursuits. Contents 1 Introduction 1 1.1 Motivation ............................................................................................................ 1 1.2 Overview ............................................................................................................... 2 1.2.1 Background................................................................................................ 2 1.2.2 Prototyping parallel functional intermediate languages...................... 2 1.2.3 The sequential STG' language.............................................................. 2 1.2.4 Expressing parallelism - static m od els................................................. 2 1.2.5 Managing parallelism - operational m o d e ls ........................................ 3 1.2.6 Simulating the target architecture ......................................................... 3 1.2.7 Compilation rules ................................................................................... 3 1.2.8 Prototyping parallel functional intermediate languages...................... 3 1.2.9 Summary, evaluation, and further work .............................................. 3 2 Background 4 2.1 Introduction............................................................................................................ 4 2.2 Parallel processing................................................................................................ 4 2.2.1 Architectural taxonomies ....................................................................... 4 2.2.2 Amdahl’s law and the corollary of modest potential ......................... 6 2.3 Architecture independence through functional programming......................... 6 2.3.1 The software crisis and parallel languages........................................... 6 2.3.2 Can programming be liberated from the von Neumann style? .... 7 2.3.3 Craph red u ction ....................................................................................... 9 2.3.4 Parallel functional programming: an introduction............................... 10 2.4 User-level annotations and expressions............................................................... 11 2.4.1 Implicit specification................................................................................ 11 2.4.2 Bulk data types.......................................................................................... 12 2.4.3 Skeletal parallelism................................................................................... 13 2.4.4 Low-level annotations............................................................................. 15 2.5 Prototyping parallel functional languages ........................................................ 18 2.5.1 The problem with performance comparisons........................................ 19 2.5.2 Is a standard benchmark suite the solution?........................................ 19 2.5.3 Existing approaches to developing functional implementations .... 22 2.6 Sum m ary............................................................................................................... 23 A framework for prototyping parallel functional intermediate languages 25 3.1 Introduction............................................................................................................ 25 3.2 A three-phase compilation system....................................................................... 25 3.3 Translation, optimisation, and code generation................................................ 27 3.4 Structuring the d e sig n ......................................................................................... 27 3.5 Animating the co m p ile r...................................................................................... 28 3.6 Sum m ary............................................................................................................... 29 The sequential STG' language 30 4.1 Introduction............................................................................................................ 30 4.2 Why use a sequential language?.......................................................................... 30 4.3 Abstract syntax...................................................................................................... 31 4.3.1 Identifiers................................................................................................... 33 4.3.2 Algebraic data-type declarations........................................................... 33 4.3.3 Named defaults and case expressions.................................................... 33 4.3.4 Unboxed and strict let expressions........................................................ 34 4.3.5 Animating the abstract s y n ta x .............................................................. 35 4.4 Concrete syntax ................................................................................................... 35 4.5 Language restrictions, type inference and free variables................................... 36 4.5.1 The STG language and the STG m achine........................................... 36 4.5.2 The advantages of static typing.............................................................. 37 4.5.3 Hindley-Milner type inference for the STG' language.............................38 4.5.4 Free variables............................................................................................. 42 4.6 Annotations are not e n o u g h ?............................................................................. 43 4.7 Denotational semantics......................................................................................... 44 4.7.1 Domain equations ................................................................................... 44 4.7.2 The meta-language................................................................................... 44 4.7.3 Valuation functions..................................................................................