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


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);

__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);

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).