Skip to content

Commit

Permalink
kokkos#6805: fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nmm0 committed Mar 13, 2024
1 parent b2e39cb commit 84b7c3c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 28 deletions.
49 changes: 22 additions & 27 deletions core/src/Kokkos_View.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,15 @@ struct MDSpanViewTraits {

// "Natural" mdspan for a view if the View's ArrayLayout is supported.
template <class Traits>
struct MDSpanViewTraits<
Traits, std::void_t<typename Impl::LayoutFromArrayLayout<
typename Traits::array_layout>::type>> {
using index_type = std::size_t;
using extents_type = typename Impl::ExtentsFromDataType<
index_type, typename Traits::data_type>::type;
using mdspan_layout_type = typename Impl::LayoutFromArrayLayout<
typename Traits::array_layout>::type;
struct MDSpanViewTraits<Traits,
std::void_t<typename Impl::LayoutFromArrayLayout<
typename Traits::array_layout>::type>> {
using index_type = std::size_t;
using extents_type =
typename Impl::ExtentsFromDataType<index_type,
typename Traits::data_type>::type;
using mdspan_layout_type =
typename Impl::LayoutFromArrayLayout<typename Traits::array_layout>::type;
using mdspan_type =
mdspan<typename Traits::value_type, extents_type, mdspan_layout_type>;
};
Expand Down Expand Up @@ -1755,30 +1756,26 @@ class View : public ViewTraits<DataType, Properties...> {
//----------------------------------------
// MDSpan converting constructors
#ifdef KOKKOS_ENABLE_IMPL_MDSPAN
template <typename U = typename Impl::MDSpanViewTraits<
traits>::mdspan_type>
template <typename U = typename Impl::MDSpanViewTraits<traits>::mdspan_type>
KOKKOS_INLINE_FUNCTION MDSPAN_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)
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())) {}
typename Impl::MDSpanViewTraits<traits>::mdspan_type>(
mds.mapping())) {}

//----------------------------------------
// Conversion to MDSpan
template <class OtherElementType, class OtherExtents, class OtherLayoutPolicy,
class OtherAccessor>
KOKKOS_INLINE_FUNCTION constexpr operator mdspan<
OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor>() {
using mdspan_type =
typename Impl::MDSpanViewTraits<traits>::mdspan_type;
return mdspan_type{
data(),
Impl::mapping_from_view_mapping<mdspan_type>(m_map)};
using mdspan_type = typename Impl::MDSpanViewTraits<traits>::mdspan_type;
return mdspan_type{data(),
Impl::mapping_from_view_mapping<mdspan_type>(m_map)};
}

template <class OtherAccessorType,
Expand All @@ -1787,16 +1784,14 @@ class View : public ViewTraits<DataType, Properties...> {
typename OtherAccessorType::data_handle_type>>>
KOKKOS_INLINE_FUNCTION constexpr auto to_mdspan(
const OtherAccessorType& other_accessor) {
using mdspan_type =
typename Impl::MDSpanViewTraits<traits>::mdspan_type;
using mdspan_type = typename Impl::MDSpanViewTraits<traits>::mdspan_type;
using ret_mdspan_type =
mdspan<typename mdspan_type::element_type,
typename mdspan_type::extents_type,
typename mdspan_type::layout_type, OtherAccessorType>;
return ret_mdspan_type{
data(),
Impl::mapping_from_view_mapping<mdspan_type>(m_map),
other_accessor};
return ret_mdspan_type{data(),
Impl::mapping_from_view_mapping<mdspan_type>(m_map),
other_accessor};
}
#endif // KOKKOS_ENABLE_IMPL_MDSPAN
};
Expand Down
2 changes: 1 addition & 1 deletion core/unit_test/view/TestMDSpanConversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct TestViewMDSpanConversion {
template <class MDSpanLayoutMapping, class ViewType>
static void test_conversion_to_mdspan(
const MDSpanLayoutMapping &ref_layout_mapping, ViewType v) {
using view_type = ViewType;
using view_type = ViewType;
using natural_mdspan_type = typename Kokkos::Impl::MDSpanViewTraits<
typename view_type::traits>::mdspan_type;

Expand Down

0 comments on commit 84b7c3c

Please sign in to comment.