private string CleanOriginalProgramVariable(string Name, out int Id) { string StrippedName = GVUtil.StripThreadIdentifier(Name, out Id); if (globalArraySourceNames.ContainsKey(StrippedName)) { return(globalArraySourceNames[StrippedName]); } else { return(StrippedName.TrimStart(new char[] { '$' }).Split(new char[] { '.' })[0]); } }
private void GetArrayNameAndAccessTypeFromAccessHasOccurredVariable(Variable v, out string ArrayName, out AccessType AccessType) { Debug.Assert(GVUtil.IsAccessHasOccurredVariable(v)); foreach (var CurrentAccessType in AccessType.Types) { var Prefix = "_" + CurrentAccessType + "_HAS_OCCURRED_"; if (v.Name.StartsWith(Prefix)) { ArrayName = globalArraySourceNames[v.Name.Substring(Prefix.Count())]; AccessType = CurrentAccessType; return; } } Debug.Assert(false); ArrayName = null; AccessType = null; }
public override Expr VisitIdentifierExpr(IdentifierExpr expr) { int id; var varName = GVUtil.StripThreadIdentifier(expr.Name, out id); if (!defs.ContainsKey(varName)) { // The variable never assigned to in the procedure return(base.VisitIdentifierExpr(expr)); } else if (defs[varName] == null) { // The variable has been assigned to, but we do not know what was assigned. freeVars.Add(varName); return(base.VisitIdentifierExpr(expr)); } else { return(verifier.MaybeDualise(VisitExpr(defs[varName]), id, procName)); } }
public ModStrideConstraint GetStrideConstraint(string variable, object regionId) { if (!strideConstraintMap.ContainsKey(regionId)) { return(null); } else { int id; var strippedVariable = GVUtil.StripThreadIdentifier(variable, out id); ModStrideConstraint msc; if (strideConstraintMap[regionId].TryGetValue(strippedVariable, out msc)) { return(new ModStrideConstraint(verifier.MaybeDualise(msc.mod, id, impl.Name), verifier.MaybeDualise(msc.modEq, id, impl.Name))); } else { return(null); } } }
private static Program GetOriginalProgram() { return(GVUtil.GetFreshProgram(CommandLineOptions.Clo.Files, false, false)); }
private void AddBarrierDivergenceCandidates(HashSet <Variable> LocalVars, Implementation Impl, IRegion region) { if (!verifier.ContainsBarrierCall(region) && !GPUVerifyVCGenCommandLineOptions.WarpSync) { return; } Expr guard = region.Guard(); if (guard != null && verifier.uniformityAnalyser.IsUniform(Impl.Name, guard)) { return; } if (IsDisjunctionOfPredicates(guard)) { string LoopPredicate = ((guard as NAryExpr).Args[0] as IdentifierExpr).Name; LoopPredicate = LoopPredicate.Substring(0, LoopPredicate.IndexOf('$')); var uniformEnabledPredicate = Expr.Eq( // Int type used here, but it doesn't matter as we will print and then re-parse the program new IdentifierExpr(Token.NoToken, new LocalVariable(Token.NoToken, new TypedIdent(Token.NoToken, LoopPredicate + "$1", Microsoft.Boogie.Type.Int))), new IdentifierExpr(Token.NoToken, new LocalVariable(Token.NoToken, new TypedIdent(Token.NoToken, LoopPredicate + "$2", Microsoft.Boogie.Type.Int))) ); verifier.AddCandidateInvariant(region, uniformEnabledPredicate, "loopPredicateEquality"); verifier.AddCandidateInvariant(region, Expr.Imp(GPUVerifier.ThreadsInSameGroup(), uniformEnabledPredicate), "loopPredicateEquality"); Dictionary <string, int> assignmentCounts = GetAssignmentCounts(Impl); HashSet <string> alreadyConsidered = new HashSet <string>(); foreach (var v in LocalVars) { string lv = GVUtil.StripThreadIdentifier(v.Name); if (alreadyConsidered.Contains(lv)) { continue; } alreadyConsidered.Add(lv); if (verifier.uniformityAnalyser.IsUniform(Impl.Name, v.Name)) { continue; } if (GPUVerifier.IsPredicate(lv)) { continue; } if (!assignmentCounts.ContainsKey(lv) || assignmentCounts[lv] <= 1) { continue; } if (!verifier.ContainsNamedVariable( GetModifiedVariables(region), lv)) { continue; } AddPredicatedEqualityCandidateInvariant(region, LoopPredicate, new LocalVariable(Token.NoToken, new TypedIdent(Token.NoToken, lv, Type.Int))); } } }