Skip to content

Make integrated build #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f5583c5
Update to latest chapel frontend and use fetchcontent for easier depe…
SAtacker Feb 20, 2025
9df7035
Fix Chapel C++20 Compile issue
SAtacker Feb 21, 2025
44600c6
Fix new chapel frontend api
SAtacker Feb 25, 2025
3f3e6f8
Use builder result and check instead of post check
SAtacker Feb 25, 2025
b6399c3
Compile ChplX integrated build
SAtacker Mar 4, 2025
07d359f
Add a script for end to end running benchmarks
SAtacker Mar 22, 2025
7dc09e0
Make it detect the platform
SAtacker Mar 22, 2025
6a96b96
Add benchmarks directory
SAtacker Mar 22, 2025
bd1c3d2
Modify CMakeLists.txt to checkout the correct chapel commit
SAtacker Mar 22, 2025
ad4ed0a
Remove unnecessary scripts
SAtacker Mar 22, 2025
8dd3442
Add build-type option to benchmarks
SAtacker Mar 22, 2025
21f7d5e
Make git-version.cpp if it does not exist
SAtacker Mar 22, 2025
801b3e1
Remove trailing whitespace and fix git-version.cpp
SAtacker Mar 22, 2025
49b5fe1
Fix git-version.cpp not generated
SAtacker Mar 22, 2025
ce3888c
MF is not generating git-version.cpp
SAtacker Mar 22, 2025
1e22428
Add result variable to see what's happening with the command
SAtacker Mar 22, 2025
f9cc48d
Fix CHPL_HOME not set
SAtacker Mar 22, 2025
424bb25
Fix script for windows
SAtacker Mar 24, 2025
2430b00
Improve the script for windows
SAtacker Mar 25, 2025
69c1887
Fix backslash in format string issue
SAtacker Mar 25, 2025
4f25067
Add address sanitizer and ub sanitizer for Debug builds
SAtacker Mar 27, 2025
af7a8a6
Initialize ctx to nullptr
SAtacker Mar 27, 2025
b85da35
Fix domain node not visited when chapel frontend version 1.25+ is used
SAtacker Mar 30, 2025
00272b7
Add install target in backend and library
SAtacker Apr 1, 2025
777b8b9
Fix for indexing operator arguments parsed in reverse
SAtacker Apr 2, 2025
87782ed
Return references to avoid copies of intrusive_ptr
SAtacker Apr 9, 2025
50a8067
Adding specialization for Array<T, Domain<1>>
hkaiser Apr 11, 2025
c2e965d
Minor changes
hkaiser Apr 12, 2025
ccb4c75
Fixing compilation warning on Windows
hkaiser Apr 13, 2025
6cb8c06
Adding specializations for iteration of simple ranges, domains, and a…
hkaiser Apr 13, 2025
5717966
Adding specialization for Array<T, Domain<1>>
SAtacker May 2, 2025
b6f336a
Array specialization (#3)
hkaiser May 2, 2025
8cffdc2
Merge branch 'dev' into make_integrated_build
SAtacker May 2, 2025
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ frontend/include/chpl/config/config.h
frontend/lib/util/git-version.cpp
frontend/BUILD_VERSION
.vscode/**
build/**
**/build/**
3 changes: 3 additions & 0 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def get_parallel_build_flags(platform_name):
if platform_name == "Windows" and shutil.which("msbuild"):
return f"/m:{threads}"


if shutil.which("ninja"):
return f"-j{threads}"

Expand All @@ -138,6 +139,7 @@ def get_parallel_build_flags(platform_name):
return ""



def build_chplx_benchmarks(cxx_compiler_path, args):
# Find .chpl files in benchmarks directory
benchmarks_dir = os.path.join(args.source_path, "benchmarks", "chplx")
Expand Down Expand Up @@ -377,6 +379,7 @@ def main():
parser.add_argument("--cxx-path", type=str, help="Provide a cxx compiler path.")
parser.add_argument("--cc-path", type=str, help="Provide a c compiler path.")
parser.add_argument("--cmake-args", type=str, help="Provide a cxx compiler path.")

parser.add_argument(
"--cmake-args-chapel", type=str, help="Provide a cxx compiler path."
)
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## benchmarks

This directory contains chapel code supported by Chplx to benchmark
105 changes: 105 additions & 0 deletions benchmarks/gups.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
use Time;
use Math;
use CTypes;

extern proc getenv(name : c_string) : c_string;
extern "atoi" proc c_atoi(arg:c_ptrConst(c_char)):c_int;

proc computeProblemSize(numArrays : int, physicalMemoryBytes : int, memRatio : int, returnLog2 : bool) {
var totalMem = physicalMemoryBytes;
var memoryTarget = totalMem / memRatio;
var numBytesPerType : int = c_sizeof(int) : int;
var bytesPerIndex :int = numArrays * numBytesPerType;
var numIndices : int = memoryTarget / bytesPerIndex;

var lgProblemSize : int = ceil(log2(numIndices:real)) : int;

if (returnLog2) {
numIndices = 2**lgProblemSize;
if (numIndices * bytesPerIndex <= memoryTarget) {
numIndices *= 2;
lgProblemSize += 1;
}
}

return if returnLog2 then lgProblemSize else numIndices;
}

proc getNextRandom(x : int) : int {
var poly = 0x7;
var hirandbit = 0x1 << (64-1);
return (x << 1) ^ (if (x & hirandbit) then poly else 0);
}

proc computeM2Values(m2 : [] int, count : int) {
var nextval = 0x1;
for i in 0..count {
m2[i] = nextval;
nextval = getNextRandom(nextval);
nextval = getNextRandom(nextval);
}
}

proc getNthRandom(N : int, m2 : [] int, m2count :int) {
var ran = 0x2;
var i :int = ceil(log2(N)) : int;
var val = 0;
var J = 0;
for j in 0..i {
J = i-j;
for k in 1..m2count {
if ((ran >> (k-1)) & 1) then val ^= m2(k-1);
}
ran = val;
if ((N >> J) & 1) then getNextRandom(ran);
}
return ran;
}

proc RAStream(vals : [] int, numvals : int, m2 : [] int, m2count : int) {
var val = getNthRandom(2, m2, m2count);
for i in 0..numvals {
val = getNextRandom(val);
vals[i] = val;
}
}

param randWidth = 64;
param physicalMemory = 17179869184; //1024;
config var memRatio = 4;
var numTables = 1;

var m2 : [0..randWidth] int;
computeM2Values(m2, randWidth);

var SZ = 134217728;
var N_U = 0;
var n = 0;
n = computeProblemSize(numTables, physicalMemory, memRatio, false);
N_U = n+2;

var z = N_U;
var randval: [0..z] int;

var indexMask = z - 1;
var T : [0..SZ] int;

for i in 0..SZ {
T[i] = i;
}

var timer : stopwatch;

timer.start();
RAStream(randval, z, m2, randWidth);
forall r in 0..z {
T ( randval ( r ) & indexMask ) ^= randval(r);
}
timer.stop();
var elapsed = timer.elapsed();

var nprocs : real = c_atoi(getenv('CHPL_RT_NUM_THREADS_PER_LOCALE'.c_str())) : real;
var t0 = elapsed / nprocs;
var nupdates : real = z * (nprocs:int) * 1;
var gups : real = ( (nupdates :real) / ( t0 / 1.0e9) );
writeln(getenv('CHPL_RT_NUM_THREADS_PER_LOCALE'.c_str()):string,",", elapsed, ",", gups, ",", physicalMemory, ",", memRatio, ",", n);
71 changes: 71 additions & 0 deletions benchmarks/heat.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (c) 2023 AUTHORS
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Notes on running:
// (1) Use CHPL_RT_NUM_THREADS_PER_LOCALE to set the desired parallelism.
// (2) This program does not support positional args.
// (3) Use --nx=YYY to set the number of cells to YYY.
// (4) use --nt=YYY to set the number of time steps to YYY.
// CHPL_RT_NUM_THREADS_PER_LOCALE=6 ./heat --nx=10_000_000

//use Time;

//extern proc getenv(name : c_string) : c_string;
config const ghosts: int = 1;
config const k: real = 0.4;
config const dt: real = 1.0;
config const dx: real = 1.0;

config const nx: int = 1000000;
config const nt: int = 100;
//config const threads: int = 1;

proc update(d : []real, d2 : []real) {
const NX : int = nx + 1;
forall i in 1..NX-1 do {
//for i in 1..NX-1 do {
d2[i] = d[i] + dt*k/(dx*dx)*(d[i+1] + d[i-1] - 2*d[i]);
}
d2[0] = d2[NX-1];
d2[NX] = d2[1];
}

//proc main() {

//const NX : int = nx + 1;
const NX : int = nx - 1;

var data: [0..NX] real;
var data2: [0..NX] real;

forall i in 0..NX do {
data[i] = 1 + (i-1 + nx) % nx;
data2[i] = 0;
}

/*
var t: stopwatch;
t.start();
*/
inlinecxx("hpx::chrono::high_resolution_timer t;");

for t in 1..nt do {
update(data, data2);
// data <=> data2;
}

/*
t.stop();
if ( data.size < 20 ) {
writeln(data);
}
writeln("chapelng,",nx,",",nt,",",getenv('CHPL_RT_NUM_THREADS_PER_LOCALE'.c_str()):string,",",dt,",",dx,",",t.elapsed(),",0");
*/

inlinecxx("const auto elapsed = t.elapsed();");
inlinecxx("std::cout << \"chapelng,\" << {} << \",\" << {} << \",\" << hpx::resource::get_num_threads() << \",\" << {} << \",\" << {} << \",\" << elapsed << \",0\";", nx, nt, dt, dx);

//}
45 changes: 45 additions & 0 deletions benchmarks/stream_add.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use CTypes;

use Time;

extern proc getenv(name : c_string) : c_string;
extern proc sizeof(type T): uint(32);
extern const RAND_MAX: c_int;
extern proc rand(): c_int;

extern proc srand(seed: c_uint);

srand(0);

proc randindex() {
return rand()%5;
}

// Example usage with an array size of 1000000
config var arraySize = 134217728; //1000000;

var A:[1..arraySize] real;
var B:[1..arraySize] real;
var C:[1..arraySize] real;

// Initialize arrays
forall i in 1..arraySize {
A[i] = randindex();
B[i] = randindex();
C[i] = randindex();
}

proc run(A : [] real, B : [] real, C : [] real) {
var copy_t: stopwatch;
copy_t.start();

forall it in 1..arraySize {
// Benchmark Copy
C[it] = A[it] + B[it];
}

copy_t.stop();
writeln(getenv('CHPL_RT_NUM_THREADS_PER_LOCALE'.c_str()):string, ",",copy_t.elapsed());
}

run(A, B, C);
43 changes: 43 additions & 0 deletions benchmarks/stream_copy.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use CTypes;

use Time;

extern proc getenv(name : c_string) : c_string;
extern proc sizeof(type T): uint(32);
extern const RAND_MAX: c_int;
extern proc rand(): c_int;

extern proc srand(seed: c_uint);

srand(0);

proc randindex() {
return rand()%5;
}

// Example usage with an array size of 1000000
config var arraySize = 134217728; //1000000;

var A:[1..arraySize] real;
var C:[1..arraySize] real;

// Initialize arrays
forall i in 1..arraySize {
A[i] = randindex();
C[i] = randindex();
}

proc run(A : [] real, C : [] real) {
const iterations = 10;
var copy_t: stopwatch;
copy_t.start();

// Benchmark Copy
forall it in 1..arraySize do {
C[it] = A[it];
}
copy_t.stop();
writeln(getenv('CHPL_RT_NUM_THREADS_PER_LOCALE'.c_str()):string, ",",copy_t.elapsed());
}

run(A, C);
42 changes: 42 additions & 0 deletions benchmarks/stream_scale.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use CTypes;

use Time;

extern proc getenv(name : c_string) : c_string;
extern proc sizeof(type T): uint(32);
extern const RAND_MAX: c_int;
extern proc rand(): c_int;

extern proc srand(seed: c_uint);

srand(0);

proc randindex() {
return rand()%5;
}

// Example usage with an array size of 1000000
config var arraySize = 134217728; //1000000;

var A:[1..arraySize] real;
var C:[1..arraySize] real;

// Initialize arrays
forall i in 1..arraySize {
A[i] = randindex();
C[i] = randindex();
}

proc run(A : [] real, C : [] real) {
var copy_t: stopwatch;
copy_t.start();

// Benchmark Copy
forall it in 1..arraySize do {
C[it] = 3.0 * A[it];
}
copy_t.stop();
writeln(getenv('CHPL_RT_NUM_THREADS_PER_LOCALE'.c_str()):string, ",",copy_t.elapsed());
}

run(A, C);
44 changes: 44 additions & 0 deletions benchmarks/stream_triad.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use CTypes;

use Time;

extern proc getenv(name : c_string) : c_string;
extern proc sizeof(type T): uint(32);
extern const RAND_MAX: c_int;
extern proc rand(): c_int;

extern proc srand(seed: c_uint);

srand(0);

proc randindex() {
return rand()%5;
}

// Example usage with an array size of 1000000
config var arraySize = 134217728; //1000000;

var A:[1..arraySize] real;
var B:[1..arraySize] real;
var C:[1..arraySize] real;

// Initialize arrays
forall i in 1..arraySize {
A[i] = randindex();
B[i] = randindex();
C[i] = randindex();
}

proc run(A : [] real, B : [] real, C : [] real) {
var copy_t: stopwatch;
copy_t.start();

// Benchmark Copy
forall it in 1..arraySize do {
C[it] = A[it] + 3.0 * B[it];
}
copy_t.stop();
writeln(getenv('CHPL_RT_NUM_THREADS_PER_LOCALE'.c_str()):string, ",",copy_t.elapsed());
}

run(A, B, C);
4 changes: 4 additions & 0 deletions library/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Format Style Options - Created with Clang Power Tools
---
BasedOnStyle: LLVM
...
Loading