抛出'cl :: sycl :: detail :: exception_implementation<(cl :: sycl :: detail :: exception_types)9>的实例后终止调用 [英] terminate called after throwing an instance of 'cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)9>'

查看:77
本文介绍了抛出'cl :: sycl :: detail :: exception_implementation<(cl :: sycl :: detail :: exception_types)9>的实例后终止调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SYCL/OpenCL/GPGPU的新手.我正在尝试构建并运行恒定添加程序

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

我正在使用

$ 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

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

什么是

抛出一个实例后调用

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

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. 系统硬件是

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

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

PS 我已经更新了代码,以了解要在其上运行代码的设备.

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

修改的片段是

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上运行.

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

couputecpp_info

显示

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

但是,它仍然显示与

抛出一个实例后调用

terminate '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>>' 已中止(核心已弃用)

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<(cl::sycl::detail::exception_types)9, cl::sycl::detail::exception_implementation<(cl::sycl::detail::exception_types)6, cl::sycl::exception> >被抛出但未被捕获.

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.

要查看异常的详细信息,请在主程序中添加try catch或在调试器中运行代码.例如:

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

这篇关于抛出'cl :: sycl :: detail :: exception_implementation&lt;(cl :: sycl :: detail :: exception_types)9&gt;的实例后终止调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