Hi,
I am using ubuntu 10.4 and the OpenCL C++ wrapper.
I also tested it with the c-binding.
I tried to get getKernelWorkGroupInfo, but compiler tell me hey don't know this function. Same with queue.setProperty. I have tried it on windows - it works without any problems.
So why do I have problems on ubuntu?
Originally posted by: Sheeep Hi,
I am using ubuntu 10.4 and the OpenCL C++ wrapper.
I also tested it with the c-binding.
I tried to get getKernelWorkGroupInfo, but compiler tell me hey don't know this function. Same with queue.setProperty. I have tried it on windows - it works without any problems.
So why do I have problems on ubuntu?
Could you please post your code here?
Hi,
here is my code.
kernel1.getWorkGroupInfo(devices[0], CL_KERNEL_WORK_GROUP_SIZE, &datasize);
work on windows, but not on ubuntu.
same with queue.setProperty(CL_QUEUE_PROFILING_ENABLE, true);
I have add a simple Kernel, because the kernel is not the problem.
MFG
Sheeep
EDIT: Ok, i have fixed one error, and update attached code. but the problem is still there:
running the code on ubuntu I get the opencl error: clGetKernelWorkGroupInfo(-30)
Same code on windows works!
But queue.setProperty(CL_QUEUE_PROFILING_ENABLE, true); works now on ubuntu too!
EDIT2:
queue.getInfo(CL_QUEUE_PROPERTIES,&info); throws an error on ubuntu:
OpenCL-Error: clGetCommandQueueInfo(-30)
on windows it works fine!
// Hostcode #include <cstdio> #include <cstdlib> #include <fstream> #include <iostream> #include <vector> #include <iterator> #define __CL_ENABLE_EXCEPTIONS #include <CL/cl.hpp> #include <ctime> int main(int argc, char** argv){ cl_int error; std::string buildlog; cl::Context context; cl::Program program; std::vector<cl::Device> devices; try{ std::vector<cl::Platform> platforms; cl::Platform::get(&platforms); cl_context_properties platform=NULL; std::vector<cl::Platform>::iterator i; if(platforms.size() > 0){ for(i = platforms.begin(); i != platforms.end(); ++i){ platform=((cl_context_properties)(*i)()); if(!strcmp((*i).getInfo<CL_PLATFORM_VENDOR>().c_str(), "Advanced Micro Devices, Inc."))break; } } cl_context_properties cps[3] = { CL_CONTEXT_PLATFORM, platform, 0 }; cl_context_properties *cprops =(platform==NULL) ? NULL : cps; context=cl::Context(CL_DEVICE_TYPE_GPU,cprops,NULL,NULL,&error); devices=context.getInfo<CL_CONTEXT_DEVICES>(); cl::CommandQueue queue=cl::CommandQueue(context,devices[0]); std::ifstream file("workgroup_test_Kernel.cl"); std::string prog(std::istreambuf_iterator<char>(file),(std::istreambuf_iterator<char>())); cl::Program::Sources source(1,std::make_pair(prog.c_str(), prog.length())); program=cl::Program(context,source,&error); program.build(devices); cl::Kernel kernel1=cl::Kernel(program,"test1",&error); cl_int datasize=5; kernel1.getWorkGroupInfo(devices[0],CL_KERNEL_WORK_GROUP_SIZE ,&datasize); // Works on Windows, error on Linux! int cpun; devices[0].getInfo(CL_DEVICE_MAX_COMPUTE_UNITS,&cpun); std::cout<<"MAX_COMPUTE_UNITS: "<<cpun<<std::endl; cl_float *a=new cl_float[datasize]; cl_float *b=new cl_float[datasize]; cl_float *c=new cl_float[datasize]; cl::Buffer CL1=cl::Buffer(context,CL_MEM_READ_ONLY |CL_MEM_USE_HOST_PTR,sizeof(a[0]) * datasize,a,&error); cl::Buffer CL2=cl::Buffer(context,CL_MEM_READ_ONLY |CL_MEM_USE_HOST_PTR,sizeof(b[0]) * datasize,b,&error); cl::Buffer CL3=cl::Buffer(context,CL_MEM_WRITE_ONLY|CL_MEM_USE_HOST_PTR,sizeof(c[0]) * datasize,c,&error); for(int i=0;i<datasize;i++){ a=i; b=datasize-i; c=0; } kernel1.setArg(0,CL1); kernel1.setArg(1,CL2); kernel1.setArg(2,CL3); queue.setProperty(CL_QUEUE_PROFILING_ENABLE, true); // Works on Windows, error on Linux! queue.enqueueNDRangeKernel(kernel1,cl::NullRange,cl::NDRange(datasize,1,1),cl::NDRange(1,1,1),NULL,NULL); queue.enqueueReadBuffer (CL3,CL_TRUE,0,sizeof(c[0])*datasize,c); for(int i=0;i<datasize;i++){ std::cout<<c<<" "; } std::cout<<std::endl; int info; queue.getInfo(CL_QUEUE_PROPERTIES,&info); std::cout << "CL_QUEUE_PROPERTIES" << info << std::endl; delete[] a,b,c; }catch(cl::Error& error){ std::cout<<"OpenCL-Error: "<<error.what()<<"("<<error.err()<<")"<<std::endl<<std::endl; } buildlog=program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(devices[0]); if(buildlog!=""){ std::cout<<std::endl<<"________________________________________________________________________________"<<std::endl; std::cout<<"Buildlog:"<<std::endl; std::cout<<buildlog<<std::endl; std::cout<<"________________________________________________________________________________"<<std::endl; } return 0; } //Kernel __kernel void test1(__global const float * a,__global const float * b,__global float * c){ int i = get_global_id(0); c = a + b; }
Hi
I have found my error:
i used integer as return types, instead of size_t for kernel1.getWorkGroupInfo(devices[0],CL_KERNEL_WORK_GROUP_SIZE ,&datasize);
and
cl_command_queue_properties for queue.getInfo(CL_QUEUE_PROPERTIES,&info);
MFG Sheeep