-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
handle Clang-CUDA #2075
handle Clang-CUDA #2075
Conversation
The fix works-for-me ™️ |
We can't add anything to clang headers. But I could add to
And enable the cuda test. I will do after the commit will be merged: #2204 |
Looks like a fine workaround, but I actually wondered, whether it would make sense that I create a PR for Clang to push/pop the new macro in Clang's |
Any chance to move this forward? I didn't run the tests, so I didn't have any issues with |
We certainly can. It may not help released versions of clang, but if reasonable change must be done to clang's headers in order to make it work better for CUDA compilation on windows going forward, I'm open to the idea. |
Stephan added the PR to "Nice to have": https://github.com/microsoft/STL/projects/6#card-74026742 And about the macro "new". As far as I understand: MFC changes "new" to a macro. So for MFC and stl to work together, stl must remove this macro and then restore. But Clang doesn't work with MFC at the moment. https://developercommunity.visualstudio.com/t/ClangCL-and-MFC-Undefined-Behaviour/1541392 And maybe zero people use CUDA + MFC... So I'm not sure if changes at libc++ headers are necessary to distract developers from their current problems. |
Adding the guard to cuda_wrappers when we're compiling on windows should be doable.
My bet is that the vast majority of CUDA code to be compiled with clang on windows initially will be TensorFlow, possibly followed by other ML toolkits. Those do care about a subset of the standard C++ library working, but not so much about MFC (unless microsoft's STL depends on it). As your example demonstrated, things do work in general. Support for the standard C++ library on the GPU is rather limited anyways Here are the tests I'm running on LLVM's CUDA test bots: https://github.com/llvm/llvm-test-suite/tree/main/External/CUDA |
My apologies for taking so long to review this. I've pushed a comment whitespace change (plus a conflict-free merge with |
which admits both clang-CUDA and `cl /showIncludes /D__CUDACC__` into the STL.
I'm going to add this to the next batch of changes to merge - please notify me if any further commits are pushed. @stl: I made a change after you approved. Normally, I would wait for reapproval to merge, but since this addresses a P0 bug I'm going to merge now and we can iron out any issues after you return from vacation. |
@CaseyCarter LGTM. (BTW, I am @StephanTLavavej here.) |
Thanks for ensuring that Clang could'a worked with CUDA! |
When compiling the tests with the CUDA backend, we're getting errors that have been fixed in for Visual Studio 2022 here: microsoft/STL#2075
* Rewrite github action file for windows - Use windows-2019 image - Use prebuilt LLVM 15 - Build boost in CI * Add full path to clang In the Github runner, another LLVM is installed in C:\Program Files, we want to use the prebuilt one * Remove continue-on-error * Prepend path to prebuilt LLVM to PATH * Comment out code that does not compile with LLVM13+ TODO: Check if this is still necessary and how to make it work with LLVM13+ * Link against LLVMSupport on Windows Required for symbols from LLVM CommandLine library * Build in Release mode to match build type of LLVM * Add step to build CPU tests * Add missing cd command * Use correct path to hipsycl-config.cmake * Add missing quotes * Run CPU tests * Fix path * Fix typo * Use cmd instead of powershell * Add path to install_dir/bin to PATH to make dlls findable * Add missing backslash * Add steps to install CUDA * Fix typo in CUDA version * Add step to build tests with CUDA backend * Build CUDA tests in own directory * Use different gencode for CUDA tests * Fix typo in CUDA gencode * Remove 10.2 from tested CUDA versions * Only test CUDA 11.0 for now * Use correct version when caching CUDA * Switch to Windows Server 2022 as OS When compiling the tests with the CUDA backend, we're getting errors that have been fixed in for Visual Studio 2022 here: microsoft/STL#2075 * Use different CUDA gencode again * Switch from hipSYCL_DIR and HIPSYCL_TARGETS to OpenSYCL_DIR and OPENSYCL_TARGETS * Fix path to OpenSYCL.config * Add missing quotes * Remove step to build CUDA tests The prebuilt LLVM was not build with CUDA enabled * Add steps to build with prebuilt clang 11 * Enable calling `setDeviceMangleContext` for LLVM 11 and 12 In fact, this is not available in LLVM 11 (only when patched with https://reviews.llvm.org/D69322) but the prebuilt LLVM in CI is exactly a patched LLVM 11. * Remove clang11 from tested clang versions
Fixes #1949
Fixes DevCom-1572308 / VSO-1441025 / AB#1441025
clang defines only
__CUDACC__
but it doesn't define__CUDACC_VER_MAJOR__
,__CUDACC_VER_MINOR__
,__CUDACC_VER_BUILD__
at all.Actually it can't pass our cuda test: https://github.com/microsoft/STL/blob/main/tests/std/tests/GH_000639_nvcc_include_all/test.compile.pass.cpp
Because clang adds the incudes: C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\Llvm\x64\lib\clang\12.0.0\include\cuda_wrappers
And they don't protect themselves from macroized "new":
STL/stl/inc/__msvc_all_public_headers.hpp
Lines 15 to 18 in bd7adb4
But it seems to be working: