Giter VIP home page Giter VIP logo

memalloy's Introduction

Licence Master branch Dev branch
License: MIT Build Status Build Status

System requirements

  • OCaml 4.07.0 or later (tested with 4.07.0)

  • OPAM packages xml-light, ocamlfind, and ocamlbuild (hint: opam install <package name>)

  • Python 2.7

  • Java runtime version 8 (tested with Java SE Development Kit 8u181).

  • Graphviz (hint: brew install graphviz)

  • Apache Ant, for building Alloy (hint: brew install ant)

Quick start

  1. Modify configure.sh to suit your OS.

  2. Run source configure.sh.

  3. Run make install. HTML documentation can now be browsed at doc/index.html.

  4. Run make quicktest. After a few minutes you should find some pictures of distinguishing executions in the png directory.

Converting .cat models to Alloy (.als) format

  • Each .cat file must begin with a description of the architecture being modelled. This must be one of: "BASIC", "C", "HW", "X86", "PPC", "ARM7", "ARM8", "PTX", "OpenCL", or "OCaml".

  • A reasonable fragment of the .cat language is supported.

    • You can define sets and relations via let x = e. Names of sets must begin with an uppercase letter, and names of relations must begin with a lowercase letter.

    • You can define functions via let f(r1,...,rn) = e. The name of the function must begin with an uppercase letter if the function returns a set, and must begin with a lowercase letter if the function returns a relation. Functions cannot return functions. Set-valued parameters must have a name beginning with an uppercase letter, and relation-valued parameters must begin with a lowercase letter. Parameters cannot be functions themselves.

    • You can define relations (but not sets) recursively via let x1 = e1 and ... and xn = en, and these are unrolled a fixed number of times when translating into Alloy (since Alloy only checks up to a finite bound anyway). The number of unrollings is set by the -u flag, which defaults to 3.

    • You can define a consistency axiom of the model called name via acyclic|irreflexive|empty e as name. You can define a 'definedness' axiom (i.e., one that must hold of every consistent execution or else the whole program is undefined) by prepending the statement above with undefined_unless, and you can define a 'deadness' axiom (i.e., one that must hold of an inconsistent execution in order to guarantee that the resultant litmus test has no other passing executions) by prepending the statement above with deadness_requires instead.

    • You can include the definitions and axioms of the submodel.cat file via include submodel.cat.

  • There are a few syntactic restrictions on .cat files.

    • The variable int, built into Herd, clashes with a keyword in Alloy, so is not allowed. You can use thd instead.

    • The variable X, built into Herd, clashes with another variable in Alloy, so is not allowed. You can use domain(atom) | range(atom) instead.

    • The variables L and A are used in Herd for 'release' and 'acquire' accesses in the Arm8 architecture, but these clash with the variables for 'local' accesses in OpenCL and 'atomic' accesses in C and OpenCL, respectively. Alloy does not allow variables to be re-used in this way, so you must use SCREL and SCACQ in the Arm8 architecture instead.

memalloy's People

Contributors

johnwickerson avatar mattwindsor91 avatar mpardalos avatar nafe avatar tyler-utah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

memalloy's Issues

layer fences

Fences that are strictly stronger than each other should contain both the strong and weak annotation. This makes reducing the tests straightforward.

Removing rf edges when minimising may lead to missed executions

If the execution involves the following thread

    a:W x 1 -po-> b:W x 2 -po-> c:R x 2

(plus some other threads to make the execution inconsistent), and b is removed, then we end up with

    a:W x 1 -po-> c:R x 0

which is certainly inconsistent. This means that the original execution will not be considered minimally inconsistent. Need to consider extending rf with co.rf in rf. Or else leave rf edges unconstrained after removal.

Register reuse can cause litmus7 segfault

In the litmus test below (produced from Allow set Power 6ev synthesis), we have 0:r1 being used as both the address of z and the destination register of the load of x. This in itself is not problematic if we can guarantee that the load of x will always occur. Since we always have a finite and small number of stores to x the litmus7 tool only needs a small buffer to store the possible values (say, 0,1,2).

However, this load of x is within a transaction, which can fail. In this case, 0:r1 will contain its initial value, the address of z. This will vary from run-to-run (since we explicitly use the stride feature of litmus7). If there are enough iterations where the transaction is rolled-back then we’ll collect a bunch of distinct addresses that eventually cause a segfault (due to the histogram collecting of litmus7 overflowing).

