The Chapel Programming Language (original) (raw)
Productive parallel computing at every scale.
writeln("Hello, world!");
// create a parallel task per processor core
coforall tid in 0..<here.maxTaskPar do
writeln("Hello from task ", tid);
// print these 1,000 messages in parallel using all cores
forall i in 1..1000 do
writeln("Hello from iteration ", i);
// print a message per compute node
coforall loc in Locales do
on loc do
writeln("Hello from locale ", loc.id);
// print a message per core per compute node
coforall loc in Locales do
on loc do
coforall tid in 0..<here.maxTaskPar do
writeln("Hello from task ", tid, " on locale ", loc.id);
// print 1,000 messages in parallel using all nodes and cores
use BlockDist;
const Inds = blockDist.createDomain(1..1000);
forall i in Inds do
writeln("Hello from iteration ", i, " running on locale ", here.id);
use IO;
// read in a file containing 'city name;temperature' lines (1BRC-style)
const stats = [line in stdin.lines()] new cityTemperature(line);
writeln(stats);
record cityTemperature {
const city: string; // city name
const temp: real; // temperature
proc init(str: string) {
const words = str.split(";");
this.city = words[0];
this.temp = words[1]: real;
}
}
// set different values at runtime with command line arguments
// e.g. --n=2048 --numSteps=256 --alpha=0.8
config const n = 1000,
numSteps = 100,
alpha = 1.0;
const fullDomain = {1..n},
interior = {2..n-1};
var u: [fullDomain] real = 1.0;
u[n/4..3*n/4] = 2.0; // make the middle a bit hotter
var un = u;
for 1..numSteps {
forall i in interior do // shared-memory parallelism
u[i] = un[i] + alpha * (un[i-1] - 2*un[i] + un[i+1]);
un <=> u; // swap the two arrays
}
writeln(un);
use Random, Math;
const nGpus = here.gpus.size,
n = Locales.size*nGpus;
var A: [1..n, 1..n] real;
fillRandom(A);
// use all nodes
coforall (loc, localRowStart) in zip(Locales, 1.. by nGpus) do on loc {
// and all GPUs within each
coforall (gpu, row) in zip(here.gpus, localRowStart..) do on gpu {
var B: [1..n] real = A[row, ..]; // copy a row from device to host
B = asin(B); // compute (kernel launch)
A[row, ..] = B; // copy the row back
}
}
writeln(A);
Users Love It
“
The use of Chapel worked as intended: the code maintenance is very much reduced, and its readability is astonishing. This enables undergraduate students to contribute to its development, something almost impossible to think of when using very complex software.
”
- Éric Laurendeau, Professor, Polytechnique Montréal
“
A lot of the nitty gritty is hidden from you until you need to know it. ... It feels like the complexity grows as you get more comfortable -- rather than being hit with everything at once.
”
- Tess Hayes, Developer, Bytoa
Chapel in Production
CHAMPS
World-class multiphysics simulation
Written by students and post-docs in Eric Laurendeau's lab at Polytechnique Montreal. Outperformed its C/OpenMP predecessor using far fewer lines of code. Dramatically accelerated the progress of grad students while also supporting contributions from undergrads for the first time.
Arkouda
Interactive data science at massive scale
Familiar Python/Jupyter client interface, powered by a Chapel server that scales to compute and memory resources beyond any comparable tool. Interactively work with dozens of TBs of data.
Coral Reef Biodiversity Analysis
Processing oceans of data
The Coral Reef Alliance uses Chapel to analyze satellite imagery of the Mesoamerican Barrier Reef System, providing biodiversity measurements 5 orders of magnitude faster than the previous solution.
ChOp
Exact optimization algorithms at scale
Chapel-based Optimization (ChOp) solves combinatorial optimization problems. It leverages CPU-GPU heterogeneity with high productivity and parallel performance.
ChplUltra
Ultralight dark matter simulation
Simulates the astrophysical dynamics of ultra-light dark matter using Chapel's productivity features to compute distributed FFTs. Scales to hundreds of nodes.
What’s New?
Transformers From Scratch in Chapel and C++, Part 2
By Thitrin Sastarasadhit on December 12, 2025
Comparison of transformers in Chapel, C++, and PyTorch focusing on multi-threaded CPUs
Reflections on ChapelCon '25
By Brandon Neth on December 5, 2025
A retrospective on ChapelCon ‘25 from general chair Brandon Neth
Chapel joins HPSF!
Chapel is now an official project of the High Performance Software Foundation / Linux Foundation
Quarterly Newsletter - November 2025
on November 13, 2025
A new quarterly newsletter is now available, covering SC25 events, updates from various talks, and more
10 Myths About Scalable Parallel Programming Languages (Redux), Part 8: Striving Toward Adoptability
By Brad Chamberlain on November 12, 2025
The eighth and final archival post from the 2012 IEEE TCSC blog series, with a current reflection on it
Chapel Featured on 'Technology Now' Podcast
on October 30, 2025
This week's 'Technology Now' podcast features a conversation about Chapel with Brad Chamberlain