Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax restrictions on rvalues in atomic sections #147

Open
MattWindsor91 opened this issue Feb 20, 2017 · 2 comments
Open

Relax restrictions on rvalues in atomic sections #147

MattWindsor91 opened this issue Feb 20, 2017 · 2 comments

Comments

@MattWindsor91
Copy link
Collaborator

Currently any atomic assignment must be either:

  • an assign to a thread lvalue from a shared lvalue or symbol (array indices and symbol parameters may be thread expressions, but nothing else); or
  • an assign to a shared lvalue from a thread expression (cannot name shared variables at all).

These are arbitrary restrictions I put in place originally to ensure Starling, back before arrays and symbols, had a RISC-style load–store semantics to its atomic commands. The idea was that anything more complicated would need to be entered in as a custom command, making Starling atomics behave very much like processor atomics.

However, since we've now introduced inline conditionals into atomics in #142, we're taking a more freeform approach to what can be modelled in Starling's atomics. Also, until true custom commands are in place, the current system of hard-coded strongly typed shorthands like CAS and ++ is inflexible and brittle.

There isn't any deep reason why these restrictions are here, and they've already resulted in needing to write some fairly janky code to get around them, so I propose we lift them and instead have atomic commands be assignments to any lvalue from any rvalue over both shared and thread environments.

Local commands will continue to be thread environment only, because the assumption that locals are atomic in the meta-theory is based entirely on the inability to observe one thread's locals from another.

@septract
Copy link
Owner

septract commented Feb 21, 2017 via email

@MattWindsor91
Copy link
Collaborator Author

Example (though this is predicated on merging #142): in Examples/PassGH/spinLockAtomicBranch.cvf we have (removing an extraneous assignment to test):

      {| isLock(x) |}
        <| test = %{ [|x|].lock };
           if (%{ [|x|].lock } == false) {
               %{ [|x|].lock := true };
           } |>
        test = !test;
      {| if test == false then isLock(x) else holdLock(x) |}

With this change we could write

      {| isLock(x) |}
        <| test = false;
           if (%{ [|x|].lock } == false) {
               test = true;
               %{ [|x|].lock := true };
           } |>
      {| if test == false then isLock(x) else holdLock(x) |}

which is closer to the actual CAS semantics.

MattWindsor91 added a commit that referenced this issue Mar 8, 2017
This fixes #147 and does a bit more, getting rid of some now-unnecessary
stored commands.
MattWindsor91 added a commit that referenced this issue Mar 9, 2017
This fixes #147 and does a bit more, getting rid of some now-unnecessary
stored commands.
MattWindsor91 added a commit that referenced this issue Mar 9, 2017
MattWindsor91 added a commit that referenced this issue Mar 13, 2017
This fixes #147 and does a bit more, getting rid of some now-unnecessary
stored commands.
MattWindsor91 added a commit that referenced this issue Mar 13, 2017
MattWindsor91 added a commit that referenced this issue Apr 19, 2017
This fixes #147 and does a bit more, getting rid of some now-unnecessary
stored commands.
MattWindsor91 added a commit that referenced this issue Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants