-
Notifications
You must be signed in to change notification settings - Fork 50
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 05_slice example to use DefaultExecutionSpace #677
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,16 +56,15 @@ void sliceExample() | |||||
const int VectorLength = 4; | ||||||
|
||||||
/* | ||||||
Finally declare the memory space in which the AoSoA will be allocated. In | ||||||
this example we are writing basic loops that will execute on the CPU. The | ||||||
HostSpace allocates memory in standard CPU RAM. | ||||||
The current example uses default spaces to work across all supported | ||||||
backends, but explicit choices like HostSpace and CudaSpace can also be | ||||||
used. | ||||||
|
||||||
Kokkos also supports execution on GPUs. For example, to create an AoSoA | ||||||
allocated on NVIDIA devices use `Kokkos::CudaSpace` instead of | ||||||
`Kokkos::HostSpace`. | ||||||
We declare the memory space in which the AoSoA will be allocated | ||||||
on the default execution space we are dealing with. | ||||||
*/ | ||||||
using MemorySpace = Kokkos::HostSpace; | ||||||
using ExecutionSpace = Kokkos::DefaultHostExecutionSpace; | ||||||
using ExecutionSpace = Kokkos::DefaultExecutionSpace; | ||||||
using MemorySpace = typename ExecutionSpace::memory_space; | ||||||
using DeviceType = Kokkos::Device<ExecutionSpace, MemorySpace>; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note that #585 will change most of the examples to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I will update the rest of the examples after #585 is merged. Will keep the PR open until then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dineshadepu should be okay to continue this PR now that we've merged the blocking PR - let me know if those changes are confusing in any way. But I do not plan to include this in the imminent release, so feel free to wait until that's finished |
||||||
|
||||||
/* | ||||||
|
@@ -78,6 +77,9 @@ void sliceExample() | |||||
Cabana::AoSoA<DataTypes, DeviceType, VectorLength> aosoa( "my_aosoa", | ||||||
num_tuple ); | ||||||
|
||||||
// Create a mirror view of the aosoa on the host for accessing it legally | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
auto aosoa_host = | ||||||
Cabana::create_mirror_view_and_copy( Kokkos::HostSpace(), aosoa ); | ||||||
/* | ||||||
Create a slice over each tuple member in the AoSoA. An integer template | ||||||
parameter is used to indicate which member to slice. A slice object | ||||||
|
@@ -88,9 +90,9 @@ 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" ); | ||||||
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 | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.