-
Notifications
You must be signed in to change notification settings - Fork 933
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
rapids-bot
merged 4 commits into
rapidsai:branch-25.02
from
PointKernel:rm-test-constexpr
Jan 10, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Copyright 2019 BlazingDB, Inc. | ||
* Copyright 2019 Eyal Rozenberg <[email protected]> | ||
* Copyright (c) 2020-2024, NVIDIA CORPORATION. | ||
* Copyright (c) 2020-2025, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -23,6 +23,8 @@ | |
*/ | ||
|
||
#include <cudf/fixed_point/temporary.hpp> | ||
#include <cudf/types.hpp> | ||
#include <cudf/utilities/error.hpp> | ||
|
||
#include <cmath> | ||
#include <cstdlib> | ||
|
@@ -44,13 +46,17 @@ namespace util { | |
* `modulus` is positive. The safety is in regard to rollover. | ||
*/ | ||
template <typename S> | ||
constexpr S round_up_safe(S number_to_round, S modulus) | ||
CUDF_HOST_DEVICE constexpr S round_up_safe(S number_to_round, S modulus) | ||
{ | ||
auto remainder = number_to_round % modulus; | ||
if (remainder == 0) { return number_to_round; } | ||
auto rounded_up = number_to_round - remainder + modulus; | ||
if (rounded_up < number_to_round) { | ||
throw std::invalid_argument("Attempt to round up beyond the type's maximum value"); | ||
#ifndef __CUDA_ARCH__ | ||
CUDF_FAIL("Attempt to round up beyond the type's maximum value", cudf::data_type_error); | ||
#else | ||
CUDF_UNREACHABLE("Attempt to round up beyond the type's maximum value"); | ||
#endif | ||
} | ||
return rounded_up; | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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 is not ideal but necessary because
base_2dspan
serves as a convenient base class, whilehost_2dspan
anddevice_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__
.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.
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 frombase_2dspan
rather than dealing with this.When we move to C++20 we'll be able to use
std::span
(and presumablycuda::std::span
) so hopefully this becomes a moot point then.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.
Good point.
Will doDoneActually,
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 customdevice_span
and host_span.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.
Yeah I think we may as well wait for C++20 so we can use
host_span
properly.