BorisTheBrave wrote:
\Even though you are reading and writing to the same thing with different threads, we just need ensure that the read and writes are atomic. We don't really care whether a particular read and write (within one iteration) come in one way round or another, as we get some convergence either way, so no race conditions. As long as we get a decent proportion of "reads after writes", we'd still see Gauss-Seidel like convergence, I guess. (And you would expect roughly as many as in the single threaded case, i.e. half of all reads come from the value updated in the current iteration instead of the previous, assuming the number of threads is much smaller than the size of island).
I'm not sure if I totally understand what you're suggesting, so I'll try to rephrase, correct me if I'm wrong. Are you basically saying that since within an iteration the solving order is unimportant (and in fact any regularity may lead to artifacts) we might as well leave that to the whim of the thread scheduler, and instead of locking a whole island, or even a sub-island, we merely lock at the level of the individual contact? Or are you going a step further and suggesting that we shouldn't even care if a particular contact's read-solve-write cycle is interrupted (and most likely screwed up), since in the long run everything is converging towards the same solution anyways? I don't know how expensive synchronization is in other languages, but I know that in Java, it's so bad that it actually might be better to do twice as many iterations to undo the damage done by concurrent accesses if it can avoid locking sections of code.
That's an interesting take, though I do notice that it removes determinism from the system, as the scheduler is now in control of what order contacts get processed in. I wonder how it would work in practice.