Hi,
Maybe it is a stupid question, if so, please apologize me.
I have an unsigned int value that can be 0x00000000 or 0x00000001 at run time; could be posible to extend the LSB bit to have 0x00000000 or 0xFFFFFFFF at run time?
Thanks in advance for any insight on this.
best regards,
Alfonso
Can you just multiply by 0xFFFFFFFF?
thanks!
I was pretty sure that it was a stupid question, but today is not my most creative day.
best regards,
Alfonso
Since the GPU does 24 bit integer math better than 32 bit integer math (as far as using all of the ALUs), there may be a better way to do that. Can anyone chime in with something that would work on int4's?
24 bits operations aren't supported now.
The best method for your problem ( and much more flexible ) is to use select function ( which I guess is translated into IL cmov operation ).
result = select( v, 0xFFF...., 0 );
I thought select looked at the MSB.
According to opencl specs for scalar type select <=> v?a:b
But to tell you the truth the best way is to use something which is compiled into cmov_logical in IL code. It might be select but maybe simply v?0xFFFF...:0x0 would do the work. I'm not sure how efficient opencl compiler is in this regard so someone must check it.
cmov_logical can be assigned to any slot so it's much more efficient than using imul ( only t slot ).
I am amazed that noone has said this but...
a = 0x00000001
b = -a
then b = 0xffffffff
Malcolm
How is multiplying by -1 different from multiplying by 0xFFFFFFFF?
So that means that a mult by (-1,-1,-1,-1) will be the correct way to do it once 24 bit int vectors are supported?
Do be careful with select. As alluded to in this thread, the definition of truth for a scalar select is different for the definition for a vector select (because truth is different for scalars and elements of vectors).