11 #ifndef _SORT_HISTI_H_ 12 #define _SORT_HISTI_H_ 22 : m_min_key(min), m_max_key(max), m_num_pes(env->m_numpes),
23 m_my_pe(env->m_mype), m_ncalls(0)
47 CH_assert(a_margin>0.0 && a_margin < 1.0);
92 Init( a_comm, a_nlocal, a_margin );
100 for (
int p=0, ki=0 ; ki < a_nlocal ; )
102 while ( a_keys[ki] < splits[p].lowerb_key ) ki++;
119 #define FACT 10000000000 128 for (
int i=0; i<a_nlocal ; i++)
141 if (!(k<=m_probe_size && k>=0))std::cout <<
"[" <<
m_my_pe <<
"] ERROR: k=" << k <<
" key=" << key <<
" max key = " <<
m_max_key << std::endl;
148 if ( tkey1 > key ) k -= inc;
157 MPI_Reduce(&loc_histo[0], &histogram[1],
m_probe_size, MPI_INDEX_TYPE, MPI_SUM, root, a_comm);
172 for (
int hi=0; hi<
m_probe_size+1 ; hi++) histogram[hi+1] += histogram[hi];
174 copy(histogram.begin(), histogram.end(), ostream_iterator<index_type>(cout,
" "));
175 std::cout << std::endl;
202 MPI_Bcast ( tt, 2, MPI_INT, root, a_comm );
222 int lenhist = histogram.size();
240 int splitterCount = 0;
245 std::vector< splitter* > active_splitters;
246 std::vector<int> toBroadcast;
259 toBroadcast.push_back(idxReal);
267 if (idxExp >= lenhist-1)
270 else sumhist = histogram[idxExp];
275 sumhist = histogram[idxExp];
297 if (idxReal == 0 ||
m_splitters[idxReal-1].achieved)
299 toBroadcast.push_back(idxReal);
312 borderChanged =
false;
319 borderChanged =
true;
326 borderChanged =
true;
334 if (lenhist >=
m_num_pes) CkPrintf(
"borderChanged should never be false %d %d %llu %llu %llu %llu %llu!!!\n",
335 idxExp, idxReal,
m_splitters[idxReal].goal, sumhist-histogram[idxExp-1], sumhist,
337 CkPrintf(
"The distributions is probably too dense to handle the given margin of error\n");
355 if (idxReal == 0 ||
m_splitters[idxReal-1].achieved)
357 toBroadcast.push_back(idxReal);
374 sumhist = histogram[idxExp];
379 splitterCount = active_splitters.size();
386 if (splitterCount > 0)
390 new_probe =
new probe[num_guesses];
394 new_probe =
new probe[num_guesses];
400 for (
int i = 0; i < toBroadcast.size(); i++)
402 if (toBroadcast[i] == 0)
423 for (
int i = 0; i < new_probe->
num_keys; i++)
427 if (splitterCount == 0)
439 active_splitters.clear();
444 if (splitterCount > 0)
457 int splitterCount = active_splitters.size();
465 for (
int i = 0; i < splitterCount; i++)
468 active_splitters[i]->virt = numVirt+1;
470 active_splitters[i]->virt = numVirt;
475 virtSent = splitterCount+1;
476 for (
int i = 0; i < splitterCount; i++)
478 active_splitters[i]->virt = 1;
491 while (idx < splitterCount)
495 accvirt += active_splitters[idx]->virt;
497 if (idx == splitterCount-1 || active_splitters[idx]->upperb_key != active_splitters[idx+1]->upperb_key)
501 divjump = (
key_type)(active_splitters[idx]->upperb_key - active_splitters[idx]->lowerb_key)/(divisors+1);
507 for (
int i = 0; i < divisors; i++)
509 if (divjump == 1 && (i+1)*divjump + active_splitters[idx]->lowerb_key > active_splitters[idx]->upperb_key)
510 newsps[num_guesses] = active_splitters[idx]->upperb_key;
512 newsps[num_guesses] = (i+1)*divjump + active_splitters[idx]->lowerb_key;
519 *ptr_num_guesses = num_guesses;
Definition: sort_hist.H:26
index_type upperb_count
Definition: sort_hist.H:37
#define CH_assert(cond)
Definition: CHArray.H:37
key_type * splitter_guesses
Definition: sort_hist.H:29
index_type goal
Definition: sort_hist.H:41
key_type * get_splitter_guesses(int *ptr_num_guesses, std::vector< splitter * > active_splitters)
Definition: sort_histI.H:454
const int m_num_pes
Definition: sort_hist.H:55
key_type upperb
Definition: sort_hist.H:21
int m_probe_size_max
Definition: sort_hist.H:61
index_type m_num_total_keys
Definition: sort_hist.H:64
IndexTM< T, N > min(const IndexTM< T, N > &a_p1, const IndexTM< T, N > &a_p2)
Definition: IndexTMI.H:396
int chare_dest
Definition: sort_hist.H:22
Definition: sort_hist.H:35
int * mws_sdispl(key_type *, int nloc, MPI_Comm c, float margin)
Definition: sort_histI.H:87
void RefineProbes(std::vector< index_type > &)
Definition: sort_histI.H:219
void Init(MPI_Comm a_comm, const int a_nloc, float)
Definition: sort_histI.H:39
int total
Definition: sort_hist.H:23
unsigned long long key_type
Definition: sort_hist.H:15
Histogram(SortComm *env, key_type min, key_type max)
Definition: sort_histI.H:21
int num_keys
Definition: sort_hist.H:30
const int m_my_pe
Definition: sort_hist.H:56
key_type upperb_key
Definition: sort_hist.H:38
index_type lowerb_count
Definition: sort_hist.H:39
int m_num_steps
Definition: sort_hist.H:57
IndexTM< T, N > max(const IndexTM< T, N > &a_p1, const IndexTM< T, N > &a_p2)
Definition: IndexTMI.H:403
int m_margin_error
Definition: sort_hist.H:62
bool achieved
Definition: sort_hist.H:43
int m_probe_size
Definition: sort_hist.H:60
key_type m_min_key
Definition: sort_hist.H:54
key_type * m_last_probe
Definition: sort_hist.H:65
int num_ranges
Definition: sort_hist.H:32
splitter * m_splitters
Definition: sort_hist.H:63
long long index_type
Definition: sort_utils.H:22
bool broadcasted
Definition: sort_hist.H:44
key_type lowerb
Definition: sort_hist.H:20
void set_limits(key_type min, key_type max)
Definition: sort_histI.H:31
int m_num_achv
Definition: sort_hist.H:59
key_type lowerb_key
Definition: sort_hist.H:40
splitter * mws_private(key_type *, int, MPI_Comm)
Definition: sort_histI.H:113
key_type m_max_key
Definition: sort_hist.H:54
resolved_range * send_info
Definition: sort_hist.H:31
int m_ncalls
Definition: sort_hist.H:58