empty openCL program throws deprecation warning

老子叫甜甜 提交于 2020-01-01 16:38:52

问题


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

and many more.

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.


回答1:


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

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)

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>


来源:https://stackoverflow.com/questions/34359925/empty-opencl-program-throws-deprecation-warning

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!