Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Several threads writing the same value in the same global memory location

Tags:

cuda

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)?

like image 698
Auron Avatar asked Dec 07 '11 13:12

Auron


1 Answers

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.

like image 156
Robert Crovella Avatar answered Sep 24 '22 12:09

Robert Crovella