Skip to content

#pragma omp atomic compare rejected during CUDA compilation #2856

Description

@eike321

Environment:

  • SU2 8.5.0
  • GCC 14.2
  • CUDA 13.1
  • Ubuntu 24.04

Describe the bug
When compiling with -Denable-cuda=true I received the following error:

../Common/src/linear_algebra/../../include/linear_algebra/../parallelization/../basic_types/../parallelization/omp_structure.hpp:292:45: error: invalid form of ?#pragma omp atomic? before ?;? token
292 | shared = shared < local ? local : shared;

I assume when CUDA is enabled, NVCC preprocesses and parses code before handing it to GCC. CUDA 13.1 appears not to fully support this OpenMP construct, even though the compiler (GCC 14.2) does.

It was fixed by changing in Common/include/parallelization/omp_structure.hpp from:

274 #define ATOMIC_COMPARE_SINCE 202011
275 #ifdef __GNUC__
276 #if __GNUC__ > 11
277 #undef ATOMIC_COMPARE_SINCE
278 #define ATOMIC_COMPARE_SINCE 201511
279 #endif
280 #endif

to:

274 #define ATOMIC_COMPARE_SINCE 202011
275 #if defined(__GNUC__) && !defined(__CUDACC__)
276 #if __GNUC__ > 11
277 #undef ATOMIC_COMPARE_SINCE
278 #define ATOMIC_COMPARE_SINCE 201511
279 #endif
280 #endif

thus disabling the GCC-specific atomic compare optimization under __CUDACC__.

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