OpenCL getInfo() not compiling with some options

I am new to OpenCL, by now I am running the following code:

int main() {
	std::vector<cl::Platform> platforms;
	std::vector<cl::Device> devices;
	cl::Platform::get(&platforms);
	platforms[0].getDevices(CL_DEVICE_TYPE_ALL, &devices);

	std::cout << "Name:           " << devices[0].getInfo<CL_DEVICE_NAME>() << std::endl;
	std::cout << "Vendor:         " << devices[0].getInfo<CL_DEVICE_VENDOR>() << std::endl;
	std::cout << "Device Version: " << devices[0].getInfo<CL_DEVICE_VERSION>() << std::endl;
	std::cout << "Device Profile: " << devices[0].getInfo<CL_DEVICE_PROFILE>() << std::endl;
	std::cout << "Driver Version: " << devices[0].getInfo<CL_DRIVER_VERSION>() << std::endl;
	std::cout << "Image Support:  " << devices[0].getInfo<CL_DEVICE_IMAGE_SUPPORT>() << std::endl;
	std::cout << "Image Width:    " << devices[0].getInfo<CL_DEVICE_IMAGE2D_MAX_WIDTH>() << std::endl;
	std::cout << "Image Height:   " << devices[0].getInfo<CL_DEVICE_IMAGE2D_MAX_HEIGHT>() << std::endl;
	//std::cout << "Image Pitch:    " << devices[0].getInfo<CL_DEVICE_IMAGE_PITCH_ALIGNMENT>() << std::endl;
}

which gives me the output:

Name:           NVIDIA GeForce GTX 1060 6GB
Vendor:         NVIDIA Corporation
Device Version: OpenCL 3.0 CUDA
Device Profile: FULL_PROFILE
Driver Version: 536.67
Image Support:  1
Image Width:    16384
Image Height:   32768

So far that is fine. But when I uncomment the line

std::cout << "Image Pitch:    " << devices[0].getInfo<CL_DEVICE_IMAGE_PITCH_ALIGNMENT>() << std::endl;

I get a compiler error error C2672: 'cl::Device::getInfo': no matching overloaded function found
In fact I get such an error for all the options to getDevice() which are marked in the Khronos Registry as “missing before version x.x”. But since we see in the output above we have OpenCL 3.0, how to get those lines compiled? What is the problem here?

It seems to be available in the C API.

I have installed CUDA 12.2.1 with driver 535.86.10:

# cat t1.cpp
#define CL_TARGET_OPENCL_VERSION 300
#include <CL/cl.h>
#include <stdint.h>
#include <iostream>

int main(int argc, char *argv[])
{
  cl_platform_id platform;
  cl_device_id device;
  cl_context context;
  cl_command_queue queue1, queue2;
  cl_program program;
  cl_mem mem1, mem2;
  cl_kernel kernel;

  clGetPlatformIDs(1, &platform, NULL);
  clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 1, &device, NULL);
  cl_uint val;
  size_t sz;
  cl_int ret=clGetDeviceInfo (device ,
        CL_DEVICE_IMAGE_PITCH_ALIGNMENT ,
        sizeof(cl_uint) ,
        &val ,
        &sz );
  std::cout << ret << "," << val << "," << sz << std::endl;
}
# g++ -o t1 t1.cpp -I/usr/local/cuda/include  -L/usr/local/cuda/lib64 -lOpenCL
# ./t1
0,0,4
#

But I agree it appears to be missing in the C++ API. It may be an oversight. You could file a bug.

Ok thanks, I downloaded the OpenCL SDK release from Khronos Releases · KhronosGroup/OpenCL-SDK · GitHub and with the header files from there it all seems to work. Looks like cuda is shipping with outdated headers.