Exemplo n.º 1
0
 public override void VisitParallelForElement(ParallelForElement element)
 {
     Console.Write("parallelfor");
     VisitElement(element.RANGE);
     Console.Write("\n{\n\t");
     List<List<Element>> code = new List<List<Element>>();
     code = element.PARALLELCODE;
     bool flag = true;
     for (int i = 0; i < code.Count; i++)
     {
         if (i == (code.Count - 1))
         {
             flag = false;
         }
         List<Element> temp = new List<Element>();
         temp = code[i];
         for (int j = 0; j < temp.Count; j++)
         {
             VisitElement(temp[j]);
             if (flag)
             {
                 Console.Write("\n\t");
             }
             else
             {
                 if (j != (temp.Count - 1))
                 {
                     Console.Write("\n\t");
                 }
                 else
                 {
                     Console.Write("\n");
                 }
             }
         }
     }
     Console.Write("}\n");
 }
Exemplo n.º 2
0
 public abstract void VisitParallelForElement(ParallelForElement element);
Exemplo n.º 3
0
 public override void VisitParallelForElement(ParallelForElement element)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 4
0
        public override void VisitParallelForElement(ParallelForElement element)
        {
            try
            {
                inParallelFor = 1;
                matStr = new StringWriter();
                matXml = new XmlTextWriter(matStr);
                matXml.Formatting = Formatting.Indented;
                matXml.WriteStartDocument();
                matXml.WriteStartElement("root");
                if (parallelVars!=null && parallelVars.Count > 0)
                    parallelVars.Clear();
                parallelString.Remove(0, parallelString.Length);
                List<Element> l1 = null;
                for (int s = 0; element.PARALLELCODE.Count > 0 && s < element.PARALLELCODE.Count; s++)
                {
                    l1 = element.PARALLELCODE[s];

                    for (int i = 0; l1 != null && i < l1.Count; i++)
                    {
                        VisitElement(l1[i]);
                        if (l1[i] is AssignmentOperationElement)
                            parallelString.Append(";");
                    }
                    //sendToSwarm(start,end,body,string)
                    //wait
                }
                inParallelFor = 0;
                matXml.WriteEndElement();
                CreateData();
                result(matStr.ToString());
                result(parallelString.ToString());
            }
            catch (Exception e) { sendres(112, "Parallel for:Error processing\n"); e.GetType(); }

            //throw new NotImplementedException();
        }
Exemplo n.º 5
0
 static void Main(String[] args)
 {
     Console.WriteLine("\nTesting the ParallelForStatementElement class");
     Console.WriteLine("\n==========================================\n");
     RangeElement elem = new RangeElement();
     VariableElement var_elem = new VariableElement();
     var_elem.setText("a");
     elem.RANGEVARIABLE = var_elem;
     IntegerElement int_elem = new IntegerElement();
     int_elem.setText("1");
     elem.STARTINGRANGE = int_elem;
     IntegerElement int_elem2 = new IntegerElement();
     int_elem2.setText("10");
     elem.ENDINGRANGE = int_elem2;
     ParallelForElement for_elem = new ParallelForElement();
     for_elem.RANGE = elem;
     ScalarVariableDeclaration scalar_elem = new ScalarVariableDeclaration();
     scalar_elem.setType("int");
     scalar_elem.setVar(var_elem);
     for_elem.ADDCODE = scalar_elem;
     for_elem.syncfunction();
     VariableElement elem2 = new VariableElement();
     elem2.setText("b");
     for_elem.ADDCODE = elem2;
     for_elem.syncfunction();
     RangeElement Relem = new RangeElement();
     Relem = for_elem.RANGE;
     Console.Write("Range is " + Relem.STARTINGRANGE.getText() + " to " + Relem.ENDINGRANGE.getText() + "\n");
     List<List<Element>> elem_list = new List<List<Element>>();
     elem_list = for_elem.PARALLELCODE;
     for(int i=0; i<elem_list.Count;i++)
     {
         List<Element> code = new List<Element>();
         code = elem_list[i];
         for (int j = 0; j<code.Count; j++)
         {
             Console.Write("The parallelfor statement code list "+ (i+1) +" has "+ code[j].ToString() + "\n");
         }
     }
 }