4#ifndef __STDC_CONSTANT_MACROS
5#define __STDC_CONSTANT_MACROS
7#ifndef __STDC_LIMIT_MACROS
8#define __STDC_LIMIT_MACROS
16#include "CombBLAS/CombBLAS.h"
17#include "CombBLAS/SpHelper.h"
25template <
typename T1,
typename T2>
29 static T_promote id(){
return std::numeric_limits<T_promote>::max(); };
51 return std::min(a, b);
56IT LabelCC(FullyDistVec<IT, IT> & father, FullyDistVec<IT, IT> & cclabel)
59 cclabel.ApplyInd([](
IT val,
IT ind){
return val==ind ? -1 : val;});
60 FullyDistSpVec<IT, IT> roots (cclabel, bind2nd(std::equal_to<IT>(), -1));
63 cclabel = cclabel(father);
64 return roots.getnnz();
67template <
class IT,
class NT>
71 auto commGrid = ind.getcommgrid();
73 int nprocs = commGrid->GetSize();
82 int loclen = ind.LocArrSize();
106 for(
int i = 0; i <
nprocs; ++i)
114 for (
int i = 0; i <
nprocs; ++i) {
132template <
class IT,
class NT>
136 auto commGrid = ind.getcommgrid();
138 int nprocs = commGrid->GetSize();
139 int * rdispls =
new int[
nprocs+1];
142 int * sdispls =
new int[
nprocs+1];
151 int loclen = ind.LocArrSize();
167 for(
int i = 0; i <
nprocs; ++i) {
168 sdispls[i + 1] = sdispls[i] +
sendcnt[i];
169 rdispls[i + 1] = rdispls[i] +
recvcnt[i];
176 for(
int i=0; i <
nprocs; ++i) {
178 std::vector<IT>().swap(
indBuf[i]);
180 std::vector<NT>().swap(
valBuf[i]);
202template <
class IT,
class NT>
205 auto commGrid =
dense.getcommgrid();
207 int nprocs = commGrid->GetSize();
212 const IT *p =
ri.GetLocArr();
230 for (
int i = 0; i <
nprocs; i++)
237 const NT * arr =
dense.GetLocArr();
238 for(
int i = 0; i <
nprocs; i++) {
252template <
class IT,
class NT>
255 auto commGrid =
ri.getcommgrid();
257 int nprocs = commGrid->GetSize();
264 const NT * arr =
dense.GetLocArr();
267 const IT *p =
ri.GetLocArr();
281 int *sdispls =
new int[
nprocs];
282 for(
int i = 0; i <
nprocs; ++i)
285 int *rdispls =
new int[
nprocs];
292 for(
int i = 0; i <
nprocs - 1; ++i) {
293 sdispls[i + 1] = sdispls[i] +
sendcnt[i];
294 rdispls[i + 1] = rdispls[i] +
recvcnt[i];
300 for(
int i = 0; i <
nprocs; ++i) {
302 std::vector<IT>().swap(
data_req[i]);
305 for(
int i = 0; i <
nprocs; ++i) {
307 std::vector<IT>().swap(
revr_map[i]);
316#pragma omp parallel for
318 for(
int i = 0; i <
totrecv; ++i)
327 for(
int i = 0; i <
totsend; ++i)
335template<
typename IT,
typename NT,
typename DER>
339 D.iota(
A.getnrow(), 0);
344 IT diff =
D.TotalLength();
345 for (
int iter = 1; diff != 0;
iter++) {
346 if (diff * 50 >
A.getnrow()) {
351 [](
IT m,
IT p) {
return p; },
352 [](
IT m,
IT p) {
return true; },
353 false,
static_cast<IT>(0));
357 [](
IT a,
IT b){
return true; },
false,
A.getnrow());
364 dup.EWiseOut(
gp, [](
IT a,
IT b) {
return static_cast<IT>(a != b); },
mod);
365 diff =
static_cast<IT>(
mod.Reduce(std::plus<IT>(),
static_cast<IT>(0)));
Mac OS X ATTR com apple quarantine q
T operator()(const T &a, const T &b)
static void Print(const std::string &s)
int replicate(const FullyDistVec< IT, NT > dense, FullyDistSpVec< IT, IT > ri, vector< vector< NT > > &bcastBuffer)
IT LabelCC(FullyDistVec< IT, IT > &parent, FullyDistVec< IT, IT > &cclabel)
FullyDistSpVec< IT, NT > Assign(FullyDistSpVec< IT, IT > &ind, FullyDistSpVec< IT, NT > &val)
int ReduceAssign(FullyDistSpVec< IT, IT > &ind, FullyDistSpVec< IT, NT > &val, vector< vector< NT > > &reduceBuffer, NT MAX_FOR_REDUCE)
FullyDistSpVec< IT, NT > Extract(const FullyDistVec< IT, NT > dense, FullyDistSpVec< IT, IT > ri)
FullyDistVec< IT, IT > SV(SpParMat< IT, NT, DER > &A, IT &nCC)
static bool returnedSAID()
promote_trait< T1, T2 >::T_promote T_promote
static T_promote add(const T_promote &arg1, const T_promote &arg2)
static T_promote multiply(const T1 &arg1, const T2 &arg2)
static T2 add(const T2 &arg1, const T2 &arg2)
static T2 multiply(const T1 &arg1, const T2 &arg2)
static void axpy(const T1 a, const T2 &x, T_promote &y)