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

<cuda/std/atomic> is incompatible with host compilation on Windows #968

Open
nvibd opened this issue Mar 3, 2021 · 3 comments
Open

<cuda/std/atomic> is incompatible with host compilation on Windows #968

nvibd opened this issue Mar 3, 2021 · 3 comments
Labels
libcu++ For all items related to libcu++

Comments

@nvibd
Copy link

nvibd commented Mar 3, 2021

As a minimal example, save the following as main.cpp and compile with MSVC / cl.exe, e.g.:

cl main.cpp -I "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include"

#include <cuda/std/atomic>

The same code will compile fine with nvcc (given arch >= 70 flags), but it will generate a bunch of errors and one warning when compiled with MSVC. I've added them at the end of the post.

This seems in conflict with libcu++'s claim: "It provides a heterogeneous implementation of the C++ Standard Library that can be used in and between CPU and GPU code".
In our application, this creates a problem as we include <cuda/std/atomic> indirectly together with pybind for Python bindings, which itself cannot be compiled with nvcc for unrelated reasons.

Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29336 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.cpp
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(13): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(13): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(14): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(14): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(15): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(15): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(742): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(742): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(743): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(743): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(744): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(744): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(1471): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(1471): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(1472): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(1472): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(1473): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_generated(1473): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_derived(151): error C2059: syntax error: 'volatile'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\__atomic_derived(151): error C2589: ':': illegal token on right side of '::'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\cuda\std\detail\../chrono(33): warning C4068: unknown pragma 'diag_suppress'
@nvibd
Copy link
Author

nvibd commented Mar 3, 2021

The libcu++ version is the one included with CUDA 11.2.

cl.exe version:
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29336 for x64
nvcc.exe version:
Cuda compilation tools, release 11.2, V11.2.67

@jrhemstad
Copy link
Collaborator

There currently isn't a guarantee that libcu++ can be compiled solely by a host compiler. See #940

@nvibd
Copy link
Author

nvibd commented Mar 3, 2021

Thanks for bringing awareness to that previous ticket. I've added a comment there.

@jrhemstad jrhemstad added the libcu++ For all items related to libcu++ label Feb 22, 2023
@jarmak-nv jarmak-nv transferred this issue from NVIDIA/libcudacxx Nov 8, 2023
@github-project-automation github-project-automation bot moved this to Todo in CCCL Nov 8, 2023
@miscco miscco removed their assignment Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libcu++ For all items related to libcu++
Projects
Status: Todo
Development

No branches or pull requests

3 participants