15 #error "This implementation can only be included once"
51 #define HAVEWANT_t int
63 displ[
i + 1] = displ[
i] +
cnt[
i];
77 destcnt[
i] = srccnt[
i];
97 for (
int i = 0;
i < size; ++
i) {
98 int r = (*rendezvous_rank)(
data[
i]);
111 for (
int i = 0;
i < size; ++
i) {
112 int r = (*rendezvous_rank)(
data[
i]);
113 sdata[sdispl[r] + scnt[r]] =
data[
i];
133 int*& send_to_want_cnt,
134 int*& send_to_want_displ,
136 int*& recv_from_have_cnt,
137 int*& recv_from_have_displ,
146 int *have_s_cnt, *have_s_displ, *have_r_cnt, *have_r_displ;
160 for (
int i = 0;
i < have_r_cnt[r]; ++
i) {
162 if (havekey2rank.find(
key) != havekey2rank.end()) {
164 sprintf(buf,
"key %lld owned by multiple ranks\n", (
long long)
key);
167 havekey2rank[
key] = r;
170 delete[] have_s_data;
172 delete[] have_s_displ;
173 delete[] have_r_data;
175 delete[] have_r_displ;
178 int *want_s_cnt, *want_s_displ, *want_r_cnt, *want_r_displ;
194 int* want_r_ownerranks =
new int[n];
196 for (
int i = 0;
i < want_r_cnt[r]; ++
i) {
197 int ix = want_r_displ[r] +
i;
199 if (havekey2rank.find(
key) == havekey2rank.end()) {
201 sprintf(buf,
"key = %lld is wanted but does not exist\n", (
long long)
key);
204 want_r_ownerranks[ix] = havekey2rank[
key];
207 delete[] want_r_data;
227 want_s_ownerranks[
i] = want_r_ownerranks[
i];
230 delete[] want_r_ownerranks;
232 delete[] want_r_displ;
242 delete[] want_s_displ;
249 for (
int i = 0;
i < n; ++
i) {
250 int r = want_s_ownerranks[
i];
257 for (
int i = 0;
i < n; ++
i) {
258 int r = want_s_ownerranks[
i];
260 want_s_data[want_s_displ[r] + want_s_cnt[r]] =
key;
263 delete[] want_s_ownerranks;
264 delete[] old_want_s_data;
271 want_s_data, want_s_cnt, want_s_displ, want_r_data, want_r_cnt, want_r_displ);
276 want_r_data[
i] = want_s_data[
i];
282 send_to_want = want_r_data;
283 send_to_want_cnt = want_r_cnt;
284 send_to_want_displ = want_r_displ;
285 recv_from_have = want_s_data;
286 recv_from_have_cnt = want_s_cnt;
287 recv_from_have_displ = want_s_displ;