Previous | Next --- Slide 45 of 59
Back to Lecture Thumbnails
Nesuna

To reiterate, as I understand it, when using the shared address space methodology, we have three barriers to first ensure that the diff reset doesn't overwrite any values, the updates to diff don't interfere with the final check, and that finally we want to make sure that every thread as met the done condition?

kevinle1

I am also confused about what the last barrier is there for.

monsterrev

Last barrier is needed so that all the threads reach that point [if we dont put this, one thread which have completed the iteration might begin the next iteration of while loop again and make the diff =0 and consider other thread which is still in its previous iteration, would see the diff value as 0 and would say it has converged which it has not.

hanzhoul

First barrier ensures that each thread clears their local myDiff. Second barrier ensures that each thread has added local myDiff to global diff. Last barrier ensures that no one clear diff before check-done is over.