From 3b7e90eabedc7ca5f6c856ed98e13684953c787f Mon Sep 17 00:00:00 2001 From: Engin Kayraklioglu Date: Tue, 24 Oct 2023 16:14:29 -0700 Subject: [PATCH] Add a test showing for GPU arrays that are not bound to on lexical scope Signed-off-by: Engin Kayraklioglu --- test/gpu/native/basics/outOfOnArr.chpl | 34 ++++++++++++++++++++++++++ test/gpu/native/basics/outOfOnArr.good | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 test/gpu/native/basics/outOfOnArr.chpl create mode 100644 test/gpu/native/basics/outOfOnArr.good diff --git a/test/gpu/native/basics/outOfOnArr.chpl b/test/gpu/native/basics/outOfOnArr.chpl new file mode 100644 index 000000000000..3d3b2fd6d32c --- /dev/null +++ b/test/gpu/native/basics/outOfOnArr.chpl @@ -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); diff --git a/test/gpu/native/basics/outOfOnArr.good b/test/gpu/native/basics/outOfOnArr.good new file mode 100644 index 000000000000..99dcb4aaf1c5 --- /dev/null +++ b/test/gpu/native/basics/outOfOnArr.good @@ -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