Skip to content

[SYCL] Program reports it does not contain the kernel requested 0 (CL_SUCESS) when using functor on GPU #640

@shiltian

Description

@shiltian

Here is a small case to reproduce:

#include <CL/sycl.hpp>

class KernelFunctor {
public:
  void operator()(cl::sycl::nd_item<1> Item) {
    const auto GID = Item.get_global_id();
  }
};

int main() {
  cl::sycl::queue Queue;
  cl::sycl::device Device = Queue.get_device();

  cl::sycl::program Prog(Queue.get_context());

  Prog.build_with_kernel_type<KernelFunctor>();
  auto Kernel = Prog.get_kernel<KernelFunctor>();

  Queue.submit([&](cl::sycl::handler &cgh){
    cgh.parallel_for(cl::sycl::nd_range<1>{16, 8}, Kernel);
  });

  return 0;
}

Compilation command:

$ clang++ -fsycl test.cpp -lOpenCL
$ SYCL_DEVICE_TYPE=GPU ./a.out
terminate called after throwing an instance of 'cl::sycl::invalid_object_error'
  what():  This instance of program does not contain the kernel requested 0 (CL_SUCCESS)
[1]    29269 abort (core dumped)  SYCL_DEVICE_TYPE=GPU ./a.out

Call stack:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6648801 in __GI_abort () at abort.c:79
#2  0x00007ffff7ad8957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7adeab6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff7adeaf1 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff7aded24 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x0000000000413b6f in cl::sycl::detail::program_impl::get_pi_kernel (this=0x65c000, KernelName="")
    at /home/shilei/Documents/sycl/intel-llvm/deploy/lib/clang/9.0.0/include/CL/sycl/detail/program_impl.hpp:418
#7  0x0000000000413726 in cl::sycl::detail::program_impl::get_kernel<KernelFunctor> (this=0x65c000, PtrToSelf=warning: RTTI symbol not found for class 'std::_Sp_counted_ptr_inplace<cl::sycl::detail::program_impl, std::allocator<cl::sycl::detail::program_impl>, (__gnu_cxx::_Lock_policy)2>'
warning: RTTI symbol not found for class 'std::_Sp_counted_ptr_inplace<cl::sycl::detail::program_impl, std::allocator<cl::sycl::detail::program_impl>, (__gnu_cxx::_Lock_policy)2>'

std::shared_ptr<cl::sycl::detail::program_impl> (use count 2, weak count 0) = {...})
    at /home/shilei/Documents/sycl/intel-llvm/deploy/lib/clang/9.0.0/include/CL/sycl/detail/program_impl.hpp:275
#8  0x000000000040ebf4 in cl::sycl::program::get_kernel<KernelFunctor> (this=0x7fffffffe268)
    at /home/shilei/Documents/sycl/intel-llvm/deploy/lib/clang/9.0.0/include/CL/sycl/program.hpp:99
#9  0x000000000040e163 in main () at test.cpp:17

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions