2
votes

I'm using OpenCL with an AMD video card and have the latest driver in Linux.

When I do something like:

int a = get_group_id(0) > 0 ? vector[ get_group_id(0)-1 ].word[ id ] : 0;

I get a wrong result. But if use a barrier(CLK_LOCAL_MEM_FENCE); after this, I get the correct results.

Why is that happening?

Ps1.: Using a NVIDIA video card on both Linux or Windows, I get the right answer without using a barrier.

The block is( using __global *input, __global *output ):

int a = get_group_id(0) > 0 ? vector[ get_group_id(0)-1 ].word[ id ] : 0;
int b = get_group_id(0) > 0 ? c + a : a;
output[b + id] = input[ d + id ]; //Last kernel line

I'm using 128 workgroup size. I've tried in HD 6790 - linux

Thanks

1
What do you do with the value after it is assigned? what workgroup size are you using? which specific video cards have you tried? - mfa

1 Answers

0
votes

Seems similar to this bug that I reported earlier: http://devgurus.amd.com/thread/158479

So I'm afraid it's a bug in the compiler and there's not much you can do, other than use your local barrier and wait until AMD fixes their stuff.

(Note that, as suggested in the linked topic, a local mem_fence should actually be enough to prevent the compiler from making this error.)