Skip to content

<yvals_core.h>: CUDA version check doesn't handle Clang-CUDA #1949

@StephanTLavavej

Description

@StephanTLavavej

After we merged #1544 which added a version check:

STL/stl/inc/yvals_core.h

Lines 548 to 553 in 3cafa97

#ifdef __CUDACC__
#if __CUDACC_VER_MAJOR__ < 10 \
|| (__CUDACC_VER_MAJOR__ == 10 \
&& (__CUDACC_VER_MINOR__ < 1 || (__CUDACC_VER_MINOR__ == 1 && __CUDACC_VER_BUILD__ < 243)))
#error STL1002: Unexpected compiler version, expected CUDA 10.1 Update 2 or newer.
#endif // ^^^ old CUDA ^^^

@fodinabor reported:

This breaks CUDA with any Clang version that does not report CUDA > 10.1 (i.e. Clang from 11.0.0 to main can build with CUDA 10.1+ but always reports 10.1)
And as the Clang version 11.0.0+ seems to be supported otherwise (implements if constexpr), it'd be great if we could just add a check whether clang is used or nvcc (or nvc++..)

I was unaware that Clang could compile CUDA code. This is detectable through predefined macros:

https://llvm.org/docs/CompileCudaWithLLVM.html#detecting-clang-vs-nvcc-from-code

We should consider:

  1. Refining this version check (adding !defined(__clang__) to the last test might be correct)
  2. Adding test coverage for this scenario (which should be possible as we have both Clang and the CUDA SDK installed on the CI machines)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions