sla

unsigned integer arithmetic in BROOK+

Discussion created by sla on Jul 17, 2008
  1.  Is stream type "unsigned int (uint) " supported?
We can see in brt.hpp:
enum __BRTStreamType
{
__BRTNONE=-1,
__BRTSTREAM=0,//stream of stream is illegal. Used in reduce to stream.
__BRTFLOAT=1,
...
__BRTUINT=19,
__BRTUINT2=20,
__BRTUINT3=21,
__BRTUINT4=22,
};
but in
kernel void brook_core(int plain, int iteration<>, uint2 key_hi<>, out int2 result<>)
we get
8: Error (syntax error) before 'Identifier'
kernel void brook_core(int plain, int iteration<>, uint2 key_hi<>, out int2 result<>)
                                                   ^

      2.  Is it possible to declare constants of unsigned int type?
if I write:
const unsigned Sc1=0xBFFFEEEE;
I get (hex)
Sc1=80000000
and if I write
const unsigned Sc1=(unsigned)0xBFFFEEEE+(unsigned)0x00001111;
I get
Sc1=C0000011
The correct result could be achieved by writing:
const unsigned Sc1=((unsigned)0xBFFF<<(unsigned)16)+ (unsigned)(0xEEEE);
But the compiler responds:
Performing Custom Build Step
NOTICE: Parse error
While processing <buffer>:59
In compiler at zzerror()[parser.tab.cpp:177]
message = parse error
ERROR: Parse error. Invalid expression.
While processing <buffer>:59
In compiler at zzparse()[parser.tab.cpp:2014]
yyvsp[0].ToString() = "unsigned"
Aborting...
NOTICE: Parse error
In compiler at zzerror()[parser.tab.cpp:177]
message = parse error
ERROR: Parse error. Expected declaration.
In compiler at zzparse()[parser.tab.cpp:1833]
yyvsp[0] = ")"
Aborting...
NOTICE: Parse error
In compiler at zzerror()[parser.tab.cpp:177]
message = parse error
ERROR: Parse error. Expected declaration.
In compiler at zzparse()[parser.tab.cpp:1833]
yyvsp[0] = "("
Aborting...
Problem with compiling c:\brook\r-72\\built\r72_brook_core.hlslProblem with compiling c:\brook\r-72\\built\r72_brook_core_partaddr.hlslProblem with compiling c:\brook\r-72\\built\r72_brook_core_fulladdr.hlsl

    3. Are there operations to perform a logical (not arithmetic) shift?

If I write
res=Sc1>>0x1f; //Sc1=0x80000000
I get
C:\Program Files\AMD\AMD BROOK 1.01.0_beta\\sdk\include\brook/brtvector.hpp(513) : error C2297: '>>' : illegal, right operand has type 'float'
.\built\r72.cpp(69) : see reference to function template instantiation 'vec<VALUE,tsize> vec<int,1>::operator >><vec<VALUE,tsize>>(const BRT_TYPE &) const' being compiled

All of the operands are unsigned int
If I write:
res=Sc1>>(unsigned)30; //Sc1=0x80000000
Then I get
fffffffe
However, all of my operands are unsigned.

Since my GPU doesn't support CAL, I had to use CPU emulation

Please advise.

Outcomes