alpaka: Some `alpaka::math::MathStdLib` functions trigger `[-Werror,-Wdouble-promotion]` when not called with `double`
Using alpaka::math::MathStdLib
functions sin
and cos
with an aruments of a different precision than float
(e.g. float
), and probably other triggers the following clang (Main/14) warning:
~alpaka/include/alpaka/math/sin/Traits.hpp:37:32:
error: implicit conversion increases floating-point precision: 'const float' to 'double' [-Werror,-Wdouble-promotion]
return sin(arg);
~~~ ^~~
This is because, e.g., sin
is not overloaded for different precisions. For float
sinf
should be used. (sinl
for long double
although this may not be supported by alpaka anyway.)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (28 by maintainers)
Templates. You might want to write an alpaka device side function that you can call on
float
,double
,MyBigNumber
,MyComplex
,__half
orbfloat16
.I found it myself now. I thought you where talking about the implementations
XXXStdLib
implementations, to which my comment before applied. You seem to be referring to the ADL fallback for types other than the ones handled by the backends. So for example if you implement your own complex number:You can use the alpaka functions and they will try to find an implementation of
sqrt
in the namespace ofMyComplex
via ADL. If you end up in this fallback, then you seem to not implement theConceptMathXXX
s.