25 template<
typename Type>
27 : std::binary_function<Type,Type,Type>
29 Type operator()(
const Type& t1,
const Type& t2)
const
31 return std::min(t1,t2);
35 template<
typename Type>
37 : std::binary_function<Type,Type,Type>
39 Type operator()(
const Type& t1,
const Type& t2)
const
41 return std::max(t1,t2);
47 template<
typename Type,
typename BinaryFunction>
56 op = memory::shared_ptr<MPI_Op>(
new MPI_Op);
57 MPI_Op_create((
void (*)(
void*,
void*,
int*, MPI_Datatype*))&operation,
true,op.get());
62 static void operation (Type *in, Type *inout,
int *len, MPI_Datatype*)
66 for (
int i=0; i< *len; ++i, ++in, ++inout) {
68 temp = func(*in, *inout);
73 Generic_MPI_Op (
const Generic_MPI_Op& ) {}
74 static memory::shared_ptr<MPI_Op> op;
78 template<
typename Type,
typename BinaryFunction>
79 memory::shared_ptr<MPI_Op> Generic_MPI_Op<Type,BinaryFunction>::op = memory::shared_ptr<MPI_Op>(
static_cast<MPI_Op*
>(0));
81 #define ComposeMPIOp(type,func,op) \
83 class Generic_MPI_Op<type, func<type> >{ \
85 static MPI_Op get(){ \
89 Generic_MPI_Op () {} \
90 Generic_MPI_Op (const Generic_MPI_Op & ) {} \
94 ComposeMPIOp(
char, std::plus, MPI_SUM);
95 ComposeMPIOp(
unsigned char, std::plus, MPI_SUM);
96 ComposeMPIOp(
short, std::plus, MPI_SUM);
97 ComposeMPIOp(
unsigned short, std::plus, MPI_SUM);
98 ComposeMPIOp(
int, std::plus, MPI_SUM);
99 ComposeMPIOp(
unsigned int, std::plus, MPI_SUM);
100 ComposeMPIOp(
long, std::plus, MPI_SUM);
101 ComposeMPIOp(
unsigned long, std::plus, MPI_SUM);
102 ComposeMPIOp(
float, std::plus, MPI_SUM);
103 ComposeMPIOp(
double, std::plus, MPI_SUM);
104 ComposeMPIOp(
long double, std::plus, MPI_SUM);
106 ComposeMPIOp(
char, std::multiplies, MPI_PROD);
107 ComposeMPIOp(
unsigned char, std::multiplies, MPI_PROD);
108 ComposeMPIOp(
short, std::multiplies, MPI_PROD);
109 ComposeMPIOp(
unsigned short, std::multiplies, MPI_PROD);
110 ComposeMPIOp(
int, std::multiplies, MPI_PROD);
111 ComposeMPIOp(
unsigned int, std::multiplies, MPI_PROD);
112 ComposeMPIOp(
long, std::multiplies, MPI_PROD);
113 ComposeMPIOp(
unsigned long, std::multiplies, MPI_PROD);
114 ComposeMPIOp(
float, std::multiplies, MPI_PROD);
115 ComposeMPIOp(
double, std::multiplies, MPI_PROD);
116 ComposeMPIOp(
long double, std::multiplies, MPI_PROD);
118 ComposeMPIOp(
char, Min, MPI_MIN);
119 ComposeMPIOp(
unsigned char, Min, MPI_MIN);
120 ComposeMPIOp(
short, Min, MPI_MIN);
121 ComposeMPIOp(
unsigned short, Min, MPI_MIN);
122 ComposeMPIOp(
int, Min, MPI_MIN);
123 ComposeMPIOp(
unsigned int, Min, MPI_MIN);
124 ComposeMPIOp(
long, Min, MPI_MIN);
125 ComposeMPIOp(
unsigned long, Min, MPI_MIN);
126 ComposeMPIOp(
float, Min, MPI_MIN);
127 ComposeMPIOp(
double, Min, MPI_MIN);
128 ComposeMPIOp(
long double, Min, MPI_MIN);
130 ComposeMPIOp(
char, Max, MPI_MAX);
131 ComposeMPIOp(
unsigned char, Max, MPI_MAX);
132 ComposeMPIOp(
short, Max, MPI_MAX);
133 ComposeMPIOp(
unsigned short, Max, MPI_MAX);
134 ComposeMPIOp(
int, Max, MPI_MAX);
135 ComposeMPIOp(
unsigned int, Max, MPI_MAX);
136 ComposeMPIOp(
long, Max, MPI_MAX);
137 ComposeMPIOp(
unsigned long, Max, MPI_MAX);
138 ComposeMPIOp(
float, Max, MPI_MAX);
139 ComposeMPIOp(
double, Max, MPI_MAX);
140 ComposeMPIOp(
long double, Max, MPI_MAX);