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 test showing for GPU arrays that are not bound to on lexical sc…
…ope (chapel-lang#23704) This came up in a meeting where arrays that outlive the scope of an `on` statement was requested. Today, you can achieve that with some class-wrapping. This PR adds a test for that. An earlier version of this pattern was written by @mppf. However, it was not working at that time. The issue was resolved by @DanilaFe in chapel-lang#22373. [Reviewed by @mppf and @bradcray] Test: - [x] nvidia
- Loading branch information
Showing
2 changed files
with
36 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,34 @@ | ||
use GpuDiagnostics; | ||
|
||
config const n = 10; | ||
|
||
class ArrWrapperClass { | ||
const Dom: domain(?); | ||
forwarding var Arr: [Dom] int; | ||
} | ||
|
||
type ArrWrapper = owned ArrWrapperClass?; | ||
|
||
startGpuDiagnostics(); | ||
|
||
var HostArr = new ArrWrapper({1..n}); | ||
var DevArr: HostArr.type; // make sure to not use a generic type | ||
|
||
on here.gpus[0] { | ||
DevArr = new ArrWrapper({1..n}); // allocates the array on the GPU | ||
|
||
foreach a in DevArr! do | ||
a += 1; | ||
} | ||
|
||
on here.gpus[0] { | ||
foreach a in DevArr! do | ||
a += 1; | ||
} | ||
|
||
HostArr!.Arr = DevArr!.Arr; | ||
|
||
writeln(HostArr!.Arr); | ||
|
||
stopGpuDiagnostics(); | ||
assertGpuDiags(kernel_launch_aod=3, kernel_launch_um=2, device_to_host=1); |
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,2 @@ | ||
warning: The prototype GPU support implies --no-checks. This may impact debuggability. To suppress this warning, compile with --no-checks explicitly | ||
2 2 2 2 2 2 2 2 2 2 |