The fix is to ensure that that registers assigned for initial locations are disjoint from registers used within the postcondition.

PPC test_4e7901fedeee29511e054bb0aff3772c
{
ok = 1;
0:r1 = z;
1:r2 = z;
0:r4 = y;
1:r3 = y;
0:r5 = x;
1:r5 = x;
0:r7 = ok;
}
P0            | P1            ;
lwz r0, 0(r1) | li r1, 1      ;
cmpwi r0, 0   | stw r1, 0(r2) ;
bne Else00    | lwz r0, 0(r3) ;
Else00:       | cmpwi r0, 0   ;
tbegin.       | bne Else02    ;
beq TxnFail0  | Else02:       ;
li r3, 1      | li r4, 1      ;
stw r3, 0(r4) | stw r4, 0(r5) ;
cmpwi r0, 0   | Exit1:        ;
bne Else01    |               ;
Else01:       |               ;
lwz r1, 0(r5) |               ;
tend.         |               ;
b TxnSuccess0 |               ;
TxnFail0:     |               ;
li r6, 0      |               ;
stw r6, 0(r7) |               ;
b Exit0       |               ;
TxnSuccess0:  |               ;
Exit0:        |               ;

exists
(ok=1 /\ 0:r0=1 /\ 1:r0=1 /\ 0:r1=1 /\ x=1 /\ y=1 /\ z=1)

Inconsistent executions in allow-set due to deadness predicate

The following execution is synthesised for the allow-set for Power 6ev. It is inconsistent.

image001

The execution was weakened from the following forbidden execution (by removing event e2).

test_258d67088b67ffdf43330d0828e7d33e 1

Quoting John:

[...] it's a deadness issue.

An execution is minimally-interesting if it is interesting and any event-removal leads to an uninteresting execution.

An execution is interesting if it is inconsistent and dead.

When you remove E2, you get an inconsistent execution, but it's not dead, so it's deemed uninteresting.

The reason the reduced (i.e. 5-event) execution is not dead is because it has a ctrl dependency coming out of a read that observes the initial value. (You don't have this in the original 6-event execution.) Executions that have this pattern are deemed not dead. This, you may recall, was because I had an issue in POPL'17 whereby if I was control dependent on a read of zero, I couldn't tell if the read had successfully seen zero or just not happened yet. I'm no longer convinced that this is actually an issue.

gen for fences as nodes

The attached xml file (renamed to test.xml.txt) was generated with fences as nodes for PPC. This is problematic for our litmus generation:

$ ./gen -arch PPC -Tlit -o out.litmus test_10117.xml
Fatal error: exception Failure("Invalid fence attributes!")

The problem is the fence event. The function mk_fence for mk_ppc.ml expects an edge.

 let mk_fence attrs =
   match List.mem "sync" attrs,
         List.mem "lwsync" attrs,
         List.mem "isync" attrs with
   | true, false, false -> SYNC
   | false, true, false -> LWSYNC
   | false, false, true -> ISYNC
   | _ -> failwith "Invalid fence attributes!"

What's the right fix to deal with both cases? Should we lowercase attrs before doing the comparison?

out.pdf
test.xml.txt

Generating ARMv8 exclusives and acquire/release instructions using offset register

MemAlloy assumes too much flexibility wrt offset-addressing for exclusives and acq/rel instructions. The "regular" LDR/STR instructions can take a base register and offset register, enabling us to create false address dependencies, like so:

LDR W0, [X1]
EOR W2,W0,W0
STR W3,[X4,W2,SXTW] ; address-dependence from load

The exclusive instructions LDXR/STXR and acq/rel instructions LDAR/STLR can't do this. They can only take a base register. So we must instead encode false address dependencies, like so:

LDR W0, [X1]
EOR W2,W0,W0
ADD W4,W4,W2
STLR W3,[X4] ; address-dependence from load

Add more regression tests

Add more regression tests to tests.sh. Include at least enough to reproduce all the results from the original POPL'17 paper.

C witness generator mistranslates SC

Some SC-marked reads and writes are being emitted as non-atomic by mistake, which produces racy/undefined behaviour.

(Remind me to come back to this issue and fill it out with more detail!)

Call gen from directory

It would be nice to be able to run 'gen' from a directory containing test directories (i.e. X_unique/) where X is a hash. There will also be a hashes.txt file inside the directory listing the hashes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.