SHA256
1
0
forked from pool/mvapich2
mvapich2/mvapich2-openpa-add-memory-barriers.patch
2023-11-10 10:35:55 +00:00

95 lines
3.5 KiB
Diff

commit 68c4106b2a8d8fdb9ba4e2bab90e90e3392b6bbd
Author: Nicolas Morey <nmorey@suse.com>
Date: Thu Oct 26 12:39:20 2023 +0200
mvapich2: openpa: add memory barriers
Backport from openPA:
commit 28d602b620b5d7ec8ca1a7f3ad8ab27d439b1751
Author: Neil Fortner <nfortne2@hdfgroup.org>
Date: Wed Dec 19 13:14:57 2012 -0600
Add more memory barriers to LL/SC ABA tests. This should fix the recent errors
on POWER7.
Reviewed by goodell.
Signed-off-by: Nicolas Morey <nmorey@suse.com>
diff --git src/openpa/test/test_primitives.c src/openpa/test/test_primitives.c
index a83b95e00578..4533c643d581 100644
--- src/openpa/test/test_primitives.c
+++ src/openpa/test/test_primitives.c
@@ -3783,12 +3783,18 @@ static int threaded_llsc_int_aba_helper_0(llsc_int_aba_t *udata)
nerrors++;
} /* end if */
+ /* Make sure shared_val is initialized before passing point 0 */
+ OPA_write_barrier();
+
/* Point 0 */
OPA_store_int(&udata->pass_point_0, 1);
/* Wait until thread 1 passes point 1 */
while(!OPA_load_int(&udata->pass_point_1));
+ /* Make sure that change_val is loaded after passing point 1 */
+ OPA_read_barrier();
+
/* Store conditional 1 to the shared value */
if(OPA_SC_int(&udata->shared_val, 1)) {
/* SC succeeded, make sure that the shared value was not changed by
@@ -3870,12 +3876,12 @@ static void *threaded_llsc_int_aba_helper_1(void *_udata)
* of this test */
OPA_store_int(&udata->shared_val, 1);
OPA_store_int(&udata->shared_val, 0);
-
- /* Write barrier to make sure the shared value was actually updated
- * before we mark point 1 as passed */
- OPA_write_barrier();
} /* end if */
+ /* Write barrier to make sure the shared_val (if appropriate) and
+ * change_val are actually updated before we mark point 1 as passed */
+ OPA_write_barrier();
+
/* Point 1 */
OPA_store_int(&udata->pass_point_1, 1);
@@ -4012,12 +4018,18 @@ static int threaded_llsc_ptr_aba_helper_0(llsc_ptr_aba_t *udata)
nerrors++;
} /* end if */
+ /* Make sure shared_val is initialized before passing point 0 */
+ OPA_write_barrier();
+
/* Point 0 */
OPA_store_int(&udata->pass_point_0, 1);
/* Wait until thread 1 passes point 1 */
while(!OPA_load_int(&udata->pass_point_1));
+ /* Make sure that change_val is loaded after passing point 1 */
+ OPA_read_barrier();
+
/* Store conditional 1 to the shared value */
if(OPA_SC_ptr(&udata->shared_val, (void *) ((int *) 0 + 1))) {
/* SC succeeded, make sure that the shared value was not changed by
@@ -4099,12 +4111,12 @@ static void *threaded_llsc_ptr_aba_helper_1(void *_udata)
* of this test */
OPA_store_ptr(&udata->shared_val, (void *) ((int *) 0 + 1));
OPA_store_ptr(&udata->shared_val, (void *) 0);
-
- /* Write barrier to make sure the shared value was actually updated
- * before we mark point 1 as passed */
- OPA_write_barrier();
} /* end if */
+ /* Write barrier to make sure the shared_val (if appropriate) and
+ * change_val are actually updated before we mark point 1 as passed */
+ OPA_write_barrier();
+
/* Point 1 */
OPA_store_int(&udata->pass_point_1, 1);