X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=shhhseqscommand.cpp;fp=shhhseqscommand.cpp;h=0cc6eb4d24d8a963b87ae58012f341d6e0c47e79;hp=82d956189a6f025fd57dc7e901e585456f59f8ab;hb=0c5f99d1282405e20458e2822aa1a54774d2fa83;hpb=a38cc7240f45bd39aa60d0df75825c17af0a082c diff --git a/shhhseqscommand.cpp b/shhhseqscommand.cpp index 82d9561..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)