exasim-project / FoamAdapter

GPL Adapter for the MIT licensed NeoFOAM
1 stars 1 forks source link

Ambiguous overloading of transcendental function in scalarAdvection #26

Open gregorweiss opened 4 hours ago

gregorweiss commented 4 hours ago

OS: Rocky 9.4 Compiler: clang 18.24.05 with CUDA 12.4 Kokkos: 4.5 (current develop branch) OF: v2406

When compiling examples, namely, scalarAdvection overloading of sin/exp/cos throw amiguity errors

In file included from /usr/local/cuda-12.4/include/crt/math_functions.h:12199,
                 from /usr/local/cuda-12.4/include/crt/common_functions.h:303,
                 from /usr/local/cuda-12.4/include/crt/host_runtime.h:285,
                 from /tmp/tmpxft_000ab31e_00000000-6_scalarAdvection.cudafe1.stub.c:8,
                 from tmpxft_000ab31e_00000000-6_scalarAdvection.cudafe1.stub.c:1:
/usr/local/cuda-12.4/include/crt/math_functions.hpp: In function ‘double rsqrt(double)’:
/usr/local/cuda-12.4/include/crt/math_functions.hpp:2955:20: error: call of overloaded ‘sqrt(const double&)’ is ambiguous
 2955 |   return 1.0 / sqrt(a);
      |                ~~~~^~~
/usr/include/bits/mathcalls.h:143:15: note: candidate: ‘double sqrt(double)’
  143 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      |               ^~~~
/usr/include/c++/11/cmath:467:23: note: candidate: ‘constexpr long double std::sqrt(long double)’
  467 |   sqrt(long double __x)
      |                       ^   
/usr/include/c++/11/cmath:463:17: note: candidate: ‘constexpr float std::sqrt(float)’
  463 |   sqrt(float __x)
      |                 ^   
~/code/openfoam/source/src/OpenFOAM/lnInclude/Scalar.H:187:20: note: candidate: ‘Foam::floatScalar Foam::sqrt(Foam::floatScalar)’
  187 | transFunc(sqrt)
      |                    ^   
~/code/openfoam/source/src/OpenFOAM/lnInclude/Scalar.H:187:21: note: candidate: ‘Foam::doubleScalar Foam::sqrt(Foam::doubleScalar)’
  187 | transFunc(sqrt)
      |                     ^   
~/code/openfoam/source/src/OpenFOAM/lnInclude/dimensionedScalar.H:68:19: note: candidate: ‘Foam::dimensionedScalar Foam::sqrt(const dimensionedScalar&)’
   68 | dimensionedScalar sqrt(const dimensionedScalar&);
      |         

So, seems to clash with definitions in CUDA, C++ std math, and Foam namespace.

Have you seen something similar, before?

greole commented 3 hours ago

Thanks for reporting. I think we had this issue before. It might be something I reintroduced after the clean-up PR. @HenningScheufler I guess it is the order of includes that causes this.