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

Cannot build Kokkos 4.0.01 with current HPX master #6407

Closed
G-071 opened this issue Jan 8, 2024 · 2 comments · Fixed by #6409
Closed

Cannot build Kokkos 4.0.01 with current HPX master #6407

G-071 opened this issue Jan 8, 2024 · 2 comments · Fixed by #6409

Comments

@G-071
Copy link
Member

G-071 commented Jan 8, 2024

It is currently not possible to build the HPX execution space in Kokkos 4.0.01 (and older) using the current HPX master branch due to some missing overload.

I have looked a bit into the issue and it appears to be somewhat older than I initially thought, being introduced into HPX master on August 20, 2023 in PR #6309, (or more specifically in ca5e2d0 )

Here, the calls to

        policy = hpx::experimental::prefer(
            execution::with_processing_units_count, policy, cores);

in the chunk_size.hpp file cause the compilation issue.

For GPU machines (such as Perlmutter) we can actually work around this problem by simply dropping these calls to prefer which allows compiling Kokkos again (see patch).
However, this does not address the underlying issue, of course! This is only a workaround meant for GPU machines where we use a different (CUDA) Kokkos Execution Space but have to still build the HPX Kokkos Execution Space (currently required for hpx-kokkos compilation).

@hkaiser Could you take a look at this for a proper fix? It seems like some overload is missing in #6309, but I am not quite certain where to look for it/introduce it.
In the future, we might also want to take a look at changing hpx-kokkos to allow for compilation without at the Kokkos HPX execution space present.

For the sake of completeness, here is the Kokkos compilation error (using gcc 11 / cuda 12):

/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/properties/property.hpp(25): error: expected a ")"
          detected during:
            instantiation of "hpx::experimental::tag_fallback_invoke" based on template arguments <hpx::parallel::execution::with_processing_units_count_t, hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters> &, const unsigned long &> 
/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/functional/invoke_result.hpp(38): here
            instantiation of class "hpx::util::invoke_result<F, Ts...> [with F=const hpx::functional::detail::tag_fallback_invoke_t_ns::tag_fallback_invoke_t, Ts=<hpx::experimental::prefer_t, const hpx::parallel::execution::with_processing_units_count_t &, hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters> &, const std::size_t &>]" 
/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/parallel/util/detail/chunk_size.hpp(173): here
            instantiation of "hpx::util::iterator_range<hpx::parallel::util::detail::chunk_size_iterator<IterOrR>, hpx::parallel::util::detail::chunk_size_iterator<IterOrR>> hpx::parallel::util::detail::get_bulk_iteration_shape(ExPolicy &, IterOrR &, std::size_t &, Stride) [with ExPolicy=hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters>, IterOrR=int64_t, Stride=std::size_t]" 
/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/parallel/algorithms/for_loop.hpp(1667): here
            instantiation of "hpx::parallel::util::detail::algorithm_result_t<ExPolicy, void> hpx::experimental::tag_fallback_invoke(hpx::experimental::for_loop_strided_t, ExPolicy &&, std::decay_t<I>, I, S, Args &&...) [with ExPolicy=hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters>, I=int64_t, S=int64_t, Args=<lambda [](int64_t)->void>, _concept_requires_1648=42, _concept_check_1648=0]" 
