Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

empty openCL program throws deprecation warning

Tags:

c++

opencl

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.

like image 812
NOhs Avatar asked Dec 18 '15 16:12

NOhs


1 Answers

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>
like image 189
jprice Avatar answered Oct 06 '22 00:10

jprice