Difference between revisions of "GPU621/Chapel"

From CDOT Wiki
Jump to: navigation, search
(Variables)
Line 14: Line 14:
 
       var myVariable1: int;
 
       var myVariable1: int;
 
       writeln("myVariable1 = ", myVariable1);
 
       writeln("myVariable1 = ", myVariable1);
 +
 +
const and param can be used to declare runtime constants and compile-time constants respectively. A const must be initialized in place, but can have its value generated at runtime. A param must be known at compile time.
 +
 +
      const myConst: real = sqrt(myVariable2);
 +
      param myParam = 3.14;
 +
      writeln("myConst = ", myConst, ", myParam = ", myParam);
  
 
= Reference =
 
= Reference =

Revision as of 22:55, 29 November 2022

Introduction

The Chapel is an open-source programming language designed for productive parallel computing at scale. The Chapel compiler is written in C and C++14. The backend is LLVM, written in C++. The goal of Chapel is to improve the programmability of parallel computers in general.

Installation

Basic

Variables

Variables are declared with the var keyword. Variable declarations must have a type, initializer, or both.

     var myVariable1: int;
     writeln("myVariable1 = ", myVariable1);

const and param can be used to declare runtime constants and compile-time constants respectively. A const must be initialized in place, but can have its value generated at runtime. A param must be known at compile time.

     const myConst: real = sqrt(myVariable2);
     param myParam = 3.14;
     writeln("myConst = ", myConst, ", myParam = ", myParam);

Reference