Exemplo n.º 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;
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
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);
    }
  }