59 _RandomAccessIter last,
64 MPI_Comm_size (comm, &nproc);
65 MPI_Comm_rank (comm, &
rank);
69 typedef typename iterator_traits<_RandomAccessIter>::pointer _IterType;
70 typedef typename iterator_traits<_RandomAccessIter>::value_type _ValueType;
72 for (_IterType iter=first+1; iter<last; ++iter) {
73 if (comp(*(iter), *(iter-1)) ==
true) {
79 _ValueType *left_boundary =
new _ValueType[nproc];
80 _ValueType *right_boundary =
new _ValueType[nproc];
82 _ValueType left = *first;
83 MPI_Allgather (&left,
sizeof (_ValueType), MPI_CHAR,
84 left_boundary,
sizeof (_ValueType), MPI_CHAR,
87 _ValueType right = *(last-1);
88 MPI_Allgather (&right,
sizeof (_ValueType), MPI_CHAR,
89 right_boundary,
sizeof (_ValueType), MPI_CHAR,
92 for (
int i=0; i<nproc-1; ++i) {
93 if (comp(left_boundary[i+1], right_boundary[i]) ==
true) {
99 delete [] left_boundary;
100 delete [] right_boundary;
103 MPI_Allgather (¬_sorted, 1, MPI_INT,
104 result, 1, MPI_INT, comm);
106 int all_result = accumulate (result, result + nproc, 0);
151 MPI_Comm_size (comm, &nproc);
152 MPI_Comm_rank (comm, &
rank);
165 const char *stage[5] = {
173 if (
rank == 0) cout << endl;
175 for (
int i=1; i<=4; ++i) {
176 double time_i = psort_timing[i] - psort_timing[i-1];
179 << setw(30) << left << stage[i]
180 << setw(10) << right <<
": "
181 << setprecision(6) << time_i <<
" sec" << endl;
186 long n_sort = 0L;
for (
int i=0; i<nproc; ++i) n_sort += dist[i];
187 double total_time = rtime[1] + rtime[2] + rtime[3] + rtime[4];
188 double mkeys_per_sec;
189 double mkeys_per_sec_proc;
191 mkeys_per_sec = ((n_sort * log2(n_sort)) / total_time) / 1e6;
192 mkeys_per_sec_proc = (((n_sort * log2(n_sort)) / total_time) / nproc) / 1e6;
194 cout << setprecision(6) << endl;
195 cout << setw(33) << left <<
"* MKeys/sec"
196 << setw(10) << right <<
": " << mkeys_per_sec << endl;
197 cout << setw(33) << left <<
"* MKeys/sec/proc"
198 << setw(10) << right <<
": " << mkeys_per_sec_proc << endl;
204 results.open (
"./results", ios::app);
215 << total_time <<
", "
216 << mkeys_per_sec <<
", "
217 << mkeys_per_sec_proc
232 MPI_Comm_size (comm, &nproc);
233 MPI_Comm_rank (comm, &
rank);
247 const char* stage[6] = {
256 if (
rank == 0) cout << endl;
258 for (
int i=1; i<=5; ++i) {
259 double time_i = psort_timing[i] - psort_timing[i-1];
262 << setw(30) << left << stage[i]
263 << setw(10) << right <<
": "
264 << setprecision(6) << time_i <<
" sec" << endl;
269 long n_sort = 0L;
for (
int i=0; i<nproc; ++i) n_sort += dist[i];
270 double total_time = rtime[1] + rtime[2] + rtime[3] + rtime[4];
271 double mkeys_per_sec;
272 double mkeys_per_sec_proc;
274 mkeys_per_sec = ((n_sort * log2(n_sort)) / total_time) / 1e6;
275 mkeys_per_sec_proc = (((n_sort * log2(n_sort)) / total_time) / nproc) / 1e6;
277 cout << setprecision(6) << endl;
278 cout << setw(33) << left <<
"* MKeys/sec"
279 << setw(10) << right <<
": " << mkeys_per_sec << endl;
280 cout << setw(33) << left <<
"* MKeys/sec/proc"
281 << setw(10) << right <<
": " << mkeys_per_sec_proc << endl;
287 results.open (
"./results", ios::app);
289 results <<
"sample sort" <<
", "
298 << total_time <<
", "
299 << mkeys_per_sec <<
", "
300 << mkeys_per_sec_proc