public static void AddCheckers(LinearTypeChecker linearTypeChecker, MoverTypeChecker moverTypeChecker, List <Declaration> decls) { if (moverTypeChecker.procToActionInfo.Count == 0) { return; } Dictionary <int, HashSet <ActionInfo> > pools = new Dictionary <int, HashSet <ActionInfo> >(); foreach (ActionInfo action in moverTypeChecker.procToActionInfo.Values) { foreach (int phaseNum in action.callerPhaseNums) { if (!pools.ContainsKey(phaseNum)) { pools[phaseNum] = new HashSet <ActionInfo>(); } pools[phaseNum].Add(action); } } Program program = moverTypeChecker.program; MoverCheck moverChecking = new MoverCheck(linearTypeChecker, moverTypeChecker, decls); foreach (int phaseNum in pools.Keys) { foreach (ActionInfo first in pools[phaseNum]) { Debug.Assert(first.moverType != MoverType.Top); if (first.moverType == MoverType.Atomic) { continue; } foreach (ActionInfo second in pools[phaseNum]) { if (first.IsRightMover) { moverChecking.CreateCommutativityChecker(program, first, second); moverChecking.CreateGatePreservationChecker(program, second, first); } if (first.IsLeftMover) { moverChecking.CreateCommutativityChecker(program, second, first); moverChecking.CreateGatePreservationChecker(program, first, second); moverChecking.CreateFailurePreservationChecker(program, second, first); } } } } }
public static void AddCheckers(LinearTypeChecker linearTypeChecker, MoverTypeChecker moverTypeChecker, List<Declaration> decls) { if (moverTypeChecker.procToActionInfo.Count == 0) return; Dictionary<int, HashSet<ActionInfo>> pools = new Dictionary<int, HashSet<ActionInfo>>(); foreach (ActionInfo action in moverTypeChecker.procToActionInfo.Values) { foreach (int phaseNum in action.callerPhaseNums) { if (!pools.ContainsKey(phaseNum)) { pools[phaseNum] = new HashSet<ActionInfo>(); } pools[phaseNum].Add(action); } } Program program = moverTypeChecker.program; MoverCheck moverChecking = new MoverCheck(linearTypeChecker, moverTypeChecker, decls); foreach (int phaseNum in pools.Keys) { foreach (ActionInfo first in pools[phaseNum]) { Debug.Assert(first.moverType != MoverType.Top); if (first.moverType == MoverType.Atomic) continue; foreach (ActionInfo second in pools[phaseNum]) { if (first.IsRightMover) { moverChecking.CreateCommutativityChecker(program, first, second); moverChecking.CreateGatePreservationChecker(program, second, first); } if (first.IsLeftMover) { moverChecking.CreateCommutativityChecker(program, second, first); moverChecking.CreateGatePreservationChecker(program, first, second); moverChecking.CreateFailurePreservationChecker(program, second, first); } } } } }
public static void AddCheckers(LinearTypeChecker linearTypeChecker, CivlTypeChecker civlTypeChecker, List <Declaration> decls) { if (civlTypeChecker.procToAtomicAction.Count == 0) { return; } MoverCheck moverChecking = new MoverCheck(linearTypeChecker, civlTypeChecker, decls); foreach (int layer in civlTypeChecker.allAtomicActionLayers) { var pool = civlTypeChecker.procToAtomicAction.Values.Where(a => a.layerRange.Contains(layer)); var moverChecks = from first in pool from second in pool where first.moverType != MoverType.Atomic select new { First = first, Second = second }; foreach (var moverCheck in moverChecks) { var first = moverCheck.First.layerToActionCopy[layer]; var second = moverCheck.Second.layerToActionCopy[layer]; if (moverCheck.First.IsRightMover) { moverChecking.CreateCommutativityChecker(first, second); moverChecking.CreateGatePreservationChecker(second, first); } if (moverCheck.First.IsLeftMover) { moverChecking.CreateCommutativityChecker(second, first); moverChecking.CreateGatePreservationChecker(first, second); moverChecking.CreateFailurePreservationChecker(second, first); } } foreach (AtomicAction atomicAction in pool.Where(a => a.IsLeftMover)) { moverChecking.CreateNonBlockingChecker(atomicAction.layerToActionCopy[layer]); } } }
public static void AddCheckers(LinearTypeChecker linearTypeChecker, CivlTypeChecker civlTypeChecker, List <Declaration> decls) { if (civlTypeChecker.procToActionInfo.Count == 0) { return; } List <ActionInfo> sortedByCreatedLayerNum = new List <ActionInfo>(civlTypeChecker.procToActionInfo.Values.Where(x => x is AtomicActionInfo && !x.isExtern)); sortedByCreatedLayerNum.Sort((x, y) => { return((x.createdAtLayerNum == y.createdAtLayerNum) ? 0 : (x.createdAtLayerNum < y.createdAtLayerNum) ? -1 : 1); }); List <ActionInfo> sortedByAvailableUptoLayerNum = new List <ActionInfo>(civlTypeChecker.procToActionInfo.Values.Where(x => x is AtomicActionInfo && !x.isExtern)); sortedByAvailableUptoLayerNum.Sort((x, y) => { return((x.availableUptoLayerNum == y.availableUptoLayerNum) ? 0 : (x.availableUptoLayerNum < y.availableUptoLayerNum) ? -1 : 1); }); Dictionary <int, HashSet <AtomicActionInfo> > pools = new Dictionary <int, HashSet <AtomicActionInfo> >(); int indexIntoSortedByCreatedLayerNum = 0; int indexIntoSortedByAvailableUptoLayerNum = 0; HashSet <AtomicActionInfo> currPool = new HashSet <AtomicActionInfo>(); while (indexIntoSortedByCreatedLayerNum < sortedByCreatedLayerNum.Count) { var currLayerNum = sortedByCreatedLayerNum[indexIntoSortedByCreatedLayerNum].createdAtLayerNum; pools[currLayerNum] = new HashSet <AtomicActionInfo>(currPool); while (indexIntoSortedByCreatedLayerNum < sortedByCreatedLayerNum.Count) { var actionInfo = sortedByCreatedLayerNum[indexIntoSortedByCreatedLayerNum] as AtomicActionInfo; if (actionInfo.createdAtLayerNum > currLayerNum) { break; } pools[currLayerNum].Add(actionInfo); indexIntoSortedByCreatedLayerNum++; } while (indexIntoSortedByAvailableUptoLayerNum < sortedByAvailableUptoLayerNum.Count) { var actionInfo = sortedByAvailableUptoLayerNum[indexIntoSortedByAvailableUptoLayerNum] as AtomicActionInfo; if (actionInfo.availableUptoLayerNum > currLayerNum) { break; } pools[currLayerNum].Remove(actionInfo); indexIntoSortedByAvailableUptoLayerNum++; } currPool = pools[currLayerNum]; } // No atomic action has mover type Top Debug.Assert(pools.All(l => l.Value.All(a => a.moverType != MoverType.Top))); Program program = civlTypeChecker.program; MoverCheck moverChecking = new MoverCheck(linearTypeChecker, civlTypeChecker, decls); var moverChecks = from layer in pools.Keys from first in pools[layer] from second in pools[layer] where first.moverType != MoverType.Atomic select new { First = first, Second = second }; foreach (var moverCheck in moverChecks) { var first = moverCheck.First; var second = moverCheck.Second; if (first.IsRightMover) { moverChecking.CreateCommutativityChecker(program, first, second); moverChecking.CreateGatePreservationChecker(program, second, first); } if (first.IsLeftMover) { moverChecking.CreateCommutativityChecker(program, second, first); moverChecking.CreateGatePreservationChecker(program, first, second); moverChecking.CreateFailurePreservationChecker(program, second, first); } } foreach (AtomicActionInfo atomicActionInfo in sortedByCreatedLayerNum) { if (atomicActionInfo.IsLeftMover && atomicActionInfo.hasAssumeCmd) { moverChecking.CreateNonBlockingChecker(program, atomicActionInfo); } } }
public static void AddCheckers(LinearTypeChecker linearTypeChecker, MoverTypeChecker moverTypeChecker, List <Declaration> decls) { if (moverTypeChecker.procToActionInfo.Count == 0) { return; } List <ActionInfo> sortedByCreatedLayerNum = new List <ActionInfo>(moverTypeChecker.procToActionInfo.Values.Where(x => x is AtomicActionInfo)); sortedByCreatedLayerNum.Sort((x, y) => { return((x.createdAtLayerNum == y.createdAtLayerNum) ? 0 : (x.createdAtLayerNum < y.createdAtLayerNum) ? -1 : 1); }); List <ActionInfo> sortedByAvailableUptoLayerNum = new List <ActionInfo>(moverTypeChecker.procToActionInfo.Values.Where(x => x is AtomicActionInfo)); sortedByAvailableUptoLayerNum.Sort((x, y) => { return((x.availableUptoLayerNum == y.availableUptoLayerNum) ? 0 : (x.availableUptoLayerNum < y.availableUptoLayerNum) ? -1 : 1); }); Dictionary <int, HashSet <AtomicActionInfo> > pools = new Dictionary <int, HashSet <AtomicActionInfo> >(); int indexIntoSortedByCreatedLayerNum = 0; int indexIntoSortedByAvailableUptoLayerNum = 0; HashSet <AtomicActionInfo> currPool = new HashSet <AtomicActionInfo>(); while (indexIntoSortedByCreatedLayerNum < sortedByCreatedLayerNum.Count) { var currLayerNum = sortedByCreatedLayerNum[indexIntoSortedByCreatedLayerNum].createdAtLayerNum; pools[currLayerNum] = new HashSet <AtomicActionInfo>(currPool); while (indexIntoSortedByCreatedLayerNum < sortedByCreatedLayerNum.Count) { var actionInfo = sortedByCreatedLayerNum[indexIntoSortedByCreatedLayerNum] as AtomicActionInfo; if (actionInfo.createdAtLayerNum > currLayerNum) { break; } pools[currLayerNum].Add(actionInfo); indexIntoSortedByCreatedLayerNum++; } while (indexIntoSortedByAvailableUptoLayerNum < sortedByAvailableUptoLayerNum.Count) { var actionInfo = sortedByAvailableUptoLayerNum[indexIntoSortedByAvailableUptoLayerNum] as AtomicActionInfo; if (actionInfo.availableUptoLayerNum > currLayerNum) { break; } pools[currLayerNum].Remove(actionInfo); indexIntoSortedByAvailableUptoLayerNum++; } currPool = pools[currLayerNum]; } Program program = moverTypeChecker.program; MoverCheck moverChecking = new MoverCheck(linearTypeChecker, moverTypeChecker, decls); foreach (int layerNum in pools.Keys) { foreach (AtomicActionInfo first in pools[layerNum]) { Debug.Assert(first.moverType != MoverType.Top); if (first.moverType == MoverType.Atomic) { continue; } foreach (AtomicActionInfo second in pools[layerNum]) { if (first.IsRightMover) { moverChecking.CreateCommutativityChecker(program, first, second); moverChecking.CreateGatePreservationChecker(program, second, first); } if (first.IsLeftMover) { moverChecking.CreateCommutativityChecker(program, second, first); moverChecking.CreateGatePreservationChecker(program, first, second); moverChecking.CreateFailurePreservationChecker(program, second, first); } } } } foreach (ActionInfo actionInfo in moverTypeChecker.procToActionInfo.Values) { AtomicActionInfo atomicActionInfo = actionInfo as AtomicActionInfo; if (atomicActionInfo != null && atomicActionInfo.IsLeftMover && atomicActionInfo.hasAssumeCmd) { moverChecking.CreateNonBlockingChecker(program, atomicActionInfo); } } }
public static void AddCheckers(LinearTypeChecker linearTypeChecker, CivlTypeChecker civlTypeChecker, List<Declaration> decls) { if (civlTypeChecker.procToActionInfo.Count == 0) return; List<ActionInfo> sortedByCreatedLayerNum = new List<ActionInfo>(civlTypeChecker.procToActionInfo.Values.Where(x => x is AtomicActionInfo && !x.isExtern)); sortedByCreatedLayerNum.Sort((x, y) => { return (x.createdAtLayerNum == y.createdAtLayerNum) ? 0 : (x.createdAtLayerNum < y.createdAtLayerNum) ? -1 : 1; }); List<ActionInfo> sortedByAvailableUptoLayerNum = new List<ActionInfo>(civlTypeChecker.procToActionInfo.Values.Where(x => x is AtomicActionInfo && !x.isExtern)); sortedByAvailableUptoLayerNum.Sort((x, y) => { return (x.availableUptoLayerNum == y.availableUptoLayerNum) ? 0 : (x.availableUptoLayerNum < y.availableUptoLayerNum) ? -1 : 1; }); Dictionary<int, HashSet<AtomicActionInfo>> pools = new Dictionary<int, HashSet<AtomicActionInfo>>(); int indexIntoSortedByCreatedLayerNum = 0; int indexIntoSortedByAvailableUptoLayerNum = 0; HashSet<AtomicActionInfo> currPool = new HashSet<AtomicActionInfo>(); while (indexIntoSortedByCreatedLayerNum < sortedByCreatedLayerNum.Count) { var currLayerNum = sortedByCreatedLayerNum[indexIntoSortedByCreatedLayerNum].createdAtLayerNum; pools[currLayerNum] = new HashSet<AtomicActionInfo>(currPool); while (indexIntoSortedByCreatedLayerNum < sortedByCreatedLayerNum.Count) { var actionInfo = sortedByCreatedLayerNum[indexIntoSortedByCreatedLayerNum] as AtomicActionInfo; if (actionInfo.createdAtLayerNum > currLayerNum) break; pools[currLayerNum].Add(actionInfo); indexIntoSortedByCreatedLayerNum++; } while (indexIntoSortedByAvailableUptoLayerNum < sortedByAvailableUptoLayerNum.Count) { var actionInfo = sortedByAvailableUptoLayerNum[indexIntoSortedByAvailableUptoLayerNum] as AtomicActionInfo; if (actionInfo.availableUptoLayerNum > currLayerNum) break; pools[currLayerNum].Remove(actionInfo); indexIntoSortedByAvailableUptoLayerNum++; } currPool = pools[currLayerNum]; } // No atomic action has mover type Top Debug.Assert(pools.All(l => l.Value.All(a => a.moverType != MoverType.Top))); Program program = civlTypeChecker.program; MoverCheck moverChecking = new MoverCheck(linearTypeChecker, civlTypeChecker, decls); var moverChecks = from layer in pools.Keys from first in pools[layer] from second in pools[layer] where first.moverType != MoverType.Atomic select new { First = first, Second = second }; foreach (var moverCheck in moverChecks) { var first = moverCheck.First; var second = moverCheck.Second; if (first.IsRightMover) { moverChecking.CreateCommutativityChecker(program, first, second); moverChecking.CreateGatePreservationChecker(program, second, first); } if (first.IsLeftMover) { moverChecking.CreateCommutativityChecker(program, second, first); moverChecking.CreateGatePreservationChecker(program, first, second); moverChecking.CreateFailurePreservationChecker(program, second, first); } } foreach (AtomicActionInfo atomicActionInfo in sortedByCreatedLayerNum) { if (atomicActionInfo.IsLeftMover && atomicActionInfo.hasAssumeCmd) { moverChecking.CreateNonBlockingChecker(program, atomicActionInfo); } } }