Exemplo n.º 1
0
 public static bool check_Error_Num(GraphVariables.clsError clsError, int idx_error) //LoS. DL in acyclic (including Fwd and Bwd)
 {
     if (clsError.Error[idx_error].messageNum == 27 || clsError.Error[idx_error].messageNum == 28 ||
         clsError.Error[idx_error].messageNum == 3 || clsError.Error[idx_error].messageNum == 4 ||
         clsError.Error[idx_error].messageNum == 5 || clsError.Error[idx_error].messageNum == 6)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        public static bool check_DFS_real_error(GraphVariables.clsError clsError, int[] getPath, int nGetpath, int v)
        {
            bool check_real = true;

            for (int i = 0; i < nGetpath; i++) //remove last node as error
            {
                for (int j = 0; j < clsError.nError; j++)
                {
                    if (!check_Error_Num(clsError, j))
                    {
                        continue;                               //filtering error
                    }
                    if (Convert.ToInt32(clsError.Error[j].Node) == v)
                    {
                        continue;
                    }
                    if (getPath[i] == Convert.ToInt32(clsError.Error[j].Node))
                    {
                        check_real = false;
                    }
                }
            }
            return(check_real);
        }
Exemplo n.º 3
0
        //might not belong to this class.
        public static void check_InstanceFlow(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, int loop, string errType, string strLoop,
                                              ref int[] InstantNode, ref int nInstantNode, ref GraphVariables.clsError clsError)
        {
            for (int i = 0; i < nInstantNode; i++)
            {
                //XOR Join에 여러 Instant In이면 error
                if (graph.Network[currentN].Node[InstantNode[i]].Kind == "XOR" && graph.Network[currentN].Node[InstantNode[i]].nPre > 1)
                {
                    int numIn = 0;
                    for (int j = 0; j < graph.Network[currentN].Node[InstantNode[i]].nPre; j++)
                    {
                        bool bLink = false;
                        for (int k = 0; k < graph.Network[currentN].nLink; k++)
                        {
                            if (graph.Network[currentN].Link[k].fromNode == graph.Network[currentN].Node[InstantNode[i]].Pre[j] && graph.Network[currentN].Link[k].toNode == InstantNode[i])
                            {
                                if (graph.Network[currentN].Link[k].bInstance)
                                {
                                    bLink = true;
                                }
                                break;
                            }
                        }
                        if (!bLink)
                        {
                            continue;
                        }

                        for (int k = 0; k < nInstantNode; k++)
                        {
                            if (graph.Network[currentN].Node[InstantNode[i]].Pre[j] == InstantNode[k])
                            {
                                numIn++;
                            }
                        }
                    }

                    if (numIn > 1) //error
                    {
                        clsError.Error[clsError.nError].Loop        = strLoop;
                        clsError.Error[clsError.nError].Node        = graph.Network[currentN].Node[InstantNode[i]].parentNum.ToString();
                        clsError.Error[clsError.nError].currentKind = graph.Network[currentN].Node[InstantNode[i]].Kind;

                        if (loop == -1)
                        {
                            clsError.Error[clsError.nError].messageNum = 10;
                        }
                        else
                        {
                            if (errType == "SESE")
                            {
                                clsError.Error[clsError.nError].Loop       = "";
                                clsError.Error[clsError.nError].SESE       = strLoop;
                                clsError.Error[clsError.nError].messageNum = 27; //SESE lack of synchronization
                            }
                            if (errType == "eFwd")
                            {
                                if (clsError.Error[clsError.nError].Node == "-1")
                                {
                                    clsError.Error[clsError.nError].messageNum = 29; //parallel error
                                }
                                else
                                {
                                    clsError.Error[clsError.nError].messageNum = 3; //rule 2.1
                                }
                            }
                            if (errType == "eBwd")
                            {
                                clsError.Error[clsError.nError].messageNum = 4;                    //rule 2.1
                            }
                            if (errType == "ePdFlow")
                            {
                                clsError.Error[clsError.nError].messageNum = 24;                       //rule 6.1
                            }
                            if (errType == "eFwd_IL")
                            {
                                clsError.Error[clsError.nError].messageNum = 25;                       //rule 6.2
                            }
                            if (errType == "eBwd_IL")
                            {
                                clsError.Error[clsError.nError].messageNum = 26;                       //rule 6.3
                            }
                        }
                        //nError++;
                        gProAnalyzer.Ultilities.recordData.add_Error(ref clsError);
                    }
                }
                //AND Join에  Instant In이 부족하면 error //===========DEADLOCK============
                if (graph.Network[currentN].Node[InstantNode[i]].Kind == "AND" && graph.Network[currentN].Node[InstantNode[i]].nPre > 1)
                {
                    int numIn = 0;
                    for (int j = 0; j < graph.Network[currentN].Node[InstantNode[i]].nPre; j++)
                    {
                        bool bLink = false;
                        for (int k = 0; k < graph.Network[currentN].nLink; k++)
                        {
                            if (graph.Network[currentN].Link[k].fromNode == graph.Network[currentN].Node[InstantNode[i]].Pre[j] && graph.Network[currentN].Link[k].toNode == InstantNode[i])
                            {
                                if (graph.Network[currentN].Link[k].bInstance)
                                {
                                    bLink = true;
                                }
                                break;
                            }
                        }
                        if (!bLink)
                        {
                            continue;
                        }

                        for (int k = 0; k < nInstantNode; k++)
                        {
                            if (graph.Network[currentN].Node[InstantNode[i]].Pre[j] == InstantNode[k])
                            {
                                numIn++;
                            }
                        }
                    }
                    if (numIn < graph.Network[currentN].Node[InstantNode[i]].nPre) //error
                    {
                        clsError.Error[clsError.nError].Loop        = strLoop;
                        clsError.Error[clsError.nError].Node        = graph.Network[currentN].Node[InstantNode[i]].parentNum.ToString();
                        clsError.Error[clsError.nError].currentKind = graph.Network[currentN].Node[InstantNode[i]].Kind;

                        if (loop == -1)
                        {
                            clsError.Error[clsError.nError].messageNum = 11;
                        }
                        else
                        {
                            if (errType == "SESE")
                            {
                                clsError.Error[clsError.nError].Loop       = "";
                                clsError.Error[clsError.nError].SESE       = strLoop;
                                clsError.Error[clsError.nError].messageNum = 28; //SESE deadlock
                            }

                            if (errType == "eFwd")
                            {
                                clsError.Error[clsError.nError].messageNum = 5;
                            }
                            if (errType == "eBwd")
                            {
                                clsError.Error[clsError.nError].messageNum = 6;
                            }
                            //same for XOR errors
                            if (errType == "ePdFlow")
                            {
                                clsError.Error[clsError.nError].messageNum = 37;                       //rule 6.1
                            }
                            if (errType == "eFwd_IL")
                            {
                                clsError.Error[clsError.nError].messageNum = 38;                       //rule 6.2
                            }
                            if (errType == "eBwd_IL")
                            {
                                clsError.Error[clsError.nError].messageNum = 39;                       //rule 6.3
                            }
                            //if (errType == "SESE") Error[nError].messageNum = 28;
                        }
                        //nError++;
                        gProAnalyzer.Ultilities.recordData.add_Error(ref clsError);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static void DFS_Recursive(int[][] adjList, ref bool[] Mark, int Entry, int Exit, ref int[] getPath, ref int nGetPath, GraphVariables.clsError clsError, ref bool flag)
        {
            if (flag == false)
            {
                return;                 //if check error is not real => exit
            }
            Stack stack = new Stack();

            Mark[Entry] = true;
            stack.Push(Entry);
            getPath[nGetPath] = Entry;
            nGetPath++;
            for (int i = 1; i <= adjList[Entry][0]; i++)
            {
                int v = adjList[Entry][i];
                if (!Mark[v] && v != Exit)
                {
                    DFS_Recursive(adjList, ref Mark, v, Exit, ref getPath, ref nGetPath, clsError, ref flag);
                }
                else
                if (v == Exit)
                {
                    //Get the trace from START to EXIT
                    //getPath[nGetPath] = v;
                    //nGetPath++;
                    //Check real error
                    bool check_real = check_DFS_real_error(clsError, getPath, nGetPath, v);
                    if (check_real == false)
                    {
                        flag = false;
                    }
                }
            }
            //remove from path
            Mark[Entry] = false;
            nGetPath--;
        }
Exemplo n.º 5
0
        public static int check_real_errors(GraphVariables.clsGraph graph, int currentN, GraphVariables.clsHWLS clsHWLS, GraphVariables.clsLoop clsLoop, int currentLoop, ref GraphVariables.clsError clsError, int errorNode) //return(1) => Real; return(2) => Potential; return(3) => Dom
        {
            int[][] adjList = null;
            if (true) //acyclic
            {
                int[]  getPath  = new int[graph.Network[currentN].nNode];
                int    START    = graph.Network[currentN].header;
                int    nGetPath = 0;
                bool[] Mark     = new bool[graph.Network[currentN].nNode];
                gProAnalyzer.Ultilities.mappingGraph.to_adjList_Directed(ref graph, currentN, ref adjList); //We already buil an instance subgraph based on InstanceNode !! Huaahhh~
                //Check "Real error" first
                for (int i = 0; i < clsError.nError; i++)                                                   //filtering the DL or LoS of acyclic only
                {
                    if (!check_Error_Num(clsError, i))
                    {
                        continue;                //filtering acylci error
                    }
                    bool flag_Real_error = true; //0: real;
                    int  EXIT            = Convert.ToInt32(clsError.Error[i].Node);
                    DFS_Recursive(adjList, ref Mark, START, EXIT, ref getPath, ref nGetPath, clsError, ref flag_Real_error);
                    if (flag_Real_error == true)
                    {
                        clsError.Error[i].TypeOfError = "R";
                    }
                    else
                    {
                        clsError.Error[i].TypeOfError = "P";
                    }
                }
                //Check "Domiance error" from "Potential error"
                for (int i = 0; i < clsError.nError; i++) //filtering the DL or LoS of acyclic only
                {
                    if (!check_Error_Num(clsError, i))
                    {
                        continue;                               //filtering acylci error
                    }
                    if (clsError.Error[i].TypeOfError != "R")
                    {
                        continue;                                            //only pick REAL errors for referencing
                    }
                    int currError = Convert.ToInt32(clsError.Error[i].Node); //This is a real error
                    for (int k = 0; k < clsError.nError; k++)                //filtering the DL or LoS of acyclic only
                    {
                        if (!check_Error_Num(clsError, k))
                        {
                            continue;                               //filtering acylci error
                        }
                        if (clsError.Error[k].Node == clsError.Error[i].Node)
                        {
                            continue;
                        }
                        if (Ultilities.checkGraph.Node_In_Set(graph.Network[currentN].Node[currError].DomEI, graph.Network[currentN].Node[currError].nDomEI, Convert.ToInt32(clsError.Error[k].Node)))
                        {
                            clsError.Error[k].TypeOfError = "D";
                        }
                    }
                }
                //Check "Dominance_by_Potential error" of Potential errors (From the leftover potential errors)
                for (int i = 0; i < clsError.nError; i++) //filtering the DL or LoS of acyclic only
                {
                    if (!check_Error_Num(clsError, i))
                    {
                        continue;                               //filtering acyclic error
                    }
                    if (clsError.Error[i].TypeOfError != "P")
                    {
                        continue;
                    }
                    int currError = Convert.ToInt32(clsError.Error[i].Node);
                    for (int k = 0; k < clsError.nError; k++) //filtering the DL or LoS of acyclic only
                    {
                        if (!check_Error_Num(clsError, k))
                        {
                            continue;                               //filtering acylci error
                        }
                        if (clsError.Error[k].Node == clsError.Error[i].Node)
                        {
                            continue;
                        }
                        if (Ultilities.checkGraph.Node_In_Set(graph.Network[currentN].Node[currError].DomEI, graph.Network[currentN].Node[currError].nDomEI, Convert.ToInt32(clsError.Error[k].Node)))
                        {
                            clsError.Error[k].TypeOfError = "DP";
                        }
                    }
                }
            }
            else //if cylic graph
            {
                //First, check Error type DL, LoS, same with above (Must reduce all loop) => Compute the dominance relations
                //If error from inside NL => check (IF REDUCE LOOP => MUST MARK other reducedLoop as having Error for easily check).
                //If current NL => Take out NL subgraph => run DFS to check "Real_Error" and "Potential_errors" -> Check "Dominance_Errors"
                //If current NL Header is "Real" => keep everything original
                //If current NL Header is "Dom" => All error wil be "Dominace_Errors"
                //If current NL Header is "Potential" => All error will be "Potential_Errors"
                #region
                int curDepth = clsHWLS.FBLOCK.maxDepth;
                do
                {
                    for (int k = 0; k < clsHWLS.FBLOCK.nFBlock; k++)
                    {
                        if (clsHWLS.FBLOCK.FBlock[k].depth != curDepth)
                        {
                            continue;
                        }
                        int orgIndx = clsHWLS.FBLOCK.FBlock[k].refIndex;
                        if (clsHWLS.FBLOCK.FBlock[k].SESE == false && clsLoop.Loop[currentLoop].Loop[orgIndx].nEntry == 1)
                        {
                            gProAnalyzer.Ultilities.makeSubNetwork.make_AcyclicSubGraph(ref graph, currentN, graph.subNet, ref clsLoop, currentLoop, orgIndx, "NL");

                            int[]  getPath  = new int[graph.Network[graph.subNet].nNode];
                            int    START    = graph.Network[graph.subNet].header;
                            int    nGetPath = 0;
                            bool[] Mark     = new bool[graph.Network[graph.subNet].nNode];
                            gProAnalyzer.Ultilities.mappingGraph.to_adjList_Directed(ref graph, graph.subNet, ref adjList); //We already buil an instance subgraph based on InstanceNode !! Huaahhh~
                            //Check "Real error" first
                            for (int i = 0; i < clsError.nError; i++)                                                       //filtering the DL or LoS of acyclic only
                            {
                                if (!(clsError.Error[k].messageNum == 3 || clsError.Error[k].messageNum == 4 || clsError.Error[k].messageNum == 29 ||
                                      clsError.Error[k].messageNum == 5 || clsError.Error[k].messageNum == 6))
                                {
                                    continue;                //filtering Loop error only [3,4,5,6,29]
                                }
                                bool flag_Real_error = true; //0: real;
                                int  EXIT            = Convert.ToInt32(clsError.Error[i].Node);
                                DFS_Recursive(adjList, ref Mark, START, EXIT, ref getPath, ref nGetPath, clsError, ref flag_Real_error);
                                if (flag_Real_error == true)
                                {
                                    clsError.Error[i].TypeOfError = "R";
                                }
                                else
                                {
                                    clsError.Error[i].TypeOfError = "P";
                                }
                            }
                        }
                    }
                    curDepth--;
                } while (curDepth > 0);
                #endregion
            }

            return(1);
        }