Skip to content

Commit 8d9412e

Browse files
Add multi-threaded tests for acquire/release atomics (#8999)
* Add multi-threaded execution tests exercising acquire/release atomics * Most tests demonstrate at least one possible result that would not be possible with `seqcst`. It's impossible to write a test that would fail on an engine that implements `acqrel` using `seqcst`, since strengthening an atomic operation is always sound. * `(atomic.fence acqrel)` currently can't be exercised in a way that's correct without being completely redundant alongside another acqrel load/store. With a relaxed memory ordering the test would make more sense. * Invoke the pause instruction in the `basic.wast` test which was previously unexercised * In support.split_wast, ensure that `(thread ...)` and `(wait ...)` expressions are captured in the split output (the latter is currently a no-op anyway but best to include it for readability and correctness). * Rename relaxed_atomic_execution_tests -> acquire_release_atomics_execution_tests to match the new proposal name * Passes in Binaryen's interpreter in an uninteresting way because `(thread)` blocks always run sequentially in a blocking manner.
1 parent dae272c commit 8d9412e

5 files changed

Lines changed: 360 additions & 2 deletions

File tree

scripts/test/relaxed_atomic_execution_tests.py renamed to scripts/test/acquire_release_atomics_execution_tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
(func (export "i64.atomic.rmw32.cmpxchg_u") (param $addr i32) (param $expected i64) (param $value i64) (result i64) (i64.atomic.rmw32.cmpxchg_u acqrel (local.get $addr) (local.get $expected) (local.get $value)))
8181
8282
(func (export "atomic.fence") (atomic.fence acqrel))
83+
84+
(func (export "pause") (pause))
8385
)
8486
8587
;; *.atomic.load*
@@ -395,6 +397,10 @@
395397
396398
(invoke "atomic.fence")
397399
400+
;; pause
401+
402+
(invoke "pause")
403+
398404
399405
;; unaligned accesses
400406

scripts/test/generate_atomic_spec_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dataclasses import dataclass
55
from enum import Enum
66

7-
from relaxed_atomic_execution_tests import acqrel_execution_tests
7+
from acquire_release_atomics_execution_tests import acqrel_execution_tests
88

99
# Workaround for python <3.10, escape characters can't appear in f-strings.
1010
# Although we require 3.10 in some places, the formatter complains without this.

scripts/test/support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def to_end(j):
9090
ret += [(chunk, [])]
9191
elif chunk.startswith('(assert_invalid'):
9292
continue
93-
elif chunk.startswith(('(assert', '(invoke', '(register')) and not ignoring_assertions:
93+
elif chunk.startswith(('(assert', '(invoke', '(register', '(thread', '(wait')) and not ignoring_assertions:
9494
# ret may be empty if there are some asserts before the first
9595
# module. in that case these are asserts *without* a module, which
9696
# are valid (they may check something that doesn't refer to a module

test/spec/relaxed-atomics.wast renamed to test/spec/acquire-release-atomics/basic.wast

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5348,6 +5348,8 @@
53485348
(func (export "i64.atomic.rmw32.cmpxchg_u") (param $addr i32) (param $expected i64) (param $value i64) (result i64) (i64.atomic.rmw32.cmpxchg_u acqrel (local.get $addr) (local.get $expected) (local.get $value)))
53495349

53505350
(func (export "atomic.fence") (atomic.fence acqrel))
5351+
5352+
(func (export "pause") (pause))
53515353
)
53525354

53535355
;; *.atomic.load*
@@ -5663,6 +5665,10 @@
56635665

56645666
(invoke "atomic.fence")
56655667

5668+
;; pause
5669+
5670+
(invoke "pause")
5671+
56665672

56675673
;; unaligned accesses
56685674

0 commit comments

Comments
 (0)