cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

tball
Journeyman III

Unable to use complex float

float,complex,variables

Hello

I have a problem defining complex numbers in my kernel.

See my attached code.

I get the following error when compiling the kernel:

/tmp/OCL3OF8Ri.cl(13): error: this declaration has no storage class or type
          specifier
      complex float data[40];
      ^

/tmp/OCL3OF8Ri.cl(13): error: expected a ";"
      complex float data[40];
                   ^

 

I might have misunderstood the type declaration stated in the OpenCL api reference guide. Could anyone lead me to the right track?

 

typedef struct gf { complex float data[40]; } gaborFeature; __kernel void fub(__global int bar) { }

0 Likes
12 Replies
omkaranathan
Adept I

Complex is not supported currently.

0 Likes

Oh.. Any eta when it will be supported?

Working on a project, which rely heavily on complex variables.

I actually thought amd stream supports OpenCL 1.0. But it is still a beta?

0 Likes

Complex is not part of the core OpenCL 1.0.

0 Likes

Thx for your help omkaranathan.

Well do you know a place where I can see all the things AMD stream differentiate from:

http://www.khronos.org/opencl/sdk/1.0/docs/man/xhtml/

0 Likes

tball,
AMD Stream OpenCL supports the full OpenCL 1.0 spec and some optional extensions that are reported by the runtime for your specific device. The data types, such as complex, that are listed in 'Reserved Data Types' are not part of OpenCL, but the names are reserved as part of the language for possible future use.
0 Likes

Well thanks for you explanation.

That explains the reserved part of the API. Actually I though it was just "reserved" data types, which you were not allowed to reimplement.

0 Likes

Hi,

 

I have a same problem as someone posted long ago. Is complex data type supported now with OpenCL 1.1?

Thanks.

 

Richeek

0 Likes

Complex data type is not a part of the OpenCL 1.1 spec, please read the spec for what datatypes are supported and what data types are reserved for possible future inclusion.
0 Likes

well, for now you will have to define your own complex type (maybe a float2) and overload the operators like *, /, fabs and all others you will need.

0 Likes

Originally posted by: laobrasuca well, for now you will have to define your own complex type (maybe a float2) and overload the operators like *, /, fabs and all others you will need.

 

 

Are you sure operator overloading is supported? I tried to overload * but it did not work for me, so I did something like this:

typedef struct my_comp
{
    float2 data;
} comp;

comp mul(comp num1, comp num2)
{
    comp temp;
    temp.data.x = num1.data.x*num2.data.x - num1.data.y*num2.data.y;
    temp.data.y = num1.data.x*num2.data.y + num1.data.y*num2.data.x;
    return temp;
}

 

I tried to overload like this:

comp operator*(comp num1, comp num2)
{
    comp temp;
    temp.data.x = num1.data.x*num2.data.x - num1.data.y*num2.data.y;
    temp.data.y = num1.data.x*num2.data.y + num1.data.y*num2.data.x;
    return temp;
}

 

Please let me know if this is not the right way?

regards,

Richeek

0 Likes

OpenCL C is, like the name suggests, like C, it is not C++. Overloading is not supported in C at all, let alone operator overloading.

0 Likes

I mean, in the next opencl c++ support release xD

0 Likes