Difference between revisions of "GPU621/The Chapel Programming Language"

From CDOT Wiki
Jump to: navigation, search
m (Keywords)
(Keywords)
Line 35: Line 35:
 
==== Keywords ====
 
==== Keywords ====
  
'''var''': variable declarations, requires a type or initializer.
+
The variable declaration requires a type or initializer.
 +
 
 +
'''var''': variable declarations.
  
 
'''const''': runtime constants and compile-time constants. Must be initialized.
 
'''const''': runtime constants and compile-time constants. Must be initialized.

Revision as of 13:55, 20 November 2020

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

  1. Xi Weng
  2. Ivan Huang
  3. Yu Li
  4. eMail All

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:

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

Keywords

The variable declaration requires a type or initializer.

var: variable declarations.

const: runtime constants and compile-time constants. Must be initialized.

param: runtime constants and compile-time constants. Must be known at compile time.

   var myVar1: real;
   const myVar2: real = sqrt(myVar1);
   param myVar3 = 3.14;

config: used before var, const, param keywords to allow overridden on the command line.

   config var myVar4: bool = false; //./variable --myVariable=true

Procedures:

A procedure is like a function in C++ that can be used or called inside the program.

   proc plus(x: int) : int
   {
     return 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 and use new keyword to create its instace.

   class myClass {
     var a, b: int;
     proc print() {
       writeln("a = ", a, " b = ", b);
     }
   }
   var foo = new myClass(0, 1);
   foo.print();

Records:

Records are similar to classes. Records doesn't support inheritance and virtual dispatch but it supports copy constructor and copy assignment. And record variables refer to a distinct memory.

Iterators

Iterators are declared like procedure in Chapel. Unlike processes, iterators typically return a sequence of values.

We declared the yield statement inside the iterator bodies, it returns a value and suspends the execution.

   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