Skip to content

Commit

Permalink
Work around a bug in MSVC/CUDA in a function.
Browse files Browse the repository at this point in the history
Nesting the functions in some partial specialized classes seems to make the issue go away ...
  • Loading branch information
crtrott committed Feb 22, 2023
1 parent 4075009 commit 43ec33e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions core/src/impl/Kokkos_ViewCtor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ struct ViewCtorProp : public ViewCtorProp<void, P>... {
}
};


#if !defined(KOKKOS_COMPILER_MSVC) || !defined(KOKKOS_COMPILER_NVCC)
template <typename... P>
auto with_properties_if_unset(const ViewCtorProp<P...> &view_ctor_prop) {
return view_ctor_prop;
Expand Down Expand Up @@ -274,6 +276,50 @@ auto with_properties_if_unset(const ViewCtorProp<P...> &view_ctor_prop,
#endif
#endif
}
#else

template<class ViewCtorP, class ... Properties>
struct WithPropertiesIfUnset;

template <class ViewCtorP>
struct WithPropertiesIfUnset<ViewCtorP> {
static constexpr auto apply_prop(const ViewCtorP &view_ctor_prop) {
return view_ctor_prop;
}
};

template <class... P, class Property, class... Properties>
struct WithPropertiesIfUnset<ViewCtorProp<P...>, Property, Properties...> {
static constexpr auto apply_prop(const ViewCtorProp<P...> &view_ctor_prop, const Property& prop, const Properties&... properties) {
if constexpr ((is_execution_space<Property>::value &&
!ViewCtorProp<P...>::has_execution_space) ||
(is_memory_space<Property>::value &&
!ViewCtorProp<P...>::has_memory_space) ||
(is_view_label<Property>::value &&
!ViewCtorProp<P...>::has_label) ||
(std::is_same_v<Property, WithoutInitializing_t> &&
ViewCtorProp<P...>::initialize)) {
using NewViewCtorProp = ViewCtorProp<P..., Property>;
NewViewCtorProp new_view_ctor_prop(view_ctor_prop);
static_cast<ViewCtorProp<void, Property> &>(new_view_ctor_prop).value =
prop;
return WithPropertiesIfUnset<NewViewCtorProp, Properties...>::apply_prop(new_view_ctor_prop, properties...);
} else
return WithPropertiesIfUnset<ViewCtorProp<P...>, Properties...>::apply_prop(
view_ctor_prop, properties...);

}
};


template <typename... P, class ... Properties>
auto with_properties_if_unset(const ViewCtorProp<P...> &view_ctor_prop, const Properties& ... properties) {
return WithPropertiesIfUnset<ViewCtorProp<P...>, Properties...>::apply_prop(
view_ctor_prop, properties...);
}


#endif

struct ExecutionSpaceTag {};
struct MemorySpaceTag {};
Expand Down

0 comments on commit 43ec33e

Please sign in to comment.