PDA

View Full Version : OpenCL function syntax



Executor
11-01-2009, 02:45 AM
I want use function (not kernel) like this: (C++)


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.

jbasic
11-01-2009, 04:57 AM
Unfortunately variable references, like in your example, are not available. You must use pointers:


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:

void doSomething(YourStruct *a)
{
a->variableInStruct = ...
}

Executor
11-01-2009, 08:24 AM
Thanks! That work fine. :)