summaryrefslogtreecommitdiff
path: root/examples/gpu
diff options
context:
space:
mode:
authorZuhaitz <zuhaitz.zechhub@gmail.com>2026-01-26 00:39:31 +0000
committerGitHub <noreply@github.com>2026-01-26 00:39:31 +0000
commitca08979910e5a234a2423e4448ad0e284bf4f508 (patch)
treee09702f7b0850feb00a6af7f315bff7448c2ed26 /examples/gpu
parent6bef876bf900458a36260ca3fe96e23b06749d74 (diff)
parent97d0583c92c733aa8497a99f5267d50151f6e965 (diff)
Merge pull request #132 from Burnett01/fix/var-const-remains-in-examples
Housekeeping: Fix var/const remains in examples and docs
Diffstat (limited to 'examples/gpu')
-rw-r--r--examples/gpu/cuda-benchmark.zc8
-rw-r--r--examples/gpu/cuda_vector_add.zc4
2 files changed, 6 insertions, 6 deletions
diff --git a/examples/gpu/cuda-benchmark.zc b/examples/gpu/cuda-benchmark.zc
index cea326e..8f4a85d 100644
--- a/examples/gpu/cuda-benchmark.zc
+++ b/examples/gpu/cuda-benchmark.zc
@@ -194,7 +194,7 @@ fn benchmark_matrix_multiply(N: int) {
cuda_copy_to_device(d_B, h_B, size * sizeof(float));
// Configure grid
- const BLOCK_SIZE = 16;
+ def BLOCK_SIZE = 16;
let blocks_per_grid = (N + BLOCK_SIZE - 1) / BLOCK_SIZE;
"-> Launching kernel: {blocks_per_grid}x{blocks_per_grid} blocks, {BLOCK_SIZE}x{BLOCK_SIZE} threads each";
@@ -232,8 +232,8 @@ fn benchmark_monte_carlo_pi(num_samples: u64) {
"-> Estimating Pi with {num_samples} samples";
- const BLOCK_SIZE = 256;
- const NUM_BLOCKS = 1024;
+ def BLOCK_SIZE = 256;
+ def NUM_BLOCKS = 1024;
let total_threads = BLOCK_SIZE * NUM_BLOCKS;
// Allocate memory
@@ -342,7 +342,7 @@ fn benchmark_nbody(num_bodies: int, num_steps: int) {
cuda_copy_to_device(d_vy, h_vy, num_bodies * sizeof(float));
cuda_copy_to_device(d_vz, h_vz, num_bodies * sizeof(float));
- const BLOCK_SIZE = 256;
+ def BLOCK_SIZE = 256;
let num_blocks = (num_bodies + BLOCK_SIZE - 1) / BLOCK_SIZE;
let dt = 0.01f;
diff --git a/examples/gpu/cuda_vector_add.zc b/examples/gpu/cuda_vector_add.zc
index d1f896a..534950d 100644
--- a/examples/gpu/cuda_vector_add.zc
+++ b/examples/gpu/cuda_vector_add.zc
@@ -15,7 +15,7 @@ fn add_kernel(a: float*, b: float*, c: float*, n: int) {
}
fn main() {
- const N = 1024;
+ def N = 1024;
"=> Zen C CUDA Vector Addition";
"-> Vector size: {N} elements";
@@ -43,7 +43,7 @@ fn main() {
cuda_copy_to_device(d_a, h_a, N * sizeof(float));
cuda_copy_to_device(d_b, h_b, N * sizeof(float));
- const BLOCK_SIZE = 256;
+ def BLOCK_SIZE = 256;
let num_blocks = (N + BLOCK_SIZE - 1) / BLOCK_SIZE;
"-> Launching: {num_blocks} blocks x {BLOCK_SIZE} threads";