Skip to content

CUDA 11.2+ diagnostic-error flags are appended to the wrong variable #5363

Description

@WeiqunZhang
  • Type: correctness
  • Severity: medium
  • Component: CMake CUDA backend
  • Location: Tools/CMake/AMReXParallelBackends.cmake:199

Problem

The CUDA backend accumulates compiler flags in _cuda_flags and later applies
that list to every amrex_${D}d target. The CUDA 11.2+ branch intended to make
device-variable misuse a hard error appends to _cuda_flag instead:

if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2)
   list(APPEND _cuda_flag --display-error-number "SHELL:--diag-error 20092")
endif ()

The target application step uses _cuda_flags, so these diagnostics are never
actually enabled.

Impact

  • CUDA 11.2+ builds silently miss the extra diagnostic enforcement that this
    branch is meant to provide.
  • Misuse that should be diagnosed as an error can pass through this configuration
    path without the intended nvcc flags.

Suggested patch

--- a/Tools/CMake/AMReXParallelBackends.cmake
+++ b/Tools/CMake/AMReXParallelBackends.cmake
@@
-   if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2)
-      list(APPEND _cuda_flag --display-error-number "SHELL:--diag-error 20092")
+   if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2)
+      list(APPEND _cuda_flags --display-error-number "SHELL:--diag-error 20092")
    endif ()

Prepared by Codex

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions