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

Make tests build without relaxed constexpr #17691

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

PointKernel
Copy link
Member

Description

Contributes to #7795

This PR updates tests to build without depending on the relaxed constexpr build option.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@PointKernel PointKernel added feature request New feature or request 3 - Ready for Review Ready for review by team libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change labels Jan 7, 2025
@PointKernel PointKernel self-assigned this Jan 7, 2025
@PointKernel PointKernel requested a review from a team as a code owner January 7, 2025 23:43
@@ -201,7 +201,7 @@ struct host_span : public cudf::detail::span_base<T, Extent, host_span<T, Extent
/// @param data Pointer to the first element in the span
/// @param size The number of elements in the span
/// @param is_device_accessible Whether the data is device accessible (e.g. pinned memory)
constexpr host_span(T* data, std::size_t size, bool is_device_accessible)
CUDF_HOST_DEVICE constexpr host_span(T* data, std::size_t size, bool is_device_accessible)
Copy link
Member Author

@PointKernel PointKernel Jan 7, 2025

Choose a reason for hiding this comment

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

This is not ideal but necessary because base_2dspan serves as a convenient base class, while host_2dspan and device_2dspan are essentially type aliases of the base. As a result, all member functions in the base must be marked as __host__ __device__. Consequently, the host span constructor invoked by these base member functions must also be __host__ __device__.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that this tradeoff is worthwhile, but could we add a comment indicating that this is the rationale? When I first started trying to remove --expt-relaxed-constexpr I considered going the opposite route and pushing a lot of logic down from base_2dspan rather than dealing with this.

When we move to C++20 we'll be able to use std::span (and presumably cuda::std::span) so hopefully this becomes a moot point then.

Copy link
Member Author

@PointKernel PointKernel Jan 9, 2025

Choose a reason for hiding this comment

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

could we add a comment indicating that this is the rationale?

Good point. Will do Done

Actually, cuda::std::span is backported to C++17, so it is already available for use. However, I’m not sure if it is mature enough to replace our custom device_span and host_span.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think we may as well wait for C++20 so we can use host_span properly.

Copy link
Contributor

@shrshi shrshi left a comment

Choose a reason for hiding this comment

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

Looks good! One question -

@PointKernel PointKernel requested a review from vyasr January 9, 2025 18:32
@@ -201,7 +201,7 @@ struct host_span : public cudf::detail::span_base<T, Extent, host_span<T, Extent
/// @param data Pointer to the first element in the span
/// @param size The number of elements in the span
/// @param is_device_accessible Whether the data is device accessible (e.g. pinned memory)
constexpr host_span(T* data, std::size_t size, bool is_device_accessible)
CUDF_HOST_DEVICE constexpr host_span(T* data, std::size_t size, bool is_device_accessible)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think we may as well wait for C++20 so we can use host_span properly.

@PointKernel
Copy link
Member Author

/merge

@rapids-bot rapids-bot bot merged commit fb2413e into rapidsai:branch-25.02 Jan 10, 2025
106 checks passed
@PointKernel PointKernel deleted the rm-test-constexpr branch January 10, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants