cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

shkurko_alexander
Journeyman III

Problems with integer arithmetic in kernel code

Hi,

I have the following kernel:

void Test(int Input<>,  out int Output<>
{

    int x = (int)0x80000000;

    Output = x;
}

After execution of this kernel at Output array I have 0x00000000.

If initialize x with (int)0x40000000, than at Output I have 0x40000000.

If inizialize x like this:

x = (int)0x40000000;

x = x << 1;

that at Output I have 0x80000000.

It initialize x with any value with 1 at last bit, I have 0x00000000 at Output

Is it a bug?

My system is Winwos XP (32bit), Radeon HD 3850, SDK 1.1

Thanks for the help,

Alexander Shkurko

0 Likes
4 Replies
Remotion
Journeyman III

Hi,

I have also problem with intereg Modulo.


kernel void mod_test(out float res<>
{
    int mi = (5 % 2);
    res = (float)mi;
}

This kernel will return 1065353215.000 instate of 1.

kernel void mod_test(out float res<>
{

    float mi = fmod(5,2);
    res = mi;

}

This one too.


I have teste it on Radeon HD 4870 GPU.

0 Likes

hi

i think problem in brcc.exe

all numbers for brcc unsigned

int x = (int)0x80000000;

for this line brcc  generate code like

int x = (int)2147483648;

don't use hex

correct code is

int x = (int)-2147483648;

 

 

0 Likes

We do not have hex or unsigned int working yet -- they are on our list of to dos. Let us know if you can modify your code and get it working without those.

Remotion, I will file a bug about modulo. Thanks for bringing it up.

 

0 Likes

To udeepta@amd:

I sent bug report with all problems I had found to streamdeveloper@amd.com.

I can use workaround for problems connected with unsigned int or hex,

but one issue is connected with wrong result of some integer calculations,

so probably I'll will wait next release of BROOK+.

Thanks for the reply.

0 Likes