1 #ifndef RESTRICTION_OP_H 2 #define RESTRICTION_OP_H 24 template <
typename T1,
typename T2>
27 static T2
id(){
return T2(); };
29 static MPI_Op
mpi_op() {
return MPI_MIN; };
31 static T2
add(
const T2 & arg1,
const T2 & arg2)
33 return std::min(arg1, arg2);
36 static T2
multiply(
const T1 & arg1,
const T2 & arg2)
41 static void axpy(
const T1 a,
const T2 & x, T2 & y)
63 template <
typename T1,
typename T2>
72 if((arg1.
prob) < (arg2.
prob))
return arg1;
89 template <
typename T1,
typename T2>
92 static T2
id(){
return T2(); };
94 static MPI_Op
mpi_op() {
return MPI_MIN; };
96 static T2
add(
const T2 & arg1,
const T2 & arg2)
98 std::cout <<
"This should have never been executed for MIS-2 to be correct" << std::endl;
99 return std::min(arg1, arg2);
102 static T2
multiply(
const T1 & arg1,
const T2 & arg2)
107 static void axpy(
const T1 a,
const T2 & x, T2 & y)
117 template <
typename ONT,
typename IT,
typename INT,
typename DER>
129 cand.
iota(nvert, 1.0);
139 while (cand.getnnz() > 0)
143 cand.
Apply([](
const double & ignore){
return (
double) GlobalMT.
rand();});
146 SpMV<Select2ndMinSR<INT, double>>(
A, cand, min_neighbor_r,
false);
147 SpMV<Select2ndMinSR<INT, double>>(
A, min_neighbor_r, min_neighbor2_r,
false);
150 [](
double x,
double y){
return std::min(x,y);},
151 [](
double x,
double y){
return true;},
152 true,
true, 2.0, 2.0,
true);
158 new_S_members = EWiseApply<ONT>(min_neighbor_r_union, cand,
159 [](
double x,
double y){
return (ONT)1;},
160 [](
double x,
double y){
return y<=x;},
161 true,
false, 2.0, 2.0,
true);
164 cand = EWiseApply<double>(cand, new_S_members,
165 [](
double x, ONT y){
return x;},
166 [](
double x, ONT y){
return true;},
167 false,
true, 0.0, (ONT) 0,
false);
170 SpMV<Select2ndMinSR<INT, ONT>>(
A, new_S_members, new_S_neighbors,
false);
171 SpMV<Select2ndMinSR<INT, ONT>>(
A, new_S_neighbors, new_S_neighbors2,
false);
174 [](ONT x, ONT y){
return x;},
175 [](ONT x, ONT y){
return true;},
176 true,
true, (ONT) 1, (ONT) 1,
true);
180 cand = EWiseApply<double>(cand, new_S_neighbors_union,
181 [](
double x, ONT y){
return x;},
182 [](
double x, ONT y){
return true;},
183 false,
true, 0.0, (ONT) 0,
false);
186 mis = EWiseApply<ONT>(mis, new_S_members,
187 [](ONT x, ONT y){
return x;},
188 [](ONT x, ONT y){
return true;},
189 true,
true, (ONT) 1, (ONT) 1,
true);
196 template <
typename IT,
typename NT>
219 mis2neigh = EWiseApply<IT>(mis2neigh, mis2,
220 [](IT x, IT y){
return x==-1?y:x;},
221 [](IT x, IT y){
return true;},
222 true,
true, (IT) -1, (IT) -1,
true);
226 mis2neigh_p = EWiseApply<VertexType<IT>>(mis2neigh, mis2neigh_p,
233 SpMV<Select2ndRandSR<bool, IT>>(
B, mis2neigh_p, mis2neigh2_p,
false);
237 mis2neigh2 = EWiseApply<IT>(mis2neigh2, mis2neigh2_p,
245 [](IT x, IT y){
return x==-1?y:x;},
246 [](IT x, IT y){
return true;},
247 true,
true, (IT) -1, (IT) -1,
true);
249 mis2neighUnion.
PrintInfo(
"mis2neighUnion");
250 if(mis2neighUnion.getnnz() != mis2neighUnion.TotalLength())
252 SpParHelper::Print(
" !!!! Error: mis2neighUnion does not include all rows/columns. !!!! ");
272 perm_col.iota(Rop.
getncol(), 0);
275 Rop(perm_row, perm_col,
true);
278 std::ostringstream outs;
279 outs <<
"Load balance (before): " << balance_before << std::endl;
280 outs <<
"Load balance (after): " << balance_after << std::endl;
std::shared_ptr< CommGrid > getcommgrid() const
friend bool operator<(const VertexType &vtx1, const VertexType &vtx2)
static bool returnedSAID()
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
Return the indices where pred is true.
static bool returnedSAID()
static bool returnedSAID()
static void axpy(T1 a, const VertexType< T2 > &x, VertexType< T2 > &y)
FullyDistSpVec< IT, ONT > MIS2(SpParMat< IT, INT, DER > A)
float LoadImbalance() const
static T2 add(const T2 &arg1, const T2 &arg2)
VertexType(T pa, double pr)
static VertexType< T2 > id()
static T2 multiply(const T1 &arg1, const T2 &arg2)
void PrintInfo(std::string vecname) const
static void axpy(const T1 a, const T2 &x, T2 &y)
static void Print(const std::string &s)
void iota(IT globalsize, NT first)
void iota(IT globalsize, NT first)
static VertexType< T2 > add(const VertexType< T2 > &arg1, const VertexType< T2 > &arg2)
static void axpy(const T1 a, const T2 &x, T2 &y)
void RestrictionOp(CCGrid &CMG, SpDCCols< IT, NT > *localmat, SpDCCols< IT, NT > *&R, SpDCCols< IT, NT > *&RT)
static T2 add(const T2 &arg1, const T2 &arg2)
static T2 multiply(const T1 &arg1, const T2 &arg2)
static VertexType< T2 > multiply(const T1 &arg1, const VertexType< T2 > &arg2)
void Apply(_UnaryOperation __unary_op)
friend std::ostream & operator<<(std::ostream &os, const VertexType &vertex)
friend bool operator==(const VertexType &vtx1, const VertexType &vtx2)