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

[BUG]: <cuda/atomic> header should be included only in device compilation mode. #449

Closed
1 task done
mfbalin opened this issue Mar 31, 2024 · 9 comments
Closed
1 task done
Labels
type: bug Something isn't working

Comments

@mfbalin
Copy link

mfbalin commented Mar 31, 2024

Is this a duplicate?

Type of Bug

Compile-time Error

Describe the bug

I want to use cuCollections when compiling for old and new CUDA architectures (sm_35 to sm_90). However, in this case, the minimum cuda architecture is sm_35 and importing cuda/atomic header gives an error.

If there is a way, this include should be performed only in device mode and when compiling for suitable cuda architectures. Otherwise, one can't use cuco::static_map in the host code. I want to dispatch to different kernels depending on the compute capability of the device. Ideally, without limiting which architectures I am providing support for (>=35).

How to Reproduce

  1. Compile for old and new architectures.
  2. Include cuco/static_map.cuh header.

Expected behavior

The host code should be compilable for any CUDA architecture.

Reproduction link

No response

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

@jrhemstad
Copy link
Collaborator

Hey @mfbalin this is a known issue and something high on my list of things I'd like to address in CCCL in the coming months. See NVIDIA/cccl#1083 for tracking this effort.

@mfbalin
Copy link
Author

mfbalin commented Apr 1, 2024

Can I hack __CUDA_ARCH_LIST__ to remove old architectures from it to compile a specific file as a workaround?

@mfbalin
Copy link
Author

mfbalin commented Apr 1, 2024

I want to compile the whole project with 35, 50, ..., 90 but only one file including cuco with 70, ..., 90.

@jrhemstad
Copy link
Collaborator

I want to compile the whole project with 35, 50, ..., 90 but only one file including cuco with 70, ..., 90.

Are you using CMake? You should be able to specify per-target properties for a specific file like this:

cmake_minimum_required(VERSION 3.18)
project(cuda_arch_example LANGUAGES CUDA)

# Add your library
add_library(my_cuda_library main.cu other.cu)

# Set the default CUDA architecture for the target
set_target_properties(my_cuda_library PROPERTIES CUDA_ARCHITECTURES "35")

# Specify a different CUDA architecture for a specific file
set_source_files_properties(other.cu PROPERTIES CUDA_ARCHITECTURES "72")

@mfbalin
Copy link
Author

mfbalin commented Apr 1, 2024

I want to compile the whole project with 35, 50, ..., 90 but only one file including cuco with 70, ..., 90.

Are you using CMake? You should be able to specify per-target properties for a specific file like this:

cmake_minimum_required(VERSION 3.18)
project(cuda_arch_example LANGUAGES CUDA)

# Add your library
add_library(my_cuda_library main.cu other.cu)

# Set the default CUDA architecture for the target
set_target_properties(my_cuda_library PROPERTIES CUDA_ARCHITECTURES "35")

# Specify a different CUDA architecture for a specific file
set_source_files_properties(other.cu PROPERTIES CUDA_ARCHITECTURES "72")

Yes, I am using CMake. This looks promising, let me try it. Thank you!

@jrhemstad
Copy link
Collaborator

@mfbalin turns out you can't use CUDA_ARCHITECTURES on a per-file basis. You'd need to move other.cu to a separate object library.

@mfbalin
Copy link
Author

mfbalin commented Apr 1, 2024

That works too, so long as there is a way to get it working.

@mfbalin
Copy link
Author

mfbalin commented Apr 1, 2024

@jrhemstad Do you know if these separate object libraries can circularly depend on each other?

EDIT: I will figure out a way. Thank you for the pointers!

@PointKernel
Copy link
Member

Closing as resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants