2 Replies Latest reply on Oct 3, 2009 1:05 AM by southgary

    problem on set KernelArguValue

    southgary

      Hello!

      I am new on OpenCL and try to execute the example on Khronos spec. When the program run to clSetKernelArg, it returns an error message, CL_INVALID_MEM_OBJECT. Anyone can give me a help?

      THANKS!

       

      __kernel void add(__global float *a, __global float *b, __global float *answer) { int gid = get_global_id(0); answer[gid] = a[gid] + b[gid]; } // Memory Allocation A_mem = clCreateBuffer(mycontext, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, buffer_size, NULL, NULL); err = clEnqueueWriteBuffer(cmd_queue, A_mem, CL_TRUE, 0, buffer_size, (void*)A, 0, NULL, NULL); B_mem = clCreateBuffer(mycontext, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, buffer_size, NULL, NULL); err = clEnqueueWriteBuffer(cmd_queue, B_mem, CL_TRUE, 0, buffer_size, (void*)B, 0, NULL, NULL); C_mem = clCreateBuffer(mycontext, CL_MEM_READ_WRITE, buffer_size, NULL, NULL); //Create the Kernal kernel = clCreateKernel(program, "add", &err); // Setup the arguments to kernel err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &A_mem); err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &B_mem); err |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &C_mem);