38 sizeof(*collection_selection) +
49 return collection_selection;
55 if (!collection_selection)
return NULL;
58 sizeof(*collection_selection) +
59 (collection_selection->is_contiguous ? 0 :
60 (collection_selection->collection_size *
61 sizeof(*collection_selection->selection_indices)));
65 memcpy(copy, collection_selection, mem_size);
73 free(collection_selection);
79 return (collection_selection == NULL)?1:collection_selection->is_contiguous;
85 return (collection_selection == NULL)?0:collection_selection->collection_size;
91 if (!collection_selection)
return NULL;
93 collection_selection->is_contiguous ?
94 NULL : collection_selection->selection_indices;
110 max_index = SIZE_MAX;
124 indices != NULL,
"ERROR(yac_collection_selection_get_max_index): "
127 max_index = indices[0];
129 if (indices[i] > max_index) {
130 max_index = indices[i];
147 ret = (a == NULL) - (b == NULL);
154 ret = (size_a > size_b) - (size_a < size_b);
161 if (contig_a && contig_b)
return 0;
164 ret = contig_a - contig_b;
171 for (
size_t i = 0; i < size_a; ++i) {
172 ret = (indices_a[i] > indices_b[i]) - (indices_a[i] < indices_b[i]);
185 if (sel == NULL) sel = &empty_sel;
187 int size_t_pack_size, int_pack_size, indices_pack_size = 0;
191 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &int_pack_size), comm);
197 "ERROR(yac_collection_selection_get_pack_size): collection too large");
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);
233 "ERROR(yac_collection_selection_pack): collection too large");
243 void const *
buffer,
int buffer_size,
int * position, MPI_Comm comm) {
247 MPI_Unpack(
buffer, buffer_size, position,
252 MPI_Unpack(
buffer, buffer_size, position,
269 "ERROR(yac_collection_selection_unpack): collection too large");
#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)