views:

72

answers:

1

Is two (or more) different threads allowed to write to the same memory location in global space in OpenCL? The write is always changing a uchar from 0 to 1 so the outcome should be predictable, but I'm getting erratic results in my program, so I'm wondering if the reason can be that some of the writes fail.

Could it help to declare the buffer write-only and copy it to a read-only buffer afterwards?

A: 

Did you try to use the cl_khr_global_int32_base_atomics extension and atom_inc intrinsic function? I would first store the data on an int32 instead of an uchar as proof of concept, then optimize the memory footprint of data structures.

Stringer Bell
I circumvented the simultaneous write problem by changing my algorithm to do a simultaneous read instead. Still, it did not work until I used int instead of uchar, even though I believe I have enabled the cl_khr_byte_addressable_store extension. I'm not going to try your atomics-tip at this point though, as it seems to work well now, but thanks for the tip anyway :)
Wonko