public void go() { string input = readInput(PATH); input = "1 c 0" + System.Environment.NewLine + input; bool sair = false; while (!sair) { splitMap(input); input = ""; sair = true; IEnumerator <string> I = KVPair_OMK_OMV.getIteratorKeys(); while (I.MoveNext()) { reduce(I.Current, KVPair_OMK_OMV.getList(I.Current)); input = input + valorORV; if (sair && chaveORV.Equals("0")) { sair = false; } } } Console.WriteLine(input); }
public void go_parallel() { breaking(); string input = readInput(TEMP_FILE_PATH + Rank); //(PATH); bool sair = false; while (!sair) { splitMap(input); input = ""; saidas = new Dictionary <int, string> (); sair = true; IEnumerator <string> I = KVPair_OMK_OMV.getIteratorKeys(); while (I.MoveNext()) { string key = I.Current; reduce(key, KVPair_OMK_OMV.getList(key)); string[] words = valorORV.Split(' '); int task_id = Math.Abs((words[0]).GetHashCode()) % Size; if (task_id == Rank) { input = input + valorORV; } else { if (!saidas.ContainsKey(task_id)) { saidas [task_id] = ""; } saidas [task_id] = saidas [task_id] + valorORV; } if (sair && chaveORV.Equals("0")) { sair = false; } } for (int i = 0; i < Size; i++) { if (i != Rank) { if (!saidas.ContainsKey(i)) { saidas [i] = ""; } rlist.Add(worldcomm.ImmediateSend <string> (saidas [i], i, 0)); } } for (int i = 0; i < Size; i++) { if (i != Rank) { input = input + worldcomm.Receive <string> (i, 0); } } rlist.WaitAll(); int exit = worldcomm.Allreduce <int> (sair ? 1 : 0, MPI.Operation <int> .Min); sair = exit == 1; } Randomize.clearFile(OUTPUT_FILE_PATH + Rank); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@OUTPUT_FILE_PATH + Rank, true)){ file.WriteLine(input); } }