[gen] Rework on printing generated litmus tests#1582
[gen] Rework on printing generated litmus tests#1582ShaleXIONG wants to merge 17 commits intoherd:masterfrom
Conversation
9514464 to
fa9bf99
Compare
array and vmsaarray and vmsa
a03a2a5 to
79f9939
Compare
array and vmsaarray and vmsa
array and vmsa3ab4c89 to
cb5b268
Compare
murzinv
left a comment
There was a problem hiding this comment.
How automatic insert of variant deal with
-info add metadata to generated test(s)
?
The reason I'm asking is that another way to inject variant into litmus test is using -info, for instance -info "variant=memtag". Now if combined with automatic variant insertion is would add two variants into the test and upset herd7
Warning: File "T.litmus": Duplicated meta-data on key Variant
(User error)
[update] I managed to merge |
0c8e202 to
b024151
Compare
007d806 to
2299e72
Compare
c803d25 to
66b54e0
Compare
This commit reworks `top_gen.ml` and `final.ml`, which now uses the module `SimpleDumper` to format and print litmus tests.
- fix the `-metadata` in the new litmus print, so it correctly switch on and off on metadata. - Fix multiple variants entry - Rework on the code so it better to understand with some comments.
Replace the location type in archExtra_gen.ml by the `lib/location.ml`
|
I will have a proper look at the code ASAP, but as a quick comment: I have a question about a change to the final conditions of generarted litmus tests introduced by this PR. For example, when running your example CLI command on current But if I run the same command on top of this PR, I get: You can see that the final condition in the second run relates the fault proposition and the values propositions disjunctively, but the first run relates them conjunctively, which is a stronger assertion logically speaking. Is this intended, and if so, what is the rationale? |
This is a mistake. I just patched. =To help you review, if you think it is helpful, we can have a chat in person or zoom and just go through code together, since there are many structure changes. |
gen/CCompile_gen.ml
Outdated
| (add_args env c,f (F.FaultSet.empty,F.FaultSet.empty)), | ||
| F.run evts m flts | ||
| | Cycle -> F.check ~is_pos:true f flts | ||
| | Observe -> F.exist_true in |
There was a problem hiding this comment.
Similarly, why is this set to F.exist_true in all cases?
Prior to this change, the command dune exec diyone7 -- -arch C PodWW Rfe PodRR Fre -cond observe would generate locations in the final condition, but now only generates exists (true).
Actually, other architectures as well now seem to always include this exists (true) line:
$ dune exec diyone7 -- -arch AArch64 PodWW Rfe PodRR Fre -cond observe
AArch64 MP
Com=Rf Fr
...
STR W2,[X3] | ;
locations [x; y; 1:X0; 1:X2;]
exists (true)
There was a problem hiding this comment.
One of the goal of this change is to line up with mprog7 -mode text. In the case where only exists locations [...], the tool mprog7 actually append a forall (true). I will match the behaviour there.
Regarding questions on when location[...] yields a different result in herd7, the example is diyone7 -variant vmsa -arch AArch64 PteV1 PodWW Rfe PodRR Fre -cond observe. The location contains fault(P1:L00,x). This requests herd7 to show the fault information in all stages.
gen/top_gen.ml
Outdated
| let merge_info lhs rhs = | ||
| let mk_map info = | ||
| List.map ( fun (k,v) -> String.capitalize_ascii k,v ) info | ||
| |> List.to_seq |> StringMap.of_seq in | ||
| StringMap.union | ||
| ( fun v1 v2 -> v1 ^ " " ^ v2 ) (mk_map lhs) (mk_map rhs) | ||
| |> StringMap.to_seq | ||
| |> List.of_seq |
There was a problem hiding this comment.
Here the variants are sorted by key, which means the following comment by @relokin is still not implemented:
The variant should appear before the metadata, if not after all the metadata.
For example, if I run:
$ dune exec diyone7 -- -oneloc -variant mixed,MixedDisjoint -arch AArch64 h2 PosWW h0 Rfe Fre -hexa -info 'Z=foo'
AArch64 WW+R+posh2h0+w0
Com=Rf Fr
Generator=diyone7 (version 7.58+1)
Orig=PosWWh2h0 Rfeh0w0 Frew0h2
Variant=mixed
Z=foo
"PosWWh2h0 Rfeh0w0 Frew0h2"
{
uint32_t 0:X0=0; 0:X1=x; uint32_t 0:X2=0;
...
The Variant key/value pair appears in between other metadata.
Code-wise, I don't see why we couldn't sort the keys via List.sort or similar, rather than StringMap.
There was a problem hiding this comment.
I update it in a way that the rhs will be merged into the lhs. Also I realised if the key collides, for example internal and user-defined, or between two user-defined. The value will be concatenate.
In the case of Variant it is in fact ok to have Variant = memtag memtag for herd7.
There was a problem hiding this comment.
One more request please. Can we make sure that the variant is always printed. That's even when I do -metadata false.
There was a problem hiding this comment.
And similarly for TTHM, -metadata false shouldn't hide. Also TTHM should appear right after the Variant=....
There was a problem hiding this comment.
All good point ! I will update now.
- Change `check` and `run` to `exists_condition` and `forall_condition` - Change `observe` to `location_list` - Add an `observe_condition` to generate final condition, `forall(true)` when `-cond observe`.
bcee036 to
5f46e15
Compare
Also fix a mistake when `prefetch` is emtpy, it now print no prefetch.
This pull request replaces the
diymanual test printing bylib/simpledumper.ml. It fixes two main problems for the initialisation list.int y[2]; y=5toint y[2] = {5,5}.pteinitialisation[PTE(x)].A good example is
diyone7 -arch AArch64 -variant kvm PodRW Pa Rfe PodRW PteV1 Rfe. The new result shows at the end of this message.Separately, we made major rework to
top_gen.mlandfinal.mlin the internal code of printing litmus test. It now uselib/SimpleDumperdirectly rather than manually print out all the information. This simplifies the code and ensure the formatting is consistent with other tools in this repo. The new formatting can be seen below. Notice that"PodRWPPa RfePaP PodRWPPteV1 RfePteV1P"is now at the end of prelude,SimpleDumper,L00, now is on the same line as the instruction, andfaultin post-condition now is in lower case and logical negation isnotrather than~.Last, we add automatic
Variant= ...based on thediy*argument-variant .... This enablesherd7directly configure the expectedvariant.It now has the same syntax as the
mprog7 -mode texttool.