Ah, I'm a dummy. Forgot to initialize the command queue! No wonder why it

was invalid...
master
mitchellhansen 8 years ago
parent c3902c2f6e
commit 5d9d3c4f4d

@ -232,11 +232,12 @@ int CL_Wrapper::store_buffer(cl_mem buffer, std::string buffer_name){
int CL_Wrapper::run_kernel(std::string kernel_name){ int CL_Wrapper::run_kernel(std::string kernel_name){
const int WORKER_SIZE = 1; const int WORKER_SIZE = 10;
size_t global_work_size[1] = { WORKER_SIZE }; size_t global_work_size[1] = { WORKER_SIZE };
cl_kernel kernel = kernel_map.at(kernel_name); cl_kernel kernel = kernel_map.at(kernel_name);
//error = clEnqueueTask(command_queue, kernel, 0, NULL, NULL);
error = clEnqueueNDRangeKernel( error = clEnqueueNDRangeKernel(
command_queue, kernel, command_queue, kernel,
1, NULL, global_work_size, 1, NULL, global_work_size,

@ -39,18 +39,19 @@ int main(){
CL_Wrapper c; CL_Wrapper c;
c.acquire_platform_and_device(); c.acquire_platform_and_device();
c.create_shared_context(); c.create_shared_context();
c.create_command_queue();
c.compile_kernel("../kernels/kernel.txt", true, "hello"); c.compile_kernel("../kernels/kernel.c", true, "hello");
c.compile_kernel("../kernels/minimal_kernel.c", true, "min_kern"); c.compile_kernel("../kernels/minimal_kernel.c", true, "min_kern");
std::string in = "hello!!!!!!!!!!!!!!!!!!!!!"; std::string in = "hello!!!!!!!!!!!!!!!!!!!!!";
cl_mem buff = clCreateBuffer( cl_mem buff = clCreateBuffer(
c.getContext(), CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, c.getContext(), CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
sizeof(char) * in.size(), &in, NULL); sizeof(char) * 128, NULL, NULL);
c.store_buffer(buff, "buffer_1"); c.store_buffer(buff, "buffer_1");
//c.set_kernel_arg("min_kern", 0, "buffer_1"); c.set_kernel_arg("min_kern", 0, "buffer_1");
c.run_kernel("min_kern"); c.run_kernel("min_kern");

Loading…
Cancel
Save