Originally posted by: Raistmer 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 ?
Isn't it working if you disable strong type checking (it's a bit annoying at times) just omit all those type conversion and simply do the binary AND?
float temp = some_value_or_expression;
tresh_tbl = ncb + (int)(temp & 0xfffff000);
Looks much simpler to me and for the hardware it shouldn't matter.
Brook+ doesn't support pointers. As mentioned in error, you are using variable addressing and pointer dereference, both are invalid.
Originally posted by: gaurav.garg
Brook+ doesn't support pointers. As mentioned in error, you are using variable addressing and pointer dereference, both are invalid.
Originally posted by: Gipsel Originally posted by: Raistmer 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 ?
Isn't it working if you disable strong type checking (it's a bit annoying at times) just omit all those type conversion and simply do the binary AND?
float temp = some_value_or_expression;
tresh_tbl = ncb + (int)(temp & 0xfffff000);
Looks much simpler to me and for the hardware it shouldn't matter.
Originally posted by: RaistmerMore ideas, please?
If you have some knowledge about the size of the values, it may be possible just to omit the AND, as the last bits are truncated either way by the float to int conversion (maybe you need to shift your values to an appropriate range first).
If not, from my experience it would be the easiest just to write a placeholder subkernel and edit the Brook generated IL to do what you want (equivalent of my non-working version, just do the AND without any conversions). IL is untyped, so it would work on that level
But it is quite late here already, maybe there is a more elegant solution.