33#ifndef __STDC_CONSTANT_MACROS
34#define __STDC_CONSTANT_MACROS
36#ifndef __STDC_LIMIT_MACROS
37#define __STDC_LIMIT_MACROS
48#include "CombBLAS/CombBLAS.h"
62 template <
typename T1,
typename T2>
66 static T_promote id(){
return std::numeric_limits<T_promote>::max(); };
88 template <
class T,
class I>
99#pragma omp parallel for
100 for(
int i=0; i<p; i++){
105 for(
I j=start+1;
j<end;
j++)
114#pragma omp parallel for
115 for(
int i=1; i<p; i++){
120 for(
I j=start;
j<end;
j++)
132 template <
typename T>
148#pragma omp parallel for
149 for(
int i=0;i<
np;i++){
156#pragma omp parallel for
157 for(
int i=0;i<
np;i++){
171 for(
int i=0;i<=
kway;i++)
182 for(
int i=0;i<
kway;i++){
260#pragma omp parallel for
274 for(
int i=0;i<
new_np;i++){
289 for(
int i=0;i<
np;i++){
294#pragma omp parallel for
295 for(
int i=0;i<
np;i++){
310 template <
typename T>
319 for(
int i = 0; i <
nprocs; i++)
321 if(i==
rank)
continue;
346 template <
class IT,
class NT>
349 auto commGrid =
dense.getcommgrid();
351 int nprocs = commGrid->GetSize();
355 std::vector<IT>
rinum =
ri.GetLocalNum();
378 for(
int i=0; i<
nprocs; i++)
392 const NT * arr =
dense.GetLocArr();
393 for(
int i=0; i<
nprocs; i++)
419 template <
class IT,
class NT>
425 std::ostringstream
outs;
428 outs<<
" Extract timing: ";
430 auto commGrid =
ri.getcommgrid();
432 int nprocs = commGrid->GetSize();
434 if(!(commGrid ==
dense.getcommgrid()))
436 std::cout <<
"Grids are not comparable for dense vector subsref" << std::endl;
454 const NT * arr =
dense.GetLocArr();
456 std::vector<IT>
rinum =
ri.GetLocalNum();
475 int * sdispls =
new int[
nprocs];
476 for(
int i=0; i<
nprocs; ++i)
479 int * rdispls =
new int[
nprocs];
493 for(
int i=0; i<
nprocs-1; ++i)
495 sdispls[i+1] = sdispls[i] +
sendcnt[i];
496 rdispls[i+1] = rdispls[i] +
recvcnt[i];
503 for(
int i=0; i<
nprocs; ++i)
506 std::vector<IT>().swap(
data_req[i]);
511 for(
int i=0; i<
nprocs; ++i)
514 std::vector<IT>().swap(
revr_map[i]);
534#pragma omp parallel for
562 std::vector<IT> ind =
ri.GetLocalInd ();
579 template <
class IT,
class NT>
582 auto commGrid = ind.getcommgrid();
584 int nprocs = commGrid->GetSize();
592 std::vector<IT>
indices = ind.GetLocalNum();
593 std::vector<NT>
values = val.GetLocalNum();
620 for(
int i=0; i<
nprocs; ++i)
634 for(
int i=0; i<
nprocs; ++i)
661 template <
class IT,
class NT>
664 auto commGrid = ind.getcommgrid();
666 int nprocs = commGrid->GetSize();
673 std::vector<IT>
indices = ind.GetLocalNum();
699 for(
int i=0; i<
nprocs; ++i)
713 for(
int i=0; i<
nprocs; ++i)
746 template <
class IT,
class NT>
752 SpParHelper::Print(
"Assign error: Index and value vectors have different size !!!\n");
760 std::cout <<
"At least one requested index is larger than the global length" << std::endl;
766 std::ostringstream
outs;
769 outs<<
" Assign timing: ";
771 auto commGrid = ind.getcommgrid();
773 int nprocs = commGrid->GetSize();
774 int * rdispls =
new int[
nprocs+1];
777 int * sdispls =
new int[
nprocs+1];
790 outs <<
"reduce (" <<
nreduce <<
"): " << reduce <<
" ";
797 std::vector<IT>
indices = ind.GetLocalNum();
798 std::vector<NT>
values = val.GetLocalNum();
823 for(
int i=0; i<
nprocs; ++i)
825 sdispls[i+1] = sdispls[i] +
sendcnt[i];
826 rdispls[i+1] = rdispls[i] +
recvcnt[i];
834 for(
int i=0; i<
nprocs; ++i)
837 std::vector<IT>().swap(
indBuf[i]);
839 std::vector<NT>().swap(
valBuf[i]);
904 template <
class IT,
class NT>
911 std::cout <<
"At least one requested index is larger than the global length" << std::endl;
917 std::ostringstream
outs;
920 outs<<
" Assign timing: ";
922 auto commGrid = ind.getcommgrid();
924 int nprocs = commGrid->GetSize();
925 int * rdispls =
new int[
nprocs+1];
928 int * sdispls =
new int[
nprocs+1];
941 outs <<
"reduce ( " <<
nreduce <<
" ): " << reduce <<
" ";
947 std::vector<IT>
indices = ind.GetLocalNum();
971 for(
int i=0; i<
nprocs; ++i)
973 sdispls[i+1] = sdispls[i] +
sendcnt[i];
974 rdispls[i+1] = rdispls[i] +
recvcnt[i];
981 for(
int i=0; i<
nprocs; ++i)
984 std::vector<IT>().swap(
indBuf[i]);
998 outs <<
"all2ll3: " << 0 <<
" ";
1034 template <
typename IT,
typename NT,
typename DER>
1058 [](
short isStar,
IT p){
return true;},
1059 false,
static_cast<short>(0));
1125 template <
typename IT>
1139 [](
short isStar,
IT p){
return true;},
1140 false,
static_cast<short>(0));
1149 [](
short isStar,
IT p){
return true;},
1150 false,
static_cast<short>(0));
1157 false,
false,
static_cast<IT>(0),
static_cast<IT>(0));
1171 false,
static_cast<IT>(0));
1181 [](
short s,
short isStar){
return static_cast<IT> (s);},
1183 false,
static_cast<short>(0));
1185 [](
IT s,
IT p){
return p;},
1186 [](
IT s,
IT p){
return true;},
1187 false,
static_cast<IT>(0));
1194 template <
typename IT,
typename NT,
typename DER>
1210 [](
IT x,
IT mnp){
return true;},
false,
static_cast<IT> (0));
1212 [](
IT mnp,
IT p){
return p >
mnp;},
false,
static_cast<IT> (0));
1222 [](
IT mnp,
IT p){
return true;},
false,
static_cast<IT> (0));
1231 std::ostringstream
outs;
1242 template <
typename IT,
typename NT,
typename DER>
1250 string spmv =
"dense";
1252 IT nv =
A.getnrow();
1262 [](
short isStar,
IT p){
return true;},
1263 false,
static_cast<IT>(0));
1274 false,
static_cast<IT> (0));
1293 false,
static_cast<IT> (0));
1300 [](
IT mnp,
IT p){
return true;},
false,
static_cast<IT> (0));
1307 std::ostringstream
outs;
1321 template <
typename IT>
1331 template <
typename IT>
1337 [](
short isStar,
IT p){
return true;},
1338 false,
static_cast<short>(0));
1346 template <
typename IT,
typename NT,
typename DER>
1356 template <
typename IT,
typename NT,
typename DER>
1359 DER* spSeq =
A.seqptr();
1369 std::cout << i <<
" (" << parent[i] <<
", "<<
cclabel[i] <<
") & "<<
j <<
"("<< parent[
j] <<
", " <<
cclabel[
j] <<
")\n";
1383 template <
typename IT>
1387 cclabel.ApplyInd([](
IT val,
IT ind){
return val==ind ? -1 : val;});
1400 return roots.getnnz();
1404 template <
typename IT,
typename NT,
typename DER>
1410 parent.iota(
nrows, 0);
1413 std::ostringstream
outs;
1490 outs <<
"Iteration: " <<
iteration <<
" converged: " <<
nrows <<
" stars: 0" <<
" nonstars: 0" ;
1547 template <
typename IT>
1550 for(
IT i=0; i<
nCC; i++)
1558 template <
typename IT>
1566 std::ostringstream
outs;
1569 outs <<
"Size of the first component: " <<
cc1.getnnz() << std::endl;
1570 outs <<
"Size of the second component: " <<
cc2.getnnz() << std::endl;
1571 outs <<
"Size of the third component: " <<
cc3.getnnz() << std::endl;
1572 outs <<
"Size of the fourth component: " <<
cc4.getnnz() << std::endl;
1576 template <
typename IT>
1580 for(
IT i=0; i<
nCC; i++)
1592 for(
IT i=0; i<
ccSizes.LocArrSize(); i++)
1607 std::cout <<
"The largest component size: " <<
largestCCSise << std::endl;
1609 output.open(
"hist.txt", std::ios_base::app );
static void Print(const std::string &s)
void omp_par_scan(T *A, T *B, I cnt)
int Mpi_Alltoallv(T *sbuff, int *s_cnt, int *sdisp, T *rbuff, int *r_cnt, int *rdisp, MPI_Comm comm)
int replicate(const FullyDistVec< IT, NT > dense, FullyDistSpVec< IT, IT > ri, vector< vector< NT > > &bcastBuffer)
FullyDistSpVec< IT, IT > UnconditionalHook2(const SpParMat< IT, NT, DER > &A, FullyDistVec< IT, IT > &parents, FullyDistVec< IT, short > stars)
bool neigborsInSameCC(const SpParMat< IT, NT, DER > &A, FullyDistVec< IT, IT > &cclabel)
void Correctness(const SpParMat< IT, NT, DER > &A, FullyDistVec< IT, IT > &cclabel, IT nCC, FullyDistVec< IT, IT > parent)
void Shortcut(FullyDistVec< IT, IT > &parent)
IT LabelCC(FullyDistVec< IT, IT > &parent, FullyDistVec< IT, IT > &cclabel)
void First4Clust(FullyDistVec< IT, IT > &cc)
void StarCheck(FullyDistVec< IT, IT > &parents, FullyDistVec< IT, short > &stars)
FullyDistSpVec< IT, NT > Assign(FullyDistSpVec< IT, IT > &ind, FullyDistSpVec< IT, NT > &val)
FullyDistVec< IT, IT > CC(SpParMat< IT, NT, DER > &A, IT &nCC)
int ReduceAssign(FullyDistSpVec< IT, IT > &ind, FullyDistSpVec< IT, NT > &val, vector< vector< NT > > &reduceBuffer, NT MAX_FOR_REDUCE)
void PrintCC(FullyDistVec< IT, IT > CC, IT nCC)
FullyDistSpVec< IT, NT > Extract(const FullyDistVec< IT, NT > dense, FullyDistSpVec< IT, IT > ri)
void HistCC(FullyDistVec< IT, IT > CC, IT nCC)
int Mpi_Alltoallv_kway(T *sbuff_, int *s_cnt_, int *sdisp_, T *rbuff_, int *r_cnt_, int *rdisp_, MPI_Comm c, int kway=2)
void StarCheckAfterHooking(const SpParMat< IT, NT, DER > &A, FullyDistVec< IT, IT > &parent, FullyDistVec< IT, short > &star, FullyDistSpVec< IT, IT > condhooks, bool isStar2StarHookPossible)
FullyDistSpVec< IT, IT > ConditionalHook(const SpParMat< IT, NT, DER > &A, FullyDistVec< IT, IT > &parent, FullyDistVec< IT, short > stars, int iteration)
int Mpi_Alltoallv_sparse(T *sendbuf, int *sendcnts, int *sdispls, T *recvbuf, int *recvcnts, int *rdispls, MPI_Comm comm)
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)