Remove fast_int inheritance from dynamic valid extents - #845
Open
MaybeWilli wants to merge 7 commits into
Open
MaybeWilli wants to merge 7 commits into
MaybeWilli wants to merge 7 commits into
Conversation
PointKernel
reviewed
Sep 16, 2026
| struct valid_extent<SizeType, dynamic_extent> : cuco::utility::fast_int<SizeType> { | ||
| using value_type = | ||
| typename cuco::utility::fast_int<SizeType>::fast_int::value_type; ///< Extent value type | ||
| struct valid_extent<SizeType, dynamic_extent> { |
Member
Member
|
/ok to test 974d6a5 |
sleeepyjack
reviewed
Sep 18, 2026
| struct valid_extent<SizeType, dynamic_extent> : cuco::utility::fast_int<SizeType> { | ||
| using value_type = | ||
| typename cuco::utility::fast_int<SizeType>::fast_int::value_type; ///< Extent value type | ||
| struct valid_extent<SizeType, dynamic_extent> { |
Collaborator
There was a problem hiding this comment.
I think we can simplify the implementation even more:
Now that the fast_int member has been removed, valid_extent is functionally the same as extent, but only allows for private construction through friend factories (make_valid_extent). There's also no longer a need for disallowing implicit conversions to SizeType.
The cleanest option is valid_extent inheriting from the corresponding extentdirectly:
template <typename SizeType, std::size_t N>
class valid_extent : public extent<SizeType, N> {
using base_type = extent<SizeType, N>;
public:
using value_type = typename base_type::value_type;
constexpr value_type value() const noexcept
{
return base_type::operator value_type();
}
private:
explicit constexpr valid_extent(value_type value = {}) noexcept
: base_type{value}
{
}
// Factory friends
};This would:
- Delete the dynamic
valid_extentspecialization. - Reuse
extent’s static/dynamic storage behavior. - Preserve private construction and explicit conversion.
- Preserve empty-base optimization for static extents.
- Keep the shared arithmetic operators unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #838.
Removed dynamic valid_extent specialization, because as of #836 / #837, fast_int's modulo utility is no longer needed by valid_extent. Made valid_extent inherit from extent, allowing valid_extent to reuse extent's existing static/dynamic behavior. valid_extent.value() is inlined with no additional instructions (verified by PTX analysis). Changed struct valid_extent to class valid_extent.