Using Chapel on Mac OS X
There are two main approaches for using Chapel on Mac OS X:
Install via Homebrew. For Homebrew users, this is the quickest way to get up and running, but it results in a copy of Chapel that only supports shared-memory (single-locale) executions.
Build Chapel from source, as with any other UNIX system. This is slightly more involved, but supports Chapel’s full feature set.
Homebrew
Chapel can be installed through Homebrew with the following commands:
brew update
brew install chapel
These commands install the latest release of Chapel. When using a
Homebrew installation of Chapel, the CHPL_HOME
directory can be found by
running the following command:
chpl --print-chpl-home
Compile and run a test program:
chpl `chpl --print-chpl-home`/examples/hello.chpl
./hello
If you’re new to Chapel, refer to the What’s Next? section of Chapel Quickstart Instructions for next steps.
Note
It is also possible for developers to use Homebrew to build and install a development version based on the main branch on GitHub:
brew install chapel --HEAD
Multi-locale Execution
The Homebrew installation of Chapel supports 2 different ways of running multi-locale programs on your shared memory machine:
Using the GASNet SMP conduit allows you to run multi-locale programs by partitioning the machine’s resources into multiple locales.
Compile and run a test program:
chpl --comm=gasnet --comm-substrate=smp \\ `chpl --print-chpl-home`/examples/hello6-taskpar-dist.chpl ./hello6-taskpar-dist -nl 4
Using the GASNNet UDP conduit allows you to run multi-locale programs by oversubscribing the machine’s resources.
Compile and run a test program:
chpl --comm=gasnet --comm-substrate=udp \\ `chpl --print-chpl-home`/examples/hello6-taskpar-dist.chpl chplrun-udp ./hello6-taskpar-dist -nl 4
Note
Note the usage of the
chplrun-udp
command to run the program. This is a necessary to setup the environment for the UDP conduit to properly launch the program locally through the network stack. You can also forgo thechplrun-udp
command and run the program directly, making sure to properly setup the environment. This will also allow you to launch jobs on multiple nodes across the network. See Using the Portable UDP Conduit for details.
For more information on the differences between these two modes, see When should I use CHPL_COMM_SUBSTRATE=udp vs CHPL_COMM_SUBSTRATE=smp?.
GPU Execution
The Homebrew installation of Chapel comes with a mode for emulating GPU execution. This allows you to test Chapel programs designed for a GPU, but it does not provide actual GPU support. If you are interested in compiling Chapel code for NVIDIA or AMD GPUs, see the GPU documentation.
Compile and run a test program:
chpl --locale-mode=gpu --gpu=cpu `chpl --print-chpl-home`/examples/gpu/hello-gpu.chpl
./hello-gpu
Warning
Chapel does not yet support GPU commutation with Apple GPUs. The above code will emulate GPU execution by treating the CPU as a GPU.
Building from Source
If you are not using the Homebrew package, it will be necessary to install a few development tools in order build Chapel. The instructions below show one way of getting a working development environment.
First, install XCode or the developer Command Line Tools. XCode can be installed from the App store. Or, you can install the developer Command Line Tools by opening a Terminal window and running:
xcode-select --install
Once this is done, open up a new Terminal window to verify that the
clang
and python3
programs can be found and have a suitable
version (see also Chapel Prerequisites) by running the following
commands:
clang --version
python3 --version
After this step, you should have a working C/C++ compiler, make
support,
and a working installation of Python 3.
Next, install CMake. Since XCode installation does not include CMake, and it’s required to build Chapel, it’s necessary to install it separately. You can install it using a source or binary release from the CMake website. At the time of this writing, the CMake binary release includes a graphical CMake.app but does not install the command-line tool. If you have CMake.app installed in your Applications folder, you can ask it to install the command-line tool with the following command:
sudo /Applications/CMake.app/Contents/bin/cmake-gui --install
Once this is done, open up a new Terminal window to verify that
cmake
is available and has a suitable version (see
Chapel Prerequisites):
cmake --version
From here, follow the main documentation for building from source at Chapel Quickstart Instructions.