forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple GPU example used in a training slide
Signed-off-by: Engin Kayraklioglu <[email protected]>
- Loading branch information
1 parent
b3ad8fc
commit 3e81941
Showing
3 changed files
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.