LLNL / RAJA

RAJA Performance Portability Layer (C++)
BSD 3-Clause "New" or "Revised" License
487 stars 103 forks source link

MSVC compilation failure w/ 64-bit intrinsics in x86 configurations #1744

Closed kennyweiss closed 1 month ago

kennyweiss commented 1 month ago

After axom updated its raja dependency on Windows from raja@2024.02.0 to raja@2024.07.0, our 32-bit x86 CI started to fail with error messages of the form:

...\x86-windows\include\RAJA\policy\atomic_builtin.hpp(160,10): error C3861: '_InterlockedExchange64': identifier not found
...\x86-windows\include\RAJA\policy\atomic_builtin.hpp(267,10): error C3861: '_InterlockedAnd64': identifier not found [D:
...\x86-windows\include\RAJA\policy\atomic_builtin.hpp(243,10): error C3861: '_InterlockedExchangeAdd64': identifier not found 
more of the error logs here ``` 2024-09-26T21:27:11.0448600Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(125,10): error C3861: '_InterlockedOr64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:11.0451521Z (compiling source file '../../../src/axom/slam/BitSet.cpp')2024-09-26T21:27:11.0452314Z 2024-09-26T21:27:11.0454720Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(160,10): error C3861: '_InterlockedExchange64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:11.0457243Z (compiling source file '../../../src/axom/slam/BitSet.cpp')2024-09-26T21:27:11.0457944Z 2024-09-26T21:27:11.0459997Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(219,10): error C3861: '_InterlockedExchangeAdd64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:11.0462257Z (compiling source file '../../../src/axom/slam/BitSet.cpp')2024-09-26T21:27:11.0462939Z 2024-09-26T21:27:11.0464894Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(243,10): error C3861: '_InterlockedExchangeAdd64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:11.0467117Z (compiling source file '../../../src/axom/slam/BitSet.cpp')2024-09-26T21:27:11.0467787Z 2024-09-26T21:27:11.0469977Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(267,10): error C3861: '_InterlockedAnd64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:11.0472208Z (compiling source file '../../../src/axom/slam/BitSet.cpp')2024-09-26T21:27:11.0472889Z 2024-09-26T21:27:11.0474798Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(291,10): error C3861: '_InterlockedXor64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:11.0476963Z (compiling source file '../../../src/axom/slam/BitSet.cpp')2024-09-26T21:27:11.0477638Z 2024-09-26T21:27:11.1754715Z OrderedSet.cpp2024-09-26T21:27:12.2705093Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(125,10): error C3861: '_InterlockedOr64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:12.2707813Z (compiling source file '../../../src/axom/slam/OrderedSet.cpp')2024-09-26T21:27:12.2708546Z 2024-09-26T21:27:12.2710565Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(160,10): error C3861: '_InterlockedExchange64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:12.2712817Z (compiling source file '../../../src/axom/slam/OrderedSet.cpp')2024-09-26T21:27:12.2713535Z 2024-09-26T21:27:12.2715520Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(219,10): error C3861: '_InterlockedExchangeAdd64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:12.2717770Z (compiling source file '../../../src/axom/slam/OrderedSet.cpp')2024-09-26T21:27:12.2718459Z 2024-09-26T21:27:12.2720438Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(243,10): error C3861: '_InterlockedExchangeAdd64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:12.2722730Z (compiling source file '../../../src/axom/slam/OrderedSet.cpp')2024-09-26T21:27:12.2723752Z 2024-09-26T21:27:12.2725687Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(267,10): error C3861: '_InterlockedAnd64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:12.2727917Z (compiling source file '../../../src/axom/slam/OrderedSet.cpp')2024-09-26T21:27:12.2728633Z 2024-09-26T21:27:12.2730560Z D:\a\axom\axom\uberenv_libs\vcpkg\installed\x86-windows\include\RAJA\policy\atomic_builtin.hpp(291,10): error C3861: '_InterlockedXor64': identifier not found [D:\a\axom\axom\build_axom\axom\slam\slam.vcxproj]2024-09-26T21:27:12.2732805Z (compiling source file '../../../src/axom/slam/OrderedSet.cpp') ```

See: https://github.com/LLNL/axom/actions/runs/11060318336

We're using vcpkg through uberenv, and the failure is with Debug and Release configurations of the x86 triplet. The CI is still building and passing tests w/ the x64 triplet.

The error appears to be related to the (un)availability of 64-bit intrinsics in intrin.h in x86 configurations. E.g. https://github.com/MicrosoftDocs/cpp-docs/blob/main/docs/intrinsics/interlockedand-intrinsic-functions.md#requirements

This suggests that perhaps additional guards are required based on, e.g. whether _WIN64 is defined.

We use some intrinsics in Axom, and have guards of the the following form: https://github.com/LLNL/axom/blob/70b360815ebed6a25e6ae369bc5efeaa58cacdbc/src/axom/core/utilities/BitUtilities.hpp#L32-L40 I think we were also planning to improve our handling of 32-bit and 64-bit intrinsics on Windows, but the current approach does not produce compilation failures on Windows.

Compilers & Libraries:

adayton1 commented 1 month ago

@kennyweiss, I will be on parental leave for the next two weeks. But I put up a branch for you to try: https://github.com/LLNL/RAJA/pull/1746