src/IJ_mv/HYPRE_IJMatrix.c
HYPRE_Int
hypre_PrefixSumInt(HYPRE_Int nvals,
                   HYPRE_Int *vals,
                   HYPRE_Int *sums)
{
   HYPRE_Int j, nthreads, bsize, tmp;

   nthreads = hypre_NumThreads();
   bsize = (nvals + nthreads - 1) / nthreads; /* This distributes the remainder */

   // if (nvals < nthreads || bsize == 1)
   // {
   sums[0] = 0;
   tmp = sums[0];
   for (j = 1; j < nvals; j++)
   {
      sums[j] += tmp + vals[j - 1];
      tmp = sums[j];
   }
   //    }
   //    else
   //    {

   //       /* Compute preliminary partial sums (in parallel) within each interval */
   // #ifdef HYPRE_USING_OPENMP
   // #pragma omp parallel for private(j) HYPRE_SMP_SCHEDULE
   // #endif
   //       for (j = 0; j < nvals; j += bsize)
   //       {
   //          HYPRE_Int  i, n = hypre_min((j+bsize), nvals);

   //          sums[0] = 0;
   //          for (i = j+1; i < n; i++)
   //          {
   //             sums[i] = sums[i-1] + vals[i-1];
   //          }
   //       }

   //       /* Compute final partial sums (in serial) for the first entry of every interval */
   //       for (j = bsize; j < nvals; j += bsize)
   //       {
   //          sums[j] = sums[j-bsize] + sums[j-1] + vals[j-1];
   //       }

   //       /* Compute final partial sums (in parallel) for the remaining entries */
   // #ifdef HYPRE_USING_OPENMP
   // #pragma omp parallel for private(j) HYPRE_SMP_SCHEDULE
   // #endif
   //       for (j = bsize; j < nvals; j += bsize)
   //       {
   //          HYPRE_Int  i, n = hypre_min((j+bsize), nvals);

   //          for (i = j+1; i < n; i++)
   //          {
   //             sums[i] += sums[j];
   //          }
   //       }
   //    }

   return hypre_error_flag;
}
/*--------------------------------------------------------------------------
 * This is a helper routine to compute a prefix sum of integer values.
 *
 * The current implementation is okay for modest numbers of threads.
 *--------------------------------------------------------------------------*/
This is a helper routine to compute a prefix sum of integer values.
The current implementation is okay for modest numbers of threads.
This is a helper routine to compute a prefix sum of integer values . The current implementation is okay for modest numbers of threads .
HYPRE_Int
hypre_PrefixSumInt(HYPRE_Int nvals,
                   HYPRE_Int *vals,
                   HYPRE_Int *sums)
{
   HYPRE_Int j, nthreads, bsize, tmp;
   nthreads = hypre_NumThreads();
   bsize = (nvals + nthreads - 1) / nthreads; 
   sums[0] = 0;
   tmp = sums[0];
   for (j = 1; j < nvals; j++)
   {
      sums[j] += tmp + vals[j - 1];
      tmp = sums[j];
   }
   return hypre_error_flag;
}
HYPRE_Int hypre_PrefixSumInt ( HYPRE_Int nvals , HYPRE_Int * vals , HYPRE_Int * sums ) { HYPRE_Int j , nthreads , bsize , tmp ; nthreads = hypre_NumThreads ( ) ; bsize = ( nvals + nthreads - 1 ) / nthreads ; sums [ 0 ] = 0 ; tmp = sums [ 0 ] ; for ( j = 1 ; j < nvals ; j ++ ) { sums [ j ] += tmp + vals [ j - 1 ] ; tmp = sums [ j ] ; } return hypre_error_flag ; }
This is a helper routine to compute a prefix sum of integer values.
This is a helper routine to compute a prefix sum of integer values .
/* This distributes the remainder */ // if (nvals < nthreads || bsize == 1) // { //    } //    else //    { //       /* Compute preliminary partial sums (in parallel) within each interval */ // #ifdef HYPRE_USING_OPENMP // #pragma omp parallel for private(j) HYPRE_SMP_SCHEDULE // #endif //       for (j = 0; j < nvals; j += bsize) //       { //          HYPRE_Int  i, n = hypre_min((j+bsize), nvals); //          sums[0] = 0; //          for (i = j+1; i < n; i++) //          { //             sums[i] = sums[i-1] + vals[i-1]; //          } //       } //       /* Compute final partial sums (in serial) for the first entry of every interval */ //       for (j = bsize; j < nvals; j += bsize) //       { //          sums[j] = sums[j-bsize] + sums[j-1] + vals[j-1]; //       } //       /* Compute final partial sums (in parallel) for the remaining entries */ // #ifdef HYPRE_USING_OPENMP // #pragma omp parallel for private(j) HYPRE_SMP_SCHEDULE // #endif //       for (j = bsize; j < nvals; j += bsize) //       { //          HYPRE_Int  i, n = hypre_min((j+bsize), nvals); //          for (i = j+1; i < n; i++) //          { //             sums[i] += sums[j]; //          } //       } //    }