[Openmp-commits] [openmp] 454d449 - [OpenMP] Use a memory fence before incrementing the dispatch buffer index (#87995)
via Openmp-commits
openmp-commits at lists.llvm.org
Tue Apr 16 10:13:52 PDT 2024
Author: Xing Xue
Date: 2024-04-16T13:13:49-04:00
New Revision: 454d4496970f665200b5b300578894d78405b6ca
URL: https://github.com/llvm/llvm-project/commit/454d4496970f665200b5b300578894d78405b6ca
DIFF: https://github.com/llvm/llvm-project/commit/454d4496970f665200b5b300578894d78405b6ca.diff
LOG: [OpenMP] Use a memory fence before incrementing the dispatch buffer index (#87995)
This patch uses a memory fence in function `__kmp_dispatch_next()` to
flush pending memory write invalidates before incrementing the
`volatile` variable `buffer_index` to fix intermittent time-outs of
OpenMP runtime LIT test cases `env/kmp_set_dispatch_buf.c` and
`worksharing/for/kmp_set_dispatch_buf.c`, noting that the same is needed
for incrementing `buffer_index` in function `__kmpc_next_section()`
(line 2600 of `kmp_dispatch.cpp`).
Added:
Modified:
openmp/runtime/src/kmp_dispatch.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_dispatch.cpp b/openmp/runtime/src/kmp_dispatch.cpp
index ac85b2b3f2fcd4..fc333765118179 100644
--- a/openmp/runtime/src/kmp_dispatch.cpp
+++ b/openmp/runtime/src/kmp_dispatch.cpp
@@ -2397,6 +2397,8 @@ static int __kmp_dispatch_next(ident_t *loc, int gtid, kmp_int32 *p_last,
sh->u.s.ordered_iteration = 0;
}
+ KMP_MB(); /* Flush all pending memory write invalidates. */
+
sh->buffer_index += __kmp_dispatch_num_buffers;
KD_TRACE(100, ("__kmp_dispatch_next: T#%d change buffer_index:%d\n",
gtid, sh->buffer_index));
More information about the Openmp-commits
mailing list