Yet Another eXchange Tool 0.11.1
Loading...
Searching...
No Matches
xt_idxlist_collection.c
Go to the documentation of this file.
1
12/*
13 * Keywords:
14 * Maintainer: Jörg Behrens <behrens@dkrz.de>
15 * Moritz Hanke <hanke@dkrz.de>
16 * Thomas Jahns <jahns@dkrz.de>
17 * URL: https://dkrz-sw.gitlab-pages.dkrz.de/yaxt/
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions are
21 * met:
22 *
23 * Redistributions of source code must retain the above copyright notice,
24 * this list of conditions and the following disclaimer.
25 *
26 * Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 *
30 * Neither the name of the DKRZ GmbH nor the names of its contributors
31 * may be used to endorse or promote products derived from this software
32 * without specific prior written permission.
33 *
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
35 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
36 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
37 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
38 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
39 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
40 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
41 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
42 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 */
46#ifdef HAVE_CONFIG_H
47#include <config.h>
48#endif
49
50#include <stdlib.h>
51#include <stdio.h>
52#include <assert.h>
53#include <string.h>
54
55#include "mpi.h"
56
57#include "xt/xt_core.h"
58#include "xt/xt_idxlist.h"
59#include "xt_idxlist_internal.h"
62#include "xt/xt_idxempty.h"
63#include "xt/xt_config.h"
64#include "xt_config_internal.h"
65#include "xt_idxvec_internal.h"
66#include "xt/xt_idxstripes.h"
68#include "xt/xt_mpi.h"
69#include "xt_idxlist_unpack.h"
70#include "xt_stripe_util.h"
71#include "core/core.h"
72#include "core/ppm_xfuncs.h"
73#include "ensure_array_size.h"
74
75static const char filename[] = "xt_idxlist_collection.c";
76
77static void
79
80static size_t
82
83static void
84idxlist_collection_pack(Xt_idxlist data, void *buffer, int buffer_size,
85 int *position, MPI_Comm comm);
86
87static Xt_idxlist
89
90static Xt_idxlist
92
93static void
95
96static const Xt_int *
98
99static int
101
102static void
104 struct Xt_stripe *restrict stripes,
105 size_t num_stripes_alloc);
106
107static int
109 Xt_int * index);
110
111static int
113 int * position);
114
115static int
117 int * position, int offset);
118
119static Xt_int
121
122static Xt_int
124
125static int
127
130 .get_pack_size = idxlist_collection_get_pack_size,
133 .sorted_copy = idxlist_collection_sorted_copy,
134 .get_indices = idxlist_collection_get_indices,
135 .get_indices_const = idxlist_collection_get_indices_const,
136 .get_num_index_stripes = idxlist_collection_get_num_index_stripes,
137 .get_index_stripes = idxlist_collection_get_index_stripes,
138 .get_index_at_position = idxlist_collection_get_index_at_position,
139 .get_indices_at_positions = NULL,
140 .get_position_of_index = idxlist_collection_get_position_of_index,
141 .get_positions_of_indices = NULL,
142 .get_position_of_index_off = idxlist_collection_get_position_of_index_off,
143 .get_positions_of_indices_off = NULL,
144 .get_min_index = idxlist_collection_get_min_index,
145 .get_max_index = idxlist_collection_get_max_index,
146 .get_sorting = idxlist_collection_get_sorting,
147 .get_bounding_box = NULL,
148 .idxlist_pack_code = COLLECTION,
149};
150
152
163
165xt_idxlist_collection_new(Xt_idxlist *idxlists, int num_idxlists) {
166 // ensure that yaxt is initialized
167 assert(xt_initialized());
168
169 /* todo: find collections in idxlists and prevent hierarchical
170 * copy, flatten list instead */
171 Xt_idxlist result;
172 size_t num_non_empty_idxlists = 0, first_non_empty_idxlist = (size_t)-1;
173 for (int i = 0; i < num_idxlists; ++i) {
174 int num_indices_of_list = xt_idxlist_get_num_indices(idxlists[i]);
175 if (first_non_empty_idxlist == (size_t)-1 && num_indices_of_list > 0)
176 first_non_empty_idxlist = (size_t)i;
177 num_non_empty_idxlists +=
178 (idxlists[i]->vtable == &idxlist_collection_vtable)
179 ? (size_t)((Xt_idxlist_collection)idxlists[i])->num_idxlists
180 : (size_t)(num_indices_of_list > 0);
181 }
182 if (num_non_empty_idxlists > 1)
183 {
184 long long num_indices
185 = xt_idxlist_get_num_indices(idxlists[first_non_empty_idxlist]);
186 Xt_int min = xt_idxlist_get_min_index(idxlists[first_non_empty_idxlist]),
187 max = xt_idxlist_get_max_index(idxlists[first_non_empty_idxlist]),
188 prev_max = max;
189 unsigned ntrans_dn = 0, ntrans_up = 0,
190 nsort_asc = 0, nsort_dsc = 0;
191 switch (xt_idxlist_get_sorting(idxlists[first_non_empty_idxlist])) {
192 case 1:
193 ++nsort_asc;
194 break;
195 case -1:
196 ++nsort_dsc;
197 break;
198 }
199 for (int i = (int)first_non_empty_idxlist+1; i < num_idxlists; ++i) {
200 int num_indices_of_list = xt_idxlist_get_num_indices(idxlists[i]);
201 if (num_indices_of_list > 0) {
202 Xt_int tmp_min, tmp_max;
203 if ((tmp_min = xt_idxlist_get_min_index(idxlists[i])) < min)
204 min = tmp_min;
205 if ((tmp_max = xt_idxlist_get_max_index(idxlists[i])) > max)
206 max = tmp_max;
207 ntrans_dn += (tmp_min < prev_max);
208 ntrans_up += (tmp_min > prev_max);
209 prev_max = tmp_max;
210 int sort = xt_idxlist_get_sorting(idxlists[i]);
211 switch (sort) {
212 case 1:
213 ++nsort_asc;
214 break;
215 case -1:
216 ++nsort_dsc;
217 break;
218 }
219 num_indices += num_indices_of_list;
220 }
221 }
222 assert(num_indices <= INT_MAX);
223 if (min != max) {
224 Xt_idxlist_collection collectionlist
225 = xmalloc(sizeof (*collectionlist)
226 + num_non_empty_idxlists
227 * sizeof (collectionlist->idxlists[0]));
228
229 collectionlist->num_idxlists = (int)num_non_empty_idxlists;
230 collectionlist->index_array_cache = NULL;
231
232 for (size_t i = first_non_empty_idxlist, j = 0;
233 i < (size_t)num_idxlists; ++i) {
234 if (idxlists[i]->vtable == &idxlist_collection_vtable) {
235 Xt_idxlist_collection comp_collection
236 = (Xt_idxlist_collection)idxlists[i];
237 size_t num_comp_idxlists
238 = (size_t)comp_collection->num_idxlists;
239 Xt_idxlist *comp_lists = comp_collection->idxlists;
240 for (size_t k = 0; k < num_comp_idxlists; ++k)
241 collectionlist->idxlists[j+k] = xt_idxlist_copy(comp_lists[k]);
242 j += num_comp_idxlists;
243 } else if (xt_idxlist_get_num_indices(idxlists[i]) > 0)
244 collectionlist->idxlists[j++] = xt_idxlist_copy(idxlists[i]);
245 }
247 (int)num_indices);
248 collectionlist->flags = XT_SORT_FLAGS(ntrans_up + nsort_asc,
249 ntrans_dn + nsort_dsc) & sort_mask;
250 result = (Xt_idxlist)collectionlist;
251 } else /* min == max => all values identical */ {
252 result =
254 .start = min, .stride = 0, .nstrides = (int)num_indices }, 1);
255 }
256 }
257 else if (num_non_empty_idxlists == 1)
258 result = xt_idxlist_copy(idxlists[first_non_empty_idxlist]);
259 else /* num_idxlists == 0 */
260 result = xt_idxempty_new();
261 return result;
262}
263
264static void
266
267 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)data;
268
269 int num_lists = collectionlist->num_idxlists;
270 for (int i = 0; i < num_lists; ++i)
271 xt_idxlist_delete(collectionlist->idxlists[i]);
272
273 free(collectionlist->index_array_cache);
274 free(collectionlist);
275}
276
277static size_t
279
280 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)data;
281
282 int size_header, num_lists = collectionlist->num_idxlists;
283 size_t size_idxlists = 0;
284
285 xt_mpi_call(MPI_Pack_size(2, MPI_INT, comm, &size_header), comm);
286
287 for (int i = 0; i < num_lists; ++i)
288 size_idxlists
289 += xt_idxlist_get_pack_size(collectionlist->idxlists[i], comm);
290
291 return (size_t)size_header + size_idxlists;
292}
293
294static void
295idxlist_collection_pack(Xt_idxlist data, void *buffer, int buffer_size,
296 int *position, MPI_Comm comm) {
297
298 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)data;
299 int num_lists = collectionlist->num_idxlists;
300 int header[2] = { COLLECTION, num_lists };
301
302 xt_mpi_call(MPI_Pack(header, 2, MPI_INT, buffer,
303 buffer_size, position, comm), comm);
304
305 for (int i = 0; i < num_lists; ++i)
306 xt_idxlist_pack(collectionlist->idxlists[i], buffer, buffer_size,
307 position, comm);
308}
309
311xt_idxlist_collection_unpack(void *buffer, int buffer_size, int *position,
312 MPI_Comm comm) {
313
314 int num_lists;
315 xt_mpi_call(MPI_Unpack(buffer, buffer_size, position,
316 &num_lists, 1, MPI_INT, comm), comm);
317
318 Xt_idxlist_collection collectionlist
319 = xmalloc(sizeof (*collectionlist)
320 + (size_t)num_lists * sizeof (collectionlist->idxlists[0]));
321
322 collectionlist->index_array_cache = NULL;
323 collectionlist->num_idxlists = num_lists;
324
325 long long num_indices = 0;
326 for (int i = 0; i < num_lists; ++i) {
327 collectionlist->idxlists[i] = xt_idxlist_unpack(buffer, buffer_size,
328 position, comm);
329 num_indices += xt_idxlist_get_num_indices(collectionlist->idxlists[i]);
330 }
331
332 assert(num_indices <= INT_MAX);
334 (int)num_indices);
335 return (Xt_idxlist)collectionlist;
336}
337
340 Xt_idxlist XT_UNUSED(idxlist_dst),
341 Xt_config XT_UNUSED(config)) {
342
343 return NULL;
344}
345
346static Xt_idxlist
348
349 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
350
351 return xt_idxlist_collection_new(collectionlist->idxlists,
352 collectionlist->num_idxlists);
353}
354
356{
358 int pos;
359};
360
361static int
362range_list_cmp(const void *a, const void *b)
363{
364 const struct range_list_sort *ra = a, *rb = b;
365 int ret;
366 if (ra->min != rb->min) {
367 ret = (ra->min > rb->min) - (ra->min < rb->min);
368 } else {
369 ret = (ra->max > rb->max) - (ra->max < rb->max);
370 }
371 return ret;
372}
373
377};
378
379static Xt_idxlist
381 struct range_list_sort *list_sorter,
382 Xt_config config)
383{
384 /* accumulate stripes into this buffer */
385 struct Xt_stripe *stripes_accum = NULL;
386 size_t stripes_accum_array_size = 0;
387 size_t num_accum_stripes;
388 const Xt_idxlist *unsorted_idxlists = collectionlist->idxlists;
389 {
390 int num_accum_stripes_;
391 xt_idxlist_get_index_stripes(unsorted_idxlists[list_sorter[0].pos], &stripes_accum,
392 &num_accum_stripes_);
393 num_accum_stripes = (size_t)num_accum_stripes_;
394 }
395 size_t num_idxlists = (size_t)collectionlist->num_idxlists;
396 struct Xt_stripe *stripe_buf = NULL; size_t stripe_buf_size = 0;
397 /* obtain stripes, locally mostly sorted if reasonably available */
398 for (size_t i = 1; i < num_idxlists; ++i) {
399 Xt_idxlist component_list, unsorted_list
400 = unsorted_idxlists[list_sorter[i].pos];
401 Xt_int *sorted_indices = NULL;
402 switch (unsorted_list->vtable->idxlist_pack_code) {
403 case EMPTY: /* xt_idxempty should not usually be part
404 * of a collection, but better safe
405 * than sorry, I guess */
406 Xt_abort(Xt_default_comm, "internal error", filename, __LINE__);
407 /* these are either too expensive or pointless to sort, just
408 * use their ranges as is */
409 case COLLECTION:
410 case STRIPES:
411 component_list = unsorted_list;
412 break;
413 case VECTOR:
414 {
415 struct Xt_config_ derived_config = *config;
416 derived_config.flags |= xt_force_nosort;
417 size_t num_indices
418 = (size_t)xt_idxlist_get_num_indices(unsorted_list);
419 const Xt_int *indices
420 = xt_idxvec_get_sorted_vector(unsorted_list, &derived_config);
421 if (!indices) {
422 const Xt_int *vector
423 = xt_idxlist_get_indices_const(unsorted_list);
424 indices = sorted_indices
425 = xmalloc(num_indices * sizeof (*sorted_indices));
426 for (size_t j = 0; j < num_indices; ++j)
427 sorted_indices[j] = vector[j];
428 config->sort_funcs->sort_xt_int(sorted_indices, num_indices);
429 }
430 component_list
431 = xt_idxvec_prealloc_new(indices, (int)num_indices);
432 }
433 break;
434 default:
435 component_list
436 = xt_idxlist_sorted_copy_custom(unsorted_list, config);
437 }
438 size_t num_stripes
439 = (size_t)(xt_idxlist_get_num_index_stripes(component_list));
440 if (num_stripes > stripe_buf_size) {
441 stripe_buf = xrealloc(stripe_buf, num_stripes * sizeof (stripe_buf[0]));
442 stripe_buf_size = num_stripes;
443 }
445 stripe_buf, stripe_buf_size);
446 if (component_list != unsorted_list) {
447 xt_idxlist_delete(component_list);
448 free(sorted_indices);
449 }
450 ENSURE_ARRAY_SIZE(stripes_accum, stripes_accum_array_size,
451 num_accum_stripes + (size_t)stripe_buf_size);
452
453 num_accum_stripes
454 += xt_stripes_merge_copy((size_t)stripe_buf_size,
455 stripes_accum + num_accum_stripes,
456 stripe_buf,
457 num_accum_stripes > 0);
458
459 }
460 /* sort/shuffle the entirety of stripes */
461 free(stripe_buf);
462 Xt_idxlist sorted_copy
463 = xt_idxstripes_sort_new((size_t)num_accum_stripes, stripes_accum, config);
464 free(stripes_accum);
465 return sorted_copy;
466}
467
468
469static Xt_idxlist
471
472 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
473 size_t num_idxlists = (size_t)collectionlist->num_idxlists;
474 Xt_int prev_max = XT_INT_MIN;
475 Xt_idxlist *idxlists = collectionlist->idxlists;
476 struct range_list_sort *list_sorter;
477 Xt_idxlist_collection sorted_collection
478 = xmalloc(sizeof (*sorted_collection)
479 + num_idxlists * sizeof(sorted_collection->idxlists[0])
480 + num_idxlists * sizeof (struct range_list_sort));
481 sorted_collection->num_idxlists = (int)num_idxlists;
482 sorted_collection->index_array_cache = NULL;
483 list_sorter
484 = (struct range_list_sort *)(sorted_collection->idxlists+num_idxlists);
485 Xt_idxlist result;
486 bool component_overlap = false;
487 for (size_t i = 0; i < num_idxlists; ++i) {
488 Xt_int min = list_sorter[i].min = xt_idxlist_get_min_index(idxlists[i]);
489 component_overlap |= (min < prev_max);
490 prev_max = list_sorter[i].max = xt_idxlist_get_max_index(idxlists[i]);
491 list_sorter[i].pos = (int)i;
492 }
493 if (component_overlap) {
494 /* individual lists not sorted or even overlapping each other */
495 /* 1. sort the lists according to minimal element */
496 qsort(list_sorter, num_idxlists, sizeof (*list_sorter),
498 /* 2. re-check overlap after sorting */
499 prev_max = XT_INT_MIN;
500 component_overlap = false;
501 for (size_t i = 0; i < num_idxlists; ++i) {
502 Xt_int min = list_sorter[i].min;
503 component_overlap |= (min < prev_max);
504 prev_max = list_sorter[i].max;
505 }
506 }
507 if (!component_overlap) {
508 /* the component lists are in a sequence either naturally or
509 * after sorting without problematic overlaps, a concatenation of
510 * their sorted copies is all that's needed. */
511 Xt_idxlist *sorted_lists = sorted_collection->idxlists;
512 for (size_t i = 0; i < num_idxlists; ++i)
513 sorted_lists[i]
514 /* list_sorter[i].pos will be an identity map if the lists
515 * were already sorted */
516 = xt_idxlist_sorted_copy_custom(idxlists[list_sorter[i].pos],
517 config);
518 sorted_collection
519 = xrealloc(sorted_collection, sizeof (*sorted_collection)
520 + num_idxlists * sizeof(sorted_collection->idxlists[0]));
523 result = (Xt_idxlist)sorted_collection;
524 } else {
525 /* components overlap in a way that cannot be resolved by sorting
526 * only the lists, need to create stripes and sort those */
527 result = coll_get_sorted_stripes(collectionlist, list_sorter, config);
528 free(sorted_collection);
529 }
530 return result;
531}
532
533static void
535
536 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
538 int offlist = 0, num_lists = collectionlist->num_idxlists;
539
540 for (int i = 0; i < num_lists; ++i) {
541
542 xt_idxlist_get_indices(collectionlist->idxlists[i], indices+offlist);
543 offlist += xt_idxlist_get_num_indices(collectionlist->idxlists[i]);
544 }
545}
546
547static const Xt_int *
549
550 Xt_idxlist_collection collection = (Xt_idxlist_collection)idxlist;
551
552 if (collection->index_array_cache) return collection->index_array_cache;
553
554 unsigned num_indices = (unsigned)xt_idxlist_get_num_indices(idxlist);
555
556 Xt_int *tmp_index_array
557 = xmalloc(num_indices * sizeof (collection->index_array_cache[0]));
558
559 idxlist_collection_get_indices(idxlist, tmp_index_array);
560
561 collection->index_array_cache = tmp_index_array;
562
563 return collection->index_array_cache;
564}
565
566static int
568{
569 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
570 int num_lists = collectionlist->num_idxlists;
571 size_t num_stripes = 0;
572 for (int i = 0; i < num_lists; ++i)
573 num_stripes
574 += (size_t)xt_idxlist_get_num_index_stripes(collectionlist->idxlists[i]);
575 assert(num_stripes <= INT_MAX);
576 return (int)num_stripes;
577}
578
579static void
581 struct Xt_stripe *restrict stripes,
582 size_t num_stripes_alloc) {
583
584 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
585
586 size_t num_stripes = 0;
587
588 size_t num_lists = (size_t)(collectionlist->num_idxlists);
589 Xt_idxlist *idxlists = collectionlist->idxlists;
590 for (size_t i = 0; i < num_lists; ++i) {
591 size_t num_stripes_of_list
592 = (size_t)(xt_idxlist_get_num_index_stripes(idxlists[i]));
593 assert(num_stripes_alloc - num_stripes >= num_stripes_of_list);
594 xt_idxlist_get_index_stripes_keep_buf(idxlists[i], stripes + num_stripes,
595 num_stripes_alloc - num_stripes);
596 num_stripes += num_stripes_of_list;
597 }
598}
599
600static int
602 Xt_int * index) {
603
604 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
605 int num_lists = collectionlist->num_idxlists;
606
607 for (int i = 0; i < num_lists; ++i) {
608 int n = xt_idxlist_get_num_indices(collectionlist->idxlists[i]);
609 if (position >= n)
610 position -= n;
611 else {
612 return xt_idxlist_get_index_at_position(collectionlist->idxlists[i],
613 position, index);
614 }
615 }
616 return 1;
617
618}
619
620static int
622 int * position, int offset) {
623
624 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
625
626 int curr_num_indices = 0;
627
628 int idxlist_offsets = 0;
629
630 assert(offset >= 0);
631
632 int i = 0, num_lists = collectionlist->num_idxlists;
633
634 do {
635 idxlist_offsets += curr_num_indices;
636 curr_num_indices = xt_idxlist_get_num_indices(collectionlist->idxlists[i]);
637 } while (idxlist_offsets + curr_num_indices <= offset && ++i < num_lists);
638
639 offset -= idxlist_offsets;
640
641 for (;i < num_lists; ++i)
642 if (!xt_idxlist_get_position_of_index_off(collectionlist->idxlists[i],
643 index, position, offset)) {
644 *position += idxlist_offsets;
645 return 0;
646 } else {
647 idxlist_offsets
648 += xt_idxlist_get_num_indices(collectionlist->idxlists[i]);
649 offset = 0;
650 }
651
652 return 1;
653}
654
655static int
657 int * position) {
658
660 position, 0);
661}
662
663static Xt_int
665
666 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
667
668 size_t num_lists = (size_t)collectionlist->num_idxlists;
669 assert(collectionlist->num_idxlists > 0);
670
671 Xt_int tmp_min, min = XT_INT_MAX;
672
673 for (size_t i = 0; i < num_lists; ++i)
674 if ((tmp_min = xt_idxlist_get_min_index(collectionlist->idxlists[i])) < min)
675 min = tmp_min;
676
677 return min;
678}
679
680static Xt_int
682
683 Xt_idxlist_collection collectionlist = (Xt_idxlist_collection)idxlist;
684
685 size_t num_lists = (size_t)collectionlist->num_idxlists;
686 assert(collectionlist->num_idxlists > 0);
687
688 Xt_int tmp_max, max = XT_INT_MIN;
689
690 for (size_t i = 0; i < num_lists; ++i)
691 if ((tmp_max = xt_idxlist_get_max_index(collectionlist->idxlists[i])) > max)
692 max = tmp_max;
693
694 return max;
695}
696
697static int
699{
700 unsigned sort_flags = (((Xt_idxlist_collection)idxlist)->flags) & sort_mask;
701 return (int)sort_flags-(sort_flags < 3);
702}
703
704
705/*
706 * Local Variables:
707 * c-basic-offset: 2
708 * coding: utf-8
709 * indent-tabs-mode: nil
710 * show-trailing-whitespace: t
711 * require-trailing-newline: t
712 * End:
713 */
int MPI_Comm
Definition core.h:64
#define XT_UNUSED(x)
Definition core.h:84
#define ENSURE_ARRAY_SIZE(arrayp, curr_array_size, req_size)
add versions of standard API functions not returning on error
#define xrealloc(ptr, size)
Definition ppm_xfuncs.h:71
#define xmalloc(size)
Definition ppm_xfuncs.h:70
const struct Xt_sort_algo_funcptr * sort_funcs
const struct xt_idxlist_vtable * vtable
void(* sort_xt_int)(Xt_int *a, size_t n)
struct Xt_stripe * stripes
void(* delete)(Xt_idxlist)
opaque configuration object for settings where the default needs to be overridden
implementation of configuration object
@ xt_force_nosort
base definitions header file
#define XT_INT_MIN
Definition xt_core.h:78
#define XT_INT_MAX
Definition xt_core.h:77
int xt_initialized(void)
XT_INT Xt_int
Definition xt_core.h:72
struct Xt_idxlist_ * Xt_idxlist
Definition xt_core.h:84
static struct xt_gpu_vtable vtable
Definition xt_gpu.c:75
Xt_idxlist xt_idxempty_new(void)
void xt_idxlist_get_index_stripes_keep_buf(Xt_idxlist idxlist, struct Xt_stripe *stripes, size_t num_stripes_alloc)
Definition xt_idxlist.c:147
index list declaration
Xt_idxlist xt_idxlist_unpack(void *buffer, int buffer_size, int *position, MPI_Comm comm)
Xt_int xt_idxlist_get_min_index(Xt_idxlist idxlist)
Definition xt_idxlist.c:349
const Xt_int * xt_idxlist_get_indices_const(Xt_idxlist idxlist)
Definition xt_idxlist.c:119
int xt_idxlist_get_index_at_position(Xt_idxlist idxlist, int position, Xt_int *index)
Definition xt_idxlist.c:176
Xt_int xt_idxlist_get_max_index(Xt_idxlist idxlist)
Definition xt_idxlist.c:354
void xt_idxlist_get_indices(Xt_idxlist idxlist, Xt_int *indices)
Definition xt_idxlist.c:113
int xt_idxlist_get_num_index_stripes(Xt_idxlist idxlist)
Definition xt_idxlist.c:129
int xt_idxlist_get_position_of_index_off(Xt_idxlist idxlist, Xt_int index, int *position, int offset)
Definition xt_idxlist.c:306
Xt_idxlist xt_idxlist_sorted_copy_custom(Xt_idxlist idxlist, Xt_config config)
Definition xt_idxlist.c:104
void xt_idxlist_pack(Xt_idxlist idxlist, void *buffer, int buffer_size, int *position, MPI_Comm comm)
Definition xt_idxlist.c:86
size_t xt_idxlist_get_pack_size(Xt_idxlist idxlist, MPI_Comm comm)
Definition xt_idxlist.c:80
void xt_idxlist_get_index_stripes(Xt_idxlist idxlist, struct Xt_stripe **stripes, int *num_stripes)
Definition xt_idxlist.c:135
Xt_idxlist xt_idxlist_copy(Xt_idxlist idxlist)
Definition xt_idxlist.c:94
int xt_idxlist_get_sorting(Xt_idxlist idxlist)
Definition xt_idxlist.c:359
void xt_idxlist_delete(Xt_idxlist idxlist)
Definition xt_idxlist.c:75
Xt_idxlist xt_idxlist_collection_unpack(void *buffer, int buffer_size, int *position, MPI_Comm comm)
static void idxlist_collection_get_indices(Xt_idxlist idxlist, Xt_int *indices)
static const char filename[]
static int idxlist_collection_get_position_of_index_off(Xt_idxlist idxlist, Xt_int index, int *position, int offset)
static int idxlist_collection_get_position_of_index(Xt_idxlist idxlist, Xt_int index, int *position)
static void idxlist_collection_delete(Xt_idxlist data)
static Xt_idxlist idxlist_collection_sorted_copy(Xt_idxlist idxlist, Xt_config config)
struct Xt_idxlist_collection_ * Xt_idxlist_collection
static Xt_idxlist idxlist_collection_copy(Xt_idxlist idxlist)
static int idxlist_collection_get_num_index_stripes(Xt_idxlist idxlist)
static int idxlist_collection_get_sorting(Xt_idxlist idxlist)
static Xt_int idxlist_collection_get_max_index(Xt_idxlist idxlist)
static int range_list_cmp(const void *a, const void *b)
static size_t idxlist_collection_get_pack_size(Xt_idxlist data, MPI_Comm comm)
static Xt_int idxlist_collection_get_min_index(Xt_idxlist idxlist)
static const struct xt_idxlist_vtable idxlist_collection_vtable
static Xt_idxlist coll_get_sorted_stripes(Xt_idxlist_collection collectionlist, struct range_list_sort *list_sorter, Xt_config config)
static int idxlist_collection_get_index_at_position(Xt_idxlist idxlist, int position, Xt_int *index)
static void idxlist_collection_pack(Xt_idxlist data, void *buffer, int buffer_size, int *position, MPI_Comm comm)
Xt_idxlist xt_idxlist_collection_get_intersection(Xt_idxlist XT_UNUSED(idxlist_src), Xt_idxlist XT_UNUSED(idxlist_dst), Xt_config XT_UNUSED(config))
static void idxlist_collection_get_index_stripes(Xt_idxlist idxlist, struct Xt_stripe *restrict stripes, size_t num_stripes_alloc)
static const Xt_int * idxlist_collection_get_indices_const(Xt_idxlist idxlist)
Xt_idxlist xt_idxlist_collection_new(Xt_idxlist *idxlists, int num_idxlists)
Provide non-public declarations common to all index lists.
#define xt_idxlist_get_num_indices(idxlist)
static void Xt_idxlist_init(Xt_idxlist idxlist, const struct xt_idxlist_vtable *vtable, int num_indices)
@ VECTOR
@ EMPTY
@ STRIPES
@ COLLECTION
Xt_idxlist xt_idxstripes_sort_new(size_t num_src_stripes, const struct Xt_stripe src_stripes[], Xt_config config)
Xt_idxlist xt_idxstripes_new(struct Xt_stripe const *stripes, int num_stripes)
Xt_idxlist xt_idxvec_prealloc_new(const Xt_int *idxvec, int num_indices)
Definition xt_idxvec.c:307
PPM_DSO_INTERNAL const Xt_int * xt_idxvec_get_sorted_vector(Xt_idxlist idxvec, Xt_config config)
Definition xt_idxvec.c:565
utility routines for MPI
#define xt_mpi_call(call, comm)
Definition xt_mpi.h:68
size_t xt_stripes_merge_copy(size_t num_stripes, struct Xt_stripe *stripes_dst, const struct Xt_stripe *stripes_src, bool lookback)
Definition xt_stripe.c:163
#define XT_SORT_FLAGS(ntrans_up, ntrans_dn)
@ sort_mask