GPU621/The Chapel Programming Language
Contents
Project Description
The Chapel is a portable, scalable, open-source modern parallel programming language designed to be productive. The Chapel is a high-level programming language that tends to be more human-readable and writable with some similarity to Python. The Chapel's performance can compete or even surpass MPI/OpenMP. This project will introduce the main functionality of Chapel programming language, compare the code and performance to C++ MPI/OpenMP, analysis the pros and cons of the Chapel.
Team Members
Installation
The Chapel is an open-source language that still constantly updates. The latest version as of the creation of this project is 1.23.0 released on October 15, 2020.
There is currently no official support for The Chapel Programming Language in major known IDE like Visual Studio, which is a downside compared to other languages in terms of usability.
Select one of the following options to install The Chapel Programming Language.
Pre-packaged Chapel installations are available for:
- Cray® XC™ systems
- Docker users (Requires to install Docker Engine, available on Linux, MAC, Windows 10)
- Mac OS X Homebrew users
GitHub source code download available here.
Users can also try The Chapel online here, though the version is currently stuck on Chapel 1.20.
The Chapel Programming Language
Main Functionality
//https://chapel-lang.org/docs/primers/
Language Basics
Variable:
Variables are declared by var keyword. Declarations require a type or initializer.
var myVar1: real;
We use const and param to declare runtime constants and compile-time constants. We can set a const variable's value at runtime. But param variable requires to set it at beginning.
const myConst: real = sqrt(myVar2); param myParam = 3.14;
We can use the config keyword to override the value on the command line.
config var myVar2: bool = false; //./variable --myVariable=true
Procedures:
A procedure is like a function in C++ that can be used or called inside the program.
proc factorial(x: int) : int { if x < 0 then halt("factorial -- Sorry, this is not the gamma procedure!"); return if x == 0 then 1 else x * factorial(x-1); }
Classes:
A class is a type of collection that collects variables, procedures and iterators. We use class keyword to declare a new class type.
class myClass { var a, b: int; proc print() { writeln("a = ", a, " b = ", b); } }
The new keyword creates an instance of a class by calling an initializer.
var foo = new myClass(0, 1); foo.print();
Records:
Records are similar to classes, but there are several important differences:
- classes support inheritance and virtual dispatch while records do not
- different class variables can refer to the same instance, while record variables refer to distinct memory
- copy-initialization and assignment can be implemented for records but not for classes.
Iterators
Chapel implements iterators using a function-like syntax, although the semantic behaviour of an iterator differs from that of a function in some important ways. Unlike functions, instead of returning a value, Chapel iterators typically return a sequence of values. The yield statement, legal only within iterator bodies, returns a value and temporarily suspends the execution of the code within the iterator.
iterator fibonacci(n): integer { var i1 = 0, i2 = 1; var i = 0; while i <= n { yield i1; var i3 = i1 + i2; i1 = i2; i2 = i3; i += 1; } }
Task Parallelism
Locality
Data Parallelism
Library Utilities
Numerical Libraries
Code Comparesion to MPI & OpenMP
Pros and Cons of Using The Chapel
Adoption
Small Number of Contributors
temp
References
- The Chapel Programming Language official page: https://chapel-lang.org/
- The Chapel Documentation: https://chapel-lang.org/docs/#
- Full-Length Chapel Tutorial: https://chapel-lang.org/tutorials.html
- Learn Chapel in Y Minutes: https://learnxinyminutes.com/docs/chapel/
- Specific Chapel Concepts or Features: https://chapel-lang.org/docs/primers/
- October 2018 Chapel Tutorial: https://chapel-lang.org/tmp/OctTut2018/slides.html
- The Chapel Promotional Video: https://youtu.be/2yye1yJPcsg
- The Chapel Overview Talk Video: https://youtu.be/ko11tLuchvg
- The Chapel Overview Talk Slide: https://chapel-lang.org/presentations/ChapelForHPCKM-presented.pdf