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

Test CUDA in all supported Standard modes. #4974

Merged
merged 5 commits into from
Sep 28, 2024

Conversation

fsb4000
Copy link
Contributor

@fsb4000 fsb4000 commented Sep 21, 2024

Fixes #4965

  1. I didn't figure out why -std=c++17 is failing without D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS and -std=c++20 is not failing.
    I got the error:
C:\Dev\STL\out\x64\out\inc\ccomplex(21): error C2220: the following warning is treated as an error
C:\Dev\STL\out\x64\out\inc\ccomplex(21): warning C4996: '_Header_ccomplex': warning STL4004: <ccomplex>, <cstdalign>, <cstdbool>, and <ctgmath> are deprecated in C++17. You can define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
C:\Dev\STL\out\x64\out\inc\cstdalign(22): warning C4996: '_Header_cstdalign': warning STL4004: <ccomplex>, <cstdalign>, <cstdbool>, and <ctgmath> are deprecated in C++17. You can define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
C:\Dev\STL\out\x64\out\inc\cstdbool(21): warning C4996: '_Header_cstdbool': warning STL4004: <ccomplex>, <cstdalign>, <cstdbool>, and <ctgmath> are deprecated in C++17. You can define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
C:\Dev\STL\out\x64\out\inc\ctgmath(22): warning C4996: '_Header_ctgmath': warning STL4004: <ccomplex>, <cstdalign>, <cstdbool>, and <ctgmath> are deprecated in C++17. You can define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
  1. C++23 is not supported as far as I tried:
$ nvcc -std=c++23
nvcc fatal   : Value 'c++23' is not defined for option 'std'
$ nvcc -std=c++2b
nvcc fatal   : Value 'c++2b' is not defined for option 'std'
  1. I found that we ignore all nvcc warnings. If I add --diag-error=128 I get:
