A GitHub template and codespace configuration with materials from the October 2023 Chapel tutorial
Find a file
Danila Fedorin 2542df46b5 Further README updates
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
2024-04-24 16:26:21 -07:00
.devcontainer Add .devcontainer JSON file for use with Codespaces 2024-04-24 10:07:42 -07:00
GPUExamples Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-basics-coforall.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-basics-distarr.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-basics-for.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-basics-on.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-hello-configurable.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-hello-dist-node-names.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-hello-production-configurable.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-hello-production.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-hello.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-hellopar.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
01-parallelism-and-locality.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
02-array-examples.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
02-configs.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
02-for-loops.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
02-procedures-and-arg-intents.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
02-range-operators.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
02-records-and-classes.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
02-static-type-inference.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
02-tuples.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
03-basics-distarr.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
03-domain-distributions.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
03-onClause.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-atomic-type.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-bounded-buffer-with-sync.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-commOverDom.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-commTable.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-implicit-loops.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-index-gather.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-parallelism-in-chapel.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-quicksort.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-reduction-expression.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-sync-vars.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-task-intents-coforall.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-task-intents-forall.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-task-private-variables.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
04-verboseComm.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
basic.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
heat-1D-block-solution.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
heat-1D-block.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
heat-1D.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
heat-2D-block.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
heat-2D-stencil.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
heat-2D.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
histogram-atomic-solution.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
histogram-reduce-solution.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
histogram-serial.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
kmer.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
kmer_large_input.txt Add more files from the tutorial zip file 2024-04-24 09:57:28 -07:00
kmer_large_input_half.txt Add more files from the tutorial zip file 2024-04-24 09:57:28 -07:00
nbody.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
parfilekmer.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00
README.md Further README updates 2024-04-24 16:26:21 -07:00
replicate.chpl Add files from the tutorial zip file 2024-04-24 09:36:12 -07:00

Introduction to Chapel

Chapel is a programming language for productive parallel computing. This repository contains code from the October 2023 Tutorial.

To get started with this template, you can either use GitHub Codespaces or your own machine (via Docker or by building from source).

The files in this repository correspond to slide decks from the tutorial. Specifically, the prefix number of each file (the 01 in 01-hello.chpl) determines which slide deck walks through that particular file. Please consult the following table for links to the individual slide decks.

Prefix Example File Slide Deck
01 01-hello.chpl Introduction to Chapel
02 02-tuples.chpl Chapel Basics
03 03-onClause.chpl Parallelism In Chapel
04 04-atomic-type.chpl More Parallelism

Using a Codespace

⚠️ Because Codespaces are a virtualized environment running on shared hardware with a modest core count, don't expect parallelism or performance observed here to be reflective of what a native installation of Chapel can achieve.

This repo includes a devcontainer.json file, making it usable from GitHub Codespaces. When viewing this repository from GitHub's UI, click Use this template > Open in a codespace to get started. The codespace includes the Visual Studio Code extension for Chapel, and tools such as chpl-language-server and chplcheck.

In the Codespace, compile Chapel programs using the Terminal tab by using the chpl compiler:

chpl 01-hello.chpl
./01-hello

Although the Codespace is set to a single-locale (single-node) mode by default, you can simulate multiple nodes by setting the CHPL_COMM environment variable to gasnet when compiling.

# Compile a program that distributes computation to multiple nodes
CHPL_COMM=gasnet chpl 01-hellopar.chpl

# Run hello using two simulated nodes
./01-hellopar -nl 2

To avoid having to include CHPL_COMM in each compilation command, you can export it:

export CHPL_COMM=gasnet
chpl 01-hellopar.chpl
./01-hellopar -nl 2

Using Docker

Install Docker (see the Installing Docker section below for suggestions). Then, use the following command:

docker pull docker.io/chapel/chapel-gasnet

Next follow the instructions at https://hub.docker.com/r/chapel/chapel to compile a hello world in Chapel, but use the chapel-gasnet container and when you run the “hello” executable specify -nl 1. Here are the commands to use:

echo 'writeln("Hello, world!");' > hello.chpl

docker run --rm -it -v "$PWD":/myapp -w /myapp chapel/chapel-gasnet /bin/bash

root@xxxxxxxxx:/myapp# chpl hello.chpl
root@xxxxxxxxx:/myapp# ./hello -nl 1
Hello, world!

Building Chapel from Source on Your Machine

Please follow the instructions on the Download Chapel page to build the Chapel compiler and runtime from source and get set up with the Chapel compiler executable chpl. From there, you can compile and run the 01-hello.chpl file in this repository as follows:

chpl 01-hello.chpl
./01-hello

To make use of multiple nodes (or to simulate multi-node execution), please refer to Multilocale Chapel Execution.

Installing Docker

Mac

Download the docker desktop for Intel or Arm as appropriate from https://docs.docker.com/get-docker/.

Start up docker desktop. You do not need a docker account.

Linux

  • First three steps on https://docs.docker.com/engine/install/ubuntu/

    1. Set up Docker's Apt repository.
      # Add Docker's official GPG key:
      sudo apt-get update
      sudo apt-get install ca-certificates curl gnupg
      sudo install -m 0755 -d /etc/apt/keyrings
      curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
      sudo chmod a+r /etc/apt/keyrings/docker.gpg
    
      # Add the repository to Apt sources:
      echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg]   https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
      sudo apt-get update
    
    1. Install the Docker packages.
      sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
    1. Verify that the Docker Engine installation is successful by running the hello-world image.
      sudo docker run hello-world
    
  • Additional steps

      sudo groupadd docker
      sudo usermod -aG docker ${USER}
    
      # maybe not necessary
      sudo chmod 666 /var/run/docker.sock
    
    

Windows

  1. download docker for windows from: https://docs.docker.com/desktop/install/windows-install/ a. when promted to log in or create an account, select continue without logging in

  2. open a Powershell terminal (preferably as admin) a. if you don't have WSL installed, execute wsl --install b. next, ensure that your Ubuntu distro is using WSL2 (rather than WSL1). Execute wsl -l -v and ensure that ubuntu says 2 under version. i. If it is on version 1, execute wsl --set-version ubuntu 2 (may take some time)

  3. open the docker desktop app to start the docker daemon a. you can check that docker is using WSL Ubuntu by going to Settings > Resources > WSL Integration

  4. in Powershell, execute docker pull chapel/chapel-gasnet

NOTE: For Windows you will probably have to replace the $PWD from the instructions at https://hub.docker.com/r/chapel/chapel with the Windows version of the current path written out