Getting "cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)" warning during runtime

Viewed 3969

Following this and this posts, I'm compiling the main.c code on this GitHub Gist.

Running CMake command find_package(OpenCL REQUIRED) I get this:

-- Looking for CL_VERSION_2_2 - found
-- Found OpenCL: C:/Program Files (x86)/IntelSWTools/system_studio_2020/OpenCL/sdk/lib/x86/OpenCL.lib (found version "2.2")

indicating that an OpenCL SDK version 2.2 was found. This is in contradiction with what I get from clinfo tool, detecting a 1.2 OpenCL for Intel's SDK/platforms. Now when running the executable I get:

cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)

My questions are:

  1. Why I get two different versions of OpenCL from CMake and clinfo?
  2. What is the warning I'm getting at runtime and how to fix that?

P.S. Here is the output of cmake .. --debug-find

1 Answers

OpenCL version in SDK and reported by clinfo are 2 different things:

  • clinfo reports OpenCL version supported by your GPU
  • SDK OpenCL version is the max version supported by SDK

Now if you use in your program OpenCL 2.0 and your GPU supports OpenCL 1.2 then I would suspect one of the CL functions will report error or the program will have undefined behavior. You can set the target OpenCL version in your program using #define CL_TARGET_OPENCL_VERSION <version>, for example

#define CL_TARGET_OPENCL_VERSION 120

and then the API above target version shouldn't be available.

Related