如何在openCL中运行helloworld程序



我在OpenCL中编写了我的第一个程序。但是我不能运行这个程序,因为失败断言平台大小:

#include <iostream>
#include <vector>
#include <cassert>
#include <fstream>
#include <string>
//#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#include <CL/cl.hpp>
using utyp = unsigned int;
constexpr utyp SIZE = 100000000;
int main(int argc, char *argv[] ) {
std::vector< cl::Platform > platforms;
const auto retGet = cl::Platform::get( &platforms );
std::cout << "retGet == " << retGet << std::endl;
std::cout << "Platforms.size == " << platforms.size() << std::endl;
assert( platforms.size() > 0 );
// etc

我使用kubuntu 18.x

谢谢你的帮助。顺致敬意,

继续。。。

我可以访问源cl::平台::get:

static cl_int get( VECTOR_CLASS<Platform>* platforms)   {
cl_uint n = 0;
if( platforms == NULL ) {
return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
}
cl_int err = ::clGetPlatformIDs(0, NULL, &n);
if (err != CL_SUCCESS) {
return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
}
//etc

::clGetPlatformID(0,NULL,&n(返回-1001。

我在文档中找不到任何描述值-1001。:/

我找到了解决方案。我不得不从这个网站安装软件包:

https://github.com/intel/compute-runtime/blob/master/DISTRIBUTIONS.md

最新更新