Results 1 to 2 of 2

Thread: Passing a float4 as a pointer

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    1

    Passing a float4 as a pointer

    Hi,

    I need to pass a float4 pointer (a C++ reference would be better, but I think those are not compliant in OpenCL) to a local OpenCL function called by my kernel. The problem is that the compiler does not allow this (I'm using the NVIDIA OpenCL implementation). My funcion looks like this:
    Code :
    void calculateSomething(float4 xt, float4 yt, float4* zt) {
       zt->x = do something with xt and yt;
       zt->y = do something with xt and yt; 
       zt->z = do something with xt and yt; 
       zt->w = do something with xt and yt; 
    }

    even if I try this it does not compile:

    Code :
    void calculateSomething(float4 xt, float4 yt, float4* zt) {
       zt->x = 1;
       zt->y = 2; 
       zt->z = 3; 
       zt->w = 4; 
    }

    I would really appreciate any hint about this problem.

    Thanks in advance,

    Federico

  2. #2
    Junior Member
    Join Date
    Jan 2010
    Posts
    2

    Re: Passing a float4 as a pointer

    hey

    Quote Originally Posted by fmilano
    I need to pass a float4 pointer (a C++ reference would be better, but I think those are not compliant in OpenCL) to a local OpenCL function called by my kernel. The problem is that the compiler does not allow this (I'm using the NVIDIA OpenCL implementation).
    c++ like references are unfortunately not part of the c language/spec.
    i also ran into this bug (?) and my solution was to just dereference the pointer, so try this:
    Code :
    void calculateSomething(float4 xt, float4 yt, float4* zt) {
       (*zt).x = 1;
       (*zt).y = 2; 
       (*zt).z = 3; 
       (*zt).w = 4; 
    }

Similar Threads

  1. Replies: 1
    Last Post: 12-27-2012, 06:03 PM
  2. Passing NULL pointer to the kernel ?
    By viewon01 in forum OpenCL
    Replies: 2
    Last Post: 07-26-2010, 06:21 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
  •