-
Notifications
You must be signed in to change notification settings - Fork 187
Backports C++17/20 <chrono> features to C++14 #45
Conversation
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.
How many tests are there that require relaxed constexpr? Could we perhaps have a mode where we don't enable the flag, add a feature that let's tests know it's not added, and XFAIL or UNSUPPORTED them when the flag is not on?
@brycelelbach any opinions on that? Another option would be to wrap the offending code in the check for relaxed constexpr, but I think we talked about that and discarded it as an option previously?
Otherwise this looks good, but I'd like to resolve the question above first. I have a feeling that without a mode without that flag, we may accidentally brick NVRTC completely by introducing a constexpr function without an annotation somewhere; I want to make sure we don't accidentally force end users to add NVRTC flags that shouldn't be necessary. (NVCC users should be able to deal with it, maybe just not be able to use some functionality on the device side - NVRTC however errors when it merely parses a host definition, so NVRTC users would just be bricked if we miss something because of this flag.)
...sts/test/std/utilities/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/streaming.pass.cpp
Show resolved
Hide resolved
|
||
#include "test_macros.h" | ||
|
||
#if TEST_STD_VER > 14 |
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 assume this is consciously C++17 only? Or you just missed it? (Same in the next file.)
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.
Nope, looks like I missed it. I wasn't as diligent about checking test files for pre-processor C++ version checks.
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.
So I looked into this further. These tests are guarded with TEST_STD_VER > 14
because they are testing functionality that wasn't made constexpr
until C++17, e.g., https://en.cppreference.com/w/cpp/chrono/time_point/operator_arith
It doesn't appear there's any language reason these operations can't be made constexpr
in C++14. Are we comfortable with backporting the constexpr
ness of these operations from C++17 to C++14?
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.
Do you need them be constexpr in C++14? I think it'd be fine if there's nothing C++17 specific in that code, given we are already backporting parts of this, but I'm unsure here.
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 don't think we have a strong need for this to be constexpr
, but if we're already backporting, might as well?
Yah, let's not assume relaxed constexpr. It's fine to have some separate tests that are relaxed constexpr specific. |
Sure, how do I configure it so that only some tests are compiled with relaxed constexpr? |
So it turns out that we don't need I originally had thought it was necessary because the tests were ODR using |
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.
LGTM, I'll start doing CI runs on your changes today.
992563e
to
5935716
Compare
nvcc was failing to compile this file due to the square brackets in the file name.
5935716
to
200b22a
Compare
Previously I had consolidated _LIBUCDACXX_STD_VER > 11 version checks, but neglected that this ended up guarding the closing of the chrono namespace. Therefore, the chrono namespace was never properly closed in C++11 mode.
Explicitly using the cuda::std:: namespace to access the February global breaks libc++. Changed to use the unqualified name and store it into a reserved name local. Also added a comment on why this is necessary.
Internal CI launched on CL 29332841. |
MSVC complained about the possible loss of precision casting an unsigned to an unsigned char.
Relaunched internal CI on CL 29338478. |
Relaunched internal CI on CL 29342510. |
Depends on #44
Moves
<chrono>
features guarded to C++17/20 to C++14Adds missing
_LIBCUDACXX_INLINE_VISIBILITY
functions in<chrono>
to ensure they are annotated with__host__ __device__
Backports libc++
std/utilities/time
tests that were previously only tested in C++17/20 to be tested with C++14Added explicit casts to
operator-
forweekday
to workaround an NVCC bugRemoved theThis turned out to not be possible because compilers warn on the "user" defined literal._LIBCUDACXX_HAS_NO_CXX20_CHRONO_LITERALS
definition since the literals were backportedPorting the tests required a few changes/workarounds to upstream tests:
Updated tests to build with
--expt-relaxed-constexpr
to allow accessingconstexpr
globals from<chrono>
in device codenvcc
does not support ODR-user ofconstexpr
global variables (e.g.,cuda::std::chrono::March
). To workaround, in several tests I created aconstexpr
local copy of the global, e.g.,Rename
operator[].pass.cpp
tooperator_index.pass.cpp
becausenvcc
doesn't like square brackets in a file nameMarked the following tests as XFAIL with gcc below 7.0 due to gcc bug:
time/time.cal/time.cal.ymdlast/time.cal.ymdlast.members/plus_minus_equal_month.pass.cpp
time/time.cal/time.cal.ymdlast/time.cal.ymdlast.members/plus_minus_equal_year.pass.cpp
time/time.cal/time.cal.ymwd/time.cal.ymwd.members/plus_minus_equal_month.pass.cpp
time/time.cal/time.cal.ymwd/time.cal.ymwd.members/plus_minus_equal_year.pass.cpp