68#if ! (HAVE_DECL___BUILTIN_CTZL || HAVE_DECL___BUILTIN_CLZL) \
69 && (HAVE_DECL___LZCNT && SIZEOF_LONG == SIZEOF_INT \
70 || HAVE_DECL___LZCNT64 && SIZEOF_LONG == 8 && CHAR_BIT == 8)
77 MPI_Comm_rank(comm, &rank);
79 char error_string[MPI_MAX_ERROR_STRING];
80 int length_of_error_string, error_class;
82 MPI_Error_class(error_code, &error_class);
83 MPI_Error_string(error_class, error_string, &length_of_error_string);
84 fprintf(stderr,
"%3d: %s\n", rank, error_string);
85 MPI_Error_string(error_code, error_string, &length_of_error_string);
86 fprintf(stderr,
"%3d: %s\n", rank, error_string);
87 MPI_Abort(comm, error_code);
94 if (!disp_len)
return 0;
96 int cur_stride = 1, cur_size = 1;
97 int last_disp = disp[0];
98 for (
size_t p = 1; p < disp_len; ++p) {
99 int new_disp = disp[p];
100 int new_stride = new_disp - last_disp;
102 cur_stride = new_stride;
104 }
else if (new_stride == cur_stride) {
107 }
else if (cur_size > 2 || (cur_size == 2 && cur_stride == 1) ) {
116 cur_stride = new_stride;
118 last_disp = new_disp;
121 if (cur_size > 2 || (cur_size == 2 && cur_stride == 1)) {
123 }
else if (cur_size == 2) {
136 if (disp_len<1)
return 0;
138 int cur_start = disp[0], cur_stride = 1, cur_size = 1;
139 int last_disp = cur_start;
141 for (
size_t p = 1; p < disp_len; ++p) {
142 int new_disp = disp[p];
143 int new_stride = new_disp - last_disp;
145 cur_stride = new_stride;
147 }
else if (new_stride == cur_stride) {
150 }
else if (cur_size > 2 || (cur_size == 2 && cur_stride == 1) ) {
152 v[i] = (
struct Xt_offset_ext){ .start = cur_start, .stride = cur_stride,
155 cur_start = new_disp;
160 v[i].start = cur_start;
164 cur_start += cur_stride;
166 cur_stride = new_stride;
168 last_disp = new_disp;
171 if (cur_size > 2 || (cur_size == 2 && cur_stride == 1)) {
172 v[i] = (
struct Xt_offset_ext){ .start = cur_start, .stride = cur_stride,
175 }
else if (cur_size == 2) {
176 v[i].start = cur_start;
180 v[i].start = cur_start + cur_stride;
185 v[i].start = cur_start;
213 void *attribute_val_out,
int *flag)
224 *(
void **)attribute_val_out = new_comm_attr;
226 retval = MPI_SUCCESS;
229 retval = MPI_ERR_NO_MEM;
237 void *attribute_val,
void *
XT_UNUSED(extra_state))
274 &attr_val, &attr_found),
276 return attr_found ? attr_val : NULL;
279#if HAVE_DECL___BUILTIN_CTZL
280#define ctzl(v) (__builtin_ctzl(v))
281#elif HAVE_DECL___BUILTIN_CLZL \
282 || HAVE_DECL___LZCNT && SIZEOF_LONG == SIZEOF_INT \
283 || HAVE_DECL___LZCNT64 && SIZEOF_LONG == 8 && CHAR_BIT == 8
285ctzl(
unsigned long v) {
287 ulong_bits =
sizeof (
unsigned long) * CHAR_BIT,
291 int c = ulong_bits - 1 - (int)
292#
if HAVE_DECL___BUILTIN_CTZL
294#elif HAVE_DECL___LZCNT && SIZEOF_LONG == SIZEOF_INT
306 ulong_bits =
sizeof (
unsigned long) * CHAR_BIT,
309 unsigned int c = ulong_bits;
310 v &= (
unsigned long)-(
long)v;
312#if SIZEOF_UNSIGNED_LONG * CHAR_BIT == 64
313 if (v & UINT64_C(0x00000000ffffffff)) c -= 32;
314 if (v & UINT64_C(0x0000ffff0000ffff)) c -= 16;
315 if (v & UINT64_C(0x00ff00ff00ff00ff)) c -= 8;
316 if (v & UINT64_C(0x0f0f0f0f0f0f0f0f)) c -= 4;
317 if (v & UINT64_C(0x3333333333333333)) c -= 2;
318 if (v & UINT64_C(0x5555555555555555)) c -= 1;
319#elif SIZEOF_UNSIGNED_LONG * CHAR_BIT == 32
320 if (v & 0x0000FFFFUL) c -= 16;
321 if (v & 0x00FF00FFUL) c -= 8;
322 if (v & 0x0F0F0F0FUL) c -= 4;
323 if (v & 0x33333333UL) c -= 2;
324 if (v & 0x55555555UL) c -= 1;
326 error
"Unexpected size of long.\n"
351 =
xmalloc(
sizeof (*new_comm_xt_attr_val)
361 new_comm_xt_attr_val), comm_dest);
365 unset_lsb = ~used_map_entry & (used_map_entry + 1),
367 comm_xt_attr_val->
used_map[position] = used_map_entry | unset_lsb;
379 comm_attr), comm_dest);
416 MPI_Request *restrict req,
417 int *restrict ops_completed,
MPI_Comm comm)
420 size_t num_req_ = (size_t)*num_req;
422#if __GNUC__ >= 11 && __GNUC__ <= 13
425#pragma GCC diagnostic push
426#pragma GCC diagnostic ignored "-Wstringop-overflow"
427#pragma GCC diagnostic ignored "-Wstringop-overread"
429 xt_mpi_call(MPI_Testsome(*num_req, req, &done_count, ops_completed,
430 MPI_STATUSES_IGNORE), comm);
431#if __GNUC__ >= 11 && __GNUC__ <= 13
432#pragma GCC diagnostic pop
435 if (done_count != MPI_UNDEFINED) {
436 if (num_req_ > (
size_t)done_count) {
437 for (
size_t i = 0, j = num_req_;
438 i < (size_t)done_count && j >= num_req_ - (size_t)done_count;
440 if (ops_completed[i] < (
int)num_req_ - done_count) {
441 while (req[--j] == MPI_REQUEST_NULL);
442 req[ops_completed[i]] = req[j];
444 num_req_ -= (size_t)done_count;
449 *num_req = (int)num_req_;
450 return num_req_ == 0;
455xt_mpi_test_some_mt(
int *restrict num_req,
456 MPI_Request *restrict req,
457 int *restrict ops_completed,
MPI_Comm comm)
460 size_t num_req_ = (size_t)*num_req;
462 size_t num_threads = (size_t)omp_get_num_threads(),
463 tid = (size_t)omp_get_thread_num();
464 size_t start_req = (num_req_ * tid) / num_threads,
465 nreq_ = (num_req_ * (tid+1)) / num_threads - start_req;
467 for (
size_t i = start_req; i < start_req + nreq_; ++i)
468 ops_completed[i] = -1;
469#if __GNUC__ >= 11 && __GNUC__ <= 13
472#pragma GCC diagnostic push
473#pragma GCC diagnostic ignored "-Wstringop-overflow"
474#pragma GCC diagnostic ignored "-Wstringop-overread"
476 xt_mpi_call(MPI_Testsome((
int)nreq_, req+start_req, &done_count,
477 ops_completed+start_req, MPI_STATUSES_IGNORE), comm);
478#if __GNUC__ >= 11 && __GNUC__ <= 13
479#pragma GCC diagnostic pop
481 if (done_count == MPI_UNDEFINED)
485 *num_req -= done_count;
487 done_count = (int)num_req_ - *num_req;
490 if (num_req_ > (
size_t)done_count) {
491 for (
size_t i = 0, j = 0; i < num_req_; ++i)
492 if (req[i] != MPI_REQUEST_NULL)
495 *num_req = (int)num_req_ - done_count;
497 num_req_ -= (size_t)done_count;
498 return num_req_ == 0;
add versions of standard API functions not returning on error
base definitions header file
MPI_Comm xt_mpi_comm_smart_dup(MPI_Comm comm, int *tag_offset)
unsigned long used_map_elem
size_t xt_disp2ext_count(size_t disp_len, const int *disp)
void xt_mpi_error(int error_code, MPI_Comm comm)
static int xt_mpi_tag_ub_val
void xt_mpi_finalize(void)
size_t xt_disp2ext(size_t disp_len, const int *disp, struct Xt_offset_ext *restrict v)
static int xt_mpi_comm_internal_keyval_delete(MPI_Comm XT_UNUSED(comm), int XT_UNUSED(comm_keyval), void *attribute_val, void *XT_UNUSED(extra_state))
static int xt_mpi_comm_internal_keyval_copy(MPI_Comm XT_UNUSED(oldcomm), int XT_UNUSED(keyval), void *XT_UNUSED(extra_state), void *XT_UNUSED(attribute_val_in), void *attribute_val_out, int *flag)
static int xt_mpi_comm_internal_keyval
void xt_mpi_comm_smart_dedup(MPI_Comm *comm, int tag_offset)
bool xt_mpi_test_some(int *restrict num_req, MPI_Request *restrict req, int *restrict ops_completed, MPI_Comm comm)
static int ctzl(unsigned long v)
static struct xt_mpi_comm_internal_attr * xt_mpi_comm_get_internal_attr(MPI_Comm comm)
void xt_mpi_comm_mark_exclusive(MPI_Comm comm)
#define xt_mpi_call(call, comm)