Skip to content

Conversation

@gebner
Copy link
Contributor

@gebner gebner commented Oct 24, 2025

  • loc_id is a logical location from which you can observe memory, on l p says that p is true at location l, locations can be e.g.:
    • a thread (i.e., on thrid (x |-> y) means that when thread number thrid reads the variable x it will reliably get y)
    • global memory
    • global memory on a GPU
  • every thread is associated with a process (which is also a location), there can be multiple processes
    • every block in a GPU kernel is logically a process
    • we can axiomatize when it is safe to move resources between blocks/devices/processes
  • slprops are stratified according to how easy it is to move them between locations:
    • placeless p means you can unconditionally move them anywhere, e.g., pure, inv, on, ghost references, etc.
    • is_send p means you can move them to threads of the same process
  • invariants require placeless slprops, fork requires is_send, mutex requires is_send

To check out the interface, a good place to look is the diff for Pulse.Lib.Core.fsti and Pulse.Lib.Send.fsti.

Pain points:

  • Trades, sigh. We already have two versions of trades with different restrictions on the closure: trade and shift (which requires the closure to be duplicable). This approach would add a lot of other useful restrictions to the mix: sending a trade across threads requires an is_sync closure, sending a trade across devices requires a placeless closure, pulling a trade out of a later requires a timeless closure, etc. Obviously, some might want a duplicable+timeless+is_sync trade too... You can work around this a bit with on, but I foresee a plethora of trade variants.
  • You need to write a lot of placeless/is_send/is_sync instances; they're usually trivial though.

Fun points:

  • Using type classes for placeless/is_send/is_sync seems to work out nicely; or at least nicer than the SMT pattern setup for timeless.

@gebner gebner force-pushed the gebner_loc branch 4 times, most recently from c05d222 to 8c3a059 Compare November 6, 2025 19:05
@gebner gebner force-pushed the gebner_loc branch 7 times, most recently from 4d6617d to c52ed47 Compare November 12, 2025 22:14
@gebner gebner changed the title Attempt at expressing location of resources and weak memory accesses Located resources Nov 12, 2025
@gebner gebner marked this pull request as ready for review November 12, 2025 22:17
Comment on lines +22 to +27
fn par (#preL: slprop) #postL #preR #postR
{| is_send preL, is_send postL, is_send preR, is_send postR |}
(f:unit -> stt unit preL (fun _ -> postL))
(g:unit -> stt unit preR (fun _ -> postR))
requires preL ** preR
ensures postL ** postR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also add a "located" version of par allowing to run from a user-specified location and spawn a thread in a separate user-specified location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can easily simulate that with impersonate.

@gebner gebner merged commit dac3a56 into main Nov 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants