Skip to content

Commit

Permalink
Fix clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
crtrott committed Apr 5, 2024
1 parent 4ce8403 commit afd4c43
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions core/src/Kokkos_Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,9 @@ static constexpr bool kokkos_omp_on_host() { return false; }
#define KOKKOS_ATTRIBUTE_NODISCARD [[nodiscard]]

#ifdef KOKKOS_ENABLE_CXX20
# define KOKKOS_IMPL_CONDITIONAL_EXPLICIT(COND) explicit(COND)
#define KOKKOS_IMPL_CONDITIONAL_EXPLICIT(COND) explicit(COND)
#else
# define KOKKOS_IMPL_CONDITIONAL_EXPLICIT(COND)
#define KOKKOS_IMPL_CONDITIONAL_EXPLICIT(COND)
#endif

#if (defined(KOKKOS_COMPILER_GNU) || defined(KOKKOS_COMPILER_CLANG) || \
Expand Down
30 changes: 17 additions & 13 deletions core/src/Kokkos_View.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1757,23 +1757,25 @@ class View : public ViewTraits<DataType, Properties...> {
// MDSpan converting constructors
#ifdef KOKKOS_ENABLE_IMPL_MDSPAN
template <typename U = typename Impl::MDSpanViewTraits<traits>::mdspan_type>
KOKKOS_INLINE_FUNCTION KOKKOS_IMPL_CONDITIONAL_EXPLICIT(traits::is_managed) View(
const typename Impl::MDSpanViewTraits<traits>::mdspan_type& mds,
std::enable_if_t<
!std::is_same_v<Impl::UnsupportedKokkosArrayLayout, U>>* = nullptr)
KOKKOS_INLINE_FUNCTION KOKKOS_IMPL_CONDITIONAL_EXPLICIT(traits::is_managed)
View(const typename Impl::MDSpanViewTraits<traits>::mdspan_type& mds,
std::enable_if_t<!std::is_same_v<Impl::UnsupportedKokkosArrayLayout,
U>>* = nullptr)
: View(mds.data_handle(),
Impl::array_layout_from_mapping<
typename traits::array_layout,
typename Impl::MDSpanViewTraits<traits>::mdspan_type>(
mds.mapping())) {}

template<class ElementType, class ExtentsType, class LayoutType, class AccessorType>
KOKKOS_INLINE_FUNCTION
KOKKOS_IMPL_CONDITIONAL_EXPLICIT((
!std::is_convertible_v<Kokkos::mdspan<ElementType, ExtentsType, LayoutType, AccessorType>,
typename Impl::MDSpanViewTraits<traits>::mdspan_type>))
View(const Kokkos::mdspan<ElementType, ExtentsType, LayoutType, AccessorType>& mds):
View(typename Impl::MDSpanViewTraits<traits>::mdspan_type(mds)) {}
template <class ElementType, class ExtentsType, class LayoutType,
class AccessorType>
KOKKOS_INLINE_FUNCTION KOKKOS_IMPL_CONDITIONAL_EXPLICIT(
(!std::is_convertible_v<
Kokkos::mdspan<ElementType, ExtentsType, LayoutType, AccessorType>,
typename Impl::MDSpanViewTraits<traits>::mdspan_type>))
View(const Kokkos::mdspan<ElementType, ExtentsType, LayoutType,
AccessorType>& mds)
: View(typename Impl::MDSpanViewTraits<traits>::mdspan_type(mds)) {}

//----------------------------------------
// Conversion to MDSpan
Expand All @@ -1786,12 +1788,14 @@ class View : public ViewTraits<DataType, Properties...> {
Impl::mapping_from_view_mapping<mdspan_type>(m_map)};
}

template <class OtherAccessorType = Kokkos::default_accessor<typename traits::value_type>,
template <class OtherAccessorType =
Kokkos::default_accessor<typename traits::value_type>,
typename = std::enable_if_t<std::is_assignable_v<
typename traits::value_type*&,
typename OtherAccessorType::data_handle_type>>>
KOKKOS_INLINE_FUNCTION constexpr auto to_mdspan(
const OtherAccessorType& other_accessor = Kokkos::default_accessor<typename traits::value_type>()) {
const OtherAccessorType& other_accessor =
Kokkos::default_accessor<typename traits::value_type>()) {
using mdspan_type = typename Impl::MDSpanViewTraits<traits>::mdspan_type;
using ret_mdspan_type =
mdspan<typename mdspan_type::element_type,
Expand Down
10 changes: 5 additions & 5 deletions core/unit_test/view/TestMDSpanConversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ struct TestViewMDSpanConversion {
// test conversion operator to different mdspan type
{
using mdspan_type = Kokkos::mdspan<
const typename natural_mdspan_type::element_type,
Kokkos::dextents<typename natural_mdspan_type::index_type, natural_mdspan_type::rank()>,
typename natural_mdspan_type::layout_type,
typename natural_mdspan_type::accessor_type>;
const typename natural_mdspan_type::element_type,
Kokkos::dextents<typename natural_mdspan_type::index_type,
natural_mdspan_type::rank()>,
typename natural_mdspan_type::layout_type,
typename natural_mdspan_type::accessor_type>;
mdspan_type cvt = v;
ASSERT_EQ(cvt.data_handle(), v.data());
ASSERT_EQ(cvt.mapping(), ref_layout_mapping);
}

}

template <class MDSpanLayoutMapping, class ViewType, class AccessorType>
Expand Down

0 comments on commit afd4c43

Please sign in to comment.