©2019 Cray Inc.
[Scope]
Chapel is a new parallel programming language that is under development at Cray Inc. in the context of the DARPA High Productivity Computing Systems initiative.
/* compile with ldc2 a.d */ | |
module a; | |
import std.stdio; | |
@safe | |
int main() | |
{ | |
int[] array; | |
array.length = 7; |
record R { | |
var x: int; | |
proc deinit() { | |
writeln("Destroying ", x); | |
} | |
} | |
proc foo() { | |
var count = 0; |
var sum: int; | |
for i in vectorizeOnly(1..n) { | |
sum += i; // is sum "order independent" ? Is there a loop-carried dependency to respect? | |
// say it turns in to | |
// %1 = load %sum | |
// %2 = add %1, i | |
// store %2, %sum | |
// would it be wrong to assert there is no loop-carried dependency? | |
} |
#include <stdio.h> | |
void setit(int* ptr) { | |
*ptr = 200; | |
} | |
void f(int x) { | |
printf("%i\n", x); | |
} |
proc bar() { | |
writeln("in bar"); | |
} | |
module Bug { | |
proc foo() { | |
writeln("in foo"); | |
} | |
} |
proc testOnBegin() { | |
sync { | |
on Locales[numLocales-1] do begin { | |
writeln("HERE"); | |
} | |
} | |
} | |
testOnBegin(); |
class Fighter { | |
var subclass:string; | |
var level:int; | |
} | |
var mem = openmem(); | |
var writer = mem.writer().write('{"subclass":"ninja", "level":3}'); | |
var reader = mem.reader(); | |
// This works |
module OtherMSBRadix { | |
use Shell; | |
use Time; | |
/* Sorting criterion has a method: | |
(key:uint,done:bool) = criterion.keyBits(record, startbit) | |
(cmp=-1,0,1,nsamebits) = criterion.prefixCompare(recordA, recordB) | |
cmp=-1,0,1 = criterion.compare(recordA, recordB) |
// shows program modified to avoid array views in inner loops | |
class AbstractKernel { | |
// assumes x[xfirst, ..] and y[yfirst, ..] have shape 1..p | |
proc kernel(x, xfirst: int, y: [?D] ?T, yfirst: int, p: int): T | |
{ | |
return x[xfirst, 0]; // out of bounds (intentionally?) | |
} | |
} |