summaryrefslogtreecommitdiff
path: root/examples/gpu
diff options
context:
space:
mode:
authorSteven <burnett@posteo.de>2026-01-25 23:49:06 +0000
committerSteven <burnett@posteo.de>2026-01-25 23:49:06 +0000
commit80d90562daedb0fda275aeb04809fd22060a196a (patch)
tree37077532f8f779556c8f833842f1599dc3ac06a4 /examples/gpu
parent62bc97a1f944e3ad06f11ecae0049bd83970a920 (diff)
fix(examples): cuda use def instead of const
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";