41 #ifndef Core_Thread_Reducer_h
42 #define Core_Thread_Reducer_h
88 T
reduce(
int myrank,
int numThreads,
const T& value);
91 T (*f_op)(
const T&,
const T&);
102 char filler_[128-
sizeof(int)];
107 void collectiveResize(
int proc,
int numThreads);
108 void allocate(
int size);
112 Reducer<T>& operator=(
const Reducer<T>&);
118 Reducer<T>::Reducer(
const char*
name, ReductionOp op)
119 : Barrier(name), f_op(op)
127 Reducer<T>::allocate(
int n)
129 join_[0]=
new DataArray[2*numThreads+2]-1;
130 join_[1]=join_[0]+numThreads;
131 p_=
new BufArray[num_threads_+2]+1;
132 for(
int i=0;i<num_threads_;i++)
133 p_[i].whichBuffer_=0;
141 delete[] (
void*)(join_[0]-1);
142 delete[] (
void*)(p_-1);
156 delete[] (
void*)(join_[0]-1);
157 delete[] (
void*)(p_-1);
168 if(n != array_size_){
169 collectiveResize(proc, n);
174 int buf=p_[proc].whichBuffer_;
175 p_[proc].whichBuffer_=1-buf;
177 dataArray* j=join_[buf];
178 j[proc].data_=myresult;
182 red=(*f_op)(red, j[i].data_);
const char * name[]
Definition: BoostGraphExampleTests.cc:87
T(* ReductionOp)(const T &, const T &)
The function that performs the reduction.
Definition: Reducer.h:67
virtual ~Reducer()
Destroy the Reducer and free associated memory.
Definition: Reducer.h:138
T reduce(int myrank, int numThreads, const T &value)
Definition: Reducer.h:166
int n
Definition: eab.py:9
Reducer(const char *name, ReductionOp)
int size
Definition: eabLatVolData.py:2