空的openCL程序引发弃用警告 [英] empty openCL program throws deprecation warning

查看:44
本文介绍了空的openCL程序引发弃用警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了AMD APP 3.0 SDK,当我将#include <CL/cl.hpp>包含到我的cpp中时,它会引发弃用警告:

I downloaded the AMD APP 3.0 SDK and as soon as I include #include <CL/cl.hpp> into my cpp it throws deprecation warnings:

1>c:\program files (x86)\amd app sdk\3.0\include\cl\cl.hpp(4240): warning 
     C4996: 'clCreateSampler': was declared deprecated

还有更多

我做错什么了吗?在编写一行有用的代码之前,我已经开始使用openCL并收到了很多警告,这让我感到不舒服.

Am I doing something wrong? I feel uncomfortable starting to play with openCL having so many warnings already before writing a single line of useful code.

推荐答案

此处的问题是cl.hpp用于OpenCL 1.X平台,但是AMD的其他SDK都支持OpenCL 2.0. clCreateSampler函数在OpenCL 2.0中已弃用.

The issue here is that cl.hpp is for OpenCL 1.X platforms, but the rest of AMD's SDK supports OpenCL 2.0. The clCreateSampler function was deprecated in OpenCL 2.0.

Khronos已发布C ++绑定的OpenCL 2.X版本-cl2.hpp-如果您希望使用C ++ API定位OpenCL 2.0设备,则应使用该版本.它可能尚未传播到供应商的SDK,但是您可以直接从Khronos获取最新版本 .要使用此标头定位OpenCL 2.0,您可以像这样包含它:

Khronos have released an OpenCL 2.X version of the C++ bindings - cl2.hpp - which is what you should use if you wish to target OpenCL 2.0 devices using the C++ API. It may not have propagated to the vendor SDKs yet, but you can get the latest version directly from Khronos. To target OpenCL 2.0 with this header, you would include it like this:

#define CL_HPP_TARGET_OPENCL_VERSION 200
#include <CL/cl2.hpp>

如果您希望改用OpenCL 1.2平台,则只需更改CL_HPP_TARGET_OPENCL_VERSION_MACRO的值:

If you wish to target OpenCL 1.2 platforms instead, you just need to change the value of the CL_HPP_TARGET_OPENCL_VERSION_MACRO:

#define CL_HPP_TARGET_OPENCL_VERSION 120
#include <CL/cl2.hpp>

(这将取消您先前收到的弃用警告)

(this will suppress the deprecation warnings that you previously received)

对于1.X平台,您仍然可以使用1.X标头(cl.hpp);您只需要明确说明弃用警告对您来说不是问题:

You could still use the 1.X header (cl.hpp) for 1.X platforms; you just need to make it clear that the deprecation warnings are not an issue for you:

#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#include <CL/cl.hpp>

这篇关于空的openCL程序引发弃用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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