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

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

wants to merge 2 commits into from

Conversation

dineshadepu
Copy link
Contributor

@dineshadepu dineshadepu commented Aug 25, 2023

I have modified 05_slice example to use DefaultExecutionSpace. The current code works for Cuda space and DefaultHostExecutionSpace. However, I am currently running into error while using DefaultExecutionSpace.

I couldn't actually able to find a fix for this. Can you please tell me how can I fix this? I will modify the code accordingly and push and change other examples as soon as this is fixed.

Many thanks.

Here is the error message.

#624

/home/dinesh/post_doc/softwares/kokkos/build/install/include/impl/Kokkos_ViewMapping.hpp(3409): error: static assertion failed
      static_assert(
      ^
          detected during:
            instantiation of "Kokkos::Impl::SharedAllocationRecord<void, void> *Kokkos::Impl::ViewMapping<Traits, std::enable_if_t<<expression>, void>>::allocate_shared(const Kokkos::Impl::ViewCtorProp<P...> &, const Traits::array_layout &, __nv_bool) [with Traits=Kokkos::ViewTraits<Cabana::SoA<Cabana::MemberTypes<double [3][3], float [4], int>, 4> *, Kokkos::Device<Kokkos::DefaultExecutionSpace, Kokkos::HostSpace>, Kokkos::MemoryManaged>, P=<Kokkos::Impl::WithoutInitializing_t, std::string, Kokkos::Impl::ViewAllocateWithoutInitializingBackwardCompat, Kokkos::HostSpace, Kokkos::DefaultExecutionSpace>]" at line 1434 of /home/dinesh/post_doc/softwares/kokkos/build/install/include/Kokkos_View.hpp
            instantiation of "Kokkos::View<DataType, Properties...>::View(const Kokkos::Impl::ViewCtorProp<P...> &, const std::enable_if_t<<expression>, Kokkos::ViewTraits<DataType, Properties...>::array_layout> &) [with DataType=Cabana::SoA<Cabana::MemberTypes<double [3][3], float [4], int>, 4> *, Properties=<Kokkos::Device<Kokkos::DefaultExecutionSpace, Kokkos::HostSpace>, Kokkos::MemoryManaged>, P=<Kokkos::Impl::WithoutInitializing_t, std::string, Kokkos::Impl::ViewAllocateWithoutInitializingBackwardCompat>]" at line 1487 of /home/dinesh/post_doc/softwares/kokkos/build/install/include/Kokkos_View.hpp
            instantiation of "Kokkos::View<DataType, Properties...>::View(const Kokkos::Impl::ViewCtorProp<P...> &, std::enable_if_t<<expression>, size_t>, size_t, size_t, size_t, size_t, size_t, size_t, size_t) [with DataType=Cabana::SoA<Cabana::MemberTypes<double [3][3], float [4], int>, 4> *, Properties=<Kokkos::Device<Kokkos::DefaultExecutionSpace, Kokkos::HostSpace>, Kokkos::MemoryManaged>, P=<Kokkos::Impl::WithoutInitializing_t, std::string, Kokkos::Impl::ViewAllocateWithoutInitializingBackwardCompat>]" at line 226 of /home/dinesh/post_doc/softwares/Cabana/core/src/Cabana_AoSoA.hpp
            instantiation of "Cabana::AoSoA<DataTypes, DeviceType, VectorLength, MemoryTraits>::AoSoA(std::string, Cabana::AoSoA<DataTypes, DeviceType, VectorLength, MemoryTraits>::size_type) [with DataTypes=Cabana::MemberTypes<double [3][3], float [4], int>, DeviceType=Kokkos::Device<Kokkos::DefaultExecutionSpace, Kokkos::HostSpace>, VectorLength=4, MemoryTraits=Kokkos::MemoryManaged]" at line 82 of /home/dinesh/post_doc/softwares/Cabana/example/core_tutorial/05_slice/slice_example.cpp

1 error detected in the compilation of "/home/dinesh/post_doc/softwares/Cabana/example/core_tutorial/05_slice/slice_example.cpp".
make[2]: *** [example/core_tutorial/05_slice/CMakeFiles/Slice.dir/build.make:76: example/core_tutorial/05_slice/CMakeFiles/Slice.dir/slice_example.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:888: example/core_tutorial/05_slice/CMakeFiles/Slice.dir/all] Error 2

1. Create aosoa_host using `Cabana::create_mirror_view_and_copy` function
@@ -64,8 +64,12 @@ void sliceExample()
allocated on NVIDIA devices use `Kokkos::CudaSpace` instead of
`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

@@ -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;
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;

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

@@ -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.

@dineshadepu dineshadepu closed this by deleting the head repository Aug 26, 2023
@dineshadepu
Copy link
Contributor Author

I will create a new branch and reopen this PR. I am running into rebase issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants