Results 1 to 3 of 3

Thread: OpenCL function syntax

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    5

    OpenCL function syntax

    I want use function (not kernel) like this: (C++)

    Code :
    void doSome(float4 &a, float4 &b)
    {
      a.x = ... do something ...
      a.y = ... do something ...
      a.z = ... do something ...
      a.w = ... do something ...
      b = ... do something ...
    }

    How i may write this on OpenCL?
    I try some variants with pointers, search in spec, but i dont find answer.

  2. #2
    Member
    Join Date
    Sep 2009
    Posts
    35

    Re: OpenCL function syntax

    Unfortunately variable references, like in your example, are not available. You must use pointers:

    Code :
    void doSomething(float4 *a, float4 *b)
    {
      *a = ...
      (*b).x = ...
    }
    Note that you must use asterisk '*' to access pointed data.

    The arrow operator '->' is not available for OpenCL data types, but should be for user defined structs and unions:
    Code :
    void doSomething(YourStruct *a)
    {
      a->variableInStruct = ...
    }

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    5

    Re: OpenCL function syntax

    Thanks! That work fine.

Similar Threads

  1. OpenCL syntax highlighting
    By jbasic in forum OpenCL
    Replies: 4
    Last Post: 08-31-2010, 08:42 AM
  2. OpenCL syntax highlighting
    By jbasic in forum OpenCL
    Replies: 3
    Last Post: 01-01-1970, 12:00 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
  •