Results 1 to 4 of 4

Thread: kernel invocation

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    6

    kernel invocation

    Im going to write a kernel which will be quite complex, can I separate it to several kernels that can invoke each other?

    when I compile the following sample code, there is an error which i dont understand
    error: illegal implicit cast between two pointers with different address spaces
    Code :
     
    kernel void B(float *b) {
       //do something
    }
    kernel void A () {
       float b;
       B(&b);
    }

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

    Re: kernel invocation

    Yes, you can have a kernel function call another kernel function. You can also call non-kernel functions.

    The error code you see is because in OpenCL each variable stays in one of the four possible memory address spaces: global, local, private and constant. They are explained in section 6.5 of the OpenCL 1.1. spec.

    You can try something like this:

    Code :
    void B(__private float *b) {
       //do something
    }
    kernel void A () {
       float b; // "b" by default is in private memory
       B(&b);
    }

    Also notice that recursive function calls are not allowed. I say this because it looks like you are trying to implement a ray-tracing engine on OpenCL and simple ray-tracing engines are recursive.
    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
    Junior Member
    Join Date
    Aug 2011
    Posts
    6

    Re: kernel invocation

    Quote Originally Posted by david.garcia
    Yes, you can have a kernel function call another kernel function. You can also call non-kernel functions.

    The error code you see is because in OpenCL each variable stays in one of the four possible memory address spaces: global, local, private and constant. They are explained in section 6.5 of the OpenCL 1.1. spec.

    You can try something like this:

    Code :
    void B(__private float *b) {
       //do something
    }
    kernel void A () {
       float b; // "b" by default is in private memory
       B(&b);
    }

    Also notice that recursive function calls are not allowed. I say this because it looks like you are trying to implement a ray-tracing engine on OpenCL and simple ray-tracing engines are recursive.
    Thank you david, yes I am writing the ray tracing engine, I have written a non-recursive C implementation and now need to implement with OpenCL, one kernel function is too complicated and lots of duplicated code.

    Regarding to the previous post, when I assign a value in the device function B, the value does not update in the kernel A, which i dont know why:

    Code :
    void B(__private float *b) {
       //do something
       // if say b = 1, when I find b in kernel A, the value is still 0
       *b = 1;
    }
    kernel void A () {
       float b; // "b" by default is in private memory
       B(&b);
    }

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

    Re: kernel invocation

    Regarding to the previous post, when I assign a value in the device function B, the value does not update in the kernel A, which i dont know why:
    Did you get any error codes from any of the OpenCL calls? That code should work.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. Replies: 4
    Last Post: 08-06-2012, 01:18 AM
  2. Replies: 1
    Last Post: 03-14-2010, 07:34 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
  •