How to reset global_id for multiple kernel?

I have 4 kernel and need to done by step like kernel[0]–>kernel[1]–>kernel[2]–>kernel[3]
but the get_global_id() seem to run at the first time only…:?:
Any suggestions?

here is my code
source.c


kernel[0]=clCreateKernel(program[0],"kernel1",&ret);
kernel[1]=clCreateKernel(program[1],"kernel2",&ret);
kernel[2]=clCreateKernel(program[2],"kernel3",&ret);
kernel[3]=clCreateKernel(program[3],"kernel4",&ret);

size_t globalWorkSize[2] = {M,M}; 
size_t localWorkSize[2] = {M,M}; 

clEnqueueNDRangeKernel(command_queue, kernel[0], 2, NULL, globalWorkSize, localWorkSize, 0,NULL, NULL);
clEnqueueNDRangeKernel(command_queue, kernel[1], 2, NULL, globalWorkSize, localWorkSize, 0,NULL, NULL);

source.cl


__kernel void kernel1(__global float* a,__global float* b,__global float* c,__global float* d,__global float* e,__global float* f)
{
    int i = get_global_id(0);
	a[i]=b[i]-c[i];
	d[i]=e[i]-f[i];
}

Each kernel should get the complete range of get_global_id() values. Why do you think they are not?

My concern with the subset of code you posted is the localWorkSize of {M,M}. If M is not small, this will fail. M cannot exceed CL_DEVICE_MAX_WORK_ITEM_SIZES and M * M cannot exceed CL_DEVICE_MAX_WORK_GROUP_SIZE.

I suggest you pass NULL for localWorkSize and let the runtime select it. Once everything is working you can tune this (but be aware that in OpenCL 1.x the global size must be a multiple of the local size).