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

MDSpan issues expose by Kokkos View refactor #358

Merged
merged 5 commits into from
Sep 6, 2024

Conversation

crtrott
Copy link
Member

@crtrott crtrott commented Sep 3, 2024

  • fixes and issue (and adds test) where layout_left_paddded <-> layout_right_padded conversion didn't work if the extents_type are not convertible
  • uses correct constraint for pair like submdspan slices
  • fixes a few missing things for CUDA and nvc++ compiler

Related to: kokkos/kokkos#7288

Copy link
Contributor

@nmm0 nmm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This includes changes from kokkos/kokkos#7250 right?

@@ -95,6 +95,7 @@ struct padded_extent {
using static_array_type = typename static_array_type_for_padded_extent<
padding_value, _Extents, _ExtentToPadIdx, _Extents::rank()>::type;

MDSPAN_INLINE_FUNCTION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you actually need this or did you just add for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static_value is called inside a couple constructors and is_always_exhaustive all of which are device callable. The "INLINE" is just for consistency, at some point we can go wholesale through this stuff and replace it all with MDSPAN_FUNCTION

@@ -136,7 +137,7 @@ struct padded_extent {
return {};
}
// Missing return statement warning from NVCC and ICC
#if defined(__NVCC__) || defined(__INTEL_COMPILER)
#if (defined(__NVCC__) || defined(__INTEL_COMPILER)) && !defined(__NVCOMPILER)
return {};
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these are contained in #356 and should disappear after rebasing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased

@@ -203,7 +204,7 @@ class layout_left_padded<PaddingValue>::mapping {
}

public:
#if !MDSPAN_HAS_CXX_20
#if !MDSPAN_HAS_CXX_20 || defined(__NVCC__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the problem here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVCC does not like the requires stuff down there. Basically, it ends up saying that there is not default constructor on the device available in C++20 mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to narrow it down in a simple reproducer.

@@ -52,6 +53,33 @@ template <class OffsetType, class ExtentType, class StrideType>
struct is_strided_slice<
strided_slice<OffsetType, ExtentType, StrideType>> : std::true_type {};

// Helper for identifying valid pair like things
template <class T, class IndexType> struct index_pair_like : std::false_type {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature macro for complex get support is called __cpp_lib_tuple_like so maybe

Suggested change
template <class T, class IndexType> struct index_pair_like : std::false_type {};
template <class T, class IndexType> struct index_tuple_like : std::false_type {};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has nothing to do with get: https://eel.is/c++draft/views.multidim#mdspan.syn
We are using an exposition only concept called index-pair-like and if you follow all the stuff down to their roots, this thing here basically implements that concept in form of a type_trait.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I looked at get was that that's what is used in first_of which now uses this concept as requirement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed that by adding special versions for complex.

…ble extents

Specifically the 1D layout_left_padded <-> layout_right_padded ctors
didn't compile for cases where the new mapping has a static extent,
but the source mapping has dynamic extent.
and test that complex<double> works like pair as slice specifier *barf*
Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me.

static constexpr bool value = std::is_convertible_v<IdxT, IndexType>;
};

// FIXME: we actually need to pass IndexType into all of these
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is left to do?

@crtrott
Copy link
Member Author

crtrott commented Sep 6, 2024

As discussed elsewhere: complex is one of the named types for which this is supposed to work based on the definition of index-pair-like I see no reason to not include it here in the back port. Every standard approved version of submdspan will take complex as slice argument, and so I don't see a good reason to exclude it from this back port to C++17.

@dalg24 dalg24 merged commit 92a1297 into kokkos:stable Sep 6, 2024
15 checks passed
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.

4 participants