Skip to content

[BUG] CUDA compiler warning for CUDF_HOST_DEVICE on constexpr variables #24238

Description

@bdice

Describe the bug

The CUDA compiler 13.3 emits warning #1835-D when CUDF_HOST_DEVICE annotates a namespace-scope constexpr variable because the macro expands to the function-only __host__ __device__ attributes.

PR #24237 removes the invalid annotation from all known cases:

  • cpp/include/cudf/join/join.hpp: JoinNoMatch
  • cpp/src/groupby/hash/compute_shared_memory_aggs.cu: ALIGNMENT
  • cpp/src/groupby/hash/helpers.cuh: GROUPBY_CG_SIZE
  • cpp/src/groupby/hash/helpers.cuh: GROUPBY_BUCKET_SIZE
  • cpp/src/groupby/hash/helpers.cuh: GROUPBY_BLOCK_SIZE
  • cpp/src/groupby/hash/helpers.cuh: GROUPBY_CARDINALITY_THRESHOLD
  • cpp/src/groupby/hash/helpers.cuh: GROUPBY_SHM_MAX_ELEMENTS
  • cpp/src/groupby/hash/helpers.cuh: valid_extent
  • cpp/src/join/key_remapping.cu: KEY_REMAP_BLOCK_SIZE

An audit of CUDF_HOST_DEVICE uses found no additional namespace-scope constexpr variables with the annotation.

Steps/Code to reproduce bug

#define CUDF_HOST_DEVICE __host__ __device__

CUDF_HOST_DEVICE constexpr int value = 42;

int main() { return value == 42 ? 0 : 1; }

Compile with the CUDA compiler 13.3:

nvcc -std=c++20 --display-error-number -c reproducer.cu

The CUDA compiler emits:

warning #1835-D: attribute "__host__" does not apply here

Promoting diagnostic 1835 to an error makes the compilation fail:

nvcc -std=c++20 --diag-error=1835 -c reproducer.cu

Expected behavior

Namespace-scope constexpr variables are not annotated with function-only attributes, and the CUDA compiler does not emit diagnostic 1835. The variables remain usable in host and device constant expressions without the annotation.

Environment overview

  • CUDA compiler 13.3.73
  • Standalone compiler reproducer; no cuDF installation is required

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions