1

I am newbie in SYCL/OpenCL/GPGPU. I am trying to build and run sample code of constant addition program,

#include <iostream>
#include <array>
#include <algorithm>

#include <CL/sycl.hpp>

namespace sycl = cl::sycl;

//<<Define ConstantAdder>>
template<typename T, typename Acc, size_t N>
class ConstantAdder {
public:
  ConstantAdder(Acc accessor, T val)
    : accessor(accessor)
    , val(val) {}

  void operator() () {
    for (size_t i = 0; i < N; i++) {
      accessor[i] += val;
    }
  }

private:
  Acc accessor;
  const T val;
};

int main(int, char**) {
  std::array<int, 4> vals = {{ 1, 2, 3, 4 }};

  sycl::queue queue(sycl::cpu_selector{});
  std::cout << "Running on "
      << queue.get_device().get_info<sycl::info::device::name>()
      << "\n";

  {
    sycl::buffer<int, 1> buf(vals.data(), sycl::range<1>(4));
    queue.submit([&] (sycl::handler& cgh) {
    auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);

    cgh.single_task(ConstantAdder<int, decltype(acc), 4>(acc, 1));
      } );
  }

  std::for_each(vals.begin(), vals.end(), [] (int i) { std::cout << i << " "; } );
  std::cout << std::endl;

  return 0;
}

I am building this code using

$ g++ constantAdder_backup.cpp -g -std=c++11 -o constantAdder -I /usr/local/computecpp/include -I/usr/include/ -L /usr/local/computecpp/lib -lComputeCpp -L /usr/lib/x86_64-linux-gnu -lOpenCL

and getting error

$ ./constantAdder
./constantAdder: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/lib/libComputeCpp.so)
./constantAdder: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/lib/libComputeCpp.so)\
./constantAdder: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/lib/libComputeCpp.so)
Running on Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
terminate called after throwing an instance of 'cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)9, cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)6, cl::sycl::exception> >'
Aborted (core dumped)

What is

terminate called after throwing an instance of 'cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)9, cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)6, cl::sycl::exception> >' Aborted (core dumped) error mean? How can I fix this? Please help me.

P.S. System hardware is

$ /usr/local/computecpp/bin/computecpp_info 
/usr/local/computecpp/bin/computecpp_info: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/bin/computecpp_info)
/usr/local/computecpp/bin/computecpp_info: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/bin/computecpp_info)
********************************************************************************

ComputeCpp Info (CE 0.7.0)

********************************************************************************

Toolchain information:

GLIBC version: 2.19
GLIBCXX: 20150426
This version of libstdc++ is supported.

********************************************************************************


Device Info:

Discovered 3 devices matching:
  platform    : <any>
  device type : <any>

--------------------------------------------------------------------------------
Device 0:

  Device is supported                     : NO - Device does not support SPIR
  CL_DEVICE_NAME                          : GeForce GTX 750 Ti
  CL_DEVICE_VENDOR                        : NVIDIA Corporation
  CL_DRIVER_VERSION                       : 384.111
  CL_DEVICE_TYPE                          : CL_DEVICE_TYPE_GPU 
--------------------------------------------------------------------------------
Device 1:

  Device is supported                     : UNTESTED - Device not tested on this OS
  CL_DEVICE_NAME                          : Intel(R) HD Graphics
  CL_DEVICE_VENDOR                        : Intel(R) Corporation
  CL_DRIVER_VERSION                       : r5.0.63503
  CL_DEVICE_TYPE                          : CL_DEVICE_TYPE_GPU 
--------------------------------------------------------------------------------
Device 2:

  Device is supported                     : YES - Tested internally by Codeplay Software Ltd.
  CL_DEVICE_NAME                          : Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
  CL_DEVICE_VENDOR                        : Intel(R) Corporation
  CL_DRIVER_VERSION                       : 1.2.0.475
  CL_DEVICE_TYPE                          : CL_DEVICE_TYPE_CPU 

