X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=shhhseqscommand.cpp;h=0cc6eb4d24d8a963b87ae58012f341d6e0c47e79;hb=250e3b11b1c9c1e1ad458ab6c7e71ac2e67e11d9;hp=3e3e5863c59abc69e4175eba7cb5b7d6f0e173c8;hpb=1a5c2356c1b955c6ec024b2baf9f46377ee7c72e;p=mothur.git diff --git a/shhhseqscommand.cpp b/shhhseqscommand.cpp index 3e3e586..0cc6eb4 100644 --- a/shhhseqscommand.cpp +++ b/shhhseqscommand.cpp @@ -377,13 +377,16 @@ vector ShhhSeqsCommand::createProcessesGroups(SequenceParser& parser, st //divide the groups between the processors vector lines; - int numGroupsPerProcessor = groups.size() / processors; - for (int i = 0; i < processors; i++) { - int startIndex = i * numGroupsPerProcessor; - int endIndex = (i+1) * numGroupsPerProcessor; - if(i == (processors - 1)){ endIndex = groups.size(); } - lines.push_back(linePair(startIndex, endIndex)); - } + int remainingPairs = groups.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, (startIndex+numPairs))); //startIndex, endIndex + startIndex = startIndex + numPairs; + remainingPairs = remainingPairs - numPairs; + } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) @@ -474,6 +477,9 @@ vector ShhhSeqsCommand::createProcessesGroups(SequenceParser& parser, st //Close all thread handles and free memory allocations. for(int i=0; i < pDataArray.size(); i++){ + if (pDataArray[i]->count != (pDataArray[i]->end-pDataArray[i]->start)) { + m->mothurOut("[ERROR]: process " + toString(i) + " only processed " + toString(pDataArray[i]->count) + " of " + toString(pDataArray[i]->end-pDataArray[i]->start) + " groups assigned to it, quitting. \n"); m->control_pressed = true; + } for (int j = 0; j < pDataArray[i]->mapfileNames.size(); j++) { mapfileNames.push_back(pDataArray[i]->mapfileNames[j]); }