41 sizeof(*collection_selection) +
52 return collection_selection;
58 if (!collection_selection)
return NULL;
61 sizeof(*collection_selection) +
62 (collection_selection->is_contiguous ? 0 :
63 (collection_selection->collection_size *
64 sizeof(*collection_selection->selection_indices)));
68 memcpy(copy, collection_selection, mem_size);
76 free(collection_selection);
82 return (collection_selection == NULL)?1:collection_selection->is_contiguous;
88 return (collection_selection == NULL)?0:collection_selection->collection_size;
94 if (!collection_selection)
return NULL;
96 collection_selection->is_contiguous ?
97 NULL : collection_selection->selection_indices;
113 max_index = SIZE_MAX;
126 YAC_ASSERT(indices != NULL,
"internal error");
128 max_index = indices[0];
130 if (indices[i] > max_index) {
131 max_index = indices[i];
148 ret = (a == NULL) - (b == NULL);
155 ret = (size_a > size_b) - (size_a < size_b);
162 if (contig_a && contig_b)
return 0;
165 ret = contig_a - contig_b;
172 for (
size_t i = 0; i < size_a; ++i) {
173 ret = (indices_a[i] > indices_b[i]) - (indices_a[i] < indices_b[i]);
186 if (sel == NULL) sel = &empty_sel;
188 int size_t_pack_size, int_pack_size, indices_pack_size = 0;
192 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &int_pack_size), comm);
205 return (
size_t)size_t_pack_size +
206 (size_t)int_pack_size +
207 (
size_t)indices_pack_size;
212 void *
buffer,
int buffer_size,
int * position, MPI_Comm comm) {
217 if (sel == NULL) sel = &empty_sel;
222 buffer, buffer_size, position, comm), comm);
227 buffer, buffer_size, position, comm), comm);
242 void const *
buffer,
int buffer_size,
int * position, MPI_Comm comm) {
246 MPI_Unpack(
buffer, buffer_size, position,
251 MPI_Unpack(
buffer, buffer_size, position,
#define YAC_ASSERT(exp, msg)
int yac_collection_selection_is_contiguous(struct yac_collection_selection const *collection_selection)
Query whether a selection is contiguous.
size_t yac_collection_selection_get_collection_size(struct yac_collection_selection const *collection_selection)
Get the size of the collection selection.
struct yac_collection_selection * yac_collection_selection_unpack(void const *buffer, int buffer_size, int *position, MPI_Comm comm)
Unpack a collection selection from a contiguous MPI buffer.
size_t yac_collection_selection_get_pack_size(struct yac_collection_selection const *sel, MPI_Comm comm)
Compute the MPI pack size of a collection selection.
size_t const * yac_collection_selection_get_indices(struct yac_collection_selection const *collection_selection)
Get explicit selection indices if non-contiguous.
void yac_collection_selection_delete(struct yac_collection_selection *collection_selection)
Delete a collection selection object.
int yac_collection_selection_compare(struct yac_collection_selection const *a, struct yac_collection_selection const *b)
Compare two collection selections.
struct yac_collection_selection * yac_collection_selection_copy(const struct yac_collection_selection *collection_selection)
Selection of indices from a collection.
void yac_collection_selection_pack(struct yac_collection_selection const *sel, void *buffer, int buffer_size, int *position, MPI_Comm comm)
Pack a collection selection into a contiguous MPI buffer.
struct yac_collection_selection * yac_collection_selection_new(size_t collection_size, size_t const *selection_indices)
Create a new collection selection.
size_t yac_collection_selection_get_max_index(struct yac_collection_selection const *selection)
Get the maximum index of a collection selection.
size_t selection_indices[]
#define yac_mpi_call(call, comm)