OpenCL 在英特尔系统上生成错误 -32
OpenCL generate error -32 on an intel system
我正尝试在 OpenCL 上学习本教程:
https://anteru.net/2012/11/03/2009/
代码如下:
// http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetPlatformIDs.html
cl_uint platformIdCount = 0;
clGetPlatformIDs(0, nullptr, &platformIdCount);
if (platformIdCount == 0) {
std::cerr << "No OpenCL platform found" << std::endl;
return 1;
}
else {
std::cout << "Found " << platformIdCount << " platform(s)" << std::endl;
}
std::vector<cl_platform_id> platformIds(platformIdCount);
clGetPlatformIDs(platformIdCount, platformIds.data(), nullptr);
for (cl_uint i = 0; i < platformIdCount; ++i) {
std::cout << "\t (" << (i + 1) << ") : " << GetPlatformName(platformIds[i]) << std::endl;
}
// http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceIDs.html
cl_uint deviceIdCount = 0;
clGetDeviceIDs(platformIds[0], CL_DEVICE_TYPE_ALL, 0, nullptr,
&deviceIdCount);
if (deviceIdCount == 0) {
std::cerr << "No OpenCL devices found" << std::endl;
return 1;
}
else {
std::cout << "Found " << deviceIdCount << " device(s)" << std::endl;
}
std::vector<cl_device_id> deviceIds(deviceIdCount);
clGetDeviceIDs(platformIds[0], CL_DEVICE_TYPE_ALL, deviceIdCount,
deviceIds.data(), nullptr);
for (cl_uint i = 0; i < deviceIdCount; ++i) {
std::cout << "\t (" << (i + 1) << ") : " << GetDeviceName(deviceIds[i]) << std::endl;
}
// http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html
const cl_context_properties contextProperties[] =
{
CL_CONTEXT_PLATFORM, reinterpret_cast<cl_context_properties> (platformIds[0]),
0, 0
};
cl_int error = CL_SUCCESS;
cl_context context = clCreateContext(contextProperties, deviceIdCount,
deviceIds.data(), nullptr, nullptr, &error);
CheckError(error);
我 运行 它在 Intel i5 笔记本电脑上。输出如下:
Found 2 platform(s)
(1) : Experimental OpenCL 2.0 CPU Only Platform
(2) : Intel(R) OpenCL
Found 1 device(s)
(1) : Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
错误代码为-32
我在 windows 7 计算机上使用 visual studio 2013。
我该如何解决?
有时英特尔 OpenCL SDK 没有所有驱动程序,尤其是对于较旧的 Xeon 和 iCore 设备。英特尔确实为这些设备提供了额外的运行时安装程序,只是没有使用 SDK。
只需 Google:英特尔 OpenCL 运行时或 try this link(截至 2-2-2015 有效):
我正尝试在 OpenCL 上学习本教程:
https://anteru.net/2012/11/03/2009/
代码如下:
// http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetPlatformIDs.html
cl_uint platformIdCount = 0;
clGetPlatformIDs(0, nullptr, &platformIdCount);
if (platformIdCount == 0) {
std::cerr << "No OpenCL platform found" << std::endl;
return 1;
}
else {
std::cout << "Found " << platformIdCount << " platform(s)" << std::endl;
}
std::vector<cl_platform_id> platformIds(platformIdCount);
clGetPlatformIDs(platformIdCount, platformIds.data(), nullptr);
for (cl_uint i = 0; i < platformIdCount; ++i) {
std::cout << "\t (" << (i + 1) << ") : " << GetPlatformName(platformIds[i]) << std::endl;
}
// http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceIDs.html
cl_uint deviceIdCount = 0;
clGetDeviceIDs(platformIds[0], CL_DEVICE_TYPE_ALL, 0, nullptr,
&deviceIdCount);
if (deviceIdCount == 0) {
std::cerr << "No OpenCL devices found" << std::endl;
return 1;
}
else {
std::cout << "Found " << deviceIdCount << " device(s)" << std::endl;
}
std::vector<cl_device_id> deviceIds(deviceIdCount);
clGetDeviceIDs(platformIds[0], CL_DEVICE_TYPE_ALL, deviceIdCount,
deviceIds.data(), nullptr);
for (cl_uint i = 0; i < deviceIdCount; ++i) {
std::cout << "\t (" << (i + 1) << ") : " << GetDeviceName(deviceIds[i]) << std::endl;
}
// http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html
const cl_context_properties contextProperties[] =
{
CL_CONTEXT_PLATFORM, reinterpret_cast<cl_context_properties> (platformIds[0]),
0, 0
};
cl_int error = CL_SUCCESS;
cl_context context = clCreateContext(contextProperties, deviceIdCount,
deviceIds.data(), nullptr, nullptr, &error);
CheckError(error);
我 运行 它在 Intel i5 笔记本电脑上。输出如下:
Found 2 platform(s)
(1) : Experimental OpenCL 2.0 CPU Only Platform
(2) : Intel(R) OpenCL
Found 1 device(s)
(1) : Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
错误代码为-32
我在 windows 7 计算机上使用 visual studio 2013。
我该如何解决?
有时英特尔 OpenCL SDK 没有所有驱动程序,尤其是对于较旧的 Xeon 和 iCore 设备。英特尔确实为这些设备提供了额外的运行时安装程序,只是没有使用 SDK。
只需 Google:英特尔 OpenCL 运行时或 try this link(截至 2-2-2015 有效):