herd / herdtools7

The Herd toolsuite to deal with .cat memory models (version 7.xx)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing (?) data edge

hernanponcedeleon opened this issue · comments

I am running herd7 (version 7.56.2, Rev: exported) on the litmus test below using the attached files (coming from the latest dev branch in the tree of @paulmckrcu)

C dep+plain

(*
 * Result: Never
 *
 * This litmus test demonstrates that in LKMM, plain accesses
 * carry dependencies much like accesses to registers:
 * the data stored to *z1 and *z2 by P0() originates from P0()'s
 * READ_ONCE(), and therefore using that data to compute the
 * conditional of P0()'s if-statement creates a control dependency
 * from that READ_ONCE() to P0()'s WRITE_ONCE() which is inside
 * the if-statement.
 *
 *)

{}

P0(int *x, int *y, int *z1, int *z2)
{
	int a = READ_ONCE(*x);
	*z1 = a;
	*z2 = *z1;
	if (*z2 == 1){
		WRITE_ONCE(*y, 1);
	}
}

P1(int *x, int *y)
{
	int r = smp_load_acquire(y);
	smp_store_release(x, r);
}

exists (x=1 /\ y=1)

As the comment states, the result should not be observable. However this is what herd7 reports

> herd7 -model linux-kernel.cat -I cat/ -bell linux-kernel.bell -macros linux-kernel.def litmus/LKMM/tree/dep_plain.litmus
Test dep+plain Allowed
States 2
x=0; y=0;
x=1; y=1;
Ok
Witnesses
Positive: 1 Negative: 2
Condition exists (x=1 /\ y=1)
Observation dep+plain Sometimes 1 2
Time dep+plain 0.02
Hash=76f5e4b940dcf810444eb27dcfffc9bf

The problem seems to be that herd7 does not recognizes the data dependency between events c and d in this execution graph
dep_plain.pdf. If I split *z2 = *z1; into int t = *z1; *z2 = t;, then I get the correct result.

What is very surprising to me is that if I use the web version of herd7 and just add the following to the cat file (before the include "lock.cat")

let carry-dep = (data ; rfi)*
let addr = carry-dep ; addr
let ctrl = carry-dep ; ctrl
let data = carry-dep ; data

I also get the correct result. This suggests there is some difference between the herd7 version executed in the web-server and the one I execute locally.

memory-model.zip

Hi @hernanponcedeleon, I could not reproduce with the latest dev branch of Paul's deposit. If I am not wrong, It may be that the linux-kernel.bell file you are using in your first experiment does not contain the fix that you have added to the cat file in your second experiment.

Hi @maranget . The changes are there

> ~/git/linux/tools/memory-model$ cat linux-kernel.bell | tail -5
(* Redefine dependencies to include those carried through plain accesses *)
let carry-dep = (data ; rfi)*
let addr = carry-dep ; addr
let ctrl = carry-dep ; ctrl
let data = carry-dep ; data

Am I passing the right flags to make herd pick up the files (specially the *.bell one) from the current directory?

> ~/git/linux/tools/memory-model$ herd7 -model linux-kernel.cat -I ./ -bell linux-kernel.bell -macros linux-kernel.def dep_plain.litmus
Test dep+plain Allowed
States 2
x=0; y=0;
x=1; y=1;
Ok
Witnesses
Positive: 1 Negative: 2
Condition exists (x=1 /\ y=1)
Observation dep+plain Sometimes 1 2
Time dep+plain 0.00
Hash=76f5e4b940dcf810444eb27dcfffc9bf

I also tried using the config file directly, but I get the same result

~/git/linux/tools/memory-model$ herd7 -conf ./linux-kernel.cfg  dep_plain.litmus
Test dep+plain Allowed
States 2
x=0; y=0;
x=1; y=1;
Ok
Witnesses
Positive: 1 Negative: 2
Condition exists (x=1 /\ y=1)
Observation dep+plain Sometimes 1 2
Time dep+plain 0.02
Hash=76f5e4b940dcf810444eb27dcfffc9bf

From the execution graph in my first msg, relation carry-dep is defined (as it is shown in the graph) and thus it seems to be picking up the correct *.bell file.

Please add option -debug files to see what files herd7 actually loads.

Found and opened: './linux-kernel.cat'
Found and opened: './linux-kernel.bell'
Found and opened: '/home/ponce/.opam/default/share/herdtools7/herd/stdlib.cat'
Found and opened: '/home/ponce/git/Dat3M/litmus/LKMM/tree/dep_plain.litmus'
Found and opened: './linux-kernel.def'
Found and opened: './lock.cat'
Found and opened: '/home/ponce/.opam/default/share/herdtools7/herd/cross.cat'
Found and opened: '/home/ponce/.opam/default/share/herdtools7/herd/cos-opt.cat'
Warning: File "/home/ponce/.opam/default/share/herdtools7/herd/cos-opt.cat", line 25, characters 0-19: including cross.cat another time
Warning: File "/home/ponce/.opam/default/share/herdtools7/herd/cos-opt.cat", line 25, characters 0-19: including cross.cat another time
Warning: File "/home/ponce/.opam/default/share/herdtools7/herd/cos-opt.cat", line 25, characters 0-19: including cross.cat another time

The *.bell file seems to be the correct one

Ok I have reproduced the problem. You are using the opam installed herdtools7 suite. Using the head version from this very deposit yields the correct result. I guess we need a new opam release. Thanks for the report.

I confirm I get the correct result using version 7.56+03, Rev: b69b01a281e19808300b876c1deb3967c15a2b53. Thanks @maranget for taking a look to this.