【问题标题】: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)9>' 的实例后调用终止
【发布时间】:2018-06-04 05:57:55
【问题描述】:

我是 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;
}

我正在使用

构建此代码

$ 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

并得到错误

$ ./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::detail::exception_implementation >' 中止(核心转储) 错误是什么意思?我怎样才能解决这个问题?请帮帮我。

附: 系统硬件是

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

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

附言 我已更新代码以了解我正在运行代码的设备。

sn-p的修改是

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::detail::exception_implementation >' 中止(核心转储)

【问题讨论】:

  • 您能否编辑以显示您尝试使用的硬件、已安装的 OpenCL 驱动程序以及位于 Linux 上“bin”文件夹中的“computecpp_info”可执行文件的输出。另外,您是否成功完成了入门指南? developer.codeplay.com/computecppce/latest/…
  • @RodBurns 我添加了computecpp的结果。

标签: c++ opencl nvidia gpgpu sycl


【解决方案1】:

有一个 cl::sycl::detail::exception_implementation&lt;(cl::sycl::detail::exception_types)9, cl::sycl::detail::exception_implementation&lt;(cl::sycl::detail::exception_types)6, cl::sycl::exception&gt; &gt; 类型的异常被抛出但未被捕获。

要查看异常的详细信息,请在您的 main 中添加 try 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;
}

【讨论】:

  • 我尝试了你的建议并得到了我在这里提出的错误stackoverflow.com/questions/50682320/…,请看看这个,给我一些意见。
  • @Akhilesh 抱歉,我对 sycl 不熟悉,您查看过文档吗?
  • 这绝对是更好地了解错误的第一步!
【解决方案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 文件夹。

【讨论】:

  • 如果您运行 hello-world 或我们提供的使用 cmake 构建的其他示例,是否一切正常?
  • 当我将device selectorsycl::queue queue(sycl::cpu_selector{}); 更改为sycl::queue queue(sycl::host_selector{}); 时,只有它工作正常。我有gpu_selector, defualt_selector,但不幸的是它没有用。
  • 但是当您按照网站上的说明操作时,hello world 示例运行良好吗?这是开始检查设置是否正确的好地方developer.codeplay.com/computecppce/latest/…
  • 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)的输出
【解决方案3】:

我在安装 cuda 9.2 时发现了同样的错误,尝试卸载 cuda 并再次运行您的代码

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    • 2018-01-06
    • 2017-03-08
    相关资源
    最近更新 更多