30#include "usort/parUtils.h"
58 for(
int i=0; i<
nprocs; ++i)
66 std::vector<std::string>().swap(
data_send[i]);
68 for(
int i=0; i<
nprocs; ++i)
90 std::cout <<
"Assertion failed at proc " << myrank <<
": Received indices are not sorted, this is unexpected" << std::endl;
102template<
typename KEY,
typename VAL,
typename IT>
112 if(dist[myrank] == 0)
excluded =
true;
115 for(
int i=0; i<
nprocs; ++i)
116 if(dist[i] != 0) ++
nreals;
133 for(
int i=0; i<
nprocs; ++i)
142 std::ostringstream
outs;
143 outs <<
"To exclude indices: ";
171 sort(array, array+
length);
174 std::pair<KEY,VAL> *
low = array;
175 std::pair<KEY,VAL> *
upp = array;
197template<
typename KEY,
typename VAL,
typename IT>
208 if(dist[myrank] == 0)
excluded =
true;
211 for(
int i=0; i<
nprocs; ++i)
212 if(dist[i] != 0) ++
nreals;
214 std::vector<IndexHolder<KEY>>
in(
length);
216#pragma omp parallel for
218 for(
int i=0; i<
length; ++i)
220 in[i] =
IndexHolder<KEY>(array[i].first,
static_cast<unsigned long>(array[i].second));
233 for(
int i=0; i<
nprocs; ++i)
242 std::ostringstream
outs;
243 outs <<
"To exclude indices: ";
268 std::vector<std::pair<KEY,VAL>>
sorted(
in.size());
269 for(
int i=0; i<
in.size(); i++)
278template<
typename KEY,
typename VAL,
typename IT>
286 std::pair<KEY, double> *
wmminput =
new std::pair<KEY,double>[
nprocs];
305 KEY median = array[(begin + end)/2].first;
310 for(
int i=0; i<
nprocs; ++i)
316 for(
int i=0; i<
nprocs; ++i)
330 low =std::lower_bound (array+begin, array+end,
wmmpair);
331 upp =std::upper_bound (array+begin, array+end,
wmmpair);
341 begin = (
low - array);
368 std::pair<KEY,VAL> *
recvbuf =
new std::pair<KEY,VAL>[
nacts];
374 for(
int i=0; i<
nprocs; ++i)
386 for(
int k=0; k < diff; ++k)
396template<
typename KEY,
typename VAL,
typename IT>
491template<
typename KEY,
typename VAL,
typename IT>
499 char _fn[] =
"temp_sortedkeys";
511 for(
int i=0; i<
length; ++i)
513 packed[i] = array[i].first;
525 std::cerr <<
"Problem reading binary input file\n";
531 for(
int i=0; i<
nprocs; ++i)
536 std::cout <<
"Elements stored on proc " << i <<
": " << std::endl;
537 std::copy(data, data+dist[i], std::ostream_iterator<KEY>(std::cout,
"\n"));
551template <
class IT,
class NT,
class DER>
564 for(
int i=0; i<
arrinfo.indarrs.size(); ++i)
569 for(
int i=0; i<
arrinfo.numarrs.size(); ++i)
582template<
typename IT,
typename NT,
typename DER>
593 for(
unsigned int i=0; i<
arrinfo.indarrs.size(); ++i)
597 for(
unsigned int i=0; i<
arrinfo.numarrs.size(); ++i)
608template<
typename IT,
typename NT,
typename DER>
619 for(
unsigned int i=0; i<
arrinfo.indarrs.size(); ++i)
623 for(
unsigned int i=0; i<
arrinfo.numarrs.size(); ++i)
636template<
typename IT,
typename NT,
typename DER>
653 for(
unsigned int i=0; i<
arrinfo.indarrs.size(); ++i)
659 for(
unsigned int i=0; i<
arrinfo.numarrs.size(); ++i)
671 for(
unsigned int i=0; i<
arrinfo.indarrs.size(); ++i)
682 for(
unsigned int i=0; i<
arrinfo.numarrs.size(); ++i)
694template <
class IT,
class NT,
class DER>
703 for(
int i=0; i<
arrs.indarrs.size(); ++i)
710 for(
int i=0; i<
arrs.numarrs.size(); ++i)
750 for(
unsigned int i=0; i<
arrwin.size(); ++i)
762 for(
unsigned int i=0; i<
arrwin.size(); ++i)
766template <
class IT,
class DER>
771 std::vector<IT>
ess(DER::esscount);
772 for(
int j=0;
j< DER::esscount; ++
j)
779template <
class IT,
class DER>
784 std::vector<IT>
ess(DER::esscount);
785 for(
int j=0;
j< DER::esscount; ++
j)
797template <
class IT,
class NT,
class DER>
817 std::ofstream
out(
filename.c_str(), std::ofstream::app);
829 std::ofstream
out(
filename.c_str(), std::ofstream::app);
863 buf[(*bytes_read) - 1] =
'\n';
864 std::cout <<
"Error in Matrix Market format, appending missing newline at end of file" << std::endl;
904 std::cout <<
"Unexpected line without a break" << std::endl;
922 lines.push_back(std::string(buf, n-1));
938 for(
unsigned int i=0; i<
arrwin.size(); ++i)
947 for(
unsigned int i=0; i<
arrwin.size(); ++i)
static void FreeWindows(std::vector< MPI_Win > &arrwin)
static void StartAccessEpoch(int owner, std::vector< MPI_Win > &arrwin, MPI_Group &group)
static void LockWindows(int ownind, std::vector< MPI_Win > &arrwin)
static bool FetchBatch(MPI_File &infile, MPI_Offset &curpos, MPI_Offset end_fpos, bool firstcall, std::vector< std::string > &lines, int myrank)
static void GetSetSizes(const SpMat< IT, NT, DER > &Matrix, IT **&sizes, MPI_Comm &comm1d)
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)
static void UnlockWindows(int ownind, std::vector< MPI_Win > &arrwin)
static void SetWindows(MPI_Comm &comm1d, const SpMat< IT, NT, DER > &Matrix, std::vector< MPI_Win > &arrwin)
static void BipartiteSwap(std::pair< KEY, VAL > *low, std::pair< KEY, VAL > *array, IT length, int nfirsthalf, int color, const MPI_Comm &comm)
static std::vector< std::pair< KEY, VAL > > KeyValuePSort(std::pair< KEY, VAL > *array, IT length, IT *dist, const MPI_Comm &comm)
static void PostExposureEpoch(int self, std::vector< MPI_Win > &arrwin, MPI_Group &group)
static void GatherMatrix(MPI_Comm &comm1d, SpMat< IT, NT, DER > &Matrix, int root)
static void PrintFile(const std::string &s, const std::string &filename)
static void BCastMatrix(MPI_Comm &comm1d, SpMat< IT, NT, DER > &Matrix, const std::vector< IT > &essentials, int root)
static void Print(const std::string &s)
static void WaitNFree(std::vector< MPI_Win > &arrwin)
static void FetchMatrix(SpMat< IT, NT, DER > &MRecv, const std::vector< IT > &essentials, std::vector< MPI_Win > &arrwin, int ownind)
static void ReDistributeToVector(int *&map_scnt, std::vector< std::vector< IT > > &locs_send, std::vector< std::vector< std::string > > &data_send, std::vector< std::array< char, MAXVERTNAME > > &distmapper_array, const MPI_Comm &comm)
static void DebugPrintKeys(std::pair< KEY, VAL > *array, IT length, IT *dist, MPI_Comm &World)
static void MemoryEfficientPSort(std::pair< KEY, VAL > *array, IT length, IT *dist, const MPI_Comm &comm)
static void LockNFetch(DER *&Matrix, int owner, std::vector< MPI_Win > &arrwin, MPI_Group &group, IT **sizes)
static void AccessNFetch(DER *&Matrix, int owner, std::vector< MPI_Win > &arrwin, MPI_Group &group, IT **sizes)
static void check_newline(int *bytes_read, int bytes_requested, char *buf)
static void IBCastMatrix(MPI_Comm &comm1d, SpMat< IT, NT, DER > &Matrix, const std::vector< IT > &essentials, int root, std::vector< MPI_Request > &indarrayReq, std::vector< MPI_Request > &numarrayReq)
int sampleSort(std::vector< T > &in, std::vector< T > &out, MPI_Comm comm)
A parallel sample sort implementation. In our implementation, we do not pose any restriction on the i...
void parallel_sort(_RandomAccessIter first, _RandomAccessIter last, _Compare comp, long *dist_in, SeqSort< _SeqSortType > &mysort, Split< _SplitType > &mysplit, Merge< _MergeType > &mymerge, MPI_Comm comm)