Results 1 to 5 of 5

Thread: Kernel call from within another kernel

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    23

    Kernel call from within another kernel

    Hello

    I have code that calls functions from within functions. So I want to know if I want to keep the same structure, is it possible that from within OpenCL kernel (as a function), I try to call another kernel (like function) and dont go back to Host program so that I dont have to make new buffers and copy data back and forth from kernel buffers and host program memories ?

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Kernel call from within another kernel

    I'm not sure I understand the question. In OpenCL calling functions inside kernels is allowed as long as the call is not recursive. Kernels can also call other kernel functions and the behavior is the same as calling any other (non-kernel) function.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: Kernel call from within another kernel

    Quote Originally Posted by akhal
    and dont go back to Host program so that I dont have to make new buffers and copy data back and forth from kernel buffers and host program memories ?
    You don't have to go back to the host or copy memory to/from the host. memory stays on the device unless you ask to copy it, and the work queue is a queue anyway: returning from the kernel is not a synchronous call back to the host it's just a chance for the device to call the next kernel in the queue.

    Calling kernels from other kernels is of limited use because you (should) only use kernels to separate global data boundaries in the first place. i.e. if you are able to share code between the kernels you'd probably combine them anyway.

  4. #4
    Junior Member
    Join Date
    Jul 2011
    Posts
    23

    Re: Kernel call from within another kernel

    Thanks for all valuable comments. But would I have to call thread awakening function i.e.,
    int x = get_global_id(0);
    again inside every kernel in kernel calling hierarchy ?

  5. #5
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: Kernel call from within another kernel

    Quote Originally Posted by akhal
    Thanks for all valuable comments. But would I have to call thread awakening function i.e.,
    int x = get_global_id(0);
    again inside every kernel in kernel calling hierarchy ?
    It doesn't awaken threads, it just returns a unique job identifier. I'm not sure what you even mean by that?

    This can be called from functions your kernel invokes, including other kernels. They are treated (mostly) the same way as any other function.

Similar Threads

  1. Can i call a same kernel more than a time?
    By luizdrumond in forum OpenCL
    Replies: 4
    Last Post: 09-02-2011, 01:01 PM
  2. Is it possible to call one kernel in another?
    By GPUworker in forum OpenCL
    Replies: 10
    Last Post: 02-08-2011, 04:15 AM

Posting Permissions

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