Skip to content

Commit

Permalink
Add a simple GPU example used in a training slide
Browse files Browse the repository at this point in the history
Signed-off-by: Engin Kayraklioglu <[email protected]>
  • Loading branch information
e-kayrakli committed Jan 13, 2025
1 parent b3ad8fc commit 3e81941
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/gpu/native/examples/amd-training/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains a test that I've sent to be used in some AMD trainings.
Even though it is doing pretty fundamental stuff, It'd be good to get it tested
nightly.
10 changes: 10 additions & 0 deletions test/gpu/native/examples/amd-training/basic.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var CpuArr: [1..1_000_000] int; // allocate an array on the host memory
on here.gpus[0] { // move the execution to the GPU
var GpuArr = CpuArr; // copy the host array onto device memory
forall elem in GpuArr do elem += 1; // increment elements by 1
CpuArr = GpuArr; // copy the array back to the host
}

// This was not part of the slide and only there for correctness
assert((+ reduce CpuArr) == 1_000_000);

Empty file.

0 comments on commit 3e81941

Please sign in to comment.