Skip to content

Commit 35aebbe

Browse files
shazqadeerShaz Qadeer
andauthored
[Civl] small fixes to cache coherence example (#1036)
Co-authored-by: Shaz Qadeer <[email protected]>
1 parent 996947e commit 35aebbe

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Test/civl/large-samples/cache-coherence.bpl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ Otherwise, they are hitting the same cache and their i arguments are the same.
363363
In this case, the conflict between their dp arguments implies that their ma arguments are different.
364364
Call these arguments ma1 and ma2; let ca1 == Hash(ma1) and ca2 == Hash(ma2).
365365
If ca1 and ca2 are different, there is no conflict.
366-
Otherwise ca1 and ca2 are different.
366+
Otherwise ca1 and ca2 are same.
367367
We get a contradiction because both invocations are referring to the same cache line
368368
but asserting that ma field of this cache line are equal to ma1 and ma2, respectively.
369369
*/
@@ -580,7 +580,7 @@ requires call YieldEvict(i, ma, value, drp);
580580
var dirState: DirState;
581581
var {:linear} {:layer 1,2} dp: Set DirPermission;
582582

583-
par dirState, dp := dir_req_begin(ma) | YieldInv#1();
583+
call dirState, dp := dir_req_begin(ma);
584584
// do not change dirState in case this is a stale evict request due to a race condition with an invalidate
585585
if (dirState == Owner(i)) {
586586
par write_mem(ma, value, dp) | YieldInv#1();
@@ -592,7 +592,7 @@ requires call YieldEvict(i, ma, value, drp);
592592
} else {
593593
call cache_nop_resp#1(i, ma, drp, dp);
594594
}
595-
par dir_req_end(ma, dirState, dp) | YieldInv#1();
595+
call dir_req_end(ma, dirState, dp);
596596
}
597597

598598
yield procedure {:layer 2} dir_read_shd_req(i: CacheId, ma: MemAddr, {:layer 1,2} {:linear_in} drp: Set CachePermission)
@@ -604,16 +604,16 @@ requires call YieldRead(i, ma, drp);
604604
var {:linear} {:layer 1,2} dp: Set DirPermission;
605605
var value: Value;
606606

607-
par dirState, dp := dir_req_begin(ma) | YieldInv#1();
607+
call dirState, dp := dir_req_begin(ma);
608608
if (dirState is Owner) {
609609
par value := cache_invalidate_exc#1(dirState->i, ma, Shared(), dp) | YieldInv#1();
610610
par write_mem(ma, value, dp) | YieldInv#1();
611611
call cache_read_resp#1(i, ma, value, Shared(), drp, dp);
612-
par dir_req_end(ma, Sharers(Set_Add(Set_Add(Set_Empty(), dirState->i), i)), dp) | YieldInv#1();
612+
call dir_req_end(ma, Sharers(Set_Add(Set_Add(Set_Empty(), dirState->i), i)), dp);
613613
} else {
614614
par value := read_mem(ma, dp) | YieldInv#1();
615615
call cache_read_resp#1(i, ma, value, if dirState->iset == Set_Empty() then Exclusive() else Shared(), drp, dp);
616-
par dir_req_end(ma, if dirState->iset == Set_Empty() then Owner(i) else Sharers(Set_Add(dirState->iset, i)), dp) | YieldInv#1();
616+
call dir_req_end(ma, if dirState->iset == Set_Empty() then Owner(i) else Sharers(Set_Add(dirState->iset, i)), dp);
617617
}
618618
}
619619

@@ -626,7 +626,7 @@ requires call YieldRead(i, ma, drp);
626626
var {:linear} {:layer 1,2} dp: Set DirPermission;
627627
var value: Value;
628628

629-
par dirState, dp := dir_req_begin(ma) | YieldInv#1();
629+
call dirState, dp := dir_req_begin(ma);
630630
if (dirState is Owner) {
631631
par value := cache_invalidate_exc#1(dirState->i, ma, Invalid(), dp) | YieldInv#1();
632632
par write_mem(ma, value, dp) | YieldInv#1();
@@ -635,7 +635,7 @@ requires call YieldRead(i, ma, drp);
635635
par value := read_mem(ma, dp) | YieldInv#1();
636636
}
637637
call cache_read_resp#1(i, ma, value, Exclusive(), drp, dp);
638-
par dir_req_end(ma, Owner(i), dp) | YieldInv#1();
638+
call dir_req_end(ma, Owner(i), dp);
639639
}
640640

641641
yield left procedure {:layer 2} invalidate_sharers(ma: MemAddr, victims: Set CacheId, {:linear_in} {:layer 1,2} dp: Set DirPermission)
@@ -662,9 +662,9 @@ ensures {:layer 2} dp == dp';
662662
}
663663
victim := Choice(victims->val);
664664
victims' := Set_Remove(victims, victim);
665-
par dpOne, dp' := get_victim(victim, ma, dp');
665+
call dpOne, dp' := get_victim(victim, ma, dp');
666666
par cache_invalidate_shd#1(victim, ma, Invalid(), dpOne) | dp' := invalidate_sharers(ma, victims', dp');
667-
par dp' := put_victim(dpOne, dp');
667+
call dp' := put_victim(dpOne, dp');
668668
}
669669

670670
yield procedure {:layer 1} get_victim(victim: CacheId, ma: MemAddr, {:layer 1} {:linear_in} dp: Set DirPermission)
@@ -690,7 +690,7 @@ refines both action {:layer 2} _ {
690690
}
691691

692692
yield procedure {:layer 1} dir_req_begin(ma: MemAddr) returns (dirState: DirState, {:linear} {:layer 1} dp: Set DirPermission)
693-
requires call YieldInv#1();
693+
preserves call YieldInv#1();
694694
refines right action {:layer 2} _ {
695695
assume Set_IsSubset(WholeDirPermission(ma), dirPermissions);
696696
dirState := dir[ma];
@@ -702,7 +702,7 @@ refines right action {:layer 2} _ {
702702
}
703703

704704
yield procedure {:layer 1} dir_req_end(ma: MemAddr, dirState: DirState, {:layer 1} {:linear_in} dp: Set DirPermission)
705-
requires call YieldInv#1();
705+
preserves call YieldInv#1();
706706
refines left action {:layer 2} _ {
707707
assert dp == WholeDirPermission(ma);
708708
assume {:add_to_pool "DirPermission", DirPermission(i0, ma)} true;

0 commit comments

Comments
 (0)