hmmer-3.3/easel/miniapps/esl-seqrange.c
/* Determine seq range for <nproc> processors with goal of putting an identical 
 * number of sequences (or as close to identical as possible) in each chunk, 
 * one chunk per processor.
 */
Determine seq range for  processors with goal of putting an identical
number of sequences (or as close to identical as possible) in each chunk,
one chunk per processor.
Determine seq range for processors with goal of putting an identical number of sequences ( or as close to identical as possible ) in each chunk one chunk per processor .
static void
range_by_seqnum(ESL_SQFILE *sqfp, int nproc, int64_t **ret_final_sqidx)
{
  int         status;
  int64_t    *final_sqidx;   
  int         p;             
  int64_t     nseq_per_proc; 
  int64_t     nseq_total;    
  int64_t     remainder;     
  int64_t     nseq_used;     
  ESL_SQASCII_DATA *ascii = &sqfp->data.ascii;
  ESL_ALLOC(final_sqidx, sizeof(int64_t) * nproc);
  nseq_total    = ascii->ssi->nprimary;
  nseq_per_proc = (int) (nseq_total / nproc);
  remainder     = nseq_total - (nseq_per_proc * nproc);
  nseq_used     = 0;
  for(p = 0; p < nproc; p++) { 
    nseq_used += nseq_per_proc;
    if(p < remainder) nseq_used++;
    final_sqidx[p] = nseq_used;
  }
  if(nseq_used != nseq_total) esl_fatal("Unable to split up sequences properly, coding error");
  *ret_final_sqidx = final_sqidx;
  return;
 ERROR:
  esl_fatal("Out of memory");
  return; 
}
static void range_by_seqnum ( ESL_SQFILE * sqfp , int nproc , int64_t * * ret_final_sqidx ) { int status ; int64_t * final_sqidx ; int p ; int64_t nseq_per_proc ; int64_t nseq_total ; int64_t remainder ; int64_t nseq_used ; ESL_SQASCII_DATA * ascii = & sqfp -> data . ascii ; ESL_ALLOC ( final_sqidx , sizeof ( int64_t ) * nproc ) ; nseq_total = ascii -> ssi -> nprimary ; nseq_per_proc = ( int ) ( nseq_total / nproc ) ; remainder = nseq_total - ( nseq_per_proc * nproc ) ; nseq_used = 0 ; for ( p = 0 ; p < nproc ; p ++ ) { nseq_used += nseq_per_proc ; if ( p < remainder ) nseq_used ++ ; final_sqidx [ p ] = nseq_used ; } if ( nseq_used != nseq_total ) esl_fatal ( " " ) ; * ret_final_sqidx = final_sqidx ; return ; ERROR : esl_fatal ( " " ) ; return ; }
Determine seq range for <nproc> processors with goal of putting an identical
 number of sequences (or as close to identical as possible) in each chunk,
 one chunk per processor.
Determine seq range for <nproc > processors with goal of putting an identical number of sequences ( or as close to identical as possible ) in each chunk one chunk per processor .
/* [0..p..nproc-1] index (in sqfp) of final seq for proc p+1 
			      * sequence index ranges 1..nseq_total */ /* counter over processes */ /* num seqs per processor for even split */ /* total number of sequences in sqfp */ /* num extra seqs after even split across all procs */ /* running total of nseqs on all procs */ /* NEVERREACHED */