Raistmer

Is it possible to do the same in kernel code?

Discussion created by Raistmer on Sep 13, 2009
Latest reply on Sep 15, 2009 by Gipsel
brook gives error...

I need to zero last few bits in float number before int cast (last bits contain noise that should be eliminated before type conversion).

In CPU code I use:

float tmp=thresh_x *(float) sqrt((float)2.0 *(float) ncb);
unsigned tmp1=((*(unsigned*)(&tmp))&0xFFFFF000);
thresh_tbl = ncb + (int)( *((float*)(&tmp1)) );

But this gives error inside kernel:

Operator not supported in kernel: variable address(&)
Statement: &tmp in tmp1 = *((uint *) &tmp) & 0xfffff000
and

Operator not supported in kernel: pointer dereference(*)
Statement: *((uint *) &tmp) in tmp1 = *((uint *) &tmp) & 0xfffff000

and

ERROR--3: In Binary expression: implicit conversion from right type to left type
Statement: *((uint *) &tmp) & 0xfffff000 in tmp1 = *((uint *) &tmp) & 0xfffff000
Expression : *((uint *) &tmp), Type : uint
Expression : 0xfffff000, Type : int

Is it possible to do such bit zeroing inside GPU kernel?
Maybe some another way ?

Outcomes