/// <summary>method <c>CacheGenerationalInstructions</c> Final generation string is calculated and cached globally in the script  </summary>
    void CacheGenerationalInstructions()
    {
        currentString = Axiom.ToString(); //start with the base axiom
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < CurrentIteration; i++)
        {
            foreach (char c in currentString)
            {
                if (isStochastic)
                {
                    sb.Append(ApplyStochasticProbablity(c)); //append randomised character set
                }
                else
                {
                    sb.Append(parcelableRules.ContainsKey(c) ? parcelableRules[c] : c.ToString()); //append default character
                }
            }

            currentString = sb.ToString();
            sb.Clear(); //temp string to add is cleared
        }

        preloadedInstructions = currentString; //instructions are updated

        if (isStochastic)
        {
            isStochastic = false; //to stop continual generation this value is stopped until clicked from the HUD script
        }
    }
Beispiel #2
0
        internal void DualiseKernel()
        {
            List <Declaration> NewTopLevelDeclarations = new List <Declaration>();

            // This loop really does have to be a "for(i ...)" loop.  The reason is
            // that dualisation may add additional functions to the program, which
            // get put into the program's top level declarations and also need to
            // be dualised.
            var decls = verifier.Program.TopLevelDeclarations.ToList();

            for (int i = 0; i < UpdateDeclarationsAndCountTotal(decls); i++)
            {
                Declaration d = decls[i];

                if (d is Axiom)
                {
                    VariableDualiser vd1       = new VariableDualiser(1, null, null);
                    VariableDualiser vd2       = new VariableDualiser(2, null, null);
                    Axiom            NewAxiom1 = vd1.VisitAxiom(d.Clone() as Axiom);
                    Axiom            NewAxiom2 = vd2.VisitAxiom(d.Clone() as Axiom);
                    NewTopLevelDeclarations.Add(NewAxiom1);

                    // Test whether dualisation had any effect by seeing whether the new
                    // axioms are syntactically indistinguishable.  If they are, then there
                    // is no point adding the second axiom.
                    if (!NewAxiom1.ToString().Equals(NewAxiom2.ToString()))
                    {
                        NewTopLevelDeclarations.Add(NewAxiom2);
                    }
                    continue;
                }

                if (d is Procedure)
                {
                    DualiseProcedure(d as Procedure);
                    NewTopLevelDeclarations.Add(d);
                    continue;
                }

                if (d is Implementation)
                {
                    DualiseImplementation(d as Implementation);
                    NewTopLevelDeclarations.Add(d);
                    continue;
                }

                if (d is Variable && ((d as Variable).IsMutable ||
                                      GPUVerifier.IsThreadLocalIdConstant(d as Variable) ||
                                      (GPUVerifier.IsGroupIdConstant(d as Variable) && !GPUVerifyVCGenCommandLineOptions.OnlyIntraGroupRaceChecking)))
                {
                    var v = d as Variable;

                    if (v.Name.Contains("_NOT_ACCESSED_") || v.Name.Contains("_ARRAY_OFFSET"))
                    {
                        NewTopLevelDeclarations.Add(v);
                        continue;
                    }
                    if (QKeyValue.FindBoolAttribute(v.Attributes, "atomic_usedmap"))
                    {
                        NewTopLevelDeclarations.Add(v);
                        continue;
                    }

                    if (verifier.KernelArrayInfo.GetGlobalArrays(true).Contains(v))
                    {
                        NewTopLevelDeclarations.Add(v);
                        continue;
                    }

                    if (verifier.KernelArrayInfo.GetGroupSharedArrays(true).Contains(v))
                    {
                        if (!GPUVerifyVCGenCommandLineOptions.OnlyIntraGroupRaceChecking)
                        {
                            Variable newV = new GlobalVariable(Token.NoToken, new TypedIdent(Token.NoToken,
                                                                                             v.Name, new MapType(Token.NoToken, new List <TypeVariable>(),
                                                                                                                 new List <Microsoft.Boogie.Type> {
                                Microsoft.Boogie.Type.GetBvType(1)
                            },
                                                                                                                 v.TypedIdent.Type)));
                            newV.Attributes = v.Attributes;
                            NewTopLevelDeclarations.Add(newV);
                        }
                        else
                        {
                            NewTopLevelDeclarations.Add(v);
                        }
                        continue;
                    }

                    NewTopLevelDeclarations.Add(new VariableDualiser(1, null, null).VisitVariable((Variable)v.Clone()));
                    if (!QKeyValue.FindBoolAttribute(v.Attributes, "race_checking"))
                    {
                        NewTopLevelDeclarations.Add(new VariableDualiser(2, null, null).VisitVariable((Variable)v.Clone()));
                    }

                    continue;
                }

                NewTopLevelDeclarations.Add(d);
            }

            verifier.Program.TopLevelDeclarations = NewTopLevelDeclarations;
        }