-
Notifications
You must be signed in to change notification settings - Fork 407
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
Require C++17 #5277
Require C++17 #5277
Conversation
f7d26e7
to
5de8588
Compare
core/src/Kokkos_Core.hpp
Outdated
@@ -102,8 +102,8 @@ void declare_configuration_metadata(const std::string& category, | |||
|
|||
} // namespace Impl | |||
|
|||
KOKKOS_ATTRIBUTE_NODISCARD bool is_initialized() noexcept; | |||
KOKKOS_ATTRIBUTE_NODISCARD bool is_finalized() noexcept; | |||
[[nodiscard]] bool is_initialized() noexcept; |
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.
before we do this, can we check that every minimum compiler supports this?
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.
https://godbolt.org/z/5Pz8jWeqo shows that the minimal compiler versions (godbolt has) are clang-5
, MSVC 14
, GCC 7.1
, and ICC 18.0.0
.
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.
ok cool
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.
Following https://en.cppreference.com/w/cpp/compiler_support/17, these compiler versions are good candidates anyway. Additionally, that would suggest ICC 19.0.0 (if constexpr), msvc 19.15 (std::is_aggregate), no changes for IntelLLVM, whatever HIPCC (we are already testing with C++17 support in one build with the minimum), nvcc 11.0, pgi 19.1.
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.
From my experience doing some of the downstream porting and testing work on Intel 'classic', you need 19.0.1, and I recommend Intel 19.0.5 or 19.1. The bare 19.0 is painfully buggy, and even 19.0.[1-4] are pretty bad. The Trilinos ATDM configuration I got added was for 19.0.5, so I don't think you'll get any complaints about picking that. 19.1 avoids some further bugs and stupid workarounds that shouldn't be necessary.
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.
Apparently, Intel "19.0.5" as reported on the command line icpc --version
is actually 19.5 as reported by the compiler's macros. We'll need to see what CMake thinks of it
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.
Require C++17, update the CI build but do not start changing the code that you do not absolutely have to in this PR
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.
Looks pretty good. Lets decide what to do with the other standard options, and also change the CI to include minimum compilers, and do a manual check with other minimum compilers (e.g. Intel 19.1)
I honestly feel much better if we have the CI pass with all these changes (which for the most part, i.e., basically without the |
GCC 7.3 |
There are a number of ICE cases that code generated by nvcc triggers in GCC 7.x for x<5. Since 7.3 was a deployed standard on a lot of lab systems, and 7.5 wasn't, we may want to require GCC 8.y or 9.z instead |
There's also a noted correction for DRs regarding CTAD in GCC 8 per https://gcc.gnu.org/projects/cxx-status.html#cxx17 |
425500b
to
47fff75
Compare
|
This still relies on #5286 for updating one CI build. |
595e6ff
to
5ee2715
Compare
5ee2715
to
808091b
Compare
Apart from updating compiler versions (which we likely could do separately), this should be ready now. I pushed all other cleanup that was initially here and that isn't required to #5295. |
bin/nvcc_wrapper
Outdated
fi | ||
shared_args="$shared_args $std_flag" | ||
;; | ||
--std=c++11|-std=c++11|--std=c++14|-std=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.
Did you mean to remove that line?
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.
Yes, [-]-std=c++17
is the only language flag we need to support for now and we require >=cuda-11 anyway.
@@ -49,11 +49,11 @@ ENDIF() | |||
|
|||
IF (KOKKOS_CXX_STANDARD STREQUAL 17) | |||
IF (KOKKOS_CXX_COMPILER_ID STREQUAL GNU AND KOKKOS_CXX_COMPILER_VERSION VERSION_LESS 7) | |||
MESSAGE(FATAL_ERROR "You have requested C++17 support for GCC ${KOKKOS_CXX_COMPILER_VERSION}. Although CMake has allowed this and GCC accepts -std=c++1z/c++17, GCC < 7 does not properly support *this capture. Please reduce the C++ standard to 14 or upgrade the compiler if you do need C++17 support.") | |||
MESSAGE(FATAL_ERROR "You have requested C++17 support for GCC ${KOKKOS_CXX_COMPILER_VERSION}. Although CMake has allowed this and GCC accepts -std=c++1z/c++17, GCC < 7 does not properly support *this capture. Please upgrade the compiler if you do need C++17 support.") |
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.
The entire IF (KOKKOS_CXX_STANDARD STREQUAL 17)
block is to be removed when we complete the full transition. Maybe mark it as a FIXME_CXX17
c53e24f
to
d1cb589
Compare
@@ -330,14 +316,11 @@ endif | |||
|
|||
# Set C++ version flags. | |||
ifeq ($(KOKKOS_INTERNAL_COMPILER_PGI), 1) | |||
KOKKOS_INTERNAL_CXX14_FLAG := --c++14 | |||
KOKKOS_INTERNAL_CXX17_FLAG := --c++17 | |||
KOKKOS_INTERNAL_CXX20_FLAG := --c++20 | |||
KOKKOS_INTERNAL_CXX23_FLAG := --c++23 | |||
else |
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.
For PGI, CMake
gives https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/Compiler/PGI-CXX.cmake, i.e., only support up to C++17.
KOKKOS_INTERNAL_CXX17_FLAG := --c++17 | ||
KOKKOS_INTERNAL_CXX20_FLAG := --c++20 | ||
KOKKOS_INTERNAL_CXX23_FLAG := --c++23 | ||
else | ||
ifeq ($(KOKKOS_INTERNAL_COMPILER_XL), 1) | ||
KOKKOS_INTERNAL_CXX14_FLAG := -std=c++14 | ||
KOKKOS_INTERNAL_CXX1Y_FLAG := -std=c++1y | ||
KOKKOS_INTERNAL_CXX17_FLAG := -std=c++17 | ||
KOKKOS_INTERNAL_CXX1Z_FLAG := -std=c++1z | ||
KOKKOS_INTERNAL_CXX20_FLAG := -std=c++20 |
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.
According to https://en.cppreference.com/w/cpp/compiler_support/17 and https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/Compiler/XL-CXX.cmake, XL
doesn't really have C++17 support, so I guess we can just drop it.
bin/nvcc_wrapper
Outdated
fi | ||
shared_args="$shared_args $std_flag" | ||
;; | ||
--std=c++11|-std=c++11|--std=c++14|-std=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.
Yes, [-]-std=c++17
is the only language flag we need to support for now and we require >=cuda-11 anyway.
70624bb
to
7b0fedf
Compare
cmake/compile_tests/cplusplus17.cpp
Outdated
|
||
int main() { | ||
// _v versions of type traits were added in C++17 | ||
constexpr bool same = std::is_same_v<double, int>; |
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.
Is it salient that this is testing a standard library feature, rather than a compiler feature? Variable templates themselves were part of C++14, so a standard library implementation could provide an implementation for this that would compile under 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.
Previously, we had std::remove_cv_t<int> i = 0;
for C++14.
I am happy to hear other suggestions. What about if constexpr
?
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.
As an edge example, libstdc++ as shipped with GCC 7.1 would pass this, though we're planning to set at least 7.3 as the minimum per #5285
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.
Given that if constexpr
is probably one of the most desirable headline features for us, that seems quite suitable as a target.
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.
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.
Looks mostly ok
I'd like for someone else to look over the nvcc_wrapper
changes
@@ -195,6 +195,7 @@ struct ErrorReporterDriverUseLambda | |||
void execute(int reporter_capacity, int test_size) { | |||
Kokkos::parallel_for( | |||
Kokkos::RangePolicy<execution_space>(0, test_size), | |||
// NOLINTNEXTLINE(kokkos-implicit-this-capture) |
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.
Wait what? Does that mean there is a bug in the clang-tidy check?
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.
#if defined(KOKKOS_CLASS_LAMBDA) && \ | ||
// FIXME_MSVC MSVC just gets confused when using the base class in the | ||
// KOKKOS_CLASS_LAMBDA | ||
#if !defined(KOKKOS_COMPILER_MSVC) && defined(KOKKOS_CLASS_LAMBDA) && \ |
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.
Isn't KOKKOS_CLASS_LAMDA
always defined now?
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.
Yes, it is, but I avoided doing all the cleanup in this pull request.
I'm also fine splitting the |
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.
Lets leave nvcc_wrapper more or less alone. I don't think we need to make it not deal with cpp14. In particular since some folks use it independent of Kokkos.
Sure. I reverted those changes. |
SYCL CI timing out is unrelated. That build required C++17 already. |
This still needs to update compiler requirements.