[test-suite] r332659 - [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Thu May 17 13:32:55 PDT 2018
Author: jlebar
Date: Thu May 17 13:32:55 2018
New Revision: 332659
URL: http://llvm.org/viewvc/llvm-project?rev=332659&view=rev
Log:
[test-suite] Test CUDA in C++14 mode with C++11 stdlibs.
Summary:
Previously (D46993) std::min/max didn't work in C++14 mode with a C++11
stdlib; we'd assumed that compiler std=c++14 implied stdlib in C++14
mode.
Reviewers: tra
Subscribers: sanjoy, mgorny, llvm-commits, rsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D46994
Modified:
test-suite/trunk/External/CUDA/CMakeLists.txt
test-suite/trunk/External/CUDA/algorithm.cu
test-suite/trunk/External/CUDA/cmath.cu
test-suite/trunk/External/CUDA/complex.cu
Modified: test-suite/trunk/External/CUDA/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/CUDA/CMakeLists.txt?rev=332659&r1=332658&r2=332659&view=diff
==============================================================================
--- test-suite/trunk/External/CUDA/CMakeLists.txt (original)
+++ test-suite/trunk/External/CUDA/CMakeLists.txt Thu May 17 13:32:55 2018
@@ -316,10 +316,6 @@ macro(create_cuda_tests)
set(_Std_LDFLAGS -std=${_Std})
foreach(_GccPath IN LISTS GCC_PATHS)
get_version(_GccVersion ${_GccPath})
- # libstdc++ seems not to support C++14 before version 5.0.
- if(${_Std} STREQUAL "c++14" AND ${_GccVersion} VERSION_LESS "5.0")
- continue()
- endif()
set(_Gcc_Suffix "libstdc++-${_GccVersion}")
# Tell clang to use libstdc++ and where to find it.
set(_Stdlib_CPPFLAGS -stdlib=libstdc++ -gcc-toolchain ${_GccPath})
@@ -327,17 +323,26 @@ macro(create_cuda_tests)
# Add libstdc++ as link dependency.
set(_Stdlib_Libs libstdcxx-${_GccVersion})
+ # libstdc++ seems not to support C++14 before version 5.0. We still
+ # want to run in C++14 mode with old libstdc++s to test compiler C++14
+ # with stdlib C++11, but we add a -D so that our tests can detect this.
+ if (${_GccVersion} VERSION_LESS "5.0")
+ list(APPEND _Stdlib_CPPFLAGS -DSTDLIB_VERSION=2011)
+ else()
+ list(APPEND _Stdlib_CPPFLAGS -DSTDLIB_VERSION=2014)
+ endif()
+
create_cuda_test_variant(${_Std} "${_Cuda_Suffix}-${_Std_Suffix}-${_Gcc_Suffix}")
endforeach()
if(HAVE_LIBCXX)
- # Same as above, but for libc++
- # Tell clang to use libc++
- # We also need to add compiler's include path for cxxabi.h
- get_filename_component(_compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY)
- set(_Stdlib_CPPFLAGS -stdlib=libc++ -I${_compiler_path}/../include/c++-build)
- set(_Stdlib_LDFLAGS -stdlib=libc++)
- set(_Stdlib_Libs libcxx)
+ # Same as above, but for libc++
+ # Tell clang to use libc++
+ # We also need to add compiler's include path for cxxabi.h
+ get_filename_component(_compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY)
+ set(_Stdlib_CPPFLAGS -stdlib=libc++ -I${_compiler_path}/../include/c++-build -DSTDLIB_VERSION=2017)
+ set(_Stdlib_LDFLAGS -stdlib=libc++)
+ set(_Stdlib_Libs libcxx)
create_cuda_test_variant(${_Std} "${_Cuda_Suffix}-${_Std_Suffix}-libc++")
endif()
endforeach()
Modified: test-suite/trunk/External/CUDA/algorithm.cu
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/CUDA/algorithm.cu?rev=332659&r1=332658&r2=332659&view=diff
==============================================================================
--- test-suite/trunk/External/CUDA/algorithm.cu (original)
+++ test-suite/trunk/External/CUDA/algorithm.cu Thu May 17 13:32:55 2018
@@ -27,7 +27,7 @@ __device__ void max() {
// initializer_lists until C++14, when it gets these for free from the standard
// library (because they're constexpr).
__device__ void cpp14_tests() {
-#if __cplusplus >= 201402L
+#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014
assert(std::greater<int>()(1, 0));
assert(std::min({5, 1, 10}) == 1);
assert(std::max({5, 1, 10}, std::less<int>()) == 10);
Modified: test-suite/trunk/External/CUDA/cmath.cu
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/CUDA/cmath.cu?rev=332659&r1=332658&r2=332659&view=diff
==============================================================================
--- test-suite/trunk/External/CUDA/cmath.cu (original)
+++ test-suite/trunk/External/CUDA/cmath.cu Thu May 17 13:32:55 2018
@@ -1145,7 +1145,7 @@ __device__ void test_hypot()
assert(std::hypot(3.f, 4.) == 5);
assert(std::hypot(3.f, 4.f) == 5);
-#if TEST_STD_VER > 14
+#if __cplusplus >= 201703L && STDLIB_VERSION >= 2017
static_assert((std::is_same<decltype(std::hypot((float)0, (float)0, (float)0)), float>::value), "");
static_assert((std::is_same<decltype(std::hypot((float)0, (bool)0, (float)0)), double>::value), "");
static_assert((std::is_same<decltype(std::hypot((float)0, (unsigned short)0, (double)0)), double>::value), "");
@@ -1158,8 +1158,8 @@ __device__ void test_hypot()
static_assert((std::is_same<decltype(std::hypot((int)0, (int)0, (int)0)), double>::value), "");
static_assert((std::is_same<decltype(hypot(Ambiguous(), Ambiguous(), Ambiguous())), Ambiguous>::value), "");
- assert(std::hypot(2,3,6) == 7);
- assert(std::hypot(1,4,8) == 9);
+ assert(std::hypot(2, 3, 6) == 7);
+ assert(std::hypot(1, 4, 8) == 9);
#endif
}
Modified: test-suite/trunk/External/CUDA/complex.cu
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/CUDA/complex.cu?rev=332659&r1=332658&r2=332659&view=diff
==============================================================================
--- test-suite/trunk/External/CUDA/complex.cu (original)
+++ test-suite/trunk/External/CUDA/complex.cu Thu May 17 13:32:55 2018
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include <assert.h>
-#include <stdio.h>
-#include <complex>
-
// These are loosely adapted from libc++'s tests. In general, we don't care a
// ton about verifying the return types or results we get, on the assumption
// that our standard library is correct. But we care deeply about calling every
@@ -19,13 +15,21 @@
// We do care about the results of complex multiplication / division, since
// these use code we've written.
+#include <stdio.h>
+
// These tests are pretty annoying to write without C++11, so we require that.
// In addition, these tests currently don't compile with libc++, because of the
// issue in https://reviews.llvm.org/D25403.
//
// TODO: Once that issue is resolved, take out !defined(_LIBCPP_VERSION) here.
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION)
+//
+// In addition, these tests don't work in C++14 mode with pre-C++14 versions of
+// libstdc++ (compile errors in <complex>).
+#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
+ (__cplusplus < 201402L || STDLIB_VERSION >= 2014)
+#include <assert.h>
+#include <complex>
#include <type_traits>
template <class T>
@@ -69,7 +73,7 @@ __device__ void test_promotion() {
}
__device__ void test_literals() {
-#if __cplusplus >= 201402L
+#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014
using namespace std::literals::complex_literals;
{
More information about the llvm-commits
mailing list