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

Require C++17 #5277

Merged
merged 9 commits into from
Aug 3, 2022
Merged

Require C++17 #5277

merged 9 commits into from
Aug 3, 2022

Conversation

masterleinad
Copy link
Contributor

@masterleinad masterleinad commented Jul 27, 2022

This still needs to update compiler requirements.

Makefile.kokkos Outdated Show resolved Hide resolved
@@ -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;
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

ok cool

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Member

@dalg24 dalg24 left a 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

Copy link
Member

@crtrott crtrott left a 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)

@masterleinad
Copy link
Contributor Author

Require C++17, update the CI build but do not start changing the code that you do not absolutely have to in this PR

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 STATIC_ASSERT changes, basically only remove guards). I don't mind pushing these changes to a separate pull request in the end.

.jenkins Outdated Show resolved Hide resolved
@crtrott
Copy link
Member

crtrott commented Jul 27, 2022

GCC 7.3
Clang 8.0
Intel 19.1
CUDA 11.0
ROCM 5.2

@PhilMiller
Copy link
Contributor

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

@PhilMiller
Copy link
Contributor

There's also a noted correction for DRs regarding CTAD in GCC 8 per https://gcc.gnu.org/projects/cxx-status.html#cxx17

@masterleinad masterleinad force-pushed the require_cxx_17 branch 3 times, most recently from 425500b to 47fff75 Compare July 28, 2022 17:59
@masterleinad
Copy link
Contributor Author

CUDA-11.7-NVCC is still failing in cuda.reducers_bhalf_t. Otherwise, things are looking good in my opinion.
All that's left then is to finalize the minimum compiler version requirements.

@masterleinad
Copy link
Contributor Author

This still relies on #5286 for updating one CI build.

@masterleinad
Copy link
Contributor Author

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.

@masterleinad masterleinad marked this pull request as ready for review July 29, 2022 19:29
.jenkins Outdated Show resolved Hide resolved
Makefile.kokkos Outdated Show resolved Hide resolved
Makefile.kokkos Outdated Show resolved Hide resolved
bin/nvcc_wrapper Outdated Show resolved Hide resolved
bin/nvcc_wrapper Outdated
fi
shared_args="$shared_args $std_flag"
;;
--std=c++11|-std=c++11|--std=c++14|-std=c++14)
Copy link
Member

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?

Copy link
Contributor Author

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.

cmake/kokkos_test_cxx_std.cmake Show resolved Hide resolved
@@ -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.")
Copy link
Member

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

@@ -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
Copy link
Contributor Author

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
Copy link
Contributor Author

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)
Copy link
Contributor Author

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.

cmake/kokkos_test_cxx_std.cmake Show resolved Hide resolved
bin/nvcc_wrapper Outdated Show resolved Hide resolved

int main() {
// _v versions of type traits were added in C++17
constexpr bool same = std::is_same_v<double, int>;
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added if constexpr but also kept std::is_same_v since the test case was initially designed to detect a working toolchain (with recent enough gcc headers), see #3809 and #3789.

Copy link
Member

@dalg24 dalg24 left a 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)
Copy link
Member

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?

Copy link
Contributor Author

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) && \
Copy link
Member

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?

Copy link
Contributor Author

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.

@masterleinad
Copy link
Contributor Author

I'd like for someone else to look over the nvcc_wrapper changes

I'm also fine splitting the nvcc_wrapper changes from this pull request if we have doubts about dropping C++14 and earlier support from it.

Copy link
Member

@crtrott crtrott left a 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.

@masterleinad
Copy link
Contributor Author

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.

@masterleinad
Copy link
Contributor Author

SYCL CI timing out is unrelated. That build required C++17 already.

@crtrott crtrott merged commit d052ce8 into kokkos:develop Aug 3, 2022
@masterleinad masterleinad mentioned this pull request Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants