NVIDIA / NVIDIA/cccl

[BUG]: host-only get_global_resource() may be called from GPU-side code.

Open
#3,023 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

### Is this a duplicate?

- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Type of Bug

Compile-time Error

### Component

Thrust

### Describe the bug

During investigation of UB issues in thrust we've ran into a peculiear case of ptxas failing due to an unresolved reference:
https://github.com/NVIDIA/cccl/pull/2813#issuecomment-2477099734
https://github.com/NVIDIA/cccl/pull/2813#issuecomment-2480198923

The bottom line is that a host-only function get_global_resounce here:
https://github.com/NVIDIA/cccl/blob/f4d358a81c23a0171efcfc9f353cc238c9d7f95a/thrust/thrust/mr/memory_resource.h#L207

Gets called from a host/device constructor here:
https://github.com/NVIDIA/cccl/blob/f4d358a81c23a0171efcfc9f353cc238c9d7f95a/thrust/thrust/mr/allocator.h#L203-L206

In some scenarios, we end up trying to call it from the GPU-side code. To add insult to injury neither NVCC nor clang currently diagnose such an invalid call. Clang bug: https://github.com/llvm/llvm-project/issues/118415

### How to Reproduce

The issue was originally seen during compilation of cub/test/catch2_test_device_three_way_partition.cu
https://github.com/NVIDIA/cccl/pull/2813#issuecomment-2477099734

### Expected behavior

If the function may be called from a GPU code, it should have appropriate attributes.

### Reproduction link

_No response_

### Operating System

_No response_

### nvidia-smi output

_No response_

### NVCC version

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.