【问题标题】:Warnings compiling simple SYCL program with Clang++使用 Clang++ 编译简单 SYCL 程序的警告
【发布时间】:2023-02-14 02:10:27
【问题描述】:

当使用 Clang++ vanilla 版本 16(非英特尔版本)编译一个非常简单的程序时,我收到了使用 dpcpp 编译器编译时不会出现的警告。我很担心,因为我无法知道这些警告是否意味着我的代码在运行时会以某种方式出现故障。

这个最小的代码生成一些关于 interop_handler 被弃用的警告:

#include <CL/sycl.hpp>
int main(){}

发出的命令如下,其中 INCLUDEDIR 用于指示 SYCL 标头所在的位置:

clang++ -std=c++17 -I$INCLUDEDIR -c t.cpp

警告是:

In file included from t.cpp:1:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl.hpp:16:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/backend.hpp:18:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/backend_traits_opencl.hpp:26:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/queue.hpp:20:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/handler.hpp:14:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/cg.hpp:27:
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/cg_types.hpp:234:32: warning: 'interop_handler' is deprecated: interop_handler class is deprecated, use interop_handle instead with host-task [-Wdeprecated-declarations]
  std::function<void(cl::sycl::interop_handler)> MFunc;
                               ^
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/interop_handler.hpp:18:7: note: 'interop_handler' has been explicitly marked deprecated here
class __SYCL_DEPRECATED("interop_handler class is deprecated, use"
      ^
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/defines_elementary.hpp:45:38: note: expanded from macro '__SYCL_DEPRECATED'
#define __SYCL_DEPRECATED(message) [[deprecated(message)]]
                                     ^
In file included from t.cpp:1:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl.hpp:16:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/backend.hpp:18:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/backend_traits_opencl.hpp:26:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/queue.hpp:20:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/handler.hpp:14:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/cg.hpp:27:
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/cg_types.hpp:237:44: warning: 'interop_handler' is deprecated: interop_handler class is deprecated, use interop_handle instead with host-task [-Wdeprecated-declarations]
  InteropTask(std::function<void(cl::sycl::interop_handler)> Func)
                                           ^
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/interop_handler.hpp:18:7: note: 'interop_handler' has been explicitly marked deprecated here
class __SYCL_DEPRECATED("interop_handler class is deprecated, use"
      ^
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/defines_elementary.hpp:45:38: note: expanded from macro '__SYCL_DEPRECATED'
#define __SYCL_DEPRECATED(message) [[deprecated(message)]]
                                     ^
In file included from t.cpp:1:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl.hpp:16:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/backend.hpp:18:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/backend_traits_opencl.hpp:26:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/queue.hpp:20:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/handler.hpp:14:
In file included from /ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/cg.hpp:27:
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/cg_types.hpp:239:23: warning: 'interop_handler' is deprecated: interop_handler class is deprecated, use interop_handle instead with host-task [-Wdeprecated-declarations]
  void call(cl::sycl::interop_handler &h) { MFunc(h); }
                      ^
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/interop_handler.hpp:18:7: note: 'interop_handler' has been explicitly marked deprecated here
class __SYCL_DEPRECATED("interop_handler class is deprecated, use"
      ^
/ONE_API_2022.3/compiler/2022.2.0/linux/include/sycl/CL/sycl/detail/defines_elementary.hpp:45:38: note: expanded from macro '__SYCL_DEPRECATED'
#define __SYCL_DEPRECATED(message) [[deprecated(message)]]
                                     ^
3 warnings generated.

如前所述,这是一个最小的例子;使用更复杂的 SYCL 代码会有更多警告。我想知道我是否应该担心以及是否有某种方法可以解决警告。

【问题讨论】:

    标签: clang intel sycl dpc++


    【解决方案1】:

    当您将 /ONE_API_2022.3/compiler/2022.2.0/linux/include/ 复制到本地目录并使用这些复制的包含调用 dpcpp

    dpcpp -Iinclude/sycl/ -Iinclude -c t.cpp
    

    然后你还会看到很多弃用警告。

    dpcpp 有一些神奇之处,因此您在调用 dpcpp 时不必手动指定 -I。我想同样的魔法可以消除来自这些自动包含文件的弃用警告。

    【讨论】:

    • 警告与 include 目录非常不同。显然,dpcpp 有很多方法可以找到它的包含标头(t.g.“$(which dpcpp)/../include”。也就是说,它与不需要出现警告或隐藏警告(如果是这种情况)有很大不同). 另外,我不希望我的问题被回答为“dpcpp does some magic”。我想确切地了解发生了什么,以便知道我是否应该担心。
    • 弃用的警告并不意味着该程序将无法正常工作。只是图书馆作者想宣传其他/新的编码方式。而且在未来版本的库中,旧方法可能无法正常工作。此外,官方的英特尔编译器也看到了这些弃用并使它们沉默。这两个事实都让我确信我不应该担心。
    【解决方案2】:

    你不能像那样用 clang 编译 SYCL 程序。
    为了编译 SYCL 程序,您需要:

    • 工作的 SYCL 编译器(即 openSYCL、oneAPI DPC++)
    • 或者 SYCL 标准的库实现来链接你的程序(但我不知道这样的实现是否存在)。

    您可以检查可用的 SYCL 实现 here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-10
      • 2012-10-17
      • 1970-01-01
      • 1970-01-01
      • 2018-11-03
      相关资源
      最近更新 更多