捕获到SYCL异常:错误:[ComputeCpp:RT0101]无法创建内核((内核名称:SYCL_class_multiply)) [英] SYCL exception caught: Error: [ComputeCpp:RT0101] Failed to create kernel ((Kernel Name: SYCL_class_multiply))

查看:99
本文介绍了捕获到SYCL异常:错误:[ComputeCpp:RT0101]无法创建内核((内核名称:SYCL_class_multiply))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了 https://github.com/codeplaysoftware/computecpp-sdk.git并修改了computecpp-sdk/samples/accessors/accessors.cpp文件.

I cloned https://github.com/codeplaysoftware/computecpp-sdk.git and modified the computecpp-sdk/samples/accessors/accessors.cpp file.

我刚刚添加了std::cout << "SYCL exception caught: " << e.get_cl_code() << '\n';.

请参阅完全修改的代码:

/***************************************************************************
 *
 *  Copyright (C) 2016 Codeplay Software Limited
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  For your convenience, a copy of the License has been included in this
 *  repository.
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *  Codeplay's ComputeCpp SDK
 *
 *  accessor.cpp
 *
 *  Description:
 *    Sample code that illustrates how to make data available on a device
 *    using accessors in SYCL.
 *
 **************************************************************************/

#include <CL/sycl.hpp>

#include <iostream>

using namespace cl::sycl;

int main() {
  /* We define the data to be passed to the device. */
  int data = 5;

  /* The scope we create here defines the lifetime of the buffer object, in SYCL
   * the lifetime of the buffer object dictates synchronization using RAII. */
  try {
    /* We can also create a queue that uses the default selector in
     * the queue's default constructor. */
    queue myQueue;

    /* We define a buffer in order to maintain data across the host and one or
     * more devices. We construct this buffer with the address of the data
     * defined above and a range specifying a single element. */
    buffer<int, 1> buf(&data, range<1>(1));

    myQueue.submit([&](handler& cgh) {
      /* We define accessors for requiring access to a buffer on the host or on
       * a device. Accessors are are like pointers to data we can use in
       * kernels to access the data. When constructing the accessor you must
       * specify the access target and mode. SYCL also provides the
       * get_access() as a buffer member function, which only requires an
       * access mode - in this case access::mode::read_write.
       * (make_access<>() has a second template argument which defaults
       * to access::mode::global) */
      auto ptr = buf.get_access<access::mode::read_write>(cgh);

      cgh.single_task<class multiply>([=]() {
        /* We use the subscript operator of the accessor constructed above to
         * read the value, multiply it by itself and then write it back to the
         * accessor again. */
        ptr[0] = ptr[0] * ptr[0];
      });
    });

    /* queue::wait() will block until kernel execution finishes,
     * successfully or otherwise. */
    myQueue.wait();

  } catch (exception const& e) {
    std::cout << "SYCL exception caught: " << e.what() << '\n';
    std::cout << "SYCL exception caught: " << e.get_cl_code() << '\n';
    return 2;
  }

  /* We check that the result is correct. */
  if (data == 25) {
    std::cout << "Hurray! 5 * 5 is " << data << '\n';
    return 0;
  } else {
    std::cout << "Oops! Something went wrong... 5 * 5 is not " << data << "!\n";
    return 1;
  }
}

构建后,我执行了二进制文件,并获得了以下错误输出:

After building I executed the binary and got the following error output:

$ ./accessors 
./accessors: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/lib/libComputeCpp.so)
./accessors: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/lib/libComputeCpp.so)
./accessors: /usr/local/cuda-8.0/lib64/libOpenCL.so.1: no version information available (required by /usr/local/computecpp/lib/libComputeCpp.so)
SYCL exception caught: Error: [ComputeCpp:RT0101] Failed to create kernel ((Kernel Name: SYCL_class_multiply))
SYCL exception caught: -45
 SYCL Runtime closed with the following errors:
SYCL objects are still alive while the runtime is shutting down

 This probably indicates that a SYCL object was created  but not properly destroyed. 
terminate called without an active exception
Aborted (core dumped)

硬件配置如下:

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

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

请帮助您理解错误并解决错误.让我知道是否需要更多信息. 我想在我的NVidia GPU上运行此示例代码.

Please help to understand the error and to solve the same. Let me know if any more information is needed. I would like to run this sample code on my NVidia GPU.

推荐答案

ComputeCpp,开放标准SYCL的实现,默认情况下输出SPIR指令,NVidia OpenCL实现无法使用SPIR指令. 相反,您将需要使用ComputeCpp输出NVidia硬件可以理解的PTX指令.

ComputeCpp, an implementation of the open standard SYCL, outputs SPIR instructions by default, the NVidia OpenCL implementation is not able to consume SPIR instructions. Instead you will need to use ComputeCpp to output PTX instructions that can be understood by the NVidia hardware.

为此,在使用GitHub上的示例代码项目进行cmake调用时,添加参数"-DCOMPUTECPP_BITCODE = ptx64".

To do this, add the argument "-DCOMPUTECPP_BITCODE=ptx64" when making your cmake call using the sample code project from GitHub.

此项目中的FindComputeCpp.cmake文件采用此标志,并提供编译器指令以输出PTX.如果您想对自己的项目执行此操作,则可以从FindComputeCpp.cmake文件中获取相关部分.

The FindComputeCpp.cmake file in this project takes this flag and gives the compiler instructions to output PTX. If you would like to do this with your own project you can take the relevant section from the FindComputeCpp.cmake file.

这篇关于捕获到SYCL异常:错误:[ComputeCpp:RT0101]无法创建内核((内核名称:SYCL_class_multiply))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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