Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify example: 05_slice to use 'DefaultExecutionSpace' #673

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions example/core_tutorial/05_slice/slice_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ void sliceExample()
allocated on NVIDIA devices use `Kokkos::CudaSpace` instead of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment will need to be updated to describe that this example uses default spaces to work across all supported backends, but explicit choices like HostSpace and CudaSpace can also be used.

`Kokkos::HostSpace`.
*/
// using MemorySpace = Kokkos::CudaSpace;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

// using ExecutionSpace = Kokkos::Cuda;

using MemorySpace = Kokkos::HostSpace;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to match the execution space. using MemorySpace = typename ExecutionSpace::memory_space;

using ExecutionSpace = Kokkos::DefaultHostExecutionSpace;
using ExecutionSpace = Kokkos::DefaultExecutionSpace;

using DeviceType = Kokkos::Device<ExecutionSpace, MemorySpace>;

/*
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this mirror creation above the slice comment

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
Expand Down
Loading