]> git.donarmstrong.com Git - mothur.git/blobdiff - parsimony.cpp
added rjsd calculator. improved work balance load between processors for paralellize...
[mothur.git] / parsimony.cpp
index b12ca1fe742240a4c80e96d0d82bcb2ef612fa18..1b08e8a3fe8470e5d34944722e186fdca7e0731b 100644 (file)
@@ -56,13 +56,14 @@ EstOutput Parsimony::getValues(Tree* t, int p, string o) {
                }
         
         lines.clear();
-        int numPairs = namesOfGroupCombos.size();
-        int numPairsPerProcessor = numPairs / processors;
-        
-        for (int i = 0; i < processors; i++) {
-            int startPos = i * numPairsPerProcessor;
-            if(i == processors - 1){ numPairsPerProcessor = numPairs - i * numPairsPerProcessor; }
-            lines.push_back(linePair(startPos, numPairsPerProcessor));
+        int remainingPairs = namesOfGroupCombos.size();
+        int startIndex = 0;
+        for (int remainingProcessors = processors; remainingProcessors > 0; remainingProcessors--) {
+            int numPairs = remainingPairs; //case for last processor
+            if (remainingProcessors != 1) { numPairs = ceil(remainingPairs / remainingProcessors); }
+            lines.push_back(linePair(startIndex, numPairs)); //startIndex, numPairs
+            startIndex = startIndex + numPairs;
+            remainingPairs = remainingPairs - numPairs;
         }
         
         data = createProcesses(t, namesOfGroupCombos, ct);