终止称为投掷的实例后 'CL :: sycl ::详细:: exception_implem

2019-09-28 12:06发布

我在SYCL / OpenCL的/ GPGPU新手。 我试图建立和运行不断追加程序的示例代码,

#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;
}

我使用的建设这个代码

$克++ constantAdder_backup.cpp -g -std = C ++ 11 -o constantAdder -I / USR /本地/ computecpp /包括-I的/ usr /包括/ -L的/ usr /本地/ computecpp / lib中-lComputeCpp -L / USR / LIB / x86_64的-Linux的GNU -lOpenCL

并得到错误

$ ./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)

什么是

终止称为投掷的“CL :: sycl ::详细实例后:: exception_implementation <(CL :: sycl ::详细:: exception_types)9,CL :: sycl ::详细:: exception_implementation <(CL :: sycl: :细节:: exception_types)6,CL :: sycl ::例外>>”中止(核心转储)错误意思? 我怎样才能解决这个问题? 请帮我。

PS系统硬件

$ /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

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

PS我已经更新了代码,知道我上运行的代码装置。

修饰的片段是

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

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

现在我正在cpu::selector (而不是NVIDIA的硬件),并打印设备。 它清楚地表明,它在其上运行Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz 。 输出

couputecpp_info

节目

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

但尽管如此,它显示了同样的错误

终止称为投掷的“CL :: sycl ::详细实例后:: exception_implementation <(CL :: sycl ::详细:: exception_types)9,CL :: sycl ::详细:: exception_implementation <(CL :: sycl: :细节:: exception_types)6,CL :: sycl ::例外>>”中止(核心转储)

Answer 1:

有类型的异常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> >被抛出,而不是被抓住。

要查看异常的详细信息在您的主要么添加一个尝试catch或在调试器中运行代码。 例如:

int main(int, char**) {
  try
  {
     /*your code here*/
  }
  catch (std::exception& ex)
  {
    std::cerr << "exception caught: " << ex.what() << std::endl;
    return 1;
  }
  return 0;
}


Answer 2:

建立你的代码,当你不使用SYCL编译器。 下面的命令可以用来做这个。

/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

您还需要确保LD_LIBRARY_PATH设置执行输出时,指向您ComputeCpp安装的lib文件夹。



Answer 3:

我注意到安装CUDA 9.2时相同的错误,尝试卸载CUDA,并再次运行代码



文章来源: terminate called after throwing an instance of 'cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)9>'