[OpenMP][FIX] Avoid a race between initialization and first state reads
authorJohannes Doerfert <johannes@jdoerfert.de>
Sat, 30 Oct 2021 19:24:25 +0000 (14:24 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Wed, 3 Nov 2021 04:21:49 +0000 (23:21 -0500)
commitccb5d2726a8bc0092857f9e69963e872d78cd4d8
tree93741ca62eb0a6d5d7a3f8d900515082dd6bab6d
parentfbe61fb0aa2384962746ac411110e5c6a33b8a10
[OpenMP][FIX] Avoid a race between initialization and first state reads

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.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D112874
openmp/libomptarget/DeviceRTL/include/Mapping.h
openmp/libomptarget/DeviceRTL/src/Kernel.cpp
openmp/libomptarget/DeviceRTL/src/Mapping.cpp
openmp/libomptarget/DeviceRTL/src/State.cpp