Page MenuHomePhabricator

[OpenMP][FIX] Avoid a race between initialization and first state reads

Authored by jdoerfert on Oct 30 2021, 12:26 PM.



When we pick state 0 to initialize state but thread N is going to be the
"main thread", in generic mode, we would require extra synchronization.
Instead, we should pick the main thread to initialize state in generic
mode and any thread in SPMD mode.

Diff Detail

Event Timeline

jdoerfert created this revision.Oct 30 2021, 12:26 PM
jdoerfert requested review of this revision.Oct 30 2021, 12:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 30 2021, 12:26 PM
Herald added a subscriber: sstefan1. · View Herald Transcript
tianshilei1992 accepted this revision.Oct 30 2021, 2:04 PM
tianshilei1992 added inline comments.

nit: in OpenMP term, it is "initial thread".

This revision is now accepted and ready to land.Oct 30 2021, 2:04 PM
jdoerfert added inline comments.Oct 31 2021, 8:33 AM

But in generic mode the initial thread, or main thread (thread 0), changes between parallel level 0 and 1. we used to use the one for level 1, now the one for level 0. As this is really asking "should I use this thread for initialization" and not "is this the initial thread (in some unspecified level)" I think the name fits.

jdoerfert added inline comments.Oct 31 2021, 10:16 AM

I'm rewording.

Rename, add helper, and avoid another race

This revision was landed with ongoing or failed builds.Nov 2 2021, 9:22 PM
This revision was automatically updated to reflect the committed changes.