PDA

View Full Version : Can vector types be returned from functions?



adam
09-05-2009, 11:19 AM
I was wondering if someone could verify if variables of vector types can be returned from non-kernel functions. In other words, as an example, is the following OpenCL code legal:

int2 foo(int i) {
int2 tmp = (int2)(i);
return tmp;
}

Thank you.

Adam

adam
09-05-2009, 05:13 PM
I have a somewhat related question to my previous one. When vectors are passed as arguments to functions, are they being passed (as if) by value? In other words, is it expected that value of v can change after a call to foo()?

int2 v;
foo(v);

Thank you.

Adam

affie
09-06-2009, 07:56 PM
Vectors passed as arguments to functions are passed by value. And vector types can be returned from non-kernel functions. The example you gave where function foo returns an int2 value is allowed.