This question is closely related to this one, but mine belongs to the CUDA world.
I have several threads in my kernel that could write the very same value in the same global memory location. This has been working fine, but I'm afraid that it could be potentially bogus, and that so far I was just being lucky.
Is there any possibility of memory corruption or unexpected behavior in my workflow (due to data races, cache syncing, etc)?
I have several threads in my kernel that could write the very same value in the same global memory location.
Contrary to some of the comments, this is safe. By safe, I mean that the value written will show up in that global memory location. There is no possibility that a write will not occur, and there is no possibility of some other spurious data corruption. Tom's answer here is applicable to this.
If different values are being written, then one of the values will end up in that location, but which value is undefined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With