From f1d6d1caff9247478e1ec448112d945a0d2f4ef9 Mon Sep 17 00:00:00 2001 From: Dinesh Adepu Date: Fri, 25 Aug 2023 15:02:31 +0100 Subject: [PATCH] Modify example: `05_slice` to use 'DefaultExecutionSpace' 1. Create aosoa_host using `Cabana::create_mirror_view_and_copy` function --- example/core_tutorial/05_slice/slice_example.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/example/core_tutorial/05_slice/slice_example.cpp b/example/core_tutorial/05_slice/slice_example.cpp index 17e1a2ec4..9904fc18b 100644 --- a/example/core_tutorial/05_slice/slice_example.cpp +++ b/example/core_tutorial/05_slice/slice_example.cpp @@ -64,8 +64,12 @@ void sliceExample() allocated on NVIDIA devices use `Kokkos::CudaSpace` instead of `Kokkos::HostSpace`. */ + // using MemorySpace = Kokkos::CudaSpace; + // using ExecutionSpace = Kokkos::Cuda; + using MemorySpace = Kokkos::HostSpace; - using ExecutionSpace = Kokkos::DefaultHostExecutionSpace; + using ExecutionSpace = Kokkos::DefaultExecutionSpace; + using DeviceType = Kokkos::Device; /* @@ -88,9 +92,13 @@ void sliceExample() because slices are unmanaged memory but may still be used for diagnostic purposes. */ - auto slice_0 = Cabana::slice<0>( aosoa, "my_slice_0" ); - auto slice_1 = Cabana::slice<1>( aosoa, "my_slice_1" ); - auto slice_2 = Cabana::slice<2>( aosoa, "my_slice_2" ); + // Create a mirror view of the aosoa on the host for accessing it legally + auto aosoa_host = + Cabana::create_mirror_view_and_copy( Kokkos::HostSpace(), aosoa ); + + auto slice_0 = Cabana::slice<0>( aosoa_host, "my_slice_0" ); + auto slice_1 = Cabana::slice<1>( aosoa_host, "my_slice_1" ); + auto slice_2 = Cabana::slice<2>( aosoa_host, "my_slice_2" ); /* Let's initialize the data using the 2D indexing scheme. Slice data can