我是OpenCL的新手。在运行Windows 7的具有Intel(R)HD Graphics 4000的Core i5计算机上工作,我安装了支持OpenCL的最新Intel驱动程序。GpuCapsViewer确认我具有OpenCL支持设置。我使用英特尔OpenCL SDK开发了一个简单的HelloWorld程序。我已经成功编译了程序,但是运行时,由于分段错误而调用clGetPlatformIDs()时,它崩溃了。这是我的代码:
#include <iostream>
#include <CL/opencl.h>
int main() {
std::cout << "Test OCL without driver" << std::endl;
cl_int err;
cl_uint num_platforms;
err = clGetPlatformIDs(0, NULL, &num_platforms);
if (err == CL_SUCCESS) {
std::cout << "Success. Platforms available: " << num_platforms
<< std::endl;
} else {
std::cout << "Error. Platforms available: " << num_platforms
<< std::endl;
}
std::cout << "Test OCL without driver" << std::endl;
std::cout << "Press button to exit." << std::endl;
std::cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
GpuCapsViewer如何成功确认OpenCL支持并可以使用它运行其演示,但我却无法运行我的代码?两者必须使用相同的功能,对吗? …