【问题标题】:SYCL No kernel named was found -46 (CL_INVALID_KERNEL_NAME)SYCL 未找到内核名称 -46 (CL_INVALID_KERNEL_NAME)
【发布时间】:2023-02-18 20:44:48
【问题描述】:

以下 c++ SYCL 代码仅适用于主机设备,使用 GPU 设备(NVIDIA 或 INTEL)我有以下错误:

没有找到名为 _ZTSZZN10MainWindow15testPerformanceEiENKUlRN2cl4sycl7handlerEE_clES3_E10FillBuffer 的内核 -46 (CL_INVALID_KERNEL_NAME)

提前致谢。

std::vector<sycl::platform> all_platforms = sycl::platform::get_platforms();
    cl::sycl::device selectedDevice;

    if (all_platforms.size()==0)
    {
        std::cout<<" No platforms found. Check OpenCL installation!\n";
        return;
    }

    for(size_t i = 0; i < all_platforms.size(); i++)
    {
        sycl::platform  current_platform = all_platforms[i];

        std::vector<sycl::device> all_devices = current_platform.get_devices();

        // Loop over all devices available from this platform.
        for( const cl::sycl::device& device : all_devices )
        {
            QString type;

            if(device.is_gpu())
            {
                selectedDevice = device;
                break;
            }
        }
    }

    sycl::queue myQueue(selectedDevice);

    try
    {
        myQueue.submit([&](sycl::handler &h) {
            sycl::stream os(1024, 768, h);
            h.parallel_for<class FillBuffer>(32, [=](sycl::id<1> i) {
                os<<i<<"\n";
              });
          }).wait();
    }
    catch (cl::sycl::exception ex)
    {
        std::cout << "cl::sycl::exception+: " << ex.what() << " category: " << ex.category().name()  << std::endl;
        return;
    }

【问题讨论】:

    标签: sycl


    【解决方案1】:

    从第一次检查开始,它看起来像是与名称空间相关的问题。

    代替

    h.parallel_for<class FillBuffer>(32, [=](sycl::id<1> i) {
                    os<<i<<"
    ";
                  });
    

    声明class FillBuffer;在你的文件的顶部,然后使用

    h.parallel_for<FillBuffer>(32, [=](sycl::id<1> i) {
                    os<<i<<"
    ";
                  });
    

    【讨论】:

      【解决方案2】:

      问题与 qmake 自动生成的 Makafile 参数顺序有关

      错误的方式(自动生成):

      $(LINKER) $(LFLAGS) /MANIFEST:embed /OUT:$(DESTDIR_TARGET) @<<
      debugmain.obj debugmainwindow.obj debugmoc_mainwindow.obj
      $(LIBS)
      <<
      

      正确方法:

          $(LINKER) debugmain.obj debugmainwindow.obj debugmoc_mainwindow.obj $(LFLAGS) /MANIFEST:embed /OUT:$(DESTDIR_TARGET) @<<
      $(LIBS)
      <<
      

      【讨论】:

      • 感谢您发布您的解决方案。
      【解决方案3】:

      由于 C 和 CXX 被启用为默认语言,我在我的 cmake 项目中遇到了这个错误。在这种情况下使用了错误的编译器/链接器。设置 project(projectName CXX) 修复了它,编译现在可以使用指定的 SYCL 编译器。

      【讨论】:

        猜你喜欢
        • 2018-11-13
        • 2019-05-17
        • 1970-01-01
        • 2022-07-01
        • 2021-07-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多