The Chapel Programming Language

Website Developer
7 min readOct 26, 2021

Chapel, or Cascade High Productivity Language, is a recently developed programming language by Cray inc. Chapel was created with a specific goal to make parallel programming at a scale far more productive. Additionally, Chapel was designed to bridge the gaps between programmers who were experienced with newer languages like python and those who had forte in older HPC languages, such as Fortran. Lastly, Chapel sought to include more externalities inside its base library to reduce the amount of imported code used. These features combined help Chapel pose itself as a great language to break into HPC with.

https://www.answersjet.com/2021/08/chapel-programming-language-history-features-applications-why-should-learn-chapel-lang.html

Creation of Chapel

Brad Chamberlain conceptualized Chapel. It arose as part of Cray, Inc.‘s participation in a High Productivity Computing Systems(HPCS) program, sponsored by the Defense Advanced Research Projects Agency(DARPA). First released in 2009, it would be a further six years before Cray, Inc. would recommend building projects with the language. This was due to a lack of support of libraries in the language and Cray’s sentiment that the language was not fully developed yet in functionality. This changed in 2015 when Cray finally began to recommend using Chapel. Currently, the most recent release was on April 15th, 2021.

When Brad and his team created Chapel, they had an essential goal of drawing in 3 different types of programmers together. They wanted a language that aimed to be as “ programmable as python, fast as FORTRAN, scalable as MPI, SHMEM or UPC, as portable as C, flexible as C++, and as fun as your favorite language.” After interviewing many recent graduates, HPC programmers, and computational scientists, Brad created a language that solved all problems. In his words, he wanted “ Something that lets computational scientists express what they want, without taking away the control that HPC programmers want, implemented in a language as attractive as recent graduates want.”

New languages in coding are a challenging prospect. These days, almost anyone can create a coding language if they have the required skills. Getting developers to choose one language over another marks a challenge in both the language’s strengths in addition to the language’s current popularity. According to Kathy Yelick, new languages should be considered to make powerful syntax, semantics, performance, and algorithm improvements. Chapel aims to solve syntax by integrating previously unimplemented features pulled from libraries into its core functionality. Because the language has been written from the ground up, Chapel has unique ways of implementing features, making the semantics of arguments much easier to read. Finally, Chapel makes a significant stride in its performance, making it an optimal choice for HPC programming.

Features of the Chapel Language

Base language

The base language features in Chapel were made with the intent of giving complete control to the programmer. This manifests itself in the language by allowing more extensive parameters within Chapel’s base functions to maintain readability. Defining a variable can be done quickly by simply stating the variable name and assigning it, such as python. But, Chapel gives the user more control if they use the optional parameters in its base language.

Here is an example of a Python variable assignment and a Chapel variable assignment:

Python:

n = 10

Chapel assignments:

n = 10

const n = 10

config const n = 10

In the above example, Chapel gives programmers who enjoy readability and cleanliness in their code while also having options for more defined functionality. The ability to add const in a variable definition prevents that variable from being retyped into something else. This would prevent a string from being retyped into an integer. The third option, config, is inherent to Chapel and is similar to sysargs function in python.

By defining the n variable with config, the programmer can include a changed parameter when running a program from the command line. While this functionality is possible in python currently, it can be quite cumbersome to use as the command line does not reference the manipulated variables by name. The ability to refer by name to a variable is just one small use case where the inherent features of chapel help facilitate significant productivity improvements.

Libraries can be created to be accessed by scripts written in other languages. During his interview with HPCNow, Brad gives an example of the programming talent that a company had available that was only familiar with python programming. Still, they needed to solve HPC or High-Performance Computing in scale, which python struggles with. The company was able to develop Python libraries implemented in Chapel. This resulted in better performance than python alone or python-with-c in addition to better scalability.

Iterators

Another exciting feature of Chapel is its Iterators. Most languages have a way of iterating through specific data types and accessing the contents. The function returns with a data type and hands it off to whatever is called it. There are additional ways of “returning” information to the function call in Chapel, one of them being a “Yield.” The “Yield” allowed a function to return a piece of information to its call and then additionally keep running and returning additional data.

