A parallel functional language compiler for message-passing multicomputers

The research presented in this thesis is about the design and implementation of Naira, a parallel, parallelising compiler for a rich, purely functional programming language. The source language of the compiler is a subset of Haskell 1.2. The front end of Naira is written entirely in the Haskell subset being compiled. Naira has been successfully parallelised and it is the largest successfully parallelised Haskell program having achieved good absolute speedups on a network of SUN workstations. Having the same basic structure as other production compilers of functional languages, Naira's parallelisation technology should carry forward to other functional language compilers. The back end of Naira is written in C and generates parallel code in the C language which is envisioned to be run on distributed-memory machines. The code generator is based on a novel compilation scheme speci ed using a restricted form of Milner's -calculus which achieves asynchronous communication. We present the rst working implementationof this scheme on distributed-memory message-passing multicomputers with split-phase transactions. Simulated assessment of the generated parallel code indicates good parallel behaviour. Parallelism is introduced using explicit, advisory user annotations in the source program and there are two major aspects of the use of annotations in the compiler. First, the front end of the compiler is parallelised so as to improve its e ciency at compilation time when it is compiling input programs. Secondly, the input programs to the compiler can themselves contain annotations based on which the compiler generates the multi-threaded parallel code. These, therefore, make Naira, unusually and uniquely, both a parallel and a parallelising compiler. We adopt a medium-grained approach to granularity where function applications form the unit of parallelism and load distribution. We have experimented with two di erent task distribution strategies, deterministic and random, and have also experimented with thread-based and quantumbased scheduling policies. Our experiments show that there is little e ciency di erence for regular programs but the quantum-based scheduler is the best in programs with irregular parallelism. The compiler has been successfully built, parallelised and assessed using both idealised and realistic measurement tools: we obtained signi cant compilation speed-ups on a variety of simulated parallel architectures. The simulated results are supported by the best results obtained on real hardware for such a large program: we measured an absolute speedup of 2.5 on a network of 5 SUN workstations. The compiler has also been shown to have good parallelising potential, based on popular test programs. Results of assessing Naira's generated unoptimised parallel code are comparable to those produced by other successful parallel implementation projects. iii Declarations I, Sahalu B Junaidu, hereby certify that this thesis, which is approximately 83K words in length, has been written by me, that it is the record of work carried out by me and that it has not been submitted in any previous application for a higher degree. date . signature of candidate . I was admitted as a research student in February 1992 and as a candidate for the degree of PhD in February 1993; the higher study for which this thesis is a record was carried out in the University of St. Andrews between 1992 and 1998. date . signature of candidate . I hereby certify that the candidate has ful lled the conditions of the Resolution and Regulations appropriate for the degree of PhD in the University of St. Andrews and that the candidate is quali ed to submit this thesis in application for that degree. date . signature of supervisor . In submitting this thesis to the University of St. Andrews I understand that I am giving permission for it to be made available for use in accordance with the regulations of the University Library for the time being in force, subject to any copyright vested in the work not being a ected thereby. I also understand that the title and abstract will be published, and that a copy of the work may be made and supplied to any bona de library or research worker. date . signature of candidate . iv