Results 1 to 3 of 3

Thread: Can vector types be returned from functions?

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    2

    Can vector types be returned from functions?

    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

  2. #2
    Junior Member
    Join Date
    Sep 2009
    Posts
    2

    Are arguments of vector type supposed to be passed by value?

    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

  3. #3
    Senior Member
    Join Date
    Sep 2002
    Location
    Santa Clara
    Posts
    105

    Re: Can vector types be returned from functions?

    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.

Similar Threads

  1. Replies: 1
    Last Post: 10-01-2009, 05:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •