Results 1 to 3 of 3

Thread: Passing NULL pointer to the kernel ?

  1. #1

    Passing NULL pointer to the kernel ?

    The OpenCL specification (1.0.43) seems to indicate that it's legal to pass a NULL pointer to an OpenCL kernel:

    "A NULL value can also be specified if the argument is a buffer object in which case a NULL value will be used as the value for the argument declared as a pointer to __global or __constant memory in the kernel." and "The memory object specified as argument value must be a buffer object (or NULL) if the argument is declared to be a pointer of a built-in or user defined type with the __global or __constant qualifier."

    But I got a crash when I do this on the AMD SDK, and I think that NVidia doesn' support it as well.

    In my case, sometimes I have nothing to pass to the kernel... how should I do ?

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

    Re: Passing NULL pointer to the kernel ?

    You are correct. I suggest filing a bug against any implementation that fails.

    In the meantime you can create a dummy CL buffer with a very small size and pass it instead of NULL.

    Of course this workaround will not work if your kernel actually tests the argument against NULL.
    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

    Re: Passing NULL pointer to the kernel ?

    It is what I do now, it is not very elegant but it works ! I just use an 'int' to tell if the buffer is a dummy one or not...

    I have do a post for AMD and I will for NVidia too...

Similar Threads

  1. Replies: 3
    Last Post: 01-22-2012, 05:29 PM
  2. Replies: 1
    Last Post: 04-21-2010, 11:16 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
Proudly hosted by Digital Ocean