Iteration through data tables is taxing, both on the programmer and the machines used to compute. Chapel aims to use new features unique to its suite of options to help alleviate this. One of these features is the for a loop. Brad Chamberlain used the following example during his presentation at CHIUW 2020:

Link to Code

In the above example, making updates to a table involved over three pages of code and three different programming languages. The programs start the same, with a simple for-loop that makes updates. But the MPI program is not to scale and needs an additional three pages of code to work at high volumes properly. Chapel’s unique architecture allows it to match the equivalent output at a mere fraction of the code base investment. Additionally, Brad further shows that with its significant improvement in cleanliness comes a massive increase in productivity. When compared in performance, Chapel was a considerable increase, as it scaled exponentially instead of linearly.

Domain Mapping

As it focuses on improved processing in addition to the advances it makes in syntax. Chapel heavily utilizes domain mapping. When a computer is executing tasks, these tasks are sent to its cores. In Chapel, the “Dmapped” functionality allows the programmer to assign how assignments are given to processing cores specifically. In his example, Brad showed different variations of the parameters used in tandem with the “Dmapped” functionality to assign cores optimally.

Mainstream Usage

One of the main obstacles that Chapel has yet to overcome is mainstream usage. While it seems like a perfect go-to for students looking into the HPC world, it finds itself lacking users. In 2018, Chamberlain gave the example of a professor who wouldn’t allow his class to do a project in Chapel, as he feared the language might not gain traction. At the time in 2018, only one major project, Arkouda, was using Chapel. Since then, five more companies have signed on with Chapel. Due to its focus on efficient HPC, early adopters of Chapel are centered around the recreations of mathematical models.

Arkouda

In 2018 Arkouda made waves by becoming the first open-source project to be developed using Chapel. Chapel made the perfect choice for its debut with its focus on Numpy and computing at massive scales. The Department of Defense is now using Arkouda for its ability to manage large sets of data.

CHAMPS

Champs, or Chapel Multi-physics simulations, is being developed by Eric Laurendeau at Polytechnique Montréal, Canada. Champs is software used in the mapping of fluid dynamics. It is written entirely in Chapel. The software handles 2d and 3d grids to solve equations. They seek to expand functionality with future developments, with aerodynamics, aero-elasticity, and aero-icing on the horizon.

CHGL: Chapel Hypergraph Library

In 2019 Chapel again broke onto the scene with CHGL. CHGL is a library for hypergraph computation. It is being developed under Jesun Firoz, Cliff Joslyn, and Mark Raugas. A hypergraph is defined as a graph in which an edge can join any number of vertices. Compared to normal graphs, hypergraphs can be highly complex and merge various forms of data — Hypergraphs capture large-volume, multi-dimensional interactions between multiple entities that are not directly expressible in graphs. CHGL serves to take these graphs and boil them down to high-level abstractions with modern language support.

ChOp

ChOp, or Chapel-based Optimization, is a project developed in tandem under Tiago Carneiro, Nouredine Melab, Jan Gmys, Daniel Tuyttens, El-Ghazali Talbi. Working from 2 different locations in France in addition to the University of Mons, Belgium. The ChOp project aims to solve sizeable combinatorial optimization problems while still accounting for productivity and parallel efficiency. Its main application is solving permutation-based combinatorial problems.

ChplUltra

ChplUltra was started in 2019 by Nikhil Padmanabhan, J. Luna Zagorac, and Richard Easther at Yale University. ChplUltra is designed to “simulate the dynamics of ultra-light dark matter for astrophysics.” The code uses a Chapel to rapidly scale the code when necessary, up to 512 different computation nodes at once. This is over 18 thousand cores!

Takeaway

Chapel is perfectly poised to breathe new life into the HPC scene with its expansive feature toolset and ease of readability. Its features to promote efficiency and scaling have created an atmosphere where physics can be mathematically challenged computationally. Recent developments have shown it has the capabilities to back the HPC claims it makes. But it must quickly find a more robust user base or risk falling by the wayside entirely.

--

--