Hi all,

I'm trying to set up a Mandelbrot on OpenCL.

The CL C code in compiling correct and the execution begins without any issues.
But when I call event.wait() an CL_OUT_OF_RESOURCES occures. I can't imagine why.

My host code (N = 512 an M = 512):
Code :
// Initialize OpenCL
    cl_int error;
    cl::vector< cl::Platform > platformList;
    cl::Platform::get(&platformList);
    checkErr(platformList.size()!=0 ? CL_SUCCESS : -1, "cl::Platform::get");
    std::cout << "Platform number is: " << platformList.size() << std::endl;
 
    std::string platformVendor;
    platformList[0].getInfo((cl_platform_info)CL_PLATFORM_VENDOR, &platformVendor);
    std::cout << "Platform is by: " << platformVendor << "\n";
    cl_context_properties cprops[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties)(platformList[0])(), 0};
 
    cl::Context context(CL_DEVICE_TYPE_GPU/*CL_DEVICE_TYPE_CPU*/,	cprops,	NULL, NULL,	&error);
    checkErr(error, "Conext::Context()");
	/** Allocate Buffers **/
	/** integers ************************************************************************************************/
		cl::Buffer maxCL( context, CL_MEM_READ_ONLY/*CL_MEM_READ_WRITE*/ | CL_MEM_USE_HOST_PTR, sizeof(int), &max, &error);
		checkErr(error, "Buffer::outCL(max)");
	/** floats **************************************************************************************************/
		cl::Buffer mCL( context, CL_MEM_READ_ONLY/*CL_MEM_READ_WRITE*/ | CL_MEM_USE_HOST_PTR, sizeof(float), &m, &error);
		checkErr(error, "Buffer::outCL(m)");
		cl::Buffer nCL( context, CL_MEM_READ_ONLY/*CL_MEM_READ_WRITE*/ | CL_MEM_USE_HOST_PTR, sizeof(float), &n, &error);
		checkErr(error, "Buffer::outCL(n)");
		cl::Buffer cxCL( context, CL_MEM_READ_ONLY/*CL_MEM_READ_WRITE*/ | CL_MEM_USE_HOST_PTR, sizeof(float), &cx, &error);
		checkErr(error, "Buffer::outCL(cx)");
		cl::Buffer cyCL( context, CL_MEM_READ_ONLY/*CL_MEM_READ_WRITE*/ | CL_MEM_USE_HOST_PTR, sizeof(float), &cy, &error);
		checkErr(error, "Buffer::outCL(cy)");
		cl::Buffer widthCL( context, CL_MEM_READ_ONLY/*CL_MEM_READ_WRITE*/ | CL_MEM_USE_HOST_PTR, sizeof(float), &width, &error);
		checkErr(error, "Buffer::outCL(width)");
		cl::Buffer heightCL( context, CL_MEM_READ_ONLY/*CL_MEM_READ_WRITE*/ | CL_MEM_USE_HOST_PTR, sizeof(float), &height, &error);
		checkErr(error, "Buffer::outCL(height)");
	/** image ***************************************************************************************************/
		cl::Buffer imageCL( context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, M*N*sizeof(GLubyte), image, &error);
		checkErr(error, "Buffer::outCL(image)");	/*****/
 
    // get OpenCL devices	
    cl::vector<cl::Device> devices;
    devices = context.getInfo<CL_CONTEXT_DEVICES>();
    checkErr(devices.size() > 0 ? CL_SUCCESS : -1, "devices.size() > 0");
 
    // read OpenCL C file
 
    #ifdef __APPLE__
	std::ifstream file("../../mandelbrot.cl");
    #else
	std::ifstream file("mandelbrot.cl");
    #endif	
    std::ios_base::iostate state = file.rdstate();
    checkErr(file.is_open() ? CL_SUCCESS:-1, "read mandelbrot.cl");
    // save file to string
    std::string prog(std::istreambuf_iterator<char>(file), (std::istreambuf_iterator<char>()));
 
    // make OpenCL C file to OpenCL source
    cl::Program::Sources source(1, std::make_pair(prog.c_str(), prog.length()+1));
 
    // build OpenCL source
    cl::Program program(context, source);
    error = program.build(devices,"");
    checkErr(error, "cl::Program program.build()");
 
    // define entry point
    cl::Kernel kernel(program, "mandelCalcCL", &error);
    checkErr(error, "Kernel::Kernel()");
 
    // set arguments
    error = kernel.setArg(0, maxCL);
    checkErr(error, "Kernel::setArg(max)");
    error = kernel.setArg(1, mCL);
    checkErr(error, "Kernel::setArg(m)");
    error = kernel.setArg(2, nCL);
    checkErr(error, "Kernel::setArg(n)");
    error = kernel.setArg(3, cxCL);
    checkErr(error, "Kernel::setArg(cx)");
    error = kernel.setArg(4, cyCL);
    checkErr(error, "Kernel::setArg(cy)");
    error = kernel.setArg(5, widthCL);
    checkErr(error, "Kernel::setArg(width)");
    error = kernel.setArg(6, heightCL);
    checkErr(error, "Kernel::setArg(height)");
    error = kernel.setArg(7, imageCL);
    checkErr(error, "Kernel::setArg(image)");
 
    // initialize queue
    cl::CommandQueue queue(context, devices[0], 0, &error);
    checkErr(error, "CommandQueue::CommandQueue()");
 
    // create event
    cl::Event event;
    error = queue.enqueueNDRangeKernel(kernel, cl::NullRange,	cl::NDRange(N*M*sizeof(GLubyte)), cl::NDRange(1/*, 1*/), NULL, &event);
    checkErr(error, "ComamndQueue::enqueueNDRangeKernel()");
 
    // wait until computation is finished
    error = event.wait();
    checkErr(error, "event.wait()");
 
    // read image buffer
    error = queue.enqueueReadBuffer(imageCL, CL_TRUE, 0, N*M*sizeof(GLubyte), &image);
    checkErr(error, "ComamndQueue::enqueueReadBuffer(image)");

I already tried a very small picture with very few iterations but the error is still the same. That means for me that I do something wrong with handling the variables.

May be you can help me to figure out this problem.

Greets
Henrik

PS:
I'm running Ubuntu 10.04 x64
on Q9450 (4 x 2,4 GHz) with 3962 MB RAM and GeForce 8600 GT (256 MB RAM, 32 CUDA cores)
CUDA is the latest version available