呼叫ClgetPlatFormids时,OpenCl返回-64
OpenCL returning -64 upon calling clGetPlatformIDs
编辑:错误代码为以下
CL_INVALID_PROPERTY if context property name in properties is not a
supported property name, if the value specified for a supported property
name is not valid, or if the same property name is specified more than once.
However if the extension cl_khr_gl_sharing is enabled, then
CL_INVALID_PROPERTY is returned if an attribute name other than those listed
in the table for properties above is specified in properties.
我正在使用mingw(x86)和x86 amd opencl libary,以下代码在最终检查之后返回null:
cl_context CreateContext()
{
cl_int errNum;
cl_uint numPlatforms;
cl_platform_id firstPlatformID;
cl_context context=NULL;
//Select an OpenCL platform
errNum=clGetPlatformIDs(1, &firstPlatformID, &numPlatforms);
if (errNum!=CL_SUCCESS||numPlatforms<=0)
{
cerr<<"Failed to find any OpenCL platforms."<<endl;
return NULL;
}
cl_context_properties contextProperties[]=
{
CL_CONTEXT_PLATFORM,
(cl_context_properties) firstPlatformID,
};
context=clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, NULL, NULL, &errNum);
cout << errNum << endl;
if (errNum!=CL_SUCCESS)
{
cerr<<"Failed to create an OpenCL GPU context, trying CPU."<<endl;
context=clCreateContextFromType(contextProperties,CL_DEVICE_TYPE_CPU, NULL, NULL, &errNum);
if (errNum!=CL_SUCCESS)
{
cerr<<"Failed to create an OpenCL GPU or CPU context."<<endl;
return NULL;
}
}
return context;
}
它可以检测到2个平台(Intel CPU,AMD GPU),但无法创建上下文。X64 Libary做同样的事情。有人知道如何修复它吗?
根据clcreatecontext的文档,您必须终止以零的cl_context_properties列表。
随着以下更改,代码对我有用:
cl_context_properties contextProperties[] =
{
CL_CONTEXT_PLATFORM,
(cl_context_properties)firstPlatformID,
0
};
相关文章:
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- 使用std::vector的OpenCL矩阵乘法
- 什么时候在C++中返回常量引用是个好主意
- 你能重载对象变量名本身返回的内容吗
- 为什么 Serial.println(<char[]>);返回随机字符?
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- 如何获取std::result_of函数的返回类型
- QueryWorkingSet总是返回false
- (C++)分析树以计算返回错误值的简单算术表达式
- 访问者访问变体并返回不同类型时出错
- 向量加法代码 OpenCL 返回 clCreateKernel 错误 -46
- openCL 内核返回垃圾值,尽管没有错误
- openCL-创建子缓冲区返回错误代码13
- OpenCL global_work_size不反映返回的实际 ID
- OPENCL-如何使辅助功能返回阵列并将内存的部分从恒定内存空间转移到私有
- OpenCL - 内核方法返回意外结果
- OpenCL/C++ - 返回一个 cl::Buffer 对象
- 呼叫ClgetPlatFormids时,OpenCl返回-64
- OpenCL :将两个字符串传递给内核,不返回任何内容
- OpenCL:返回std::future而不是阻塞clFinish