From 3e819414e25848251c9feda7b0439126bf0082b5 Mon Sep 17 00:00:00 2001 From: Engin Kayraklioglu Date: Mon, 13 Jan 2025 09:36:40 -0800 Subject: [PATCH] Add a simple GPU example used in a training slide Signed-off-by: Engin Kayraklioglu --- test/gpu/native/examples/amd-training/README.md | 3 +++ test/gpu/native/examples/amd-training/basic.chpl | 10 ++++++++++ test/gpu/native/examples/amd-training/basic.good | 0 3 files changed, 13 insertions(+) create mode 100644 test/gpu/native/examples/amd-training/README.md create mode 100644 test/gpu/native/examples/amd-training/basic.chpl create mode 100644 test/gpu/native/examples/amd-training/basic.good diff --git a/test/gpu/native/examples/amd-training/README.md b/test/gpu/native/examples/amd-training/README.md new file mode 100644 index 000000000000..66e933fbfcc2 --- /dev/null +++ b/test/gpu/native/examples/amd-training/README.md @@ -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. diff --git a/test/gpu/native/examples/amd-training/basic.chpl b/test/gpu/native/examples/amd-training/basic.chpl new file mode 100644 index 000000000000..d407c573ae72 --- /dev/null +++ b/test/gpu/native/examples/amd-training/basic.chpl @@ -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); + diff --git a/test/gpu/native/examples/amd-training/basic.good b/test/gpu/native/examples/amd-training/basic.good new file mode 100644 index 000000000000..e69de29bb2d1