If you encounter problems when using any of these OpenCL devices, please consult
this website for known issues:
https://computecpp.codeplay.com/releases/v0.7.0/platform-support-notes

********************************************************************************

P.S. I have updated the code to know device I am running code on.

snippet of modification is

sycl::queue queue(sycl::cpu_selector{});

std::cout << "Running on "
    << queue.get_device().get_info<sycl::info::device::name>()
    << "\n";

Now I am taking cpu::selector (not an nvidia hardware), and printing the device. It clearly shows that it is running on Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz. The output of

couputecpp_info

shows

Device is supported                     : YES - Tested internally by Codeplay Software Ltd

But still, it's showing the same error as

terminate called after throwing an instance of 'cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)9, cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)6, cl::sycl::exception> >' Aborted (core dumped)

Akhilesh
  • 1,024
  • 1
  • 9
  • 26
  • Can you edit to show what hardware you are trying to use, what OpenCL drivers you have installed and the output of the "computecpp_info" executable, located in the "bin" folder on Linux. Also, have you completed the Getting Started guide successfully? https://developer.codeplay.com/computecppce/latest/getting-started-guide – Rod Burns Jun 04 '18 at 09:05
  • @RodBurns I have added the result of `computecpp`. – Akhilesh Jun 04 '18 at 09:43

3 Answers3

2

There is an exception of type cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)9, cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)6, cl::sycl::exception> > being thrown and not being caught.

To see the details of the exception either add a try catch in your main or run your code in a debugger. e.g.:

int main(int, char**) {
  try
  {
     /*your code here*/
  }
  catch (std::exception& ex)
  {
    std::cerr << "exception caught: " << ex.what() << std::endl;
    return 1;
  }
  return 0;
}
Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
  • I tried what you suggested and got error which I raised here https://stackoverflow.com/questions/50682320/sycl-exception-caught-error-computecpprt0101-failed-to-create-kernel-kern , Please have a look at this, and give me some input. – Akhilesh Jun 05 '18 at 07:17
  • @Akhilesh sorry I'm not familiar with sycl, have you looked in the documentation? – Alan Birtles Jun 05 '18 at 07:22
  • This is definitely a good first step to understanding more about the error! – Rod Burns Jun 07 '18 at 14:56
1

You are not using the SYCL compiler when building your code. The following command could be used to do this.

/bin/compute++ constantAdder_backup.cpp -g -std=c++11 -o constantAdder -I /usr/local/computecpp/include -I/usr/include/ -L /usr/local/computecpp/lib -lComputeCpp -L /usr/lib/x86_64-linux-gnu -lOpenCL

You'll also need to ensure that LD_LIBRARY_PATH is set up to point to the lib folder of your ComputeCpp installation when executing the output.

Rod Burns
  • 2,104
  • 13
  • 24
  • Does everything work fine if you run the hello-world or other samples we provide building with cmake? – Rod Burns Jun 06 '18 at 10:05
  • When I am changing the `device selector` from `sycl::queue queue(sycl::cpu_selector{});` to `sycl::queue queue(sycl::host_selector{});`, then only it's working fine. I have `gpu_selector, defualt_selector` but unfortunately it didn't work. – Akhilesh Jun 06 '18 at 10:13
  • But does the hello world sample run fine when you follow the instructions on the website? That's a good place to start to check things are set up correctly https://developer.codeplay.com/computecppce/latest/getting-started-guide – Rod Burns Jun 06 '18 at 10:21
  • The output of hello_world `computecpp-sdk/build/samples/hello-world$ ./hello-world ./hello-world: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /home/prabu-test/MachineLearning/Akhil/BUILD/ComputeCpp-CE-0.7.0-Ubuntu-14.04-x86_64/lib/libComputeCpp.so) Running on GeForce GTX 750 Ti terminate called after throwing an instance of 'cl::sycl::exception' Aborted (core dumped)` – Akhilesh Jun 06 '18 at 11:01
0

I notice the same bug when cuda 9.2 installed, try to uninstall cuda and run again your code

Charlie Lutaud
  • 503
  • 5
  • 10