Exemple #1
0
 static typename WDP::ReductionType
 parallel_reduce(int begin, int end, WDP wd) {
   typename WDP::ReductionType result = wd.identity();
   for (int i=begin; i != end; ++i) {
     result = wd.reduce( result, wd.generate(i) );
   }
   return result;
 }
 void tpi_reduction_join(TPI_Work * work, const void* src)
 {
   typedef typename WDP::ReductionType ReductionType;
 
   const WDPPlusRange<WDP>* wdp_wrapper = static_cast<const WDPPlusRange<WDP>*>(work->info);
   WDP wdp = wdp_wrapper->wdp;
 
   ReductionType& work_reduce = *(static_cast<ReductionType*>(work->reduce));
   const ReductionType& src_reduce  = *(static_cast<const ReductionType*>(src));
 
   work_reduce = wdp.reduce(work_reduce, src_reduce);
 }
Exemple #3
0
 void tpi_execute(TPI_Work * work)
 {
   // get work/data pair
   const WDPPlusRange<WDP>* const_wdp_wrapper = static_cast<const WDPPlusRange<WDP>*>(work->info);
   WDPPlusRange<WDP>* wdp_wrapper = const_cast<WDPPlusRange<WDP>*>(const_wdp_wrapper);
   WDP wdp = wdp_wrapper->wdp;
   int beg = wdp_wrapper->beg, end = wdp_wrapper->end;
   int ibeg, iend;
   // determine my share of the work
   tpi_work_span(work, beg, end, ibeg, iend);
   // do my share of the work
   for (int i=ibeg; i<iend; ++i) {
     wdp.execute(i);
   }
 }
Exemple #4
0
  void tpi_reduction_work(TPI_Work * work)
  {
    const WDPPlusRange<WDP>* wdp_wrapper = static_cast<const WDPPlusRange<WDP>*>(work->info);
    int beg = wdp_wrapper->beg, end = wdp_wrapper->end;
    WDP wdp = wdp_wrapper->wdp;
    int ibeg, iend;
    tpi_work_span(work, beg, end, ibeg, iend);

    typedef typename WDP::ReductionType ReductionType;
    ReductionType tmpi;
    ReductionType &res = *(static_cast<ReductionType*>(work->reduce));

    for (int i=ibeg; i<iend; ++i) {
      tmpi = wdp.generate(i);
      res = wdp.reduce(res, tmpi);
    }
  }
Exemple #5
0
 static typename WDP::ReductionType
 parallel_reduce(int beg, int end, WDP wd) {
   typedef typename WDP::ReductionType ReductionType;
   ReductionType result = wd.identity();
   WDPPlusRange<WDP> wdp_plus(beg,end,wd);
   TPI_Run_threads_reduce(tpi_reduction_work<WDP>, &wdp_plus,
                          tpi_reduction_join<WDP>,
                          tpi_reduction_init<WDP>, sizeof(result), &result);
   return result;
 }
Exemple #6
0
 static void parallel_for(int beg, int end, WDP wd) {
   for (int i=beg; i != end; ++i) {
     wd.execute(i);
   }
 }