karx11erx

SOLVED: global variables in kernels

Discussion created by karx11erx on May 28, 2009
Latest reply on May 28, 2009 by karx11erx

I am currently trying to write kernel functions processing two doubles at a time, like e.g. this one:

 

double2 _f1 = {1.0, 1.0};

double2 _f6 = {6.0, 6.0};
double2 _f20 = {20.0, 20.0};
double2 _f42 = {42.0, 42.0};
double2 _f72 = {72.0, 72.0};
double2 _f110 = {110.0, 110.0};
double2 _f156 = {156.0, 156.0};
double2 _f210 = {210.0, 210.0};
double2 _f272 = {272.0, 272.0};

kernel double2 SinD2 (double2 phi<>)
{
double2 phi2 = phi * phi;
return phi * (_f1 - phi2 / _f6 * (_f1 - phi2 / _f20 * (_f1 - phi2 / _f42 * (_f1 - phi2 / _f72 * (_f1 - phi2 / _f110 * (_f1 - phi2 / _f156 * (_f1 - phi2 / _f210 * (_f1 - phi2 / _f272))))))));
}

The _f...-Variables aren't recognized in the kernel. So I cannot use global variables in kernels? I am getting:

1>WARNING: ASSERT(GetResultSymbol().IsValid() + mDataTypeValue.IsValid() >= 1) failed
1>While processing :191
1>In compiler at AST::DelayedLookup::ResolveSymbols()[astdelayedlookup.cpp:139]
1>  *mName = _f1
1>Message: unknown symbol

 

The reason I am trying this is that something like

double2 v;
v.x = 1.0;
v.y = 1.0;
v = v * 0.5;

is rejected with an error message about type conflicts. Now if I turn off strong type checking, this compiles.

The question is: Does "v = v * 0.5;" actually multiply each v.x and v.y with 0.5? It would in GLSL, so I suppose the hardware supports it, but does the CAL compiler?

Another question. Provided double2 * double works as intended, could I theoretically double stream processing speed for doubles when processing double2 data? I assume that when passing single doubles to a kernel, half of the thread ALUs stay passive, is that right? The thought is that each thread processor can process 4 floats which would mean two double2s simultaneously, so if I give a thread a double2 to process it should process both in the same time it takes for a double.

Solution: double2 * double multiplies both double2 components with the double value.

Outcomes