Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
462 changes: 462 additions & 0 deletions chpl-src/announcing-chapel-2.7.chpl

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions chpl-src/announcing-chapel-2.7.execopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--print=false
Empty file.
92 changes: 92 additions & 0 deletions content/posts/announcing-chapel-2.7/code/Print.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
use Types;
use CTypes;

extern {
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdbool.h>

void printMyChar(int8_t x);
void printMyInt64(int64_t x);
void printMyUint64(uint64_t x);
void printMyReal64(double x);
void printMyBool(bool x);
void printStr(const char* str);

void printMyInt64(int64_t x) {
printf("%" PRId64, x);
}

void printMyUint64(uint64_t x) {
printf("%" PRIu64, x);
}

void printMyReal64(double x) {
printf("%lf", x);
}

void printMyChar(int8_t x) {
printf("%c", x);
}

void printMyBool(bool x) {
if (x) {
printf("true");
} else {
printf("false");
}
}

void printStr(const char* str) {
printf("%s", str);
}
}

extern proc printMyChar(x: real(64));
extern proc printMyInt64(x: int(64));
extern proc printMyUint64(x: uint(64));
extern proc printMyReal64(x: real(64));
extern proc printMyBool(x: bool);
extern proc printStr(str: c_ptrConst(c_char));

proc doPrintSpace() do printMyChar(32);
proc doPrintNewline() do printMyChar(10);

proc print(x: ?t) {
if t == bool {
printMyBool(x);
} else if isIntType(t) {
printMyInt64(x);
} else if isUintType(t) {
printMyUint64(x);
} else if isRealType(t) {
printMyReal64(x);
} else if t == string {
printStr(x.c_str());
} else if t == c_ptrConst(c_char) {
printStr(x);
} else if isTupleType(t) {
// TODO: Param loop this...
// TODO: Move this to 'print'...
if x.size >= 1 then print(x[0]);
if x.size >= 2 { doPrintSpace(); print(x[1]); }
if x.size >= 3 { doPrintSpace(); print(x[2]); }
if x.size >= 4 { doPrintSpace(); print(x[3]); }
if x.size >= 5 { doPrintSpace(); print(x[4]); }
if x.size >= 6 { doPrintSpace(); print(x[5]); }
if x.size >= 7 { doPrintSpace(); print(x[6]); }
if x.size >= 8 { doPrintSpace(); print(x[7]); }
if x.size >= 9 { doPrintSpace(); print(x[8]); }
} else if isEnumType(t) {
var temp : int = chpl__enumToOrder(x);
printMyInt64(temp);
} else {
// TODO: 'halt()'
}
}

proc println(x) {
print(x);
doPrintNewline();
}
1 change: 1 addition & 0 deletions content/posts/announcing-chapel-2.7/code/Print.notest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a helper module
14 changes: 14 additions & 0 deletions content/posts/announcing-chapel-2.7/code/array-formals.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
proc foo(A: [?D] ?t) param {
param isRect =
if A.isDefaultRectangular() then "rectangular" else "not rectangular";
param eltType = A.eltType:string;
param dim = D.rank:string;
return isRect + " " + dim + "-dimensional array of " + eltType;
}

use BlockDist;
var A: [1..10] int;
var B = blockDist.createArray(1..10, 1..10, real);

param infoA = foo(A);
param infoB = foo(B);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--dyno-resolve-only
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dyno resolve-only test
5 changes: 5 additions & 0 deletions content/posts/announcing-chapel-2.7/code/casts.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum color { red = 1, green, blue }

var myTup = (42, "hello");
var castTup = myTup : (real, int);
param redBytes = color.red : bytes;
1 change: 1 addition & 0 deletions content/posts/announcing-chapel-2.7/code/casts.compopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--dyno-resolve-only
Empty file.
1 change: 1 addition & 0 deletions content/posts/announcing-chapel-2.7/code/casts.noexec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dyno resolve-only test
32 changes: 32 additions & 0 deletions content/posts/announcing-chapel-2.7/code/converter.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use IO;
use Print; // helper module while we work toward resolving more of IO

// utilize generic varargs and param for-loops to mimic 'writeln' behavior
proc myWriteln(const args...?n) {
for param i in 0..<n {
print(args(i));
}
println("");
}

// return a tuple from a procedure
proc double(arg: int) {
return (arg, arg*2);
}

proc main() {
// uses generic varargs and a param for-loop to mimic 'writeln' behavior
myWriteln(1, " != ", 2.0);

// grouped variable initialization, unpacking the result of 'double'
var (a, b) = double(5);
myWriteln("a = ", a, ", b = ", b);

// Open 'stdout' and use the IO module to write a string!
//
// Utilizes shared objects, ranges, generic types, enums, interoperability,
// and a great deal of string manipulating-module code.
var s = new file(chpl_cstdout());
var w = s.writer();
w.writeLiteral("Hello, World!\n");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--dyno --verify --no-checks --local
3 changes: 3 additions & 0 deletions content/posts/announcing-chapel-2.7/code/converter.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1 != 2.000000
a = 5, b = 10
Hello, World!
1 change: 1 addition & 0 deletions content/posts/announcing-chapel-2.7/code/converter.skipif
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHPL_LLVM==none
12 changes: 12 additions & 0 deletions content/posts/announcing-chapel-2.7/code/debug.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use Debugger;

proc main() {
on Locales[1] {
var myArr = [i in 1..10] i;
breakpoint;
on Locales[0] {
writeln(myArr);
breakpoint;
}
}
}
1 change: 1 addition & 0 deletions content/posts/announcing-chapel-2.7/code/debug.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 2 3 4 5 6 7 8 9 10
1 change: 1 addition & 0 deletions content/posts/announcing-chapel-2.7/code/debug.numlocales
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
1 change: 1 addition & 0 deletions content/posts/announcing-chapel-2.7/code/debug.skipif
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHPL_COMM==none
17 changes: 17 additions & 0 deletions content/posts/announcing-chapel-2.7/code/outOfBounds.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
proc main() {
var arr = [i in -9..9] i,
s1 = sliceToString(arr, -5..#6),
s2 = sliceToString(arr, 0.. by 2 # 6),
s3 = sliceToString(arr, 5..#5 by -1);
writeln("Slice 1: ", s1);
writeln("Slice 2: ", s2);
writeln("Slice 3: ", s3);
}

proc sliceToString(arr, slice) {
var s: string;
for i in slice {
s += arr[i]:string + " ";
}
return s.strip();
}
2 changes: 2 additions & 0 deletions content/posts/announcing-chapel-2.7/code/outOfBounds.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
outOfBounds.chpl:14: error: halt reached - array index out of bounds
note: index was 10 but array bounds are -9..9
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion content/posts/transformer-part1/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
title: "Transformers From Scratch in Chapel and C++, Part 1"
date: 2025-11-20
tags: ["User Experiences", "Language Comparison", "Performance", "Benchmarks"]
tags: ["User Experiences", "Language Comparison", "Vectorization", "Performance", "Benchmarks"]
summary: "An implementation of a transformer using Chapel, comparing to C++ and PyTorch"
authors: ["Thitrin Sastarasadhit"]
series: ["Transformers From Scratch in Chapel and C++"]
Expand Down