/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/functional/detail/tag_fallback_invoke.hpp(296): here
            instantiation of "auto hpx::functional::detail::tag_base_ns::tag_fallback<Tag, Enable>::operator()(Args &&...) const->hpx::functional::detail::tag_fallback_invoke_result_t<Tag, Args &&...> [with Tag=hpx::experimental::for_loop_strided_t, Enable=hpx::meta::constant<std::integral_constant<__nv_bool, true>>, Args=<hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters>, int64_t, int64_t, const int64_t &, lambda [](int64_t)->void>, <unnamed>=void]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/Kokkos_HPX.hpp(1047): here
            [ 3 instantiation contexts not shown ]
            instantiation of "void Kokkos::Impl::ViewValueFunctor<DeviceType, ValueType, true>::parallel_for_implementation() [with DeviceType=Kokkos::Device<Kokkos::HostSpace::execution_space, Kokkos::HostSpace::memory_space>, ValueType=uint32_t]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/impl/Kokkos_ViewMapping.hpp(3082): here
            instantiation of "std::enable_if_t<<expression>, void> Kokkos::Impl::ViewValueFunctor<DeviceType, ValueType, true>::construct_shared_allocation() [with DeviceType=Kokkos::Device<Kokkos::HostSpace::execution_space, Kokkos::HostSpace::memory_space>, ValueType=uint32_t, Dummy=uint32_t]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/impl/Kokkos_ViewMapping.hpp(3463): here
            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<uint32_t *, Kokkos::HostSpace>, P=<std::string, Kokkos::HostSpace::memory_space, Kokkos::HostSpace::execution_space>]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/Kokkos_View.hpp(1434): here
            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=uint32_t *, Properties=<Kokkos::HostSpace>, P=<std::string>]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/Kokkos_View.hpp(1536): here
            instantiation of "Kokkos::View<DataType, Properties...>::View(const Label &, std::enable_if_t<Kokkos::Impl::is_view_label<Label>::value, const size_t>, size_t, size_t, size_t, size_t, size_t, size_t, size_t) [with DataType=uint32_t *, Properties=<Kokkos::HostSpace>, Label=char [27]]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/Kokkos_HPX.hpp(557): here

/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/properties/property.hpp(25): error: no instance of overloaded function "hpx::parallel::execution::with_processing_units_count_t::operator()" matches the argument list
            argument types are: (hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters>)
            object type is: hpx::parallel::execution::with_processing_units_count_t
          detected during:
            instantiation of "hpx::experimental::tag_fallback_invoke" based on template arguments <hpx::parallel::execution::with_processing_units_count_t, hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters> &, const unsigned long &> 
/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/functional/invoke_result.hpp(38): here
            instantiation of class "hpx::util::invoke_result<F, Ts...> [with F=const hpx::functional::detail::tag_fallback_invoke_t_ns::tag_fallback_invoke_t, Ts=<hpx::experimental::prefer_t, const hpx::parallel::execution::with_processing_units_count_t &, hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters> &, const std::size_t &>]" 
/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/parallel/util/detail/chunk_size.hpp(173): here
            instantiation of "hpx::util::iterator_range<hpx::parallel::util::detail::chunk_size_iterator<IterOrR>, hpx::parallel::util::detail::chunk_size_iterator<IterOrR>> hpx::parallel::util::detail::get_bulk_iteration_shape(ExPolicy &, IterOrR &, std::size_t &, Stride) [with ExPolicy=hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters>, IterOrR=int64_t, Stride=std::size_t]" 
/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/parallel/algorithms/for_loop.hpp(1667): here
            instantiation of "hpx::parallel::util::detail::algorithm_result_t<ExPolicy, void> hpx::experimental::tag_fallback_invoke(hpx::experimental::for_loop_strided_t, ExPolicy &&, std::decay_t<I>, I, S, Args &&...) [with ExPolicy=hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters>, I=int64_t, S=int64_t, Args=<lambda [](int64_t)->void>, _concept_requires_1648=42, _concept_check_1648=0]" 
/home/daissgr/workshop/KokkosTiger/build/hpx/include/hpx/functional/detail/tag_fallback_invoke.hpp(296): here
            instantiation of "auto hpx::functional::detail::tag_base_ns::tag_fallback<Tag, Enable>::operator()(Args &&...) const->hpx::functional::detail::tag_fallback_invoke_result_t<Tag, Args &&...> [with Tag=hpx::experimental::for_loop_strided_t, Enable=hpx::meta::constant<std::integral_constant<__nv_bool, true>>, Args=<hpx::execution::detail::parallel_policy_shim<hpx::execution::parallel_executor, hpx::execution::experimental::default_parameters>, int64_t, int64_t, const int64_t &, lambda [](int64_t)->void>, <unnamed>=void]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/Kokkos_HPX.hpp(1047): here
            [ 3 instantiation contexts not shown ]
            instantiation of "void Kokkos::Impl::ViewValueFunctor<DeviceType, ValueType, true>::parallel_for_implementation() [with DeviceType=Kokkos::Device<Kokkos::HostSpace::execution_space, Kokkos::HostSpace::memory_space>, ValueType=uint32_t]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/impl/Kokkos_ViewMapping.hpp(3082): here
            instantiation of "std::enable_if_t<<expression>, void> Kokkos::Impl::ViewValueFunctor<DeviceType, ValueType, true>::construct_shared_allocation() [with DeviceType=Kokkos::Device<Kokkos::HostSpace::execution_space, Kokkos::HostSpace::memory_space>, ValueType=uint32_t, Dummy=uint32_t]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/impl/Kokkos_ViewMapping.hpp(3463): here
            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<uint32_t *, Kokkos::HostSpace>, P=<std::string, Kokkos::HostSpace::memory_space, Kokkos::HostSpace::execution_space>]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/Kokkos_View.hpp(1434): here
            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=uint32_t *, Properties=<Kokkos::HostSpace>, P=<std::string>]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/Kokkos_View.hpp(1536): here
            instantiation of "Kokkos::View<DataType, Properties...>::View(const Label &, std::enable_if_t<Kokkos::Impl::is_view_label<Label>::value, const size_t>, size_t, size_t, size_t, size_t, size_t, size_t, size_t) [with DataType=uint32_t *, Properties=<Kokkos::HostSpace>, Label=char [27]]" 
