chevydevil

Problem with passing more than 1 input __global to kernel

Discussion created by chevydevil on Jan 7, 2010
Latest reply on Jan 7, 2010 by chevydevil

Hello.

I have a problem passing more then one input __global to a kernel. The error is "CL_INVALID_MEM_OBJECT". The follwing code shows what i do. It runs if i either remove inputBuffer or inputBuffer2 but never together.

cmdQ = cl::CommandQueue(context, devices[0],0, &err); checkErr(err, "CommandQueue::CommandQueue"); //input arrays for (int i=0; i<problemSize-3; i+=3){ input[i]=random(0.0,30.0); input[i+1]=random(0.0,30); input[i+2]=random(0.0,30.0); } for (int i=0; i<problemSize-3; i+=3){ input2[i]=random(0.0,30.0); input2[i+1]=random(0.0,30); input2[i+2]=random(0.0,30.0); } //allocate memory for input inputBuffer = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(cl_float) * problemSize, 0, &err ); checkErr(err,"Buffer::inputBuffer"); inputBuffer2 = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(cl_float) * problemSize, 0, &err ); checkErr(err,"Buffer::inputBuffer"); cmdQ.enqueueWriteBuffer(inputBuffer, CL_TRUE, 0, sizeof(float) * problemSize, input); cmdQ.enqueueWriteBuffer(inputBuffer2, CL_TRUE, 0, sizeof(float) * problemSize, input2); kernel = cl::Kernel(program, _kernelname, &err); checkErr(err, "Program::build()"); err = kernel.setArg(0, inputBuffer); checkErr(err, "kernel.setarg0)"); err = kernel.setArg(1, inputBuffer2); checkErr(err, "kernel.setarg1"); err = kernel.setArg(2, outputBuffer); checkErr(err, "kernel.setarg2)"); err = kernel.setArg(3, stime); checkErr(err, "kernel.setarg3"); cl::KernelFunctor func =kernel.bind(cmdQ, cl::NDRange(problemSize), cl::NDRange(16) ); //////////////////////and the kernel//////////////////////////////////////////////////// __kernel void squareArray( __global float* input, __global float* input2, __global float* output, float stime) { output[get_global_id(0)] = input[get_global_id(0)]+input2[get_global_id(0)]*stime; };

Outcomes