34 #ifndef _SP_PAR_HELPER_H_
35 #define _SP_PAR_HELPER_H_
44 #include "psort/psort.h"
51 template <
typename IT>
53 std::vector< std::vector< std::string > > & data_send, std::vector<std::array<char, MAXVERTNAME>> & distmapper_array,
const MPI_Comm & comm);
55 template<
typename KEY,
typename VAL,
typename IT>
56 static void GlobalSelect(IT gl_rank, std::pair<KEY,VAL> * & low, std::pair<KEY,VAL> * & upp, std::pair<KEY,VAL> * array, IT length,
const MPI_Comm & comm);
58 template<
typename KEY,
typename VAL,
typename IT>
59 static void BipartiteSwap(std::pair<KEY,VAL> * low, std::pair<KEY,VAL> * array, IT length,
int nfirsthalf,
int color,
const MPI_Comm & comm);
68 template<
typename KEY,
typename VAL,
typename IT>
69 static void MemoryEfficientPSort(std::pair<KEY,VAL> * array, IT length, IT * dist,
const MPI_Comm & comm);
71 template<
typename KEY,
typename VAL,
typename IT>
72 static std::vector<std::pair<KEY,VAL>>
KeyValuePSort(std::pair<KEY,VAL> * array, IT length, IT * dist,
const MPI_Comm & comm);
74 template<
typename KEY,
typename VAL,
typename IT>
75 static void DebugPrintKeys(std::pair<KEY,VAL> * array, IT length, IT * dist, MPI_Comm & World);
77 template<
typename IT,
typename NT,
typename DER>
78 static void FetchMatrix(SpMat<IT,NT,DER> & MRecv,
const std::vector<IT> & essentials, std::vector<MPI_Win> & arrwin,
int ownind);
80 template<
typename IT,
typename NT,
typename DER>
81 static void BCastMatrix(MPI_Comm & comm1d, SpMat<IT,NT,DER> & Matrix,
const std::vector<IT> & essentials,
int root);
83 template<
typename IT,
typename NT,
typename DER>
84 static void GatherMatrix(MPI_Comm & comm1d, SpMat<IT,NT,DER> & Matrix,
int root);
86 template<
typename IT,
typename NT,
typename DER>
87 static void SetWindows(MPI_Comm & comm1d,
const SpMat< IT,NT,DER > & Matrix, std::vector<MPI_Win> & arrwin);
89 template <
typename IT,
typename NT,
typename DER>
90 static void GetSetSizes(
const SpMat<IT,NT,DER> & Matrix, IT ** & sizes, MPI_Comm & comm1d);
92 template <
typename IT,
typename DER>
93 static void AccessNFetch(DER * & Matrix,
int owner, std::vector<MPI_Win> & arrwin, MPI_Group & group, IT ** sizes);
95 template <
typename IT,
typename DER>
96 static void LockNFetch(DER * & Matrix,
int owner, std::vector<MPI_Win> & arrwin, MPI_Group & group, IT ** sizes);
98 static void StartAccessEpoch(
int owner, std::vector<MPI_Win> & arrwin, MPI_Group & group);
99 static void PostExposureEpoch(
int self, std::vector<MPI_Win> & arrwin, MPI_Group & group);
100 static void LockWindows(
int ownind, std::vector<MPI_Win> & arrwin);
101 static void UnlockWindows(
int ownind, std::vector<MPI_Win> & arrwin);
103 static void Print(
const std::string & s);
104 static void Print(
const std::string & s, MPI_Comm & world);
105 static void PrintFile(
const std::string & s,
const std::string & filename);
106 static void PrintFile(
const std::string & s,
const std::string & filename, MPI_Comm & world);
107 static void check_newline(
int *bytes_read,
int bytes_requested,
char *buf);
108 static bool FetchBatch(MPI_File & infile, MPI_Offset & curpos, MPI_Offset end_fpos,
bool firstcall, std::vector<std::string> & lines,
int myrank);
110 static void WaitNFree(std::vector<MPI_Win> & arrwin);
111 static void FreeWindows(std::vector<MPI_Win> & arrwin);