-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #770 from herd/herd-topo-solver
[herd] New solver The new solver substitutes variables in equations following dependencies. It should be functionally equivalent to the previous solver. his PR introduces an enhanced equation solver (step 2. below), which should run slightly faster than the previous one and also follows equation structure more closely. Equations produced by "semantic" modules are solved by a two step process: 1. Identify class of equivalent variables. Variables in a class are replaced by a class representative. As a result, sets of mutually dependent "variable = variable" equations are discarded during that step. Nevertheless the representative variable may be present in other, dependent, equations and in the final execution candidate. 2. Solve equations by substitution and computation. Previous step 2. proceeds by iteration until stabilisation. The new step 2. orders equations according to their dependencies and then substitutes variables into equations, computes results and checks equations by following this dependency order. Mutually dependent sets of equations yield strongly connected components of the dependency graph and are handled as such as follows: the execution is normally discarded, except if the variant `-variant oota` is active where circular equations are kept unsolved. In such a case the resulting execution will have unsolved variables, and, if the model accepts such "oota"-like execution, it will make its way to final outcome. As the old solver, the new solver will accept the simplest out-of-thin-air equations, that is, cyclic variable definitions. Small unrelated additions to the test still most often lead to rejection. Typically, the following tests yields some OOTA result ``` C oota-test { x = 0; y = 0; } P0(atomic_int *x, atomic_int *y) { int r1 = atomic_load_explicit(y, memory_order_relaxed); atomic_store_explicit(x, r1, memory_order_relaxed); // int r2 = (r1 != 0); } P1(atomic_int *x, atomic_int *y) { int r4 = atomic_load_explicit(x, memory_order_relaxed); atomic_store_explicit(y, r4, memory_order_relaxed); } locations [0:r1; 1:r4;] ``` In effect some unsolved variable appear in the list of outcomes: ``` % herd7 -c11 oota-test.litmus Test oota-test Allowed States 2 0:r1=S8; 1:r4=S8; 0:r1=0; 1:r4=0; Ok Witnesses Positive: 1 Negative: 3 Condition exists (not (0:r1=0)) Observation oota-test Sometimes 1 3 Time oota-test 0.01 ``` Uncommenting the definition of 0:r2 at the end of `P0` yields the rejection of the "OOTA" execution, although the C11 model allows it. In effect, the said execution does not get through the solver. However, with the new variant `-variant oota` the "OOTA" behaviour will be accepted. The PR introduces another new variant `-variant oldsolver` that disables the topological solver, resorting to the old, iterative, solver. Finally, all those subtleties are of no importance for models that reject cyclic dependencies, such as all hardware models and the revised C11 model.
- Loading branch information
Showing
17 changed files
with
450 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
C C13 | ||
(* Forbidden by rc11, allowed by most C11 models that tolerate oota *) | ||
{ | ||
x = 0; | ||
y = 0; | ||
} | ||
|
||
P0(atomic_int *x, atomic_int *y) { | ||
int r1 = atomic_load_explicit(y, memory_order_relaxed); | ||
atomic_store_explicit(x, r1, memory_order_relaxed); | ||
int r2 = (r1^r1)+r1; | ||
} | ||
|
||
P1(atomic_int *x, atomic_int *y) { | ||
int r4 = atomic_load_explicit(x, memory_order_relaxed); | ||
atomic_store_explicit(y, r4, memory_order_relaxed); | ||
} | ||
|
||
locations [0:r2; 1:r4;] | ||
exists 0:r1 != 0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Test C13 Allowed | ||
States 1 | ||
0:r1=0x0; 0:r2=0x0; 1:r4=0x0; | ||
No | ||
Witnesses | ||
Positive: 0 Negative: 3 | ||
Condition exists (not (0:r1=0x0)) | ||
Observation C13 Never 0 3 | ||
Hash=45b06aedc4caf5ef4fdf494a986f8199 | ||
|
Oops, something went wrong.