Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Add more dialects to host only TU tests (#346)
Browse files Browse the repository at this point in the history
* Expand host TU testing up to c++20, clear test files during compose to save space
* Fix missing H/D annotations in cmath
* Fix Span using deduction guides in gcc-6+c++17.
* Block gcc-6 on deduction guides test in <span>
* Remove compiler exclusion test from host_only tests, add a try_compile for dialect instead
* Fix usage of long double builtins on newer MSVC versions
  • Loading branch information
wmaxey authored Feb 1, 2023
1 parent 1e0b242 commit 7120c63
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 21 deletions.
55 changes: 44 additions & 11 deletions .upstream-tests/test/host_only/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
function(libcudacxx_add_standalone_header_test test_file_output_var header_under_test)
add_custom_target(libcudacxx_tu_tests)

set(cpp_std_versions 11 14 17 20)

set(cpp_11_exclusions)
set(cpp_14_exclusions)
set(cpp_17_exclusions)
set(cpp_20_exclusions)

function(libcudacxx_add_standalone_header_test test_file_output_var header_under_test version)
# ex: build/.../header_tests/cuda/std/version.cpp
set(test_cpp "${CMAKE_CURRENT_BINARY_DIR}/header_tests/${header_under_test}.cpp")

Expand All @@ -9,22 +18,46 @@ function(libcudacxx_add_standalone_header_test test_file_output_var header_under

set(${test_file_output_var} ${test_cpp} PARENT_SCOPE)
# ex: cuda/std/version -> cuda_std_version
string(REPLACE "/" "_" executable_name ${header_under_test})
add_executable(${executable_name} ${test_cpp})
target_include_directories(${executable_name} PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_compile_options(${executable_name} PRIVATE

string(REPLACE "/" "_" executable_name "${header_under_test}-${version}")
list(FIND cpp_${version}_exclusions ${header_under_test} header_excluded)

if ("${header_excluded}" EQUAL "-1")
add_library(${executable_name} OBJECT ${test_cpp})
target_include_directories(${executable_name} PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_compile_options(${executable_name} PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Werror>
-Wall -Werror>
$<$<CXX_COMPILER_ID:MSVC>:
/W4 /WX>)
set_target_properties(${executable_name} PROPERTIES CXX_STANDARD 11)
/W4 /WX>)
set_target_properties(${executable_name} PROPERTIES CXX_STANDARD ${version})
set_target_properties(${executable_name} PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(${executable_name} PROPERTIES CXX_EXTENSIONS OFF)
add_dependencies(libcudacxx_tu_tests ${executable_name})
endif()

endfunction()

# Don't generate CUDA targets, they fail currently.
# file(GLOB cuda_headers LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/cuda/*)
file(GLOB cuda_std_headers LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/cuda/std/*)

foreach(header IN LISTS cuda_headers cuda_std_headers)
libcudacxx_add_standalone_header_test(test_file ${header})
message(STATUS "Detected ${header} ... Writing ${test_file}")
foreach(version IN LISTS cpp_std_versions)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(cxx_version "/std:c++${version}")
else()
set(cxx_version "-std=c++${version}")
endif()

try_compile(
dialect_supported
${CMAKE_BINARY_DIR}/dialect_check_${version} "${CMAKE_CURRENT_SOURCE_DIR}/detect_dialect.cpp"
COMPILE_DEFINITIONS ${cxx_version}
)

if (dialect_supported)
foreach(header IN LISTS cuda_headers cuda_std_headers)
libcudacxx_add_standalone_header_test(test_file ${header} ${version})
endforeach()
endif()
endforeach()
7 changes: 7 additions & 0 deletions .upstream-tests/test/host_only/detect_dialect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <type_traits>
#include <atomic>
#include <thread>

int main() {
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14

// gcc-6 does not support deduction guides until 7
// UNSUPPORTED: gcc-6

// <span>

// template<class It, class EndOrSize>
Expand Down Expand Up @@ -94,6 +97,6 @@ int main(int, char**)
test_iterator_sentinel();
test_c_array();
test_std_array();

return 0;
}
6 changes: 3 additions & 3 deletions environments/linux/docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
args: &ubuntu22-args
BUILDKIT_INLINE_CACHE: "1"
USE_LLVM_INSTALLER: "1"
ROOT_IMAGE: "nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu22.04"
ROOT_IMAGE: "nvcr.io/nvidia/cuda:12.0.0-devel-ubuntu22.04"
COMPILERS: "g++-11 g++-12 clang-11 clang-12 clang-13 clang-14 clang-15"
deploy: &deploy-template
resources:
Expand All @@ -38,7 +38,7 @@ services:
args: &ubuntu20-args
BUILDKIT_INLINE_CACHE: "1"
USE_LLVM_INSTALLER: 0
ROOT_IMAGE: "nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu20.04"
ROOT_IMAGE: "nvcr.io/nvidia/cuda:12.0.0-devel-ubuntu20.04"
COMPILERS: "g++-8 g++-9 g++-10 clang-8 clang-9 clang-10"
deploy: *deploy-template

Expand All @@ -56,7 +56,7 @@ services:
args: &ubuntu18-args
BUILDKIT_INLINE_CACHE: "1"
USE_LLVM_INSTALLER: 0
ROOT_IMAGE: "nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu18.04"
ROOT_IMAGE: "nvcr.io/nvidia/cuda:12.0.0-devel-ubuntu18.04"
COMPILERS: "g++-6 g++-7 clang-7"
deploy: *deploy-template

Expand Down
5 changes: 3 additions & 2 deletions environments/linux/docker/ubuntu.base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ ADD ./.upstream-tests/utils /libcudacxx/utils

# Install compiler and configure project
RUN cmake -S /libcudacxx -B /build \
-G Ninja \
-DLIBCUDACXX_ENABLE_STATIC_LIBRARY=OFF \
-DLIBCUDACXX_ENABLE_LIBCUDACXX_TESTS=ON \
-DLIBCUDACXX_ENABLE_LIBCXX_TESTS=ON \
Expand All @@ -88,8 +89,8 @@ RUN cmake -S /libcudacxx -B /build \
-DCMAKE_CUDA_COMPILER=${CUDACXX_PATH} \
-DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler"

RUN make -j -C /build/libcxx
RUN make -j -C /build/test/host_only
RUN ninja -C /build libcudacxx_tu_tests && ninja -C /build clean
RUN ninja -C /build cxx

ENV LIBCUDACXX_SITE_CONFIG=/build/test/lit.site.cfg
ENV LIBCXX_SITE_CONFIG=/build/libcxx/test/lit.site.cfg
8 changes: 4 additions & 4 deletions include/cuda/std/detail/libcxx/include/span
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ public:
#endif
template <class _OtherElementType, enable_if_t<
is_convertible<_OtherElementType(*)[], element_type (*)[]>::value, nullptr_t> = nullptr>
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14
span( array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
template <class _OtherElementType, enable_if_t<
is_convertible<_OtherElementType(*)[], element_type (*)[]>::value, nullptr_t> = nullptr>
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14
span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}

template <class _OtherElementType, enable_if_t<
Expand Down Expand Up @@ -501,7 +501,7 @@ public:
_LIBCUDACXX_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }

_LIBCUDACXX_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept
{ return {reinterpret_cast<const byte *>(data()), size_bytes()}; }

Expand All @@ -528,7 +528,7 @@ auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept

#endif // _LIBCUDACXX_STD_VER > 11

#if _LIBCUDACXX_STD_VER > 14
#if _LIBCUDACXX_STD_VER > 14 && !defined(_LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES)

// Deduction guides
template<class _Tp, size_t _Sz>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@
#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L

// __builtin replacements/workarounds
#if _MSC_VER < 1934
#define __builtin_huge_vall() _LInf._Long_double
#define __builtin_nanl(__dummmy) _LNan._Long_double
#define __builtin_nansl(__dummy) _LSnan._Long_double
#else
#define __builtin_huge_vall() __builtin_huge_val()
#define __builtin_nanl(__v) __builtin_nan(__v)
#define __builtin_nansl(__v) __builtin_nans(__v)
#endif

#endif // _LIBCUDACXX_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H

0 comments on commit 7120c63

Please sign in to comment.