86 int buffer_size,
int *position,
89 idxlist->
vtable->
pack(idxlist, buffer, buffer_size,
112 die(
"xt_idxlist_get_indices_const: fatal error: "
113 "get_indices_const not implemented");
131 INSTR_DEF(instr_fallback,
"xt_idxlist_get_index_stripes.fallback")
142 Xt_int *indices =
xmalloc((
size_t)num_indices *
sizeof (indices[0]));
147 stripes, num_stripes);
166 int num_pos,
Xt_int *indices,
169 INSTR_DEF(instr_fallback,
"xt_idxlist_get_intersection.fallback")
183 for (
int ip=0; ip<num_pos; ip++) {
185 &indices[ip]) != 0) {
186 indices[ip] = undef_idx;
204 int num_indices,
int * positions,
205 int single_match_only) {
207 INSTR_DEF(instr_fallback,
"xt_idxlist_get_positions_of_indices.fallback")
220 tmp_indices =
xmalloc((
size_t)num_tmp_indices *
sizeof (tmp_indices[0]));
226 num_indices, positions,
239 const struct Xt_stripe stripes[num_stripes],
242 int single_match_only)
247 num_stripes, stripes, num_ext, pos_ext, single_match_only);
257 num_stripes, stripes, num_ext, pos_ext, single_match_only);
265 int * position,
int offset) {
274 int num_indices,
int * positions,
277 INSTR_DEF(instr_fallback,
"xt_idxlist_get_intersection.fallback")
286 for (
int i = 0; i < num_indices; ++i) {
288 int temp_position, offset;
297 &temp_position, offset);
300 positions[i] = temp_position;
319 Xt_int global_stride[ndim],
322 idx = (
Xt_int)(idx - global_start_index);
324 for (
size_t i = 0; i < ndim - 1; ++i) {
325 position[i] = (
Xt_int)(idx / global_stride[i]);
326 idx = (
Xt_int)(idx % global_stride[i]);
329 position[ndim - 1] = idx;
333 const Xt_int global_size[ndim],
334 Xt_int global_start_index,
337 INSTR_DEF(instr_fallback,
"xt_idxlist_get_bounding_box.fallback")
341 if (num_indices == 0) {
343 for (
size_t i = 0; i < ndim; ++i) {
353 global_start_index, bounds);
359 Xt_int global_stride[ndim];
361 global_stride[ndim - 1] = 1;
363 for (
size_t i = ndim - 2; i < ndim; --i)
364 global_stride[i] = (
Xt_int)(global_stride[i+1] * global_size[i+1]);
367 Xt_int curr_position[ndim];
371 global_start_index, curr_position);
373 for (
size_t i = 0; i < ndim; ++i) {
374 bounds[i].start = curr_position[i];
378 for (
int j = 1; j < num_indices; ++j) {
382 global_start_index, curr_position);
384 for (
size_t i = 0; i < ndim; ++i) {
386 if (curr_position[i] < bounds[i].
start) {
388 bounds[i].size = (
Xt_int)(bounds[i].size + curr_position[i] - bounds[i].
start);
389 bounds[i].start = curr_position[i];
391 }
else if (curr_position[i] >= bounds[i].
start + bounds[i].size) {
393 bounds[i].size = (
Xt_int)(curr_position[i] - bounds[i].
start + 1);
403 static pthread_mutex_t nextIdMutex = PTHREAD_MUTEX_INITIALIZER;
411 if (pthread_mutex_lock(&nextIdMutex))
412 die(
"unexpected pthread locking error");
416 die(
"unique ID counter overflow");
418 if (pthread_mutex_unlock(&nextIdMutex))
419 die(
"unexpected pthread locking error");
427 assert(idxlist->
uid);
add versions of standard API functions not returning on error
const struct xt_idxlist_vtable * vtable
size_t(* get_pack_size)(Xt_idxlist, MPI_Comm)
Xt_int(* get_max_index)(Xt_idxlist)
int(* get_position_of_index_off)(Xt_idxlist, Xt_int, int *, int)
int(* get_index_at_position)(Xt_idxlist, int, Xt_int *)
int(* get_indices_at_positions)(Xt_idxlist idxlist, const int *positions, int num, Xt_int *index, Xt_int undef_idx)
Xt_int const *(* get_indices_const)(Xt_idxlist idxlist)
void(* delete)(Xt_idxlist)
int(* get_pos_exts_of_index_stripes)(Xt_idxlist, int, const struct Xt_stripe *, int *, struct Xt_pos_ext **, int)
void(* pack)(Xt_idxlist, void *, int, int *, MPI_Comm)
void(* get_index_stripes)(Xt_idxlist, struct Xt_stripe **, int *)
Xt_idxlist(* copy)(Xt_idxlist)
int(* get_position_of_index)(Xt_idxlist, Xt_int, int *)
void(* get_bounding_box)(Xt_idxlist idxlist, unsigned ndim, const Xt_int global_size[ndim], Xt_int global_start_index, struct Xt_bounds bounds[ndim])
void(* get_indices)(Xt_idxlist, Xt_int *indices)
Xt_int(* get_min_index)(Xt_idxlist)
int(* get_positions_of_indices)(Xt_idxlist, Xt_int const *, int, int *, int)
int(* get_positions_of_indices_off)(Xt_idxlist, Xt_int const *, int, int *, int *)
base definitions header file
void xt_idxlist_get_index_stripes_keep_buf(Xt_idxlist idxlist, struct Xt_stripe **stripes, int *num_stripes)
int xt_idxlist_get_num_indices(Xt_idxlist idxlist)
int xt_idxlist_get_positions_of_indices(Xt_idxlist idxlist, Xt_int const *indices, int num_indices, int *positions, int single_match_only)
Xt_int xt_idxlist_get_min_index(Xt_idxlist idxlist)
Xt_int xt_idxlist_get_max_index(Xt_idxlist idxlist)
int xt_idxlist_get_position_of_index(Xt_idxlist idxlist, Xt_int idx, int *position)
void xt_idxlist_get_indices(Xt_idxlist idxlist, Xt_int *indices)
int xt_idxlist_get_positions_of_indices_off(Xt_idxlist idxlist, const Xt_int *indices, int num_indices, int *positions, int *offsets)
Xt_uid xt_idxlist_new_uid(void)
int xt_idxlist_get_index_at_position(Xt_idxlist idxlist, int position, Xt_int *idx)
int xt_idxlist_get_position_of_index_off(Xt_idxlist idxlist, Xt_int idx, int *position, int offset)
Xt_uid xt_idxlist_get_uid(Xt_idxlist idxlist)
void xt_idxlist_pack(Xt_idxlist idxlist, void *buffer, int buffer_size, int *position, MPI_Comm comm)
size_t xt_idxlist_get_pack_size(Xt_idxlist idxlist, MPI_Comm comm)
int xt_idxlist_get_indices_at_positions(Xt_idxlist idxlist, const int *positions, int num_pos, Xt_int *indices, Xt_int undef_idx)
void xt_idxlist_get_index_stripes(Xt_idxlist idxlist, struct Xt_stripe **stripes, int *num_stripes)
void xt_idxlist_get_bounding_box(Xt_idxlist idxlist, unsigned ndim, const Xt_int global_size[ndim], Xt_int global_start_index, struct Xt_bounds bounds[ndim])
int xt_idxlist_get_pos_exts_of_index_stripes(Xt_idxlist idxlist, int num_stripes, const struct Xt_stripe stripes[num_stripes], int *num_ext, struct Xt_pos_ext **pos_ext, int single_match_only)
Xt_idxlist xt_idxlist_copy(Xt_idxlist idxlist)
const Xt_int * xt_idxlist_get_indices_const(Xt_idxlist idxlist)
static void get_position_in_ndim_space(Xt_int idx, unsigned ndim, Xt_int global_stride[ndim], Xt_int global_start_index, Xt_int position[ndim])
void xt_idxlist_delete(Xt_idxlist idxlist)
Provide non-public declarations common to all index lists.
Xt_idxlist xt_idxstripes_prealloc_new(const struct Xt_stripe *stripes, int num_stripes)
Xt_idxlist xt_idxvec_prealloc_new(const Xt_int *idxvec, int num_indices)
void xt_convert_indices_to_stripes_keep_buf(const Xt_int *restrict indices, int num_indices, struct Xt_stripe **stripes, int *num_stripes)