Windows 10
Intel Core i7
NVidia GeForce 1080
I have been following along this guys tutorials up on YouTube.
I am on video 6 of 9
I have followed his tutorial exactly. I have even created my .CL file. Ensured that it’s in the same folder as the executable. However, my app is crashing on
err = program.build("-cl-std=CL1.2");
I am getting the error
ERROR: clBuildProgram(-11)
I’m hoping someone can help me figure out why I might be getting this error. Again, I am very new… As in, this is my second day trying to learn OpenCL.
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <fstream>
#include <CL/cl.hpp>
using namespace std;
int main()
{
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
auto platform = platforms.front();
std::vector<cl::Device> devices;
platform.getDevices(CL_DEVICE_TYPE_GPU, &devices);
auto device = devices.front();
std::ifstream hellowWorldFile("FirstOpenCL.cl");
std::string src(std::istreambuf_iterator<char>(hellowWorldFile), (std::istreambuf_iterator<char>()));
cl::Program::Sources sources(1, std::make_pair(src.c_str(), src.length() + 1));
cl::Context context(device);
cl::Program program(context, sources);
cl_int err;
try
{
err = program.build("-cl-std=CL1.2");
}
catch (cl::Error errA)
{
std::cerr
<< "ERROR: "
<< errA.what()
<< "("
<< errA.err()
<< ")"
<< std::endl;
}
char buf[16];
cl::Buffer memBuff(context, CL_MEM_WRITE_ONLY|CL_MEM_HOST_READ_ONLY, sizeof(buf));
cl::Kernel kernel(program, "FirstOpenCL", &err);
kernel.setArg(0, memBuff);
cl::CommandQueue queue(context, device);
queue.enqueueTask(kernel);
queue.enqueueReadBuffer(memBuff, CL_TRUE, 0, sizeof(buf), buf);
std::cout << buf;
std::cin.get();
return 0;
}
Here is the opencl file
_kernel void FirstOpenCL(__global char* data)
{
data[0] = 'H';
data[1] = 'e';
data[2] = 'l';
data[3] = 'l';
data[4] = 'o';
data[5] = '';
data[6] = 'W';
data[7] = 'o';
data[8] = 'r';
data[9] = 'l';
data[10] = 'd';
data[11] = '!';
data[12] = '
';
}