summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Unknown <afd@afd-THINK>2012-04-24 17:54:30 +0100
committerGravatar Unknown <afd@afd-THINK>2012-04-24 17:54:30 +0100
commitf8e2214a74883e9a473d9ca15be94e5c7f28859f (patch)
treec1b23ee2c295523b5cd0eb66ed2720354b7563c8
parentc3a39f3cc1924ce8332b89db501c99b8822d5892 (diff)
Significantly changed the way race checking is performed. Made eager race checking and symmetry reduction default, and removed the option to turn these off - makes the code a lot cleaner.
-rw-r--r--Source/GPUVerify/AsymmetricExpressionFinder.cs4
-rw-r--r--Source/GPUVerify/CommandLineOptions.cs19
-rw-r--r--Source/GPUVerify/ElementEncodingRaceInstrumenter.cs374
-rw-r--r--Source/GPUVerify/GPUVerifier.cs64
-rw-r--r--Source/GPUVerify/IRaceInstrumenter.cs7
-rw-r--r--Source/GPUVerify/KernelDualiser.cs123
-rw-r--r--Source/GPUVerify/NullRaceInstrumenter.cs16
-rw-r--r--Source/GPUVerify/RaceInstrumenterBase.cs217
-rw-r--r--Source/GPUVerify/SetEncodingRaceInstrumenter.cs190
9 files changed, 197 insertions, 817 deletions
diff --git a/Source/GPUVerify/AsymmetricExpressionFinder.cs b/Source/GPUVerify/AsymmetricExpressionFinder.cs
index 40c7eb32..4fb18352 100644
--- a/Source/GPUVerify/AsymmetricExpressionFinder.cs
+++ b/Source/GPUVerify/AsymmetricExpressionFinder.cs
@@ -18,7 +18,9 @@ namespace GPUVerify
public override Variable VisitVariable(Variable node)
{
if (node.TypedIdent.Name.Contains("_READ_HAS_OCCURRED") ||
- node.TypedIdent.Name.Contains("_READ_OFFSET"))
+ node.TypedIdent.Name.Contains("_READ_OFFSET") ||
+ node.TypedIdent.Name.Contains("_WRITE_HAS_OCCURRED") ||
+ node.TypedIdent.Name.Contains("_WRITE_OFFSET"))
{
found = true;
}
diff --git a/Source/GPUVerify/CommandLineOptions.cs b/Source/GPUVerify/CommandLineOptions.cs
index b2e54dbd..272efd99 100644
--- a/Source/GPUVerify/CommandLineOptions.cs
+++ b/Source/GPUVerify/CommandLineOptions.cs
@@ -24,9 +24,7 @@ namespace GPUVerify
public static bool DividedArray = false;
public static string ArrayToCheck = null;
public static bool DividedAccesses = false;
- public static bool Eager = false;
- public static bool Symmetry = false;
public static bool SetEncoding = false;
public static bool ShowStages = false;
@@ -34,8 +32,6 @@ namespace GPUVerify
public static bool AddDivergenceCandidatesOnlyIfModified = true;
public static bool AddDivergenceCandidatesOnlyToBarrierLoops = true;
- public static bool AssignAtBarriers = false;
-
public static bool ShowUniformityAnalysis = false;
public static bool DoUniformityAnalysis = true;
@@ -121,21 +117,11 @@ namespace GPUVerify
DividedArray = true;
break;
- case "-symmetry":
- case "/symmetry":
- Symmetry = true;
- break;
-
case "-setEncoding":
case "/setEncoding":
SetEncoding = true;
break;
- case "-eager":
- case "/eager":
- Eager = true;
- break;
-
case "-showStages":
case "/showStages":
ShowStages = true;
@@ -163,11 +149,6 @@ namespace GPUVerify
AddDivergenceCandidatesOnlyToBarrierLoops = false;
break;
- case "-assignAtBarriers":
- case "/assignAtBarriers":
- AssignAtBarriers = true;
- break;
-
case "-showUniformityAnalysis":
case "/showUniformityAnalysis":
ShowUniformityAnalysis = true;
diff --git a/Source/GPUVerify/ElementEncodingRaceInstrumenter.cs b/Source/GPUVerify/ElementEncodingRaceInstrumenter.cs
index 1763bb58..c249ef0f 100644
--- a/Source/GPUVerify/ElementEncodingRaceInstrumenter.cs
+++ b/Source/GPUVerify/ElementEncodingRaceInstrumenter.cs
@@ -18,41 +18,20 @@ namespace GPUVerify
- protected override void AddLogAccessProcedure(Variable v, string ReadOrWrite)
+ protected override void AddLogAccessProcedure(Variable v, string Access)
{
- Variable XParameterVariable;
- Variable YParameterVariable;
- Variable ZParameterVariable;
- Procedure LogReadOrWriteProcedure;
+ Procedure LogAccessProcedure = MakeLogAccessProcedureHeader(v, Access);
- MakeLogAccessProcedureHeader(v, ReadOrWrite, out XParameterVariable, out YParameterVariable, out ZParameterVariable, out LogReadOrWriteProcedure);
+ Variable AccessHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, Access);
+ Variable AccessOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, Access);
- IdentifierExprSeq modifies = LogReadOrWriteProcedure.Modifies;
- Variable ReadOrWriteHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite);
- Variable ReadOrWriteOffsetXVariable = null;
- Variable ReadOrWriteOffsetYVariable = null;
- Variable ReadOrWriteOffsetZVariable = null;
+ Variable PredicateParameter = new LocalVariable(v.tok, new TypedIdent(v.tok, "_P", Microsoft.Boogie.Type.Bool));
- if (XParameterVariable != null)
- {
- ReadOrWriteOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, ReadOrWrite);
- modifies.Add(new IdentifierExpr(v.tok, ReadOrWriteOffsetXVariable));
- }
- if (YParameterVariable != null)
- {
- Debug.Assert(XParameterVariable != null);
- ReadOrWriteOffsetYVariable = GPUVerifier.MakeOffsetYVariable(v, ReadOrWrite);
- modifies.Add(new IdentifierExpr(v.tok, ReadOrWriteOffsetYVariable));
- }
- if (ZParameterVariable != null)
- {
- Debug.Assert(XParameterVariable != null);
- Debug.Assert(YParameterVariable != null);
- ReadOrWriteOffsetZVariable = GPUVerifier.MakeOffsetZVariable(v, ReadOrWrite);
- modifies.Add(new IdentifierExpr(v.tok, ReadOrWriteOffsetZVariable));
- }
-
- modifies.Add(new IdentifierExpr(v.tok, ReadOrWriteHasOccurredVariable));
+ Debug.Assert(v.TypedIdent.Type is MapType);
+ MapType mt = v.TypedIdent.Type as MapType;
+ Debug.Assert(mt.Arguments.Length == 1);
+ Variable OffsetParameter = new LocalVariable(v.tok, new TypedIdent(v.tok, "_offset", mt.Arguments[0]));
+ Debug.Assert(!(mt.Result is MapType));
VariableSeq locals = new VariableSeq();
Variable TrackVariable = new LocalVariable(v.tok, new TypedIdent(v.tok, "track", Microsoft.Boogie.Type.Bool));
@@ -63,103 +42,110 @@ namespace GPUVerify
CmdSeq simpleCmds = new CmdSeq();
simpleCmds.Add(new HavocCmd(v.tok, new IdentifierExprSeq(new IdentifierExpr[] { new IdentifierExpr(v.tok, TrackVariable) })));
- simpleCmds.Add(MakeConditionalAssignment(ReadOrWriteHasOccurredVariable, new IdentifierExpr(v.tok, TrackVariable), Expr.True));
- if (ReadOrWriteOffsetXVariable != null)
- {
- simpleCmds.Add(MakeConditionalAssignment(ReadOrWriteOffsetXVariable, new IdentifierExpr(v.tok, TrackVariable), new IdentifierExpr(v.tok, XParameterVariable)));
- }
- if (ReadOrWriteOffsetYVariable != null)
- {
- simpleCmds.Add(MakeConditionalAssignment(ReadOrWriteOffsetYVariable, new IdentifierExpr(v.tok, TrackVariable), new IdentifierExpr(v.tok, YParameterVariable)));
- }
- if (ReadOrWriteOffsetZVariable != null)
- {
- simpleCmds.Add(MakeConditionalAssignment(ReadOrWriteOffsetZVariable, new IdentifierExpr(v.tok, TrackVariable), new IdentifierExpr(v.tok, ZParameterVariable)));
- }
-
-
- bigblocks.Add(new BigBlock(v.tok, "_LOG_" + ReadOrWrite + "", simpleCmds, null, null));
- StmtList statements = new StmtList(bigblocks, v.tok);
+ simpleCmds.Add(MakeConditionalAssignment(VariableForThread(1, AccessHasOccurredVariable),
+ Expr.And(new IdentifierExpr(v.tok, VariableForThread(1, PredicateParameter)), new IdentifierExpr(v.tok, TrackVariable)), Expr.True));
+ simpleCmds.Add(MakeConditionalAssignment(VariableForThread(1, AccessOffsetXVariable),
+ Expr.And(new IdentifierExpr(v.tok, VariableForThread(1, PredicateParameter)), new IdentifierExpr(v.tok, TrackVariable)),
+ new IdentifierExpr(v.tok, VariableForThread(1, OffsetParameter))));
- Implementation LogReadOrWriteImplementation = new Implementation(v.tok, "_LOG_" + ReadOrWrite + "_" + v.Name, new TypeVariableSeq(), LogReadOrWriteProcedure.InParams, new VariableSeq(), locals, statements);
- LogReadOrWriteImplementation.AddAttribute("inline", new object[] { new LiteralExpr(v.tok, BigNum.FromInt(1)) });
-
- LogReadOrWriteImplementation.Proc = LogReadOrWriteProcedure;
-
- verifier.Program.TopLevelDeclarations.Add(LogReadOrWriteProcedure);
- verifier.Program.TopLevelDeclarations.Add(LogReadOrWriteImplementation);
- }
-
- protected override void AddLogRaceDeclarations(Variable v, String ReadOrWrite, out IdentifierExprSeq ResetAtBarrier, out IdentifierExprSeq ModifiedAtLog)
- {
- ModifiedAtLog = new IdentifierExprSeq();
- ResetAtBarrier = new IdentifierExprSeq();
-
- Variable AccessHasOccurred = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite);
-
- if (CommandLineOptions.Symmetry && ReadOrWrite.Equals("READ"))
+ if (Access.Equals("READ"))
{
- verifier.HalfDualisedVariableNames.Add(AccessHasOccurred.Name);
+ // Check read by thread 2 does not conflict with write by thread 1
+ Variable WriteHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "WRITE");
+ Variable WriteOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, "WRITE");
+ Expr WriteReadGuard = new IdentifierExpr(Token.NoToken, VariableForThread(2, PredicateParameter));
+ WriteReadGuard = Expr.And(WriteReadGuard, new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteHasOccurredVariable)));
+ WriteReadGuard = Expr.And(WriteReadGuard, Expr.Eq(new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteOffsetXVariable)),
+ new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter))));
+ if (!verifier.ArrayModelledAdversarially(v))
+ {
+ WriteReadGuard = Expr.And(WriteReadGuard, Expr.Neq(
+ MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteOffsetXVariable)), 1, "WRITE"),
+ MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter)), 2, "READ")
+ ));
+ }
+ WriteReadGuard = Expr.Not(WriteReadGuard);
+ simpleCmds.Add(new AssertCmd(Token.NoToken, WriteReadGuard));
}
-
- ModifiedAtLog.Add(new IdentifierExpr(v.tok, AccessHasOccurred));
- ResetAtBarrier.Add(new IdentifierExpr(v.tok, AccessHasOccurred));
-
- verifier.Program.TopLevelDeclarations.Add(AccessHasOccurred);
- if (v.TypedIdent.Type is MapType)
+ else
{
- MapType mt = v.TypedIdent.Type as MapType;
- Debug.Assert(mt.Arguments.Length == 1);
+ Debug.Assert(Access.Equals("WRITE"));
- Variable AccessOffsetX = GPUVerifier.MakeOffsetXVariable(v, ReadOrWrite);
+ // Check write by thread 2 does not conflict with write by thread 1
+ Variable WriteHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "WRITE");
+ Variable WriteOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, "WRITE");
- if (CommandLineOptions.Symmetry && ReadOrWrite.Equals("READ"))
+ Expr WriteWriteGuard = new IdentifierExpr(Token.NoToken, VariableForThread(2, PredicateParameter));
+ WriteWriteGuard = Expr.And(WriteWriteGuard, new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteHasOccurredVariable)));
+ WriteWriteGuard = Expr.And(WriteWriteGuard, Expr.Eq(new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteOffsetXVariable)),
+ new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter))));
+ if (!verifier.ArrayModelledAdversarially(v))
+ {
+ WriteWriteGuard = Expr.And(WriteWriteGuard, Expr.Neq(
+ MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(1, WriteOffsetXVariable)), 1, "WRITE"),
+ MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter)), 2, "WRITE")
+ ));
+ }
+ WriteWriteGuard = Expr.Not(WriteWriteGuard);
+ simpleCmds.Add(new AssertCmd(Token.NoToken, WriteWriteGuard));
+
+ // Check write by thread 2 does not conflict with read by thread 1
+ Variable ReadHasOccurredVariable = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "READ");
+ Variable ReadOffsetXVariable = GPUVerifier.MakeOffsetXVariable(v, "READ");
+
+ Expr ReadWriteGuard = new IdentifierExpr(Token.NoToken, VariableForThread(2, PredicateParameter));
+ ReadWriteGuard = Expr.And(ReadWriteGuard, new IdentifierExpr(Token.NoToken, VariableForThread(1, ReadHasOccurredVariable)));
+ ReadWriteGuard = Expr.And(ReadWriteGuard, Expr.Eq(new IdentifierExpr(Token.NoToken, VariableForThread(1, ReadOffsetXVariable)),
+ new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter))));
+ if (!verifier.ArrayModelledAdversarially(v))
{
- verifier.HalfDualisedVariableNames.Add(AccessOffsetX.Name);
+ ReadWriteGuard = Expr.And(ReadWriteGuard, Expr.Neq(
+ MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(1, ReadOffsetXVariable)), 1, "WRITE"),
+ MakeAccessedIndex(v, new IdentifierExpr(Token.NoToken, VariableForThread(2, OffsetParameter)), 2, "READ")
+ ));
}
+ ReadWriteGuard = Expr.Not(ReadWriteGuard);
+ simpleCmds.Add(new AssertCmd(Token.NoToken, ReadWriteGuard));
- ModifiedAtLog.Add(new IdentifierExpr(v.tok, AccessOffsetX));
- verifier.Program.TopLevelDeclarations.Add(AccessOffsetX);
+ }
- if (mt.Result is MapType)
- {
- MapType mt2 = mt.Result as MapType;
- Debug.Assert(mt2.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt2.Arguments[0]));
+ bigblocks.Add(new BigBlock(v.tok, "_LOG_" + Access + "", simpleCmds, null, null));
- Variable AccessOffsetY = GPUVerifier.MakeOffsetYVariable(v, ReadOrWrite);
+ LogAccessProcedure.Modifies.Add(new IdentifierExpr(Token.NoToken, VariableForThread(1, AccessHasOccurredVariable)));
+ LogAccessProcedure.Modifies.Add(new IdentifierExpr(Token.NoToken, VariableForThread(1, AccessOffsetXVariable)));
- if (CommandLineOptions.Symmetry && ReadOrWrite.Equals("READ"))
- {
- verifier.HalfDualisedVariableNames.Add(AccessOffsetY.Name);
- }
+ Implementation LogAccessImplementation = new Implementation(v.tok, "_LOG_" + Access + "_" + v.Name, new TypeVariableSeq(), LogAccessProcedure.InParams, new VariableSeq(), locals, new StmtList(bigblocks, v.tok));
+ LogAccessImplementation.AddAttribute("inline", new object[] { new LiteralExpr(v.tok, BigNum.FromInt(1)) });
- ModifiedAtLog.Add(new IdentifierExpr(v.tok, AccessOffsetY));
- verifier.Program.TopLevelDeclarations.Add(AccessOffsetY);
+ LogAccessImplementation.Proc = LogAccessProcedure;
- if (mt2.Result is MapType)
- {
- MapType mt3 = mt2.Arguments[0] as MapType;
- Debug.Assert(mt3.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt3.Arguments[0]));
- Debug.Assert(!(mt3.Result is MapType));
+ verifier.Program.TopLevelDeclarations.Add(LogAccessProcedure);
+ verifier.Program.TopLevelDeclarations.Add(LogAccessImplementation);
+ }
- Variable AccessOffsetZ = GPUVerifier.MakeOffsetZVariable(v, ReadOrWrite);
+ private Variable VariableForThread(int thread, Variable v)
+ {
+ return new VariableDualiser(thread, null, null).VisitVariable(v.Clone() as Variable);
+ }
- if (CommandLineOptions.Symmetry && ReadOrWrite.Equals("READ"))
- {
- verifier.HalfDualisedVariableNames.Add(AccessOffsetZ.Name);
- }
+ protected override void AddLogRaceDeclarations(Variable v, String ReadOrWrite)
+ {
+ Variable AccessHasOccurred = GPUVerifier.MakeAccessHasOccurredVariable(v.Name, ReadOrWrite);
- ModifiedAtLog.Add(new IdentifierExpr(v.tok, AccessOffsetZ));
- verifier.Program.TopLevelDeclarations.Add(AccessOffsetZ);
- }
- }
- }
+ // Assumes full symmetry reduction
- }
+ verifier.Program.TopLevelDeclarations.Add(new VariableDualiser(1, null, null).VisitVariable(AccessHasOccurred.Clone() as Variable));
+ Debug.Assert(v.TypedIdent.Type is MapType);
+ MapType mt = v.TypedIdent.Type as MapType;
+ Debug.Assert(mt.Arguments.Length == 1);
+
+ Variable AccessOffsetX = GPUVerifier.MakeOffsetXVariable(v, ReadOrWrite);
+ verifier.Program.TopLevelDeclarations.Add(new VariableDualiser(1, null, null).VisitVariable(AccessOffsetX.Clone() as Variable));
+
+ }
+
private static AssignCmd MakeConditionalAssignment(Variable lhs, Expr condition, Expr rhs)
{
@@ -174,144 +160,29 @@ namespace GPUVerify
{
IdentifierExpr AccessOccurred1 = new IdentifierExpr(tok,
new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, AccessType)));
- IdentifierExpr AccessOccurred2 = new IdentifierExpr(tok,
- new VariableDualiser(2, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, AccessType)));
-
- if (CommandLineOptions.AssignAtBarriers)
- {
- List<AssignLhs> lhss = new List<AssignLhs>();
- List<Expr> rhss = new List<Expr>();
-
- lhss.Add(new SimpleAssignLhs(tok, AccessOccurred1));
- rhss.Add(Expr.False);
-
- if (!CommandLineOptions.Symmetry || !AccessType.Equals("READ"))
- {
- lhss.Add(new SimpleAssignLhs(tok, AccessOccurred2));
- rhss.Add(Expr.False);
- }
-
- bb.simpleCmds.Add(new AssignCmd(tok, lhss, rhss));
- }
- else
- {
- bb.simpleCmds.Add(new AssumeCmd(Token.NoToken, Expr.Not(AccessOccurred1)));
- if (!CommandLineOptions.Symmetry || !AccessType.Equals("READ"))
- {
- bb.simpleCmds.Add(new AssumeCmd(Token.NoToken, Expr.Not(AccessOccurred2)));
- }
- }
+ bb.simpleCmds.Add(new AssumeCmd(Token.NoToken, Expr.Not(AccessOccurred1)));
}
- public override void CheckForRaces(BigBlock bb, Variable v, bool ReadWriteOnly)
+ private Expr MakeAccessedIndex(Variable v, Expr offsetExpr, int Thread, string AccessType)
{
- if (!ReadWriteOnly)
- {
- bb.simpleCmds.Add(new AssertCmd(v.tok, Expr.Not(GenerateRaceCondition(v, "WRITE", "WRITE"))));
- }
- bb.simpleCmds.Add(new AssertCmd(v.tok, Expr.Not(GenerateRaceCondition(v, "READ", "WRITE"))));
- if (!CommandLineOptions.Symmetry)
- {
- bb.simpleCmds.Add(new AssertCmd(v.tok, Expr.Not(GenerateRaceCondition(v, "WRITE", "READ"))));
- }
- }
-
- protected override Expr GenerateRaceCondition(Variable v, string FirstAccessType, string SecondAccessType)
- {
- Expr RaceCondition = Expr.And(
- new IdentifierExpr(v.tok, new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, FirstAccessType))),
- new IdentifierExpr(v.tok, new VariableDualiser(2, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, SecondAccessType))));
-
- if (GPUVerifier.HasXDimension(v))
- {
- RaceCondition = Expr.And(RaceCondition, Expr.Eq(
- new IdentifierExpr(v.tok, new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeOffsetXVariable(v, FirstAccessType))),
- new IdentifierExpr(v.tok, new VariableDualiser(2, null, null).VisitVariable(GPUVerifier.MakeOffsetXVariable(v, SecondAccessType)))
- ));
- }
-
- if (GPUVerifier.HasYDimension(v))
- {
- RaceCondition = Expr.And(RaceCondition, Expr.Eq(
- new IdentifierExpr(v.tok, new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeOffsetYVariable(v, FirstAccessType))),
- new IdentifierExpr(v.tok, new VariableDualiser(2, null, null).VisitVariable(GPUVerifier.MakeOffsetYVariable(v, SecondAccessType)))
- ));
- }
-
- if (GPUVerifier.HasZDimension(v))
- {
- RaceCondition = Expr.And(RaceCondition, Expr.Eq(
- new IdentifierExpr(v.tok, new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeOffsetZVariable(v, FirstAccessType))),
- new IdentifierExpr(v.tok, new VariableDualiser(2, null, null).VisitVariable(GPUVerifier.MakeOffsetZVariable(v, SecondAccessType)))
- ));
- }
-
- if (FirstAccessType.Equals("WRITE") && SecondAccessType.Equals("WRITE") && !verifier.ArrayModelledAdversarially(v))
- {
- RaceCondition = Expr.And(RaceCondition, Expr.Neq(
- MakeWrittenIndex(v, 1),
- MakeWrittenIndex(v, 2)
- ));
- }
-
- return RaceCondition;
- }
-
- private static Expr MakeWrittenIndex(Variable v, int OneOrTwo)
- {
- Expr result = new IdentifierExpr(v.tok, new VariableDualiser(OneOrTwo, null, null).VisitVariable(v.Clone() as Variable));
-
- if (v.TypedIdent.Type is MapType)
- {
- MapType mt = v.TypedIdent.Type as MapType;
- Debug.Assert(mt.Arguments.Length == 1);
-
- result = Expr.Select(result,
- new Expr[] { new IdentifierExpr(v.tok, new VariableDualiser(OneOrTwo, null, null).VisitVariable(GPUVerifier.MakeOffsetXVariable(v, "WRITE"))) });
-
- if (mt.Result is MapType)
- {
- MapType mt2 = mt.Result as MapType;
- Debug.Assert(mt2.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt2.Arguments[0]));
-
- result = Expr.Select(result,
- new Expr[] { new IdentifierExpr(v.tok, new VariableDualiser(OneOrTwo, null, null).VisitVariable(GPUVerifier.MakeOffsetYVariable(v, "WRITE"))) });
-
- if (mt2.Result is MapType)
- {
- MapType mt3 = mt2.Arguments[0] as MapType;
- Debug.Assert(mt3.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt3.Arguments[0]));
- Debug.Assert(!(mt3.Result is MapType));
-
- result = Expr.Select(result,
- new Expr[] { new IdentifierExpr(v.tok, new VariableDualiser(OneOrTwo, null, null).VisitVariable(GPUVerifier.MakeOffsetZVariable(v, "WRITE"))) });
-
- }
- }
- }
-
+ Expr result = new IdentifierExpr(v.tok, new VariableDualiser(Thread, null, null).VisitVariable(v.Clone() as Variable));
+ Debug.Assert(v.TypedIdent.Type is MapType);
+ MapType mt = v.TypedIdent.Type as MapType;
+ Debug.Assert(mt.Arguments.Length == 1);
+
+ result = Expr.Select(result,
+ new Expr[] { offsetExpr });
+ Debug.Assert(!(mt.Result is MapType));
return result;
-
}
protected override void AddRequiresNoPendingAccess(Variable v)
{
IdentifierExpr ReadAccessOccurred1 = new IdentifierExpr(v.tok, new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "READ")));
- IdentifierExpr ReadAccessOccurred2 = new IdentifierExpr(v.tok, new VariableDualiser(2, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "READ")));
IdentifierExpr WriteAccessOccurred1 = new IdentifierExpr(v.tok, new VariableDualiser(1, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "WRITE")));
- IdentifierExpr WriteAccessOccurred2 = new IdentifierExpr(v.tok, new VariableDualiser(2, null, null).VisitVariable(GPUVerifier.MakeAccessHasOccurredVariable(v.Name, "WRITE")));
- if (CommandLineOptions.Symmetry)
- {
- verifier.KernelProcedure.Requires.Add(new Requires(false, Expr.And(Expr.Not(ReadAccessOccurred1), Expr.And(Expr.Not(WriteAccessOccurred1), Expr.Not(WriteAccessOccurred2)))));
- }
- else
- {
- verifier.KernelProcedure.Requires.Add(new Requires(false, Expr.And(Expr.Not(ReadAccessOccurred1), Expr.And(Expr.Not(ReadAccessOccurred2), Expr.And(Expr.Not(WriteAccessOccurred1), Expr.Not(WriteAccessOccurred2))))));
- }
+ verifier.KernelProcedure.Requires.Add(new Requires(false, Expr.And(Expr.Not(ReadAccessOccurred1), Expr.Not(WriteAccessOccurred1))));
}
protected override Expr NoReadOrWriteExpr(Variable v, string ReadOrWrite, string OneOrTwo)
@@ -327,24 +198,12 @@ namespace GPUVerify
protected override void AddAccessedOffsetIsThreadGlobalIdCandidateInvariant(WhileCmd wc, Variable v, string ReadOrWrite)
{
Expr expr = AccessedOffsetIsThreadGlobalIdExpr(v, ReadOrWrite, 1);
-
- if (ReadOrWrite.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- expr = Expr.And(expr, AccessedOffsetIsThreadGlobalIdExpr(v, ReadOrWrite, 2));
- }
-
verifier.AddCandidateInvariant(wc, expr, "accessed offset is global id");
}
protected override void AddAccessedOffsetIsThreadLocalIdCandidateInvariant(WhileCmd wc, Variable v, string ReadOrWrite)
{
Expr expr = AccessedOffsetIsThreadLocalIdExpr(v, ReadOrWrite, 1);
-
- if (ReadOrWrite.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- expr = Expr.And(expr, AccessedOffsetIsThreadLocalIdExpr(v, ReadOrWrite, 2));
- }
-
verifier.AddCandidateInvariant(wc, expr, "accessed offset is local id");
}
@@ -391,11 +250,6 @@ namespace GPUVerify
protected override void AddAccessedOffsetIsThreadFlattened2DLocalIdCandidateInvariant(WhileCmd wc, Variable v, string ReadOrWrite)
{
Expr expr = AccessedOffsetIsThreadFlattened2DLocalIdExpr(v, ReadOrWrite, 1);
- if (ReadOrWrite.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- expr = Expr.And(expr, AccessedOffsetIsThreadFlattened2DLocalIdExpr(v, ReadOrWrite, 2));
- }
-
verifier.AddCandidateInvariant(wc, expr, "accessed offset is flattened 2D local id");
}
@@ -420,11 +274,6 @@ namespace GPUVerify
protected override void AddAccessedOffsetIsThreadFlattened2DGlobalIdCandidateInvariant(WhileCmd wc, Variable v, string ReadOrWrite)
{
Expr expr = AccessedOffsetIsThreadFlattened2DGlobalIdExpr(v, ReadOrWrite, 1);
- if (ReadOrWrite.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- expr = Expr.And(expr, AccessedOffsetIsThreadFlattened2DGlobalIdExpr(v, ReadOrWrite, 2));
- }
-
verifier.AddCandidateInvariant(wc, expr, "accessed offset is flattened 2D global id");
}
@@ -448,14 +297,7 @@ namespace GPUVerify
protected override void AddAccessedOffsetInRangeCTimesLocalIdToCTimesLocalIdPlusC(WhileCmd wc, Variable v, Expr constant, string ReadOrWrite)
{
-
Expr expr = MakeCTimesLocalIdRangeExpression(v, constant, ReadOrWrite, 1);
-
- if (ReadOrWrite.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- expr = Expr.And(expr, MakeCTimesLocalIdRangeExpression(v, constant, ReadOrWrite, 2));
- }
-
verifier.AddCandidateInvariant(wc,
expr, "accessed offset in range [ C*local_id, (C+1)*local_id )");
}
@@ -490,12 +332,6 @@ namespace GPUVerify
protected override void AddAccessedOffsetInRangeCTimesGlobalIdToCTimesGlobalIdPlusC(WhileCmd wc, Variable v, Expr constant, string ReadOrWrite)
{
Expr expr = MakeCTimesGloalIdRangeExpr(v, constant, ReadOrWrite, 1);
-
- if (ReadOrWrite.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- expr = Expr.And(expr, MakeCTimesGloalIdRangeExpr(v, constant, ReadOrWrite, 2));
- }
-
verifier.AddCandidateInvariant(wc,
expr, "accessed offset in range [ C*global_id, (C+1)*global_id )");
}
diff --git a/Source/GPUVerify/GPUVerifier.cs b/Source/GPUVerify/GPUVerifier.cs
index 9acf7619..f6ba390b 100644
--- a/Source/GPUVerify/GPUVerifier.cs
+++ b/Source/GPUVerify/GPUVerifier.cs
@@ -23,9 +23,6 @@ namespace GPUVerify
private HashSet<string> ReservedNames = new HashSet<string>();
- internal HashSet<string> HalfDualisedProcedureNames = new HashSet<string>();
- internal HashSet<string> HalfDualisedVariableNames = new HashSet<string>();
-
private int TempCounter = 0;
private int invariantGenerationCounter;
@@ -375,10 +372,7 @@ namespace GPUVerify
emitProgram(outputFilename + "_cross_thread_invariants");
}
- if (CommandLineOptions.Eager)
- {
- AddEagerRaceChecking();
- }
+ RaceInstrumenter.AddRaceCheckingDeclarations();
GenerateBarrierImplementation();
@@ -614,36 +608,6 @@ namespace GPUVerify
}
}
- private void AddEagerRaceChecking()
- {
- foreach(Variable v in NonLocalState.getAllNonLocalVariables())
- {
- foreach (Declaration d in Program.TopLevelDeclarations)
- {
- if (!(d is Implementation))
- {
- continue;
- }
-
- Implementation impl = d as Implementation;
-
- if (impl.Name.Equals("_LOG_READ_" + v.Name) || impl.Name.Equals("_LOG_WRITE_" + v.Name))
- {
- BigBlock bb = new BigBlock(v.tok, "__CheckForRaces", new CmdSeq(), null, null);
- RaceInstrumenter.CheckForRaces(bb, v, impl.Name.Equals("_LOG_READ_" + v.Name));
- StmtList newStatements = new StmtList(new List<BigBlock>(), v.tok);
-
- foreach(BigBlock bb2 in impl.StructuredStmts.BigBlocks)
- {
- newStatements.BigBlocks.Add(bb2);
- }
- newStatements.BigBlocks.Add(bb);
- impl.StructuredStmts = newStatements;
- }
- }
- }
- }
-
private void ComputeInvariant()
{
@@ -1069,16 +1033,6 @@ namespace GPUVerify
}
KernelImplementation.StructuredStmts.BigBlocks[0].simpleCmds = newCommands;
- // Last barrier is needed if we don't use eager race checking
- if (!CommandLineOptions.Eager)
- {
- CmdSeq lastCommand = new CmdSeq();
- lastCommand.Add(LastBarrier);
- BigBlock bb = new BigBlock(KernelProcedure.tok, "__lastBarrier", lastCommand, null, null);
-
- KernelImplementation.StructuredStmts.BigBlocks.Add(bb);
- }
-
}
private void GenerateStandardKernelContract()
@@ -1112,11 +1066,7 @@ namespace GPUVerify
Proc.Requires.Add(new Requires(false, AssumeDistinctThreads));
Proc.Requires.Add(new Requires(false, AssumeThreadIdsInRange));
- if (Proc != KernelProcedure)
- {
- RaceInstrumenter.AddNoRaceContract(Proc);
- }
- else
+ if (Proc == KernelProcedure)
{
bool foundNonUniform = false;
int indexOfFirstNonUniformParameter;
@@ -1157,8 +1107,6 @@ namespace GPUVerify
}
Implementation Impl = D as Implementation;
- RaceInstrumenter.AddNoRaceInvariants(Impl);
-
if (QKeyValue.FindIntAttribute(Impl.Proc.Attributes, "inline", -1) == 1)
{
continue;
@@ -1360,7 +1308,7 @@ namespace GPUVerify
checkNonDivergence.ec = new IfCmd(tok, Expr.Or(Expr.Not(P1), Expr.Not(P2)), returnstatement, null, null);
}
- bigblocks.Add(RaceInstrumenter.MakeRaceCheckingStatements(tok));
+ bigblocks.Add(RaceInstrumenter.MakeResetReadWriteSetsStatements(tok));
BigBlock havocSharedState = new BigBlock(tok, "__HavocSharedState", new CmdSeq(), null, null);
bigblocks.Add(havocSharedState);
@@ -1983,11 +1931,7 @@ namespace GPUVerify
if (d is Variable && ((d as Variable).IsMutable || IsThreadLocalIdConstant(d as Variable)))
{
NewTopLevelDeclarations.Add(new VariableDualiser(1, null, null).VisitVariable((Variable)d.Clone()));
-
- if (!HalfDualisedVariableNames.Contains((d as Variable).Name))
- {
- NewTopLevelDeclarations.Add(new VariableDualiser(2, null, null).VisitVariable((Variable)d.Clone()));
- }
+ NewTopLevelDeclarations.Add(new VariableDualiser(2, null, null).VisitVariable((Variable)d.Clone()));
continue;
}
diff --git a/Source/GPUVerify/IRaceInstrumenter.cs b/Source/GPUVerify/IRaceInstrumenter.cs
index f1b877a5..65d2cc1b 100644
--- a/Source/GPUVerify/IRaceInstrumenter.cs
+++ b/Source/GPUVerify/IRaceInstrumenter.cs
@@ -18,16 +18,13 @@ namespace GPUVerify
// this will return false.
bool AddRaceCheckingInstrumentation();
- BigBlock MakeRaceCheckingStatements(IToken tok);
+ void AddRaceCheckingDeclarations();
- void CheckForRaces(BigBlock bb, Variable v, bool ReadWriteOnly);
+ BigBlock MakeResetReadWriteSetsStatements(IToken tok);
void AddRaceCheckingCandidateRequires(Procedure Proc);
void AddRaceCheckingCandidateEnsures(Procedure Proc);
- void AddNoRaceContract(Procedure Proc);
-
- void AddNoRaceInvariants(Implementation Impl);
}
}
diff --git a/Source/GPUVerify/KernelDualiser.cs b/Source/GPUVerify/KernelDualiser.cs
index 41546a84..0496a4e0 100644
--- a/Source/GPUVerify/KernelDualiser.cs
+++ b/Source/GPUVerify/KernelDualiser.cs
@@ -23,30 +23,11 @@ namespace GPUVerify
{
procName = proc.Name;
- bool HalfDualise = verifier.HalfDualisedProcedureNames.Contains(proc.Name);
-
proc.Requires = DualiseRequires(proc.Requires);
proc.Ensures = DualiseEnsures(proc.Ensures);
- proc.InParams = DualiseVariableSequence(proc.InParams, HalfDualise);
- proc.OutParams = DualiseVariableSequence(proc.OutParams, HalfDualise);
- IdentifierExprSeq NewModifies = new IdentifierExprSeq();
- foreach (IdentifierExpr v in proc.Modifies)
- {
- NewModifies.Add(new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitIdentifierExpr((IdentifierExpr)v.Clone()));
- }
-
- if (!HalfDualise)
- {
- foreach (IdentifierExpr v in proc.Modifies)
- {
- if (!CommandLineOptions.Symmetry || !verifier.HalfDualisedVariableNames.Contains(v.Name))
- {
- NewModifies.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitIdentifierExpr((IdentifierExpr)v.Clone()));
- }
- }
- }
- proc.Modifies = NewModifies;
+ proc.InParams = DualiseVariableSequence(proc.InParams);
+ proc.OutParams = DualiseVariableSequence(proc.OutParams);
procName = null;
}
@@ -59,7 +40,7 @@ namespace GPUVerify
newRequires.Add(new Requires(r.Free, new VariableDualiser(1, verifier.uniformityAnalyser, procName).
VisitExpr(r.Condition.Clone() as Expr)));
- if ((!CommandLineOptions.Symmetry || !ContainsAsymmetricExpression(r.Condition))
+ if (!ContainsAsymmetricExpression(r.Condition)
&& !verifier.uniformityAnalyser.IsUniform(procName, r.Condition))
{
newRequires.Add(new Requires(r.Free, new VariableDualiser(2, verifier.uniformityAnalyser, procName).
@@ -76,7 +57,7 @@ namespace GPUVerify
{
newEnsures.Add(new Ensures(e.Free, new VariableDualiser(1, verifier.uniformityAnalyser, procName).
VisitExpr(e.Condition.Clone() as Expr)));
- if ((!CommandLineOptions.Symmetry || !ContainsAsymmetricExpression(e.Condition))
+ if (!ContainsAsymmetricExpression(e.Condition)
&& !verifier.uniformityAnalyser.IsUniform(procName, e.Condition))
{
newEnsures.Add(new Ensures(e.Free, new VariableDualiser(2, verifier.uniformityAnalyser, procName).
@@ -87,7 +68,7 @@ namespace GPUVerify
}
- private StmtList MakeDual(StmtList stmtList, bool HalfDualise)
+ private StmtList MakeDual(StmtList stmtList)
{
Contract.Requires(stmtList != null);
@@ -95,13 +76,13 @@ namespace GPUVerify
foreach (BigBlock bodyBlock in stmtList.BigBlocks)
{
- result.BigBlocks.Add(MakeDual(bodyBlock, HalfDualise));
+ result.BigBlocks.Add(MakeDual(bodyBlock));
}
return result;
}
- private BigBlock MakeDual(BigBlock bb, bool HalfDualise)
+ private BigBlock MakeDual(BigBlock bb)
{
// Not sure what to do about the transfer command
@@ -126,14 +107,11 @@ namespace GPUVerify
nonUniformNewIns.Add(new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitExpr(Call.Ins[i]));
}
}
- if (!HalfDualise && !verifier.HalfDualisedProcedureNames.Contains(Call.callee))
+ for (int i = 0; i < Call.Ins.Count; i++)
{
- for (int i = 0; i < Call.Ins.Count; i++)
+ if (!(verifier.uniformityAnalyser.knowsOf(Call.callee) && verifier.uniformityAnalyser.IsUniform(Call.callee, verifier.uniformityAnalyser.GetInParameter(Call.callee, i))))
{
- if (!(verifier.uniformityAnalyser.knowsOf(Call.callee) && verifier.uniformityAnalyser.IsUniform(Call.callee, verifier.uniformityAnalyser.GetInParameter(Call.callee, i))))
- {
- nonUniformNewIns.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitExpr(Call.Ins[i]));
- }
+ nonUniformNewIns.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitExpr(Call.Ins[i]));
}
}
@@ -154,14 +132,11 @@ namespace GPUVerify
}
}
- if (!HalfDualise && !verifier.HalfDualisedProcedureNames.Contains(Call.callee))
+ for (int i = 0; i < Call.Outs.Count; i++)
{
- for (int i = 0; i < Call.Outs.Count; i++)
+ if (!(verifier.uniformityAnalyser.knowsOf(Call.callee) && verifier.uniformityAnalyser.IsUniform(Call.callee, verifier.uniformityAnalyser.GetOutParameter(Call.callee, i))))
{
- if (!(verifier.uniformityAnalyser.knowsOf(Call.callee) && verifier.uniformityAnalyser.IsUniform(Call.callee, verifier.uniformityAnalyser.GetOutParameter(Call.callee, i))))
- {
- nonUniformNewOuts.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitIdentifierExpr(Call.Outs[i].Clone() as IdentifierExpr) as IdentifierExpr);
- }
+ nonUniformNewOuts.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitIdentifierExpr(Call.Outs[i].Clone() as IdentifierExpr) as IdentifierExpr);
}
}
@@ -191,18 +166,10 @@ namespace GPUVerify
List<Expr> newRhss = new List<Expr>();
newLhss.Add(new VariableDualiser(1, verifier.uniformityAnalyser, procName).Visit(assign.Lhss.ElementAt(0).Clone() as AssignLhs) as AssignLhs);
-
- if (!HalfDualise)
- {
- newLhss.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).Visit(assign.Lhss.ElementAt(0).Clone() as AssignLhs) as AssignLhs);
- }
+ newLhss.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).Visit(assign.Lhss.ElementAt(0).Clone() as AssignLhs) as AssignLhs);
newRhss.Add(new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitExpr(assign.Rhss.ElementAt(0).Clone() as Expr));
-
- if (!HalfDualise)
- {
- newRhss.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitExpr(assign.Rhss.ElementAt(0).Clone() as Expr));
- }
+ newRhss.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitExpr(assign.Rhss.ElementAt(0).Clone() as Expr));
AssignCmd newAssign = new AssignCmd(assign.tok, newLhss, newRhss);
@@ -216,25 +183,17 @@ namespace GPUVerify
HavocCmd newHavoc;
- if (HalfDualise)
- {
- newHavoc = new HavocCmd(havoc.tok, new IdentifierExprSeq(new IdentifierExpr[] {
- (IdentifierExpr)(new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitIdentifierExpr(havoc.Vars[0].Clone() as IdentifierExpr))
- }));
- }
- else
- {
- newHavoc = new HavocCmd(havoc.tok, new IdentifierExprSeq(new IdentifierExpr[] {
- (IdentifierExpr)(new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitIdentifierExpr(havoc.Vars[0].Clone() as IdentifierExpr)),
- (IdentifierExpr)(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitIdentifierExpr(havoc.Vars[0].Clone() as IdentifierExpr))
- }));
- }
+ newHavoc = new HavocCmd(havoc.tok, new IdentifierExprSeq(new IdentifierExpr[] {
+ (IdentifierExpr)(new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitIdentifierExpr(havoc.Vars[0].Clone() as IdentifierExpr)),
+ (IdentifierExpr)(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitIdentifierExpr(havoc.Vars[0].Clone() as IdentifierExpr))
+ }));
+
result.simpleCmds.Add(newHavoc);
}
else if (c is AssertCmd)
{
AssertCmd ass = c as AssertCmd;
- if (HalfDualise || ContainsAsymmetricExpression(ass.Expr))
+ if (ContainsAsymmetricExpression(ass.Expr))
{
result.simpleCmds.Add(new AssertCmd(c.tok, new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitExpr(ass.Expr.Clone() as Expr)));
}
@@ -247,7 +206,7 @@ namespace GPUVerify
else if (c is AssumeCmd)
{
AssumeCmd ass = c as AssumeCmd;
- if (HalfDualise || ContainsAsymmetricExpression(ass.Expr))
+ if (ContainsAsymmetricExpression(ass.Expr))
{
result.simpleCmds.Add(new AssumeCmd(c.tok, new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitExpr(ass.Expr.Clone() as Expr)));
}
@@ -278,16 +237,16 @@ namespace GPUVerify
}
result.ec = new WhileCmd(bb.ec.tok,
NewGuard,
- MakeDualInvariants((bb.ec as WhileCmd).Invariants), MakeDual((bb.ec as WhileCmd).Body, HalfDualise));
+ MakeDualInvariants((bb.ec as WhileCmd).Invariants), MakeDual((bb.ec as WhileCmd).Body));
}
else if (bb.ec is IfCmd)
{
Debug.Assert(verifier.uniformityAnalyser.IsUniform(procName, (bb.ec as IfCmd).Guard));
result.ec = new IfCmd(bb.ec.tok,
(bb.ec as IfCmd).Guard,
- MakeDual((bb.ec as IfCmd).thn, HalfDualise),
+ MakeDual((bb.ec as IfCmd).thn),
null,
- (bb.ec as IfCmd).elseBlock == null ? null : MakeDual((bb.ec as IfCmd).elseBlock, HalfDualise));
+ (bb.ec as IfCmd).elseBlock == null ? null : MakeDual((bb.ec as IfCmd).elseBlock));
}
else if (bb.ec is BreakCmd)
@@ -314,7 +273,7 @@ namespace GPUVerify
newP.Attributes = p.Attributes;
result.Add(newP);
}
- if ((!CommandLineOptions.Symmetry || !ContainsAsymmetricExpression(p.Expr))
+ if (!ContainsAsymmetricExpression(p.Expr)
&& !verifier.uniformityAnalyser.IsUniform(procName, p.Expr))
{
PredicateCmd newP = new AssertCmd(p.tok, Dualise(p.Expr, 2));
@@ -326,7 +285,7 @@ namespace GPUVerify
return result;
}
- private void MakeDualLocalVariables(Implementation impl, bool HalfDualise)
+ private void MakeDualLocalVariables(Implementation impl)
{
VariableSeq NewLocalVars = new VariableSeq();
@@ -340,11 +299,8 @@ namespace GPUVerify
{
NewLocalVars.Add(
new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitVariable(v.Clone() as Variable));
- if (!HalfDualise)
- {
- NewLocalVars.Add(
- new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitVariable(v.Clone() as Variable));
- }
+ NewLocalVars.Add(
+ new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitVariable(v.Clone() as Variable));
}
}
@@ -358,7 +314,7 @@ namespace GPUVerify
return finder.foundAsymmetricExpr();
}
- private VariableSeq DualiseVariableSequence(VariableSeq seq, bool HalfDualise)
+ private VariableSeq DualiseVariableSequence(VariableSeq seq)
{
VariableSeq uniform = new VariableSeq();
VariableSeq nonuniform = new VariableSeq();
@@ -375,14 +331,11 @@ namespace GPUVerify
}
}
- if (!HalfDualise)
+ foreach (Variable v in seq)
{
- foreach (Variable v in seq)
+ if (!verifier.uniformityAnalyser.IsUniform(procName, v.Name))
{
- if (!verifier.uniformityAnalyser.IsUniform(procName, v.Name))
- {
- nonuniform.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitVariable((Variable)v.Clone()));
- }
+ nonuniform.Add(new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitVariable((Variable)v.Clone()));
}
}
@@ -396,12 +349,10 @@ namespace GPUVerify
{
procName = impl.Name;
- bool HalfDualise = verifier.HalfDualisedProcedureNames.Contains(impl.Name);
-
- impl.InParams = DualiseVariableSequence(impl.InParams, HalfDualise);
- impl.OutParams = DualiseVariableSequence(impl.OutParams, HalfDualise);
- MakeDualLocalVariables(impl, HalfDualise);
- impl.StructuredStmts = MakeDual(impl.StructuredStmts, HalfDualise);
+ impl.InParams = DualiseVariableSequence(impl.InParams);
+ impl.OutParams = DualiseVariableSequence(impl.OutParams);
+ MakeDualLocalVariables(impl);
+ impl.StructuredStmts = MakeDual(impl.StructuredStmts);
procName = null;
}
diff --git a/Source/GPUVerify/NullRaceInstrumenter.cs b/Source/GPUVerify/NullRaceInstrumenter.cs
index b2941815..73f038fb 100644
--- a/Source/GPUVerify/NullRaceInstrumenter.cs
+++ b/Source/GPUVerify/NullRaceInstrumenter.cs
@@ -19,18 +19,14 @@ namespace GPUVerify
}
- public void CheckForRaces(BigBlock bb, Variable v, bool ReadWriteOnly)
- {
- }
-
public bool AddRaceCheckingInstrumentation()
{
return true;
}
- public Microsoft.Boogie.BigBlock MakeRaceCheckingStatements(Microsoft.Boogie.IToken tok)
+ public Microsoft.Boogie.BigBlock MakeResetReadWriteSetsStatements(Microsoft.Boogie.IToken tok)
{
- return new BigBlock(tok, "__CheckForRaces", new CmdSeq(), null, null);
+ return new BigBlock(tok, "__ResetReadWriteSets", new CmdSeq(), null, null);
}
public void AddRaceCheckingCandidateRequires(Procedure Proc)
@@ -43,13 +39,7 @@ namespace GPUVerify
}
-
- public void AddNoRaceContract(Procedure proc)
- {
-
- }
-
- public void AddNoRaceInvariants(Implementation impl)
+ public void AddRaceCheckingDeclarations()
{
}
diff --git a/Source/GPUVerify/RaceInstrumenterBase.cs b/Source/GPUVerify/RaceInstrumenterBase.cs
index 33af1965..7ae7ca44 100644
--- a/Source/GPUVerify/RaceInstrumenterBase.cs
+++ b/Source/GPUVerify/RaceInstrumenterBase.cs
@@ -66,15 +66,13 @@ namespace GPUVerify
if (verifier.ContainsBarrierCall(wc.Body))
{
if (verifier.ContainsNamedVariable(
- LoopInvariantGenerator.GetModifiedVariables(wc.Body), GPUVerifier.MakeAccessHasOccurredVariableName(v.Name, "READ"))
- || CommandLineOptions.AssignAtBarriers)
+ LoopInvariantGenerator.GetModifiedVariables(wc.Body), GPUVerifier.MakeAccessHasOccurredVariableName(v.Name, "READ")))
{
AddNoReadOrWriteCandidateInvariant(wc, v, "READ");
}
if (verifier.ContainsNamedVariable(
- LoopInvariantGenerator.GetModifiedVariables(wc.Body), GPUVerifier.MakeAccessHasOccurredVariableName(v.Name, "WRITE"))
- || CommandLineOptions.AssignAtBarriers)
+ LoopInvariantGenerator.GetModifiedVariables(wc.Body), GPUVerifier.MakeAccessHasOccurredVariableName(v.Name, "WRITE")))
{
AddNoReadOrWriteCandidateInvariant(wc, v, "WRITE");
}
@@ -85,31 +83,17 @@ namespace GPUVerify
{
AddNoReadOrWriteCandidateRequires(Proc, v, "READ", "1");
AddNoReadOrWriteCandidateRequires(Proc, v, "WRITE", "1");
- if (!CommandLineOptions.Symmetry)
- {
- AddNoReadOrWriteCandidateRequires(Proc, v, "READ", "2");
- }
- AddNoReadOrWriteCandidateRequires(Proc, v, "WRITE", "2");
}
private void AddNoReadOrWriteCandidateEnsures(Procedure Proc, Variable v)
{
AddNoReadOrWriteCandidateEnsures(Proc, v, "READ", "1");
AddNoReadOrWriteCandidateEnsures(Proc, v, "WRITE", "1");
- if (!CommandLineOptions.Symmetry)
- {
- AddNoReadOrWriteCandidateEnsures(Proc, v, "READ", "2");
- }
- AddNoReadOrWriteCandidateEnsures(Proc, v, "WRITE", "2");
}
private void AddNoReadOrWriteCandidateInvariant(WhileCmd wc, Variable v, string ReadOrWrite)
{
Expr candidate = NoReadOrWriteExpr(v, ReadOrWrite, "1");
- if (ReadOrWrite.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- candidate = Expr.And(candidate, NoReadOrWriteExpr(v, ReadOrWrite, "2"));
- }
verifier.AddCandidateInvariant(wc, candidate, "no " + ReadOrWrite.ToLower());
}
@@ -201,11 +185,6 @@ namespace GPUVerify
private void AddAccessRelatedCandidateInvariant(WhileCmd wc, string accessKind, Expr candidateInvariantExpr, string procName, string tag)
{
Expr candidate = new VariableDualiser(1, verifier.uniformityAnalyser, procName).VisitExpr(candidateInvariantExpr.Clone() as Expr);
- if (accessKind.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- candidate = Expr.And(candidate, new VariableDualiser(2, verifier.uniformityAnalyser, procName).VisitExpr(candidateInvariantExpr.Clone() as Expr));
- }
-
verifier.AddCandidateInvariant(wc, candidate, tag);
}
@@ -733,23 +712,13 @@ namespace GPUVerify
private void AddReadOrWrittenOffsetIsThreadIdCandidateRequires(Procedure Proc, Variable v)
{
AddAccessedOffsetIsThreadLocalIdCandidateRequires(Proc, v, "WRITE", 1);
- AddAccessedOffsetIsThreadLocalIdCandidateRequires(Proc, v, "WRITE", 2);
AddAccessedOffsetIsThreadLocalIdCandidateRequires(Proc, v, "READ", 1);
- if (!CommandLineOptions.Symmetry)
- {
- AddAccessedOffsetIsThreadLocalIdCandidateRequires(Proc, v, "READ", 2);
- }
}
private void AddReadOrWrittenOffsetIsThreadIdCandidateEnsures(Procedure Proc, Variable v)
{
AddAccessedOffsetIsThreadLocalIdCandidateEnsures(Proc, v, "WRITE", 1);
- AddAccessedOffsetIsThreadLocalIdCandidateEnsures(Proc, v, "WRITE", 2);
AddAccessedOffsetIsThreadLocalIdCandidateEnsures(Proc, v, "READ", 1);
- if (!CommandLineOptions.Symmetry)
- {
- AddAccessedOffsetIsThreadLocalIdCandidateEnsures(Proc, v, "READ", 2);
- }
}
protected abstract void AddAccessedOffsetIsThreadLocalIdCandidateInvariant(WhileCmd wc, Variable v, string ReadOrWrite);
@@ -777,6 +746,7 @@ namespace GPUVerify
AddRequiresNoPendingAccess(v);
}
}
+
public bool AddRaceCheckingInstrumentation()
{
@@ -802,24 +772,14 @@ namespace GPUVerify
if (failedToFindSecondAccess || !addedLogWrite)
return false;
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- AddRaceCheckingDecsAndProcsForVar(v);
- }
-
return true;
}
private void AddRaceCheckingDecsAndProcsForVar(Variable v)
{
- IdentifierExprSeq ReadDeclsResetAtBarrier;
- IdentifierExprSeq WriteDeclsResetAtBarrier;
- IdentifierExprSeq ReadDeclsModifiedAtLogRead;
- IdentifierExprSeq WriteDeclsModifiedAtLogWrite;
-
- AddLogRaceDeclarations(v, "READ", out ReadDeclsResetAtBarrier, out ReadDeclsModifiedAtLogRead);
- AddLogRaceDeclarations(v, "WRITE", out WriteDeclsResetAtBarrier, out WriteDeclsModifiedAtLogWrite);
+ AddLogRaceDeclarations(v, "READ");
+ AddLogRaceDeclarations(v, "WRITE");
AddLogAccessProcedure(v, "READ");
AddLogAccessProcedure(v, "WRITE");
@@ -996,27 +956,20 @@ namespace GPUVerify
}
- protected abstract void AddLogRaceDeclarations(Variable v, String ReadOrWrite, out IdentifierExprSeq ResetAtBarrier, out IdentifierExprSeq ModifiedAtLog);
+ protected abstract void AddLogRaceDeclarations(Variable v, string ReadOrWrite);
protected abstract void AddLogAccessProcedure(Variable v, string ReadOrWrite);
- public BigBlock MakeRaceCheckingStatements(IToken tok)
+ public BigBlock MakeResetReadWriteSetsStatements(IToken tok)
{
- BigBlock checkForRaces = new BigBlock(tok, "__CheckForRaces", new CmdSeq(), null, null);
- if (!CommandLineOptions.Eager)
- {
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- CheckForRaces(checkForRaces, v, false);
- }
- }
+ BigBlock result = new BigBlock(tok, "__ResetReadWriteSets", new CmdSeq(), null, null);
foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
{
- SetNoAccessOccurred(tok, checkForRaces, v);
+ SetNoAccessOccurred(tok, result, v);
}
- return checkForRaces;
+ return result;
}
private void SetNoAccessOccurred(IToken tok, BigBlock bb, Variable v)
@@ -1027,66 +980,33 @@ namespace GPUVerify
protected abstract void SetNoAccessOccurred(IToken tok, BigBlock bb, Variable v, string AccessType);
- public abstract void CheckForRaces(BigBlock bb, Variable v, bool ReadWriteOnly);
-
- protected void MakeLogAccessProcedureHeader(Variable v, string ReadOrWrite, out Variable XParameterVariable, out Variable YParameterVariable, out Variable ZParameterVariable, out Procedure LogReadOrWriteProcedure)
+ protected Procedure MakeLogAccessProcedureHeader(Variable v, string ReadOrWrite)
{
VariableSeq inParams = new VariableSeq();
- XParameterVariable = null;
- YParameterVariable = null;
- ZParameterVariable = null;
- if (v.TypedIdent.Type is MapType)
- {
- MapType mt = v.TypedIdent.Type as MapType;
- Debug.Assert(mt.Arguments.Length == 1);
+ Variable PredicateParameter = new LocalVariable(v.tok, new TypedIdent(v.tok, "_P", Microsoft.Boogie.Type.Bool));
- XParameterVariable = new LocalVariable(v.tok, new TypedIdent(v.tok, "_X_index", mt.Arguments[0]));
- if (mt.Result is MapType)
- {
- MapType mt2 = mt.Result as MapType;
- Debug.Assert(mt2.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt2.Arguments[0]));
- YParameterVariable = new LocalVariable(v.tok, new TypedIdent(v.tok, "_Y_index", mt2.Arguments[0]));
- if (mt2.Result is MapType)
- {
- MapType mt3 = mt2.Arguments[0] as MapType;
- Debug.Assert(mt3.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt3.Arguments[0]));
- Debug.Assert(!(mt3.Result is MapType));
- ZParameterVariable = new LocalVariable(v.tok, new TypedIdent(v.tok, "_Z_index", mt3.Arguments[0]));
- }
- }
- }
+ Debug.Assert(v.TypedIdent.Type is MapType);
+ MapType mt = v.TypedIdent.Type as MapType;
+ Debug.Assert(mt.Arguments.Length == 1);
+ Variable OffsetParameter = new LocalVariable(v.tok, new TypedIdent(v.tok, "_offset", mt.Arguments[0]));
+ Debug.Assert(!(mt.Result is MapType));
- if (ZParameterVariable != null)
- {
- inParams.Add(ZParameterVariable);
- }
-
- if (YParameterVariable != null)
- {
- inParams.Add(YParameterVariable);
- }
+ inParams.Add(new VariableDualiser(1, null, null).VisitVariable(PredicateParameter.Clone() as Variable));
+ inParams.Add(new VariableDualiser(1, null, null).VisitVariable(OffsetParameter.Clone() as Variable));
- if (XParameterVariable != null)
- {
- inParams.Add(XParameterVariable);
- }
+ inParams.Add(new VariableDualiser(2, null, null).VisitVariable(PredicateParameter.Clone() as Variable));
+ inParams.Add(new VariableDualiser(2, null, null).VisitVariable(OffsetParameter.Clone() as Variable));
string LogProcedureName = "_LOG_" + ReadOrWrite + "_" + v.Name;
- LogReadOrWriteProcedure = GetLogAccessProcedure(v.tok, LogProcedureName);
+ Procedure result = GetLogAccessProcedure(v.tok, LogProcedureName);
- LogReadOrWriteProcedure.InParams = inParams;
+ result.InParams = inParams;
- if (CommandLineOptions.Symmetry && ReadOrWrite.Equals("READ"))
- {
- verifier.HalfDualisedProcedureNames.Add(LogReadOrWriteProcedure.Name);
- }
-
- LogReadOrWriteProcedure.AddAttribute("inline", new object[] { new LiteralExpr(v.tok, BigNum.FromInt(1)) });
+ result.AddAttribute("inline", new object[] { new LiteralExpr(v.tok, BigNum.FromInt(1)) });
+ return result;
}
public void AddRaceCheckingCandidateRequires(Procedure Proc)
@@ -1119,81 +1039,6 @@ namespace GPUVerify
protected abstract Expr NoReadOrWriteExpr(Variable v, string ReadOrWrite, string OneOrTwo);
-
- public void AddNoRaceContract(Procedure proc)
- {
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- proc.Requires.Add(new Requires(false, Expr.Not(GenerateRaceCondition(v, "WRITE", "WRITE"))));
- proc.Requires.Add(new Requires(false, Expr.Not(GenerateRaceCondition(v, "READ", "WRITE"))));
- if (!CommandLineOptions.Symmetry)
- {
- proc.Requires.Add(new Requires(false, Expr.Not(GenerateRaceCondition(v, "WRITE", "READ"))));
- }
-
- proc.Ensures.Add(new Ensures(false, Expr.Not(GenerateRaceCondition(v, "WRITE", "WRITE"))));
- proc.Ensures.Add(new Ensures(false, Expr.Not(GenerateRaceCondition(v, "READ", "WRITE"))));
- if (!CommandLineOptions.Symmetry)
- {
- proc.Ensures.Add(new Ensures(false, Expr.Not(GenerateRaceCondition(v, "WRITE", "READ"))));
- }
-
- }
- }
-
- public void AddNoRaceInvariants(Implementation impl)
- {
- AddNoRaceInvariants(impl.StructuredStmts);
- }
-
- private void AddNoRaceInvariants(StmtList stmtList)
- {
- foreach (BigBlock bb in stmtList.BigBlocks)
- {
- AddNoRaceInvariants(bb);
- }
- }
-
- private void AddNoRaceInvariants(BigBlock bb)
- {
- if (bb.ec is WhileCmd)
- {
- WhileCmd wc = bb.ec as WhileCmd;
- foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
- {
- wc.Invariants.Add(new AssertCmd(v.tok, Expr.Not(GenerateRaceCondition(v, "WRITE", "WRITE"))));
- wc.Invariants.Add(new AssertCmd(v.tok, Expr.Not(GenerateRaceCondition(v, "READ", "WRITE"))));
- if (!CommandLineOptions.Symmetry)
- {
- wc.Invariants.Add(new AssertCmd(v.tok, Expr.Not(GenerateRaceCondition(v, "WRITE", "READ"))));
- }
- }
-
- AddNoRaceInvariants(wc.Body);
-
- }
- else if (bb.ec is IfCmd)
- {
- AddNoRaceInvariants((bb.ec as IfCmd).thn);
- if ((bb.ec as IfCmd).elseBlock != null)
- {
- AddNoRaceInvariants((bb.ec as IfCmd).elseBlock);
- }
- }
- else if (bb.ec is BreakCmd)
- {
- // Do nothing
- }
- else
- {
- Debug.Assert(bb.ec == null);
- }
- }
-
-
- protected abstract Expr GenerateRaceCondition(Variable v, string FirstAccessType, string SecondAccessType);
-
-
private HashSet<Expr> GetOffsetsAccessed(StmtList stmts, Variable v, string AccessType)
{
HashSet<Expr> result = new HashSet<Expr> ();
@@ -1266,9 +1111,19 @@ namespace GPUVerify
return result;
}
+ public void AddRaceCheckingDeclarations()
+ {
+ foreach (Variable v in NonLocalStateToCheck.getAllNonLocalVariables())
+ {
+ AddRaceCheckingDecsAndProcsForVar(v);
+ }
+ }
+
+
}
+
class FindReferencesToNamedVariableVisitor : StandardVisitor
{
internal bool found = false;
@@ -1289,4 +1144,6 @@ namespace GPUVerify
}
}
+
+
}
diff --git a/Source/GPUVerify/SetEncodingRaceInstrumenter.cs b/Source/GPUVerify/SetEncodingRaceInstrumenter.cs
index 2a684c98..d67071c9 100644
--- a/Source/GPUVerify/SetEncodingRaceInstrumenter.cs
+++ b/Source/GPUVerify/SetEncodingRaceInstrumenter.cs
@@ -11,20 +11,14 @@ namespace GPUVerify
class SetEncodingRaceInstrumenter : RaceInstrumenterBase
{
- protected override void AddLogRaceDeclarations(Variable v, String ReadOrWrite, out IdentifierExprSeq ResetAtBarrier, out IdentifierExprSeq ModifiedAtLog)
+ protected override void AddLogRaceDeclarations(Variable v, string ReadOrWrite)
{
- Variable AccessSet = MakeAccessSetVariable(v, ReadOrWrite);
+ // TODO: requires revision due to major changes in this code.
- if (CommandLineOptions.Symmetry && ReadOrWrite.Equals("READ"))
- {
- verifier.HalfDualisedVariableNames.Add(AccessSet.Name);
- }
+ Variable AccessSet = MakeAccessSetVariable(v, ReadOrWrite);
verifier.Program.TopLevelDeclarations.Add(AccessSet);
- ResetAtBarrier = new IdentifierExprSeq(new IdentifierExpr[] { new IdentifierExpr(v.tok, AccessSet) });
- ModifiedAtLog = ResetAtBarrier;
-
}
private static Variable MakeAccessSetVariable(Variable v, String ReadOrWrite)
@@ -96,97 +90,10 @@ namespace GPUVerify
protected override void AddLogAccessProcedure(Variable v, string ReadOrWrite)
{
- Variable XParameterVariable;
- Variable YParameterVariable;
- Variable ZParameterVariable;
- Procedure LogReadOrWriteProcedure;
-
- MakeLogAccessProcedureHeader(v, ReadOrWrite, out XParameterVariable, out YParameterVariable, out ZParameterVariable, out LogReadOrWriteProcedure);
-
- LogReadOrWriteProcedure.Modifies.Add(new IdentifierExpr(v.tok, MakeAccessSetVariable(v, ReadOrWrite)));
-
- List<BigBlock> bigblocks = new List<BigBlock>();
-
- CmdSeq simpleCmds = new CmdSeq();
-
- List<Expr> trueExpr = new List<Expr>(new Expr[] { Expr.True });
-
- if (v.TypedIdent.Type is MapType)
- {
- MapType mt = v.TypedIdent.Type as MapType;
- Debug.Assert(mt.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt.Arguments[0]));
-
- if (mt.Result is MapType)
- {
- MapType mt2 = mt.Result as MapType;
- Debug.Assert(mt2.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt2.Arguments[0]));
-
- if (mt2.Result is MapType)
- {
- MapType mt3 = mt2.Arguments[0] as MapType;
- Debug.Assert(mt3.Arguments.Length == 1);
- Debug.Assert(GPUVerifier.IsIntOrBv32(mt3.Arguments[0]));
- Debug.Assert(!(mt3.Result is MapType));
-
- simpleCmds.Add(
- new AssignCmd(v.tok,
- new List<AssignLhs>(new AssignLhs[] {
- new MapAssignLhs(v.tok,
- new MapAssignLhs(v.tok,
- new MapAssignLhs(v.tok,
- new SimpleAssignLhs(v.tok, new IdentifierExpr(v.tok, MakeAccessSetVariable(v, ReadOrWrite)))
- , new List<Expr>(new Expr[] { new IdentifierExpr(v.tok, ZParameterVariable) }))
- , new List<Expr>(new Expr[] { new IdentifierExpr(v.tok, YParameterVariable) }))
- , new List<Expr>(new Expr[] { new IdentifierExpr(v.tok, XParameterVariable) }))
- }), trueExpr));
-
- }
- else
- {
- simpleCmds.Add(
- new AssignCmd(v.tok,
- new List<AssignLhs>(new AssignLhs[] {
- new MapAssignLhs(v.tok,
- new MapAssignLhs(v.tok,
- new SimpleAssignLhs(v.tok, new IdentifierExpr(v.tok, MakeAccessSetVariable(v, ReadOrWrite)))
- , new List<Expr>(new Expr[] { new IdentifierExpr(v.tok, YParameterVariable) }))
- , new List<Expr>(new Expr[] { new IdentifierExpr(v.tok, XParameterVariable) }))
- }), trueExpr));
- }
- }
- else
- {
- simpleCmds.Add(
- new AssignCmd(v.tok,
- new List<AssignLhs>(new AssignLhs[] {
- new MapAssignLhs(v.tok,
- new SimpleAssignLhs(v.tok, new IdentifierExpr(v.tok, MakeAccessSetVariable(v, ReadOrWrite)))
- , new List<Expr>(new Expr[] { new IdentifierExpr(v.tok, XParameterVariable) }))
- }), trueExpr));
- }
- }
- else
- {
- simpleCmds.Add(new AssignCmd(v.tok,
- new List<AssignLhs>(new AssignLhs[] { new SimpleAssignLhs(v.tok, new IdentifierExpr(v.tok, MakeAccessSetVariable(v, ReadOrWrite))) }),
- trueExpr));
- }
-
-
- bigblocks.Add(new BigBlock(v.tok, "_LOG_" + ReadOrWrite + "", simpleCmds, null, null));
-
- StmtList statements = new StmtList(bigblocks, v.tok);
-
- Implementation LogReadOrWriteImplementation = new Implementation(v.tok, "_LOG_" + ReadOrWrite + "_" + v.Name, new TypeVariableSeq(), LogReadOrWriteProcedure.InParams, new VariableSeq(), new VariableSeq(), statements);
- LogReadOrWriteImplementation.AddAttribute("inline", new object[] { new LiteralExpr(v.tok, BigNum.FromInt(1)) });
-
- LogReadOrWriteImplementation.Proc = LogReadOrWriteProcedure;
-
- verifier.Program.TopLevelDeclarations.Add(LogReadOrWriteProcedure);
- verifier.Program.TopLevelDeclarations.Add(LogReadOrWriteImplementation);
+ // TODO: requires major revision due to significant changes in calling code
+ throw new NotImplementedException();
}
+
protected override void SetNoAccessOccurred(IToken tok, BigBlock bb, Variable v, string AccessType)
{
@@ -194,34 +101,12 @@ namespace GPUVerify
MakeAccessSetVariable(v, AccessType)));
IdentifierExprSeq VariablesToHavoc = new IdentifierExprSeq();
VariablesToHavoc.Add(AccessSet1);
- if (!CommandLineOptions.Symmetry || !AccessType.Equals("READ"))
- {
- IdentifierExpr AccessSet2 = new IdentifierExpr(tok, new VariableDualiser(2, null, null).VisitVariable(
- MakeAccessSetVariable(v, AccessType)));
- VariablesToHavoc.Add(AccessSet2);
- }
bb.simpleCmds.Add(new HavocCmd(tok, VariablesToHavoc));
AddAssumeNoAccess(bb, v, AccessType);
}
- public override void CheckForRaces(BigBlock bb, Variable v, bool ReadWriteOnly)
- {
- if (!ReadWriteOnly)
- {
- AddRaceCheck(bb, v, "WRITE", "WRITE");
- }
- AddRaceCheck(bb, v, "READ", "WRITE");
- if (!CommandLineOptions.Symmetry)
- {
- AddRaceCheck(bb, v, "WRITE", "READ");
- }
-
-
- }
-
-
private static Microsoft.Boogie.Type GetIndexType(Variable v, int index)
{
@@ -257,53 +142,6 @@ namespace GPUVerify
return mt3.Arguments[0];
}
- private void AddRaceCheck(BigBlock bb, Variable v, String Access1, String Access2)
- {
- Expr AssertExpr = GenerateRaceCondition(v, Access1, Access2);
-
- bb.simpleCmds.Add(new AssertCmd(v.tok, AssertExpr));
- }
-
- protected override Expr GenerateRaceCondition(Variable v, String Access1, String Access2)
- {
- VariableSeq DummyVars1;
- Expr SetExpr1 = AccessExpr(v, Access1, 1, out DummyVars1);
-
- VariableSeq DummyVars2;
- Expr SetExpr2 = AccessExpr(v, Access2, 2, out DummyVars2);
-
- Debug.Assert(DummyVars1.Length == DummyVars2.Length);
- for (int i = 0; i < DummyVars1.Length; i++)
- {
- Debug.Assert(DummyVars1[i].Name.Equals(DummyVars2[i].Name));
- }
-
- Expr AssertExpr = Expr.And(SetExpr1, SetExpr2);
-
- if (Access1.Equals("WRITE") && Access2.Equals("WRITE") && !verifier.ArrayModelledAdversarially(v))
- {
- VariableSeq DummyVarsAccess1;
- VariableSeq DummyVarsAccess2;
- Expr IndexExpr1 = QuantifiedIndexExpr(v, new VariableDualiser(1, null, null).VisitVariable(v.Clone() as Variable), out DummyVarsAccess1);
- Expr IndexExpr2 = QuantifiedIndexExpr(v, new VariableDualiser(2, null, null).VisitVariable(v.Clone() as Variable), out DummyVarsAccess2);
- Debug.Assert(DummyVarsAccess1.Length == DummyVarsAccess2.Length);
- Debug.Assert(DummyVars1.Length == DummyVarsAccess1.Length);
- for (int i = 0; i < DummyVars1.Length; i++)
- {
- Debug.Assert(DummyVarsAccess1[i].Name.Equals(DummyVarsAccess2[i].Name));
- Debug.Assert(DummyVars1[i].Name.Equals(DummyVarsAccess1[i].Name));
- }
- AssertExpr = Expr.And(AssertExpr, Expr.Neq(IndexExpr1, IndexExpr2));
- }
-
- AssertExpr = Expr.Not(AssertExpr);
- if (DummyVars1.Length > 0)
- {
- AssertExpr = new ForallExpr(v.tok, DummyVars1, AssertExpr);
- }
- return AssertExpr;
- }
-
private static void SetNameDeep(IdentifierExpr e, string name)
{
e.Name = e.Decl.Name = e.Decl.TypedIdent.Name = name;
@@ -317,11 +155,6 @@ namespace GPUVerify
private static void AddAssumeNoAccess(BigBlock bb, Variable v, String AccessType)
{
bb.simpleCmds.Add(new AssumeCmd(v.tok, NoAccessExpr(v, AccessType, 1)));
-
- if (!CommandLineOptions.Symmetry || !AccessType.Equals("READ"))
- {
- bb.simpleCmds.Add(new AssumeCmd(v.tok, NoAccessExpr(v, AccessType, 2)));
- }
}
private static Expr NoAccessExpr(Variable v, String AccessType, int Thread)
@@ -408,12 +241,7 @@ namespace GPUVerify
protected override void AddRequiresNoPendingAccess(Variable v)
{
verifier.KernelProcedure.Requires.Add(new Requires(false, NoAccessExpr(v, "WRITE", 1)));
- verifier.KernelProcedure.Requires.Add(new Requires(false, NoAccessExpr(v, "WRITE", 2)));
verifier.KernelProcedure.Requires.Add(new Requires(false, NoAccessExpr(v, "READ", 1)));
- if(!CommandLineOptions.Symmetry)
- {
- verifier.KernelProcedure.Requires.Add(new Requires(false, NoAccessExpr(v, "READ", 2)));
- }
}
@@ -427,12 +255,6 @@ namespace GPUVerify
protected override void AddAccessedOffsetIsThreadLocalIdCandidateInvariant(WhileCmd wc, Variable v, string ReadOrWrite)
{
Expr expr = AccessOnlyAtThreadId(v, ReadOrWrite, 1);
-
- if (ReadOrWrite.Equals("WRITE") || !CommandLineOptions.Symmetry)
- {
- expr = Expr.And(expr, AccessOnlyAtThreadId(v, ReadOrWrite, 2));
- }
-
verifier.AddCandidateInvariant(wc, expr, "accessed offset is local id");
}