for example:
struct Point
{
int x,
int y;
};
If all threads write their own Point
into the same location in global memory in the same time, is it possible that the final result Point
in that location has x
value of thread A and y
value of thread B?
This question is closely related to Concurrent writes in the same global memory location and Is global memory write considered atomic in CUDA?
[This answer was copied from a comment that should have been an answer.]
Is it possible that the final result Point in that location has x value of thread A and y value of thread B?
Yes. To avoid such a scenario you need to write a Point
as a single atomic value (ie, reinterpret a Point
as a double
or int64
and use an atomic set).