Results 1 to 2 of 2

Thread: How to reset global_id for multiple kernel?

  1. #1
    Newbie
    Join Date
    Aug 2013
    Posts
    2

    Question 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
    Code :
    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
    Code :
    __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];
    }

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    161
    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •