Description
#include <CL/sycl.hpp>
using namespace cl::sycl;
int main() {
queue q;
q.submit([&](handler &cgh) {
cgh.single_task<no_known_host_conversion>([=]() {
float4 f4{2.0};
auto res = cl::sycl::sqrt(f4);
});
});
q.wait();
return 0;
}
The host compilation fails using the above code as it cannot find sqrt overloads for cl::sycl::vec<float, 4> as it appears to default to std::sqrt for host rather than a vec4 implementation. This happens when compiling to fatbinary or compiling host/device separately (device compiles, host fails in this case).
Example error output:
../build/lib/clang/9.0.0/include/CL/sycl.hpp:27:
../build/lib/clang/9.0.0/include/CL/sycl/math.hpp:300:10: error: no matching function for call to 'sqrt'
return __sycl_std::sqrt(x);
^~~~~~~~~~~~~~~~
math_host_conflict.cpp:16:30: note: in instantiation of function template specialization 'cl::sycl::sqrt<cl::sycl::vec<float, 4> >' requested here
auto res = cl::sycl::sqrt(f4);
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:143:13: note: candidate function not viable: no known conversion from 'cl::sycl::vec<float, 4>' to 'double' for 1st
argument
__MATHCALL (sqrt,, (Mdouble __x));
^
/usr/include/math.h:273:25: note: expanded from macro '__MATHCALL'
__MATHDECL (Mdouble,function,suffix, args)
^
/usr/include/math.h:275:22: note: expanded from macro '__MATHDECL'
__MATHDECL_1(type, function,suffix, args);
^
/usr/include/math.h:283:31: note: expanded from macro '__MATHDECL_1'
extern type __MATH_PRECNAME(function,suffix) args __THROW
^
/usr/include/math.h:286:42: note: expanded from macro '__MATH_PRECNAME'
#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:105:23: note: expanded from macro '__CONCAT'
#define __CONCAT(x,y) x ## y
^
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cmath:463:3: note: candidate function not viable: no known conversion from 'cl::sycl::vec<float, 4>' to 'float'
for 1st argument
sqrt(float __x)
^
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cmath:467:3: note: candidate function not viable: no known conversion from 'cl::sycl::vec<float, 4>' to
'long double' for 1st argument
sqrt(long double __x)
^
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cmath:475:5: note: candidate template ignored: substitution failure [with _Tp = cl::sycl::vec<float, 4>]: no
type named '__type' in '__gnu_cxx::__enable_if<false, double>'
sqrt(_Tp __x)
^
1 error generated.
I believe this will fail for more than just vec4's and the sqrt function.