Skip to content

Commit

Permalink
Properly define asmo and fr in Vulkan (#528)
Browse files Browse the repository at this point in the history
Signed-off-by: Hernan Ponce de Leon <[email protected]>
Co-authored-by: Hernan Ponce de Leon <[email protected]>
  • Loading branch information
hernanponcedeleon and hernan-poncedeleon authored Oct 7, 2023
1 parent 35f36bc commit 3f3c8ce
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 8 deletions.
2 changes: 2 additions & 0 deletions cat/ptx-v6.0.cat
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ PTX
(*******************)

// Explicitly add transitivity for coherence since the co in PTX is not total
// and recompute fr based on the new co
let co = co+
let fr = rf^-1; co

(* Events *)
let strong-write = W & (RLX | REL)
Expand Down
2 changes: 2 additions & 0 deletions cat/ptx-v7.5.cat
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ PTX
(*******************)

// Explicitly add transitivity for coherence since the co in PTX is not total
// and recompute fr based on the new co
let co = co+
let fr = rf^-1; co

(* Events *)
let strong-write = W & (RLX | REL)
Expand Down
11 changes: 9 additions & 2 deletions cat/spirv-check.cat
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ let inscope = (DV * DV) |
(swg & ((DV | QF | WG) * (DV | QF | WG))) |
(ssg & ((DV | QF | WG | SG) * (DV | QF | WG | SG)))

let mutordatom = (loc & vloc & inscope & (ATOM * ATOM)) \ id // mutually ordered atomics
// mutually ordered atomics
let mutordatom = (loc & vloc & inscope & (ATOM * ATOM)) \ id

let avvisSem = ((SC0 | SC1) * (AVDEVICE | VISDEVICE))
| (SC0 * ((SEMAV | SEMVIS) & SEMSC0))
Expand All @@ -56,7 +57,13 @@ let avvisinc = ((avvisSem | avvisSem^-1) \ id) |
let posctosem = ((SC0 * SEMSC0) | (SC1 * SEMSC1)) & po
let posemtosc = ((SEMSC0 * SC0) | (SEMSC1 * SC1)) & po

let asmo = co & (ATOM * ATOM)
let asmo = co & ((ATOM | IW) * ATOM)
// From-read is defined based on scoped modification order
// instead of coherence. For reads that read-from init, they
// from-read all writes at the same location.
let fr = (rf^-1; asmo) | (([IW]; rf)^-1; ((loc;[W]) \ id))
let fre = fr & ext

let rs = [REL & ATOM]; ((asmo \ (asmo; asmo+)); [RMW])*
let hypors = [W & ATOM]; ((asmo \ (asmo; asmo+)); [RMW])*

Expand Down
12 changes: 9 additions & 3 deletions cat/spirv-nochains.cat
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ let avvisinc = ((avvisSem | avvisSem^-1) \ id) |
let posctosem = ((SC0 * SEMSC0) | (SC1 * SEMSC1)) & po
let posemtosc = ((SEMSC0 * SC0) | (SEMSC1 * SC1)) & po

let asmo = co & (ATOM * ATOM)
let asmo = co & ((ATOM | IW) * ATOM)
// From-read is defined based on scoped modification order
// instead of coherence. For reads that read-from init, they
// from-read all writes at the same location.
let fr = (rf^-1; asmo) | (([IW]; rf)^-1; ((loc;[W]) \ id))
let fre = fr & ext

let rs = [REL & ATOM]; ((asmo \ (asmo; asmo+)); [RMW])*
let hypors = [W & ATOM]; ((asmo \ (asmo; asmo+)); [RMW])*

Expand All @@ -68,7 +74,7 @@ let sw = inscope & (
([REL & ATOM]; rs; (rf & mutordatom); [ATOM & R]; posctosem; [ACQ & F]) | // atomic->fence
([REL & F]; posemtosc; [ATOM & W]; hypors; (rf & mutordatom); [ATOM & R]; posctosem; [ACQ & F]) | // fence->fence
// (stor[CBAR]) terms are redundant because scbarinst is an equivalence relation on scbarinst, but they make the sequence of instructions more clear.
([REL & F]; po?; [CBAR]; ((syncbar & inscope) \ id); [CBAR]; po?; [ACQ & F]) // fence->cbar->cbar->fence,
([REL & F]; po?; [CBAR]; ((syncbar & inscope) \ id); [CBAR]; po?; [ACQ & F]) // fence->cbar->cbar->fence,
)

let ithbsemsc0 = ( ssw |
Expand Down Expand Up @@ -139,7 +145,7 @@ acyclic (locord | rf | fr | asmo) as consistency-cycle
empty (rf; ([R \ ATOM])) & (([W]; locord); ([W]; locord)+) as consistency-rf

// rmw events are atomic
empty rmw & (fre; coe) as atomic
empty rmw & (fre; (asmo & ext)) as atomic

let non-rmw-reads = (R \ RMW) * (R \ RMW)
empty ((((locord | locord^-1) | mutordatom) \ non-rmw-reads) \ (loc \ id \ non-rmw-reads)) as locord-complete
Expand Down
13 changes: 10 additions & 3 deletions cat/spirv.cat
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ let inscope = (DV * DV) |
(swg & ((DV | QF | WG) * (DV | QF | WG))) |
(ssg & ((DV | QF | WG | SG) * (DV | QF | WG | SG)))

let mutordatom = (loc & vloc & inscope & (ATOM * ATOM)) \ id // mutually ordered atomics
// mutually ordered atomics
let mutordatom = (loc & vloc & inscope & (ATOM * ATOM)) \ id

let avvisSem = ((SC0 | SC1) * (AVDEVICE | VISDEVICE))
| (SC0 * ((SEMAV | SEMVIS) & SEMSC0))
Expand All @@ -56,7 +57,13 @@ let avvisinc = ((avvisSem | avvisSem^-1) \ id) |
let posctosem = ((SC0 * SEMSC0) | (SC1 * SEMSC1)) & po
let posemtosc = ((SEMSC0 * SC0) | (SEMSC1 * SC1)) & po

let asmo = co & (ATOM * ATOM)
let asmo = co & ((ATOM | IW) * ATOM)
// From-read is defined based on scoped modification order
// instead of coherence. For reads that read-from init, they
// from-read all writes at the same location.
let fr = (rf^-1; asmo) | (([IW]; rf)^-1; ((loc;[W]) \ id))
let fre = fr & ext

let rs = [REL & ATOM]; ((asmo \ (asmo; asmo+)); [RMW])*
let hypors = [W & ATOM]; ((asmo \ (asmo; asmo+)); [RMW])*

Expand Down Expand Up @@ -138,7 +145,7 @@ acyclic (locord | rf | fr | asmo) as consistency-cycle
empty (rf; ([R \ ATOM])) & (([W]; locord); ([W]; locord)+) as consistency-rf

// rmw events are atomic
empty rmw & (fre; coe) as atomic
empty rmw & (fre; (asmo & ext)) as atomic

let non-rmw-reads = (R \ RMW) * (R \ RMW)
empty ((((locord | locord^-1) | mutordatom) \ non-rmw-reads) \ (loc \ id \ non-rmw-reads)) as locord-complete
Expand Down
1 change: 1 addition & 0 deletions dartagnan/src/test/resources/PTXv6_0-expected.csv
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ litmus/PTX/Manual/LB-dlb-no-fence-1,1
litmus/PTX/Manual/LB-dlb-no-fence-2,1
litmus/PTX/Nvidia/SB+bar-dyn-reg-const,0
litmus/PTX/Nvidia/SB+bar-sta-reg-const,1
litmus/PTX/Manual/CoWW-weak.litmus,1
1 change: 1 addition & 0 deletions dartagnan/src/test/resources/PTXv7_5-expected.csv
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ litmus/PTX/Manual/LB-dlb-no-fence-1.litmus,1
litmus/PTX/Manual/LB-dlb-no-fence-2.litmus,1
litmus/PTX/Nvidia/SB+bar-dyn-reg-const.litmus,0
litmus/PTX/Nvidia/SB+bar-sta-reg-const.litmus,1
litmus/PTX/Manual/CoWW-weak.litmus,1
1 change: 1 addition & 0 deletions dartagnan/src/test/resources/VULKAN-expected.csv
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ litmus/VULKAN/Manual/MP-mesa-fence-loop.litmus,0
litmus/VULKAN/Manual/MP-mesa-optimized.litmus,1
litmus/VULKAN/Manual/MP-avvis.litmus,0
litmus/VULKAN/Manual/MP-no-avvis.litmus,1
litmus/VULKAN/Manual/CoWW-RR.litmus,1
12 changes: 12 additions & 0 deletions litmus/PTX/Manual/CoWW-RR.litmus
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PTX CoWW-RR
"Non-atomic memory operations may be observed by one thread in a different order than they were written by another thread"
{
P1:r0 = 0;
P1:r1 = 0;
x=0;
}
P0@cta 0,gpu 0 | P1@cta 0,gpu 0 ;
st.weak x, 1 | ld.weak r0, x ;
st.weak x, 2 | ld.weak r1, x ;
exists
(P1:r0 == 2 /\ P1:r1 == 1)
12 changes: 12 additions & 0 deletions litmus/VULKAN/Manual/CoWW-RR.litmus
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Vulkan CoWW-RR
"Non-atomic memory operations may be observed by one thread in a different order than they were written by another thread"
{
P1:r0 = 0;
P1:r1 = 0;
x=0;
}
P0@sg 0, wg 0, qf 0 | P1@sg 0,wg 1, qf 0 ;
st.sc0 x, 1 | ld.sc0 r0, x ;
st.sc0 x, 2 | ld.sc0 r1, x ;
exists
(P1:r0 == 2 /\ P1:r1 == 1)

0 comments on commit 3f3c8ce

Please sign in to comment.