-
Notifications
You must be signed in to change notification settings - Fork 407
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
Add support for View::rank[_dynamic]()
#5870
Conversation
I agree with this change, keeping it consistent with ViewTraits, even though there seem to be handful of comparison of different integer signedness warnings to be handled. We also happened to have called the struct that contains the iteration pattern |
Down the line, whatever we do with these interfaces ought to support code that's generic over both |
I added to the MDspan project since it's related (i.e. rank returning |
311d00f
to
547ed20
Compare
using value_type = T; | ||
using type = integral_constant<T, v>; | ||
static constexpr T value = v; | ||
KOKKOS_FUNCTION constexpr operator value_type() const noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're re-implementing it anyway because of the need for __host__ __device__
we could eventually deprecate this conversion if we wanted to make the view API more similar to mdspan.
That's assuming this utility class is not used elsewhere...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You read my mind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But not doing that for a while. We need to get users off of View::Rank first and we want to make it reasonably easy for them to support a range of Kokkos versions.
View::rank[_dynamic]()
and deprecate View::Rank
View::rank[_dynamic]()
d5f33f0
to
6837770
Compare
message += std::to_string(dst.extent(0)); | ||
for (size_t r = 1; r < dst_type::rank; r++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are to avoid warning pointless comparison of unsigned integer with zero when the loop is from 0 to rank-1
@@ -814,14 +814,14 @@ class View : public ViewTraits<DataType, Properties...> { | |||
|
|||
template <typename... Is> | |||
static KOKKOS_FUNCTION void check_access_member_function_valid_args(Is...) { | |||
static_assert(traits::rank <= sizeof...(Is), ""); | |||
static_assert(rank <= sizeof...(Is), ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
traits::rank[_dynamic_rank]
are still valid but it is cleaner without qualifying.
@@ -29,7 +29,7 @@ struct is_admissible_to_kokkos_std_algorithms : std::false_type {}; | |||
|
|||
template <typename T> | |||
struct is_admissible_to_kokkos_std_algorithms< | |||
T, std::enable_if_t< ::Kokkos::is_view<T>::value && T::rank == 1 && | |||
T, std::enable_if_t< ::Kokkos::is_view<T>::value && T::rank() == 1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSVC was choking on that guy. Was giving failed static assertions all over the place in algorithms
@@ -1716,7 +1705,7 @@ struct RankDataType<ValueType, 0> { | |||
|
|||
template <unsigned N, typename... Args> | |||
KOKKOS_FUNCTION std::enable_if_t< | |||
N == View<Args...>::rank && | |||
N == View<Args...>::rank() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change and the one below was for MSVC :(
Co-Authored-By: Christian Trott <crtrott@sandia.gov>
15bf1a3
to
2969679
Compare
Retest this please |
Retest this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me.
Ignoring HIP failure |
Related to #5717
View::rank[_dynamic]
implicitly convertible toint
size_t
and callableDeprecatedone in DeprecateView::Rank
(never mentioned in the API reference for View)View::Rank
"uppercase R" in favor ofView::rank
"lowercase r" #5882Not sure it is worth the trouble. Opening so we can discuss.We agreed to move forward at the dev meeting.View
memberView::Rank
View::rank
size_t
View::rank()
size_t
View::rank_dynamic
size_t
View::rank_dynamic()
size_t
Two things worth noting:
View::rank()
member over therank(View)
free function is that it can be used in constant expressions.View::rank
as it was defined before was left up to the implementation (up to the compiler not to Kokkos) but in practice it was oftenint
which means this change may yield warnings about comparing signed and unsigned integral types. It may also break code that was using the type ofView::rank
. The rational for choosingsize_t
was to align withstd::mdspan
.