我开始为使用 OpenCL 编写一个小“引擎”。现在,我遇到了一个很奇怪的问题。
当我调用clGetDeviceInfo()
查询特定设备的信息时,参数的某些选项param_name
返回错误代码-30(= CL_INVALID_VALUE)。一个非常著名的选项是 CL_DEVICE_EXTENSIONS 选项,无论我使用什么 sdk 或平台,它都应该返回一串扩展名。我检查了每一个边缘,并且对参数进行了双重检查。
我不明白的另一件事是,当我在工作的 Windows 机器上运行我的源代码时,该clGetPlatformInfo()
函数还返回我查询 CL_PLATFORM_EXTENSIONS 字符串的 CL_INVALID_VALUE。在家里,我使用的是运行 Ubuntu 的 Linux 机器,它显示扩展字符串没有任何问题。
以下是我平台的数据:
工作:
- 英特尔酷睿 i5 2500 处理器
- 英伟达 Geforce 210 GPU
- AMD APP SDK 3.0 测试版
家:
- 英特尔酷睿 i7 5820K CPU
- AMD Radeon HD7700 显卡
- AMD APP SDK 3.0 测试版
这是来源:
源代码是用 cpp 编写的,opencl 函数嵌入在一些包装类(即 OCLDevice)中。
OCLDevice::OCLDevice(cl_device_id device)
{
cl_int errNum;
cl_uint uintBuffer;
cl_long longBuffer;
cl_bool boolBuffer;
char str[128];
size_t strSize = (sizeof(char) * 128);
size_t retSize;
//Device name string.
errNum =
clGetDeviceInfo(device,CL_DEVICE_NAME,strSize,(void*)str,&retSize);
throwException();
this->name = string(str,retSize);
//The platform associated with this device.
errNum =
clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(cl_platform_id),
(void*)&(this->platform), &retSize);
throwException();
//The OpenCL device type.
errNum =
clGetDeviceInfo(device, CL_DEVICE_TYPE,
sizeof(cl_device_type),
(void*)&(this->devType),&retSize);
throwException();
//Vendor name string.
errNum =
clGetDeviceInfo(device,CL_DEVICE_VENDOR,
strSize,(void*)str,&retSize);
throwException();
this->vendor = string(str,retSize);
//A unique device vendor identifier.
//An example of a unique device identifier could be the PCIe ID.
errNum =
clGetDeviceInfo(device, CL_DEVICE_VENDOR_ID,
sizeof(unsigned int),
(void*)&(this->vendorID),&retSize);
throwException();
//Returns a space separated list of extension names
//supported by the device.
clearString(str,retSize); //fills the char string with 0-characters
errNum =
clGetDeviceInfo(device,CL_DEVICE_EXTENSIONS,strSize,str,&retSize);
throwException();
//some more queries (some with some without the same error)...
}
正如您在代码param_value_size > param_value_size_ret中看到的那样,也没有理由返回错误。param_name从标头复制以保存,没有输入错误。
如果有人知道这个问题的答案,那就太好了。