cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

timchist
Elite

Problems with accessing arrays with a negative offset (R9 290, Catalyst 15.7)

In some cases in OpenCL kernels we are getting incorrect values when reading from arrays using a negative index. For example, we could have something like this:

_global float a[10];

_global float* b = a + 5;

float c = b[-1]  + b[-2];     // this sometimes returns incorrect value

This happens on R9 290 running under Catalyst 15.7 driver (Win 7 x64) and does not happen with Catalyst 14.9 or with HD 7970 (any driver version).

We could not figure out when exactly the problem happens, but managed to prepare a test case that reproduces the error in our environment. I'm attaching it to this post.

0 Likes
7 Replies
dipak
Big Boss

Hi Tim,

The above kernel code seems working fine on a R9 290X m/c if I modify one of the following changes:

1) make the "offset" variable as volatile , that is, "volatile int offset = x > 0 ? -1: 0;"

OR

2)use "select" function instead of ternary operator, that is,  "int offset = select(0, -1, x > 0);"

Note: putting a printf to see the  "offset" value or any buffer value/address, producing the correct result.

So, I guess, the issue is not related to negative index, instead of optimization or something else.

Regards,

0 Likes

Hi Dipak,

thanks for your reply. We found a workaround too, although a slightly different one. However, as we don't know what exactly is causing the problem (yes, it seems you are right -- it's not negative offset on its own, but something else), it's difficult to audit our existing code (we don't want what to look for). Could you please report this to the dev team for further investigation?

Thank you,

Tim

0 Likes

Sure, I'll check with the dev. team.

0 Likes
timchist
Elite

Status update: this is still broken in Catalyst 15.8 beta.

0 Likes
timchist
Elite

Just checked 15.9.1 beta -- the problem still persists.

0 Likes
timchist
Elite

No improvements in 15.10 beta either.

0 Likes

Hi Tim,

It seems that the above issue is no longer reproducible with the latest Crimson driver 16.4.1 (16.15.2211.1001). Could you please check and confirm?

Regards,

0 Likes