aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorPeixin Qiao <qiaopeixin@huawei.com>2022-08-20 23:31:13 +0800
committerPeixin Qiao <qiaopeixin@huawei.com>2022-08-20 23:31:13 +0800
commitaa4146031132c8007bc9b9109221036c24923d2a (patch)
treee6ffc25f97ca7cb1abd1c5dd76dce6a3f58c0d6e /clang/lib/Frontend/CompilerInvocation.cpp
parent347c462e97bbb22ef9d95ef2f161e2eb82843f8e (diff)
downloadllvm-aa4146031132c8007bc9b9109221036c24923d2a.zip
llvm-aa4146031132c8007bc9b9109221036c24923d2a.tar.gz
llvm-aa4146031132c8007bc9b9109221036c24923d2a.tar.bz2
[flang][OpenMP] Handle the data race for firstprivate and lastprivate
Remove barriers for firstprivate except if the variable is also lastprivatized. Re-arrange code and put all last-privates inside a single scf.if. As OpenMP Spec 5.0, to avoid the data races, concurrent updates of the original list item must be synchronized with the read of the original list item that occurs as a result of the firstprivate clause. Adding barrier(s) before and/or after the worksharing region would remove the data races, and it is the application(user)'s job. However, when one list item is in both firstprivate and lastprivate clauses, the standard (https://www.openmp.org/spec-html/5.0/openmpsu105.html) states the following: ``` If a list item appears in both firstprivate and lastprivate clauses, the update required for the lastprivate clause occurs after all initializations for the firstprivate clause. ``` So, the synchronization should be ensured by compiler such as emiting one barrier since the lastprivate clause follows the reads of the original list item performed for the initialization of each of the firstprivate list item. Add FIXME for two special cases, sections construct and linear clause. The data race problem for single construct will be handled later. This implementation is based on the discussion with OpenMP committee and clang code (clang/lib/CodeGen/CGStmtOpenMP.cpp). Reviewed By: kiranchandramohan, NimishMishra Differential Revision: https://reviews.llvm.org/D131832
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions