How to Install and Use Chapel Programming Language on Ubuntu 20.04 LTS


In this article, I will take you through the steps to install and use chapel programming language on Ubuntu 20.04 LTS. According to Chapel Official Documentation, It is a programming language designed for productive parallel computing on large-scale systems. It is designed as an imperative block-structured language so that it will be easy to learn for users of Python, C, C++, Fortran, Java, Matlab, and the like. Chapel is being developed in an open-source manner at GitHub under the Apache v2.0 license. Chapel can be easily run on devices like Desktops, Laptops, clusters, cloud in addition to the high end devices like Supercomputers.

Features of Chapel Programming Language

  • It supports Multithreaded execution model.
  • It supports global-view data aggregates with user-defined implementations.
  • It supports code reuse and rapid prototyping via object-oriented design, type inference, and features for generic programming.
  • Any of the existing code can be easily integrated with the Chapel programs via interoperability features.

How to Install and Use Chapel Programming Language on Ubuntu 20.04 LTS

How to Install and Use Chapel Programming Language on Ubuntu 20.04 LTS

Also Read: How to Install Reveal.js on Ubuntu 20.04 LTS [Easy Steps]

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt, tar and curl utility installed in Your Server.


Step 2: Update Your Server

Before installing any new package, you need to first update your Server by using apt update command. This will update all the installed packages with the latest available versions.

root@localhost:~# apt update
Hit:1 focal InRelease
Get:2 focal-updates InRelease [114 kB]
Get:3 focal-backports InRelease [101 kB]
Hit:4 focal InRelease
Hit:5 focal-pgdg InRelease
Hit:6 focal InRelease
Hit:7 stable InRelease
Get:8 focal-security InRelease [114 kB]
Hit:9 stable InRelease
Hit:10 focal InRelease
Get:11 focal-updates/main amd64 Packages [1,302 kB]
Get:12 focal-updates/main i386 Packages [553 kB]
Get:13 focal-updates/main amd64 DEP-11 Metadata [284 kB]


Step 3: Install Dependencies

Before installing chapel, you need to have all the dependencies installed in your Server. You can use apt package manager to install all the required dependencies as shown below.

root@localhost:~# apt install gcc g++ m4 perl python3 python3-pip python3-venv python3-dev bash make mawk git pkg-config cmake llvm-11-dev llvm-11 llvm-11-tools clang-11 libclang-11-dev libedit-dev


Step 4: Download Chapel Source File

You can go to Chapel Download Page and download the latest source file using wget or curl utility. Here I am using curl utility to download the chapel source file. Below curl command will download the source file into local directory path.

root@localhost:~# curl -L -o chapel-1.25.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 626 100 626 0 0 4287 0 --:--:-- --:--:-- --:--:-- 4317
100 82.0M 100 82.0M 0 0 15.6M 0 0:00:05 0:00:05 --:--:-- 16.9M

Once downloaded you can also verify the size of file by using du -sh chapel-1.25.0.tar.gz command.

root@localhost:~# du -sh chapel-1.25.0.tar.gz
83M chapel-1.25.0.tar.gz


Step 5: Extract Source Release 

Then unpack the downloaded source release using tar -xzf chapel-1.25.0.tar.gz command as shown below. This will extract the files in the present directory location.

root@localhost:~# tar -xzf chapel-1.25.0.tar.gz


Step 6: Setup Your Environment

You now need to go to chapel directory using cd chapel-1.25.0 command and then configure the environment using source util/quickstart/setchplenv.bash command as shown below.

root@localhost:~# cd chapel-1.25.0
root@localhost:~/chapel-1.25.0# source util/quickstart/setchplenv.bash
Setting CHPL_HOME to /root/chapel-1.25.0
Updating PATH to include /root/chapel-1.25.0/bin/linux64-x86_64
and /root/chapel-1.25.0/util
Updating MANPATH to include /root/chapel-1.25.0/man
Setting CHPL_COMM to none
Setting CHPL_TASKS to fifo
Setting CHPL_MEM to cstdlib
Setting CHPL_GMP to none
Setting CHPL_RE2 to none
Setting CHPL_LLVM to none


Step 7: Build Chapel

Finally, build the Chapel using GNU make command. This will take targets as arguments from Makefile available in the current directory and then start running the actions associated with it.

root@localhost:~/chapel-1.25.0# make
Making the compiler...
rm -rf /root/chapel-1.25.0/third-party/llvm/install/none
cd llvm && make
make[3]: Nothing to be done for 'default'.
mkdir -p ../build/compiler/linux64/gnu/x86_64/llvm-none/none
echo > /root/chapel-1.25.0/configured-prefix
Updating ./../build/compiler/linux64/gnu/x86_64/llvm-none/none/CONFIGURED_PREFIX from ./../build/compiler/linux64/gnu/x86_64/llvm-none/none/CONFIGURED_PREFIX.incoming
Updating ./../build/compiler/linux64/gnu/x86_64/llvm-none/none/CLANG_SETTINGS from ./../build/compiler/linux64/gnu/x86_64/llvm-none/none/CLANG_SETTINGS.incoming
***** adt/ *****
making ../../build/compiler/linux64/gnu/x86_64/llvm-none/none/adt subdirectory to store platform-specific files
g++ -c -MMD -MP -O3 -I. -I../include/linux64 -I../include -I../../build/compiler/linux64/gnu/x86_64/llvm-none/none -I../../runtime/include/encoding -I/root/chapel-1.25.0/third-party/utf8-decoder -I../next/include -DCOMPILER_SUBDIR=adt -o ../../build/compiler/linux64/gnu/x86_64/llvm-none/none/adt/bitVec.o bitVec.cpp
g++ -c -MMD -MP -O3 -I. -I../include/linux64 -I../include -I../../build/compiler/linux64/gnu/x86_64/llvm-none/none -I../../runtime/include/encoding -I/root/chapel-1.25.0/third-party/utf8-decoder -I../next/include -DCOMPILER_SUBDIR=adt -o ../../build/compiler/linux64/gnu/x86_64/llvm-none/none/adt/vec.o vec.cpp


Step 8: Write Your First Chapel Program

Now that chapel has been installed successfully, it is now time to write your first chapel program. Here I am writing and showing a sample example.chpl program using our favorite nano editor. This will only print "Hi, This is from CyberITHub" on the output.

root@localhost:~/chapel-1.25.0# nano example.chpl
writeln("Hi, This is from CyberITHub!");

Compile Your Program

root@localhost:~/chapel-1.25.0# chpl -o example example.chpl


root@localhost:~/chapel-1.25.0# ./example
Hi, This is from CyberITHub!

Leave a Comment