A Gentle Introduction to GPH

$Revision: 1.4 $

Hans-Wolfgang Loidl

Philip W. Trinder

   Department of Computing and Electrical Engineering,
   Heriot-Watt University 
   {hwloidl,trinder}@cee.hw.ac.uk
  

July 2001


Table of Contents
Introduction
A Quick Introduction to Using GUM and GPH
GpH - A Parallel Functional Language
Hints on Parallel Performance Tuning
Using GPH in Practice
Troubleshooting
Internals of GUM
Bibliography
Appendix A.

This document gives an introduction to the semi-explicit, parallel, functional language GPH, a modest extension of Haskell98. No previous knowledge of parallel programming is assumed. However, the reader should already be familiar with Haskell.

This is an early draft. The sections on using GPH and the general overview of GPH should be the most useful parts for now.

Introduction

With functional languages all you have to do to write a parallel program is to write a sequential one, lean back, and let the compiler do the automatic parallelisation, right? Wrong! At least not with current compiler technology. There are a few research systems that perform automatic parallelisation but even in these systems it is often necessary to restructure the program to obtain good parallel performance.

Our parallel functional language, GPH, extends the standard non-strict functional language Haskell with two new combinators in order to specify parallelism. All the programmer has to do is to expose the parallelism, by annotating expressions that can be evaluated in parallel, without having to control the details of parallel execution. So, if there are only two new combinators, why a full paper explaining how to use them? Well, it turns out that the undisciplined use of these combinators yields programs that are hard to understand and maintain. The reason is the mixture of code for computing a result and for generating parallelism. Although, this is standard in parallel imperative languages it goes against the philosophy of functional languages. Therefore, we will also discuss a way to discipline the programmer for writing parallel programs that are easy to maintain.

This paper is an introduction to GPH and to parallel, lazy, functional programming in this language. No previous knowledge of other parallel languages is assumed. However, we do assume that the reader has some familiarity with the Haskell language. See the Haskell Bookshelf for tutorials and introductions to Haskell. We will guide the reader through the subtleties of tuning the performance of GPH programs by providing numerous examples and graphs showing the dynamic behaviour of the programs. The reader is encouraged to try the programs online, using either the GranSim simulator or the parallel GUM system. See the GPH Web Page about information how to obtain and install these systems.

The rest of this document is structured as follows. First we give a quick introduction to using GPH and is written for an experienced Haskell programmer, who is familiar with GHC. Then we discuss the programming language, GPH, as well as evaluation strategies as a way of structuring the parallelism in a GPH program. We gives some hints on how to improve the performance of GPH programs. Finally, we look into various internals of the GUM runtime-system, in particular the memory management.