Skip to content

[SYCL] Host compilation failure for vec4 sqrt (likely other math functions as well) #43

Closed

Description

@agozillon
#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.

Activity

  1. added
    bugSomething isn't working
    on Mar 6, 2019
  2. bader commented on Mar 6, 2019

    @bader
    Contributor

    @agozillon, we have a fix for this issue.
    Will upload the patch soon.
    Thanks!

  3. agozillon commented on Mar 7, 2019

    @agozillon
    ContributorAuthor

    awesome, thank you guys for the quick fix!

  4. bader commented on May 22, 2019

    @bader
    Contributor

    @agozillon, this issue should have been fixed by #48.
    Could you confirm that, please?

  5. agozillon commented on May 22, 2019

    @agozillon
    ContributorAuthor

    I can confirm that this is fixed and I am happy to close the issue if you are! Thank you.

  6. bader commented on May 22, 2019

    @bader
    Contributor

    @agozillon, thanks for confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions