Skip to content

Tutorial for using the MPL compiler for Parallel ML

License

Notifications You must be signed in to change notification settings

MPLLang/mpl-tutorial

Repository files navigation

MPL Tutorial

Introduction

MPL is a compiler for parallel programming on shared-memory multicore machines. The MPL language is essentially Standard ML (SML) with extensions for parallelism.

This tutorial provides an introduction to using MPL. You don't need to already know SML, but you should be comfortable with using the command-line shell and know some basic programming (integers, booleans, conditionals, variables, functions, recursion, etc.).

All source code is contained in this repo. Some of the examples use the mpllib.

Get started

(Note: more detailed instructions available here).

We recommend that you clone this repository and then run the tutorial in a Docker container using the top-level Dockerfile.

$ git clone https://github.com/MPLLang/mpl-tutorial.git
$ cd mpl-tutorial
$ ./start-container.sh

This opens a bash shell in the container, which should have a prompt that looks something like this (the numbers after root@ may differ; this is normal):

root@b80fc75d8c76:~/mpl-tutorial#

For simplicity throughout the tutorial, we will write <container># before commands that are intended to be run inside the Docker container.

Inside the container

The directory structure inside the container is as follows. Starting the container puts us inside the mpl-tutorial directory.

root
├── mpl            # the MPLLang/mpl repository
└── mpl-tutorial   # this repository

Inside the container, the directory mpl-tutorial is mounted from your local machine. Any changes within this directory will be visible both inside and outside the container. This ensure that any changes you make will not be lost when you exit the container, and also allows you to use any text editor outside the container to edit files.

Pull the library

Once you have started the container, you need to pull the library code:

<container># pwd
/root/mpl-tutorial
<container># smlpkg sync

This populates the directory lib with packages that this tutorial depends on. You only need to do this once, when starting the tutorial for the first time.

Do not modify the contents of the lib subdirectory. These are maintained by the package manager.

Table of Contents

  1. Setup: running with docker and/or installing the compiler
  2. Hello World: writing, compiling, and running a simple program
  3. Parallelism and Granularity Control: simple parallelism with ForkJoin.par, and work-efficiency via granularity control
  4. Trees: parallel algorithms on binary trees, tree balance experiments
  5. Sequences: parallel algorithms on sequences
  6. MCSS: the Maximum Contigous Subsequence Sum problem
  7. BFS: Breadth First Search.

FAQ

Help: Inside the Docker container, a process dies with the message Killed. This is likely due to a Docker memory limit. See the Docker Resource Limits section of Setup for instructions on how to fix.

Help: When compiling, I see a long string of errors such as Undefined structure. Make sure you've pulled the library code. See the Pull the library section, above.

About

Tutorial for using the MPL compiler for Parallel ML

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages