85 int buffer_size,
int *position,
88 idxlist->
vtable->
pack(idxlist, buffer, buffer_size,
111 die(
"xt_idxlist_get_indices_const: fatal error: " 112 "get_indices_const not implemented");
121 INSTR_DEF(instr_fallback,
"xt_idxlist_get_index_stripes.fallback")
134 Xt_int *indices =
xmalloc((
size_t)num_indices *
sizeof (indices[0]));
139 stripes, num_stripes);
155 int num_pos,
Xt_int *indices,
158 INSTR_DEF(instr_fallback,
"xt_idxlist_get_intersection.fallback")
172 for (
int ip=0; ip<num_pos; ip++) {
174 &indices[ip]) != 0) {
175 indices[ip] = undef_idx;
194 int single_match_only) {
196 INSTR_DEF(instr_fallback,
"xt_idxlist_get_positions_of_indices.fallback")
209 tmp_indices =
xmalloc((
size_t)num_tmp_indices *
sizeof (tmp_indices[0]));
215 num_indices, positions,
228 const struct Xt_stripe stripes[num_stripes],
231 int single_match_only)
236 num_stripes, stripes, num_ext, pos_ext, single_match_only);
246 num_stripes, stripes, num_ext, pos_ext, single_match_only);
254 int * position,
int offset) {
263 int num_indices,
int * positions,
266 INSTR_DEF(instr_fallback,
"xt_idxlist_get_intersection.fallback")
275 for (
int i = 0; i < num_indices; ++i) {
277 int temp_position, offset;
286 &temp_position, offset);
289 positions[i] = temp_position;
308 Xt_int global_stride[ndim],
311 idx = (
Xt_int)(idx - global_start_index);
313 for (
size_t i = 0; i < ndim - 1; ++i) {
314 position[i] = (
Xt_int)(idx / global_stride[i]);
315 idx = (
Xt_int)(idx % global_stride[i]);
318 position[ndim - 1] = idx;
322 const Xt_int global_size[ndim],
323 Xt_int global_start_index,
326 INSTR_DEF(instr_fallback,
"xt_idxlist_get_bounding_box.fallback")
330 if (num_indices == 0) {
332 for (
size_t i = 0; i < ndim; ++i) {
342 global_start_index, bounds);
348 Xt_int global_stride[ndim];
350 global_stride[ndim - 1] = 1;
352 for (
size_t i = ndim - 2; i < ndim; --i)
353 global_stride[i] = (
Xt_int)(global_stride[i+1] * global_size[i+1]);
356 Xt_int curr_position[ndim];
360 global_start_index, curr_position);
362 for (
size_t i = 0; i < ndim; ++i) {
363 bounds[i].start = curr_position[i];
367 for (
int j = 1; j < num_indices; ++j) {
371 global_start_index, curr_position);
373 for (
size_t i = 0; i < ndim; ++i) {
375 if (curr_position[i] < bounds[i].
start) {
377 bounds[i].size = (
Xt_int)(bounds[i].size + curr_position[i] - bounds[i].start);
378 bounds[i].start = curr_position[i];
380 }
else if (curr_position[i] >= bounds[i].start + bounds[i].size) {
382 bounds[i].size = (
Xt_int)(curr_position[i] - bounds[i].start + 1);
392 static pthread_mutex_t nextIdMutex = PTHREAD_MUTEX_INITIALIZER;
400 if (pthread_mutex_lock(&nextIdMutex))
401 die(
"unexpected pthread locking error");
405 die(
"unique ID counter overflow");
407 if (pthread_mutex_unlock(&nextIdMutex))
408 die(
"unexpected pthread locking error");
416 assert(idxlist->
uid);
const Xt_int * xt_idxlist_get_indices_const(Xt_idxlist idxlist)
void xt_idxlist_get_indices(Xt_idxlist idxlist, Xt_int *indices)
int xt_idxlist_get_positions_of_indices(Xt_idxlist idxlist, Xt_int const *indices, int num_indices, int *positions, int single_match_only)
int(* get_position_of_index)(Xt_idxlist, Xt_int, int *)
base definitions header file
int xt_idxlist_get_position_of_index_off(Xt_idxlist idxlist, Xt_int idx, int *position, int offset)
int(* get_pos_exts_of_index_stripes)(Xt_idxlist, int, const struct Xt_stripe *, int *, struct Xt_pos_ext **, int)
Xt_idxlist xt_idxlist_copy(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])
Xt_idxlist xt_idxstripes_prealloc_new(const struct Xt_stripe *stripes, int num_stripes)
add versions of standard API functions not returning on error
int(* get_index_at_position)(Xt_idxlist, int, Xt_int *)
void xt_idxlist_get_index_stripes(Xt_idxlist idxlist, struct Xt_stripe **stripes, int *num_stripes)
Xt_uid xt_idxlist_new_uid(void)
int(* get_indices_at_positions)(Xt_idxlist idxlist, const int *positions, int num, Xt_int *index, Xt_int undef_idx)
void xt_convert_indices_to_stripes(const Xt_int *indices, int num_indices, struct Xt_stripe **stripes, int *num_stripes)
Xt_uid xt_idxlist_get_uid(Xt_idxlist idxlist)
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_delete(Xt_idxlist idxlist)
int(* get_position_of_index_off)(Xt_idxlist, Xt_int, int *, int)
void(* get_indices)(Xt_idxlist, Xt_int *indices)
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])
int(* get_positions_of_indices_off)(Xt_idxlist, Xt_int const *, int, int *, int *)
int xt_idxlist_get_num_indices(Xt_idxlist idxlist)
Xt_idxlist(* copy)(Xt_idxlist)
Xt_int(* get_max_index)(Xt_idxlist)
Provide non-public declarations common to all index lists.
int xt_idxlist_get_positions_of_indices_off(Xt_idxlist idxlist, const Xt_int *indices, int num_indices, int *positions, int *offsets)
void(* get_index_stripes)(Xt_idxlist, struct Xt_stripe **, int *)
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)
void(* pack)(Xt_idxlist, void *, int, int *, MPI_Comm)
size_t xt_idxlist_get_pack_size(Xt_idxlist idxlist, MPI_Comm comm)
void(* delete)(Xt_idxlist)
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(* get_positions_of_indices)(Xt_idxlist, Xt_int const *, int, int *, int)
Xt_int xt_idxlist_get_max_index(Xt_idxlist idxlist)
Xt_int xt_idxlist_get_min_index(Xt_idxlist idxlist)
const struct xt_idxlist_vtable * vtable
Xt_int const *(* get_indices_const)(Xt_idxlist idxlist)
size_t(* get_pack_size)(Xt_idxlist, MPI_Comm)
Xt_int(* get_min_index)(Xt_idxlist)
int xt_idxlist_get_position_of_index(Xt_idxlist idxlist, Xt_int idx, int *position)
Xt_idxlist xt_idxvec_prealloc_new(const Xt_int *idxvec, int num_indices)
int xt_idxlist_get_index_at_position(Xt_idxlist idxlist, int position, Xt_int *idx)
void xt_idxlist_pack(Xt_idxlist idxlist, void *buffer, int buffer_size, int *position, MPI_Comm comm)