/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/Kokkos_HPX.hpp(557): here

2 errors detected in the compilation of "/home/daissgr/workshop/KokkosTiger/src/kokkos/core/src/impl/Kokkos_Core.cpp".
make[2]: *** [core/src/CMakeFiles/kokkoscore.dir/build.make:104: core/src/CMakeFiles/kokkoscore.dir/impl/Kokkos_Core.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1041: core/src/CMakeFiles/kokkoscore.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
@hkaiser
Copy link
Member

hkaiser commented Jan 8, 2024

@G-071 can you please try if this patch helps working around the issue you're seeing?

diff --git a/libs/core/properties/include/hpx/properties/property.hpp b/libs/core/properties/include/hpx/properties/property.hpp
index e47690aa08a..ecaaabbdefd 100644
--- a/libs/core/properties/include/hpx/properties/property.hpp
+++ b/libs/core/properties/include/hpx/properties/property.hpp
@@ -22,7 +22,9 @@ namespace hpx::experimental {
         template <typename Tag, typename... Tn>
         friend constexpr HPX_FORCEINLINE auto tag_fallback_invoke(
                 prefer_t, Tag tag, Tn&&... tn)
+#if !defined(HPX_CUDA_VERSION) || (HPX_CUDA_VERSION >= 1102)
             noexcept(noexcept(tag(HPX_FORWARD(Tn, tn)...)))
+#endif
             -> decltype(tag(HPX_FORWARD(Tn, tn)...))
         // clang-format on
         {
@@ -33,7 +35,9 @@ namespace hpx::experimental {
         template <typename Tag, typename T0, typename... Tn>
         friend constexpr HPX_FORCEINLINE auto tag_fallback_invoke(
                 prefer_t, Tag, T0&& t0, Tn&&...)
+#if !defined(HPX_CUDA_VERSION) || (HPX_CUDA_VERSION >= 1102)
             noexcept(noexcept(HPX_FORWARD(T0, t0)))
+#endif
             -> std::enable_if_t<
                     !hpx::functional::is_tag_invocable_v<
                         prefer_t, Tag, T0, Tn...> &&

(I chose to use HPX_CUDA_VERSION >= 1102 as we do similar things in other places).

@hkaiser
Copy link
Member

hkaiser commented Jan 8, 2024

Or even:

diff --git a/libs/core/properties/include/hpx/properties/property.hpp b/libs/core/properties/include/hpx/properties/property.hpp
index e47690aa08a..f8dade84120 100644
--- a/libs/core/properties/include/hpx/properties/property.hpp
+++ b/libs/core/properties/include/hpx/properties/property.hpp
@@ -22,7 +22,7 @@ namespace hpx::experimental {
         template <typename Tag, typename... Tn>
         friend constexpr HPX_FORCEINLINE auto tag_fallback_invoke(
                 prefer_t, Tag tag, Tn&&... tn)
-            noexcept(noexcept(tag(HPX_FORWARD(Tn, tn)...)))
+            noexcept(hpx::functional::is_nothrow_tag_invocable_v<Tag, Tn&&...>)
             -> decltype(tag(HPX_FORWARD(Tn, tn)...))
         // clang-format on
         {

@hkaiser hkaiser added this to the 1.10.0 milestone Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants