Hi,
is it possible to lock part of the code executed on the device
such that multiple threads writing on the same memory cell
do not “disturb” each other?
By the way, the value the threads will be writing is the same
- maybe I do not need to lock this part of the code?
For example:
__global__ void comp(int* array)
{
// Do some computation
// ...
// Compute an index (it will happen that more than
// one thread computes the same 'id')
int id = compId();
// Should I lock somehow the following line before writing to 'array'?
array[id] = 1;
// ...
}
‘array’ will be read on the host after the method above completes.
Thanks a lot.
Chavo