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

More CUDA fixes exposed during Kokkos integration #347

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/experimental/__p0009_bits/extents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace detail {
// Function used to check compatibility of extents in converting constructor
// can't be a private member function for some reason.
template <size_t... Extents, size_t... OtherExtents>
MDSPAN_INLINE_FUNCTION
static constexpr std::integral_constant<bool, false> __check_compatible_extents(
std::integral_constant<bool, false>,
std::integer_sequence<size_t, Extents...>,
Expand All @@ -49,6 +50,7 @@ struct __compare_extent_compatible : std::integral_constant<bool,
{};

template <size_t... Extents, size_t... OtherExtents>
MDSPAN_INLINE_FUNCTION
static constexpr std::integral_constant<
bool, _MDSPAN_FOLD_AND(__compare_extent_compatible<Extents, OtherExtents>::value)>
__check_compatible_extents(
Expand Down
6 changes: 6 additions & 0 deletions include/experimental/__p0009_bits/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ template <std::size_t N>
using with_rank = std::integral_constant<std::size_t, N>;

template <class I1, class I2>
MDSPAN_INLINE_FUNCTION
constexpr bool common_integral_compare(I1 x, I2 y)
{
static_assert(std::is_integral<I1>::value &&
Expand All @@ -24,11 +25,14 @@ constexpr bool common_integral_compare(I1 x, I2 y)
}

template <class T1, class T2, class F>
MDSPAN_INLINE_FUNCTION
constexpr bool rankwise_equal(with_rank<0>, const T1&, const T2&, F)
{
return true;
}

template <std::size_t N, class T1, class T2, class F>
MDSPAN_INLINE_FUNCTION
constexpr bool rankwise_equal(with_rank<N>, const T1& x, const T2& y, F func)
{
bool match = true;
Expand All @@ -43,6 +47,7 @@ constexpr bool rankwise_equal(with_rank<N>, const T1& x, const T2& y, F func)
constexpr struct
{
template <class T, class I>
MDSPAN_INLINE_FUNCTION
constexpr auto operator()(const T& x, I i) const
{
return x.extent(i);
Expand All @@ -52,6 +57,7 @@ constexpr struct
constexpr struct
{
template <class T, class I>
MDSPAN_INLINE_FUNCTION
constexpr auto operator()(const T& x, I i) const
{
return x.stride(i);
Expand Down
22 changes: 18 additions & 4 deletions include/experimental/__p2630_bits/submdspan_mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,19 @@ MDSPAN_IMPL_PROPOSED_NAMESPACE::layout_left_padded<PaddingValue>::mapping<Extent
out_of_bounds ? this->required_span_size()
: this->operator()(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::first_of(slices)...));
if constexpr (dst_ext_t::rank() == 0) { // result rank-0
using dst_mapping_t = typename layout_left::template mapping<dst_ext_t>;
return submdspan_mapping_result<dst_mapping_t>{dst_mapping_t{dst_ext}, offset};
// The following for some reasons leads to compiler error later, while not using a typedef works:
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate the detailed explanation of how this somehow broke CUDA+GCC :P

// Compilers: CUDA 11.2 with GCC 9.1
//
// using dst_mapping_t = typename layout_left::template mapping<dst_ext_t>;
// return submdspan_mapping_result<dst_mapping_t>{dst_mapping_t{dst_ext}, offset};
//
// Error: submdspan_mapping.hpp:299:23: error: 'dst_mapping_t' does not name a type
// 299 | using dst_mapping_t = typename layout_left::template mapping<dst_ext_t>;
// The same error is given (about dst_mapping_t not naming type) when a different name is used in 299:
// using dst_mapping_t2 = typename layout_left::template mapping<dst_ext_t>;

return submdspan_mapping_result<typename layout_left::template mapping<dst_ext_t>>
{typename layout_left::template mapping<dst_ext_t>{dst_ext}, offset};
} else { // general case
// Figure out if any slice's lower bound equals the corresponding extent.
// If so, bypass evaluating the layout mapping. This fixes LWG Issue 4060.
Expand Down Expand Up @@ -509,8 +520,11 @@ MDSPAN_IMPL_PROPOSED_NAMESPACE::layout_right_padded<PaddingValue>::mapping<Exten
out_of_bounds ? this->required_span_size()
: this->operator()(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::first_of(slices)...));
if constexpr (dst_ext_t::rank() == 0) { // result rank-0
using dst_mapping_t = typename layout_right::template mapping<dst_ext_t>;
return submdspan_mapping_result<dst_mapping_t>{dst_mapping_t{dst_ext}, offset};
// Same issue as in layout_left_padded: see comment there
// using dst_mapping_t = typename layout_right::template mapping<dst_ext_t>;
// return submdspan_mapping_result<dst_mapping_t>{dst_mapping_t{dst_ext}, offset};
return submdspan_mapping_result<typename layout_right::template mapping<dst_ext_t>>
{typename layout_right::template mapping<dst_ext_t>{dst_ext}, offset};
} else { // general case
using deduce_layout = MDSPAN_IMPL_STANDARD_NAMESPACE::detail::deduce_layout_right_submapping<
typename dst_ext_t::index_type, dst_ext_t::rank(),
Expand Down
Loading