C:/Dev/STL/out/x64/out/inc\xutility(5069): error: loop is not reachable
          for (; _First != _Last; ++_Dest, (void) ++_First) {
          ^
          detected during:
            instantiation of "_OutIt std::_Move_unchecked(_InIt, _InIt, _OutIt) [with _InIt=std::seed_seq::result_type *, _OutIt=std::seed_seq::result_type *]" at line 1756 of C:/Dev/STL/out/x64/out/inc\vector
            instantiation of "std::vector<_Ty, _Alloc>::iterator std::vector<_Ty, _Alloc>::erase(std::vector<_Ty, _Alloc>::const_iterator, std::vector<_Ty, _Alloc>::const_iterator) [with _Ty=std::seed_seq::result_type, _Alloc=std::allocator<std::seed_seq::result_type>]" at line 3541 of C:/Dev/STL/out/x64/out/inc\vector
            instantiation of "void std::vector<__nv_bool, _Alloc>::_Trim(std::vector<__nv_bool, _Alloc>::size_type) [with _Alloc=std::allocator<__nv_bool>]" at line 2886 of C:/Dev/STL/out/x64/out/inc\vector
            instantiation of "std::vector<__nv_bool, _Alloc>::vector(std::vector<__nv_bool, _Alloc>::size_type, const _Alloc &) [with _Alloc=std::allocator<__nv_bool>]" at line 681 of C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.34120\include\ppltasks.h

C:/Dev/STL/out/x64/out/inc\xutility(4735): error: loop is not reachable
      for (; _Count != 0; ++_Dest, (void) ++_First, --_Count) {
      ^
          detected during:
            instantiation of "_OutIt std::_Copy_n_unchecked4(_InIt, _SizeTy, _OutIt) [with _InIt=void **, _SizeTy=size_t, _OutIt=void **]" at line 1430 of C:/Dev/STL/out/x64/out/inc\vector
            instantiation of "void std::vector<_Ty, _Alloc>::_Assign_counted_range(_Iter, std::vector<_Ty, _Alloc>::size_type) [with _Ty=void *, _Alloc=std::allocator<void *>, _Iter=void **]" at line 1492 of C:/Dev/STL/out/x64/out/inc\vector
            instantiation of "std::vector<_Ty, _Alloc> &std::vector<_Ty, _Alloc>::operator=(const std::vector<_Ty, _Alloc> &) [with _Ty=void *, _Alloc=std::allocator<void *>]" at line 181 of C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.34120\include\ppltasks.h

10 errors detected in the compilation of "C:/Dev/STL/tests/std/tests/GH_000639_nvcc_include_all/test.compile.pass.cpp".

--diag-error=177

C:\Dev\STL\out\x64\out\inc\memory_resource(586): error: variable "_Guard" was declared but never referenced
              lock_guard<mutex> _Guard{_Mtx};
                                ^

C:\Dev\STL\out\x64\out\inc\condition_variable(66): error: variable "_Guard" was declared but never referenced
          lock_guard<mutex> _Guard{*_Myptr};
                            ^

C:\Dev\STL\out\x64\out\inc\condition_variable(71): error: variable "_Guard" was declared but never referenced
          lock_guard<mutex> _Guard{*_Myptr};
                            ^

C:\Dev\STL\out\x64\out\inc\shared_mutex(92): error: variable "_Lock" was declared but never referenced
          lock_guard<mutex> _Lock(_Mymtx);
                            ^

C:\Dev\STL\out\x64\out\inc\shared_mutex(133): error: variable "_Lock" was declared but never referenced
              lock_guard<mutex> _Lock(_Mymtx);
                                ^

C:\Dev\STL\out\x64\out\inc\shared_mutex(151): error: variable "_Lock" was declared but never referenced
          lock_guard<mutex> _Lock(_Mymtx);
                            ^

C:\Dev\STL\out\x64\out\inc\shared_mutex(187): error: variable "_Lock" was declared but never referenced
              lock_guard<mutex> _Lock(_Mymtx);
                                ^

45 errors detected in the compilation of "C:/Dev/STL/tests/std/tests/GH_000639_nvcc_include_all/test.compile.pass.cpp".

--diag-error=186

C:\Dev\STL\out\x64\out\inc\xstring(2401): error: pointless comparison of unsigned integer with zero
          do { if (_Result_size >= 0) { } else { do { (void) ((1 != _CrtDbgReport(2, "C:\\Dev\\STL\\out\\x64\\out\\inc\\xstring", 2401, 0, "%s", "the returned size can't be smaller than 0")) || (__debugbreak(), 0)); ::_invalid_parameter(L"\"the returned size can't be smaller than 0\"", L"", L"C:\\Dev\\STL\\out\\x64\\out\\inc\\xstring", static_cast<unsigned int>(2401), 0); } while (false); } ; } while (false);
                                ^
          detected during instantiation of "void std::basic_string<_Elem, _Traits, _Alloc>::_Resize_and_overwrite(std::basic_string<_Elem, _Traits, _Alloc>::size_type, _Operation) [with _Elem=__wchar_t, _Traits=std::char_traits<__wchar_t>, _Alloc=std::allocator<__wchar_t>, _Operation=lambda [](__wchar_t *, size_t)->size_t]" at line 1405 of C:\Dev\STL\out\x64\out\inc\filesystem

1 error detected in the compilation of "C:/Dev/STL/tests/std/tests/GH_000639_nvcc_include_all/test.compile.pass.cpp".
test.compile.pass.cpp

I didn't find how to enable all/almost all warnings with one command and if the warnings are good. We can enable three with --diag-error=128,177,186 but I don't want to add string like this--diag-error=1,2,3,4,5,...,200. And I found this:

STL/stl/inc/string

Lines 459 to 469 in 1e312b3

// TRANSITION, CUDA - warning: pointless comparison of unsigned integer with zero
template <class _Elem, class _Ty>
_NODISCARD basic_string<_Elem> _UIntegral_to_string(const _Ty _Val) {
// convert _Val to string
static_assert(is_integral_v<_Ty>, "_Ty must be integral");
static_assert(is_unsigned_v<_Ty>, "_Ty must be unsigned");
_Elem _Buff[21]; // can hold 2^64 - 1, plus NUL
_Elem* const _Buff_end = _STD end(_Buff);
_Elem* const _RNext = _UIntegral_to_buff(_Buff_end, _Val);
return basic_string<_Elem>(_RNext, _Buff_end);
}

So we took care about some nvcc warnings in the past...

  1. About the typename: https://gcc.godbolt.org/z/6TcboYYEe so I think the issue is fixed in CUDA 12.5.1, so we don't need to report upstream to Nvidia.

@fsb4000 fsb4000 requested a review from a team as a code owner September 21, 2024 15:16
@StephanTLavavej StephanTLavavej added the test Related to test code label Sep 21, 2024
@StephanTLavavej StephanTLavavej self-assigned this Sep 22, 2024
stl/inc/__msvc_iter_core.hpp Outdated Show resolved Hide resolved
tests/std/tests/GH_000639_nvcc_include_all/env.lst Outdated Show resolved Hide resolved
@CaseyCarter
Copy link
Member

I pushed a couple of commits to (1) address a comment nitpick, and (2) resolve the deprecation macro question by guarding the definition in __msvc_all_public_headers.hpp so we can define the more precise macro on the command line.

@StephanTLavavej StephanTLavavej removed their assignment Sep 24, 2024
@StephanTLavavej
Copy link
Member

Thanks! I'm still mystified as to why C++20 mode isn't emitting the C++17 deprecation warnings for C headers, or C++20's own deprecation warning for <ciso646>, but C++20 mode is clearly activated (since otherwise the typename workaround in concept _Cpp17_random_delta would not have been necessary), so I don't think this PR needs to be blocked over the mysterious absence of warnings.

@CaseyCarter
Copy link
Member

Thanks! I'm still mystified as to why C++20 mode isn't emitting the C++17 deprecation warnings for C headers, or C++20's own deprecation warning for <ciso646>, but C++20 mode is clearly activated (since otherwise the typename workaround in concept _Cpp17_random_delta would not have been necessary), so I don't think this PR needs to be blocked over the mysterious absence of warnings.

Wild guess: some predefined global warning suppression to avoid the force-included header emitting warnings?

@fsb4000
Copy link
Contributor Author

fsb4000 commented Sep 25, 2024

Thanks! I'm still mystified as to why C++20 mode isn't emitting the C++17 deprecation warnings for C headers

My guess: these headers are deprecated in C++17 but removed in C++20, so probably cuda_runtime.h do something different for C++20 and this is why we don't see the warnings.

@StephanTLavavej StephanTLavavej self-assigned this Sep 27, 2024
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 97e52d1 into microsoft:main Sep 28, 2024
39 checks passed
@StephanTLavavej
Copy link
Member

Thanks for this major improvement in test coverage! ✅ 📈 😻

@fsb4000 fsb4000 deleted the fix4965 branch September 29, 2024 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Related to test code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Test CUDA in all supported Standard modes
5 participants