Skip to content

C++20: bump camp submodule and modify SFINAE to ensure compatibility #2020

Open
johnbowen42 wants to merge 14 commits into
developfrom
bowen/update-camp-submodule
Open

C++20: bump camp submodule and modify SFINAE to ensure compatibility #2020
johnbowen42 wants to merge 14 commits into
developfrom
bowen/update-camp-submodule

Conversation

@johnbowen42
Copy link
Copy Markdown
Contributor

@johnbowen42 johnbowen42 commented Apr 28, 2026

This PR does more than just bump the camp submodule. Changing the submodule required some modernization and changes to ensure compatibility.

@johnbowen42 johnbowen42 requested a review from rhornung67 May 7, 2026 23:47
@johnbowen42 johnbowen42 changed the title draft: bump camp submodule C++20: bump camp submodule and modify SFINAE to ensure compatibility May 7, 2026
Comment thread include/RAJA/internal/Iterators.hpp
Comment thread include/RAJA/pattern/scan.hpp Outdated
///
template<typename ExecPolicy, typename Res, typename... Args>
template<concepts::ExecutionPolicy ExecPolicy, typename Res, typename... Args>
RAJA_INLINE concepts::enable_if_t<resources::EventProxy<Res>,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will make another pass here to remove SFINAE entirely here

template<typename IdxT = hip_dim_member_t,
typename IdxNDims = NonCachedIndicesAndDims>
RAJA_DEVICE static constexpr IdxT size(IdxNDims const& idxNDims = IdxNDims {})
RAJA_DEVICE static constexpr IdxT size(IdxNDims const& = IdxNDims {})
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is actually an unrelated change--but I was getting unused variable warnings from this file while working on the HIP backend. I can remove and put in a separate PR if reviewers would like.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this is in hip, then it should also be in cuda.

Comment thread include/RAJA/pattern/scan.hpp Outdated
Comment thread include/RAJA/index/RangeSegment.hpp Outdated
Comment thread include/RAJA/pattern/detail/TypeTraits.hpp Outdated
Comment thread include/RAJA/pattern/scan.hpp Outdated
Comment thread include/RAJA/pattern/scan.hpp Outdated
Comment thread include/RAJA/pattern/scan.hpp Outdated
Comment thread test/include/RAJA_test-index-types.hpp Outdated
Comment on lines +28 to +29
// TODO(bowen): Did we ever support passing these types to Span? They do not
// model Integral
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good question, did the tests using StrongIdxTypeList work before, but don't now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes they did--I am trying to figure out why now. Somehow we were instantiating Span with StrongIndexType before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There was a bug with the old concept approach--if you replace
static_assert(type_traits::is_integral<IndexType>::value, "IndexType must model Integral"); with std::is_integral_v inside the Span class template definition in main the same tests fail to compile

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, so I changed the kernel tests (kernel uses span to create segments) to use a different list defined by this header. Let me know what you think

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess what we really want is something to convertible to integral?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But I think that we do want to support types like our strongly typed index types that look like ints.

Copy link
Copy Markdown
Contributor Author

@johnbowen42 johnbowen42 May 14, 2026

Choose a reason for hiding this comment

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

I appreciate that we want to support that, but StrongTypeIndex did not look like an int (see

RAJA_INDEX_VALUE(StrongIndexType, "StrongIndexType");
). Even the index types that are meant to look like ints here are commented out of the test suite. I think our "support" for that index type through our test suite was largely an accident of the implementation of camp's concepts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we should open an issue and revisit this aspect of the testing suite separate from this PR, because it looks like we were trying to support these types of indices but not actually supporting them in reality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm open to making the change here as well, but I think it would expand the scope of this PR

Copy link
Copy Markdown
Contributor Author

@johnbowen42 johnbowen42 May 14, 2026

Choose a reason for hiding this comment

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

@artv3 @MrBurmark Ok I thought about this more and I think I have a reasonable solution--see the new SpanIndex concept here https://github.com/llnl/RAJA/pull/2020/changes#diff-38e454fee010a2097ab28fc9773b94e23501f140ce26ebd7acb5da2402f0e052R317 and https://github.com/llnl/RAJA/pull/2020/changes#diff-b36ff9f682b4cc0577fac7779445c486b66e2abef955db1227a7b9cca3128ff7R68. I tried using the same trick with the other StrongInt and StrongULL types in the https://github.com/llnl/RAJA/blob/4ea83c49c874476fc0bec9500902ef527d240a95/test/include/RAJA_test-index-types.hpp, but compilation failed here, so that is still an open task

It's a bit ambiguous whether Span was intended to be used this way. The tests seem to make it seem so, but the old static asserts seem to indicate otherwise. In any case, this new concept fixes compilation and restores test coverage.

Comment thread include/RAJA/index/RangeSegment.hpp Outdated
Comment thread include/RAJA/util/Operators.hpp Outdated
Comment thread include/RAJA/util/Operators.hpp Outdated
Comment thread include/RAJA/policy/PolicyBase.hpp Outdated
Comment thread include/RAJA/util/Span.hpp Outdated
*
*/
template<typename IterType, typename IndexType>
template<concepts::RandomAccessIterator IterType, concepts::Integral IndexType>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will this still work with strong index types?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope, and it never should have based on the static assert before. See here #2020 (comment)

@artv3
Copy link
Copy Markdown
Member

artv3 commented May 13, 2026

FYI: I did a short review. Once the first batch of comments are addressed, I am happy to revisit the code.

Comment thread include/RAJA/pattern/scan.hpp Outdated
type_traits::is_resource<Res>,
std::is_constructible<camp::resources::Resource, Res>,
type_traits::is_range<Container>>
std::is_constructible<camp::resources::Resource, Res>>
Copy link
Copy Markdown
Member

@MrBurmark MrBurmark May 15, 2026

Choose a reason for hiding this comment

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

Is this not required for anything that satisfies concepts::Resource?

Comment on lines +259 to +260
concepts::Range InContainer,
concepts::Range OutContainer,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't these be RandomAccessRanges, given that this is just a wrapper around a function that requires that?

namespace concepts
{
template<typename T>
concept SpanIndex = concepts::Integral<T> || concepts::IndexValued<T>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I imagine we're going to need this concept more generally in the future, so it should probably be in a more general location and have a more general name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In general, I have been wondering if our approach to creating concepts across many headers is the right approach. Should we try to consolidate all our definitions into a single header? I feel like this might be useful for understanding RAJA for new developers

Comment on lines +286 to +287
Tester<Index> test1; // should compile
// Tester<Ty> test2; // should not compile
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

static_assert(requires...)?

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.

6 participants