Skip to content

<cmath>: New intrinsics broke CUDA #1885

@StephanTLavavej

Description

@StephanTLavavej

When #1336 added usage of new intrinsics to <cmath>, we forgot about CUDA. 🙀 (Long ago, we broke CUDA by adding new type traits intrinsics in C++14 mode, but these math functions were just different enough that I didn't remember the interaction. Oops!)

I'm not exactly sure why our CUDA unit test didn't catch this, given that the affected overloads aren't templates:

STL/stl/inc/cmath

Lines 62 to 70 in f675d68

_NODISCARD _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* strengthened */ {
#ifdef _M_CEE
return _CSTD ceilf(_Xx);
#elif defined(__clang__)
return __builtin_ceilf(_Xx);
#else // ^^^ __clang__ / !__clang__ vvv
return __ceilf(_Xx);
#endif // __clang__
}

We are including <cmath>, so there's probably some detail of the CUDA compilation process that I don't understand:

#include <cmath>

#define _MSVC_TESTING_NVCC
#include <__msvc_all_public_headers.hpp>

In any event, fixing this should be easy, we just need to backport it to VS 2019 16.9.

Originally encountered in pytorch/pytorch#54382 and tracked by Microsoft-internal VSO-1314894 / AB#1314894 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!high priorityImportant!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions