53 if (redists != NULL) {
54 int redists_are_null = redists[0] == NULL;
55 for (
size_t i = 1; i < num_redists; ++i)
57 redists_are_null == (redists[i] == NULL),
58 "ERROR(combine_redists): invalid argument")
59 if (redists_are_null)
return NULL;
65 if (num_redists == 1)
return xt_redist_copy(redists[0]);
68 xt_redist_collection_new(
70 xt_redist_get_MPI_Comm(redists[0]));
73 Xt_redist * redists_buffer =
76 for (
size_t j = 0; j < num_redists; ++j)
77 redists_buffer[i * num_redists + j] = redists[j];
79 xt_redist_collection_new(
81 xt_redist_get_MPI_Comm(redists[0]));
89 char const * routine_name) {
93 "ERROR(%s): state of exchange \"%s\" is inconsistent",
94 routine_name, exchange->
name);
102 xt_redist_s_exchange(
118 exchange->
request = XT_REQUEST_NULL;
123 (
redist != NULL) && (xt_redist_get_num_send_msg(
redist) > 0);
125 (
redist != NULL) && (xt_redist_get_num_recv_msg(
redist) > 0);
160 (exchange->
redist == NULL)?NULL:xt_redist_copy(exchange->
redist),
188 "the \"%s\"-exchange is currently in wait state (are you missing a get?)",
189 routine_name, exchange->
name);
192 "the \"%s\"-exchange is currently in wait state (are you missing a put?)",
193 routine_name, exchange->
name);
197 xt_request_wait(&(exchange->
request));
210 "ERROR(%s): invalid exchange state", routine_name);
212 switch (exchange->
state) {
236 "ERROR(%s): invalid exchange state", routine_name);
238 switch (exchange->
state) {
262 "ERROR(%s): invalid exchange state", routine_name);
264 switch (exchange->
state) {
279 char const * routine_name) {
282 if (exchange->
redist != NULL) {
294 "ERROR(%s): the \"%s\"-exchange is not in idle state, "
295 "internal error?", routine_name, exchange->
name);
306 "ERROR(%s): the \"%s\"-exchange is invalid state, "
307 "internal error?", routine_name, exchange->
name);
316 xt_request_wait(&(exchange->
request));
323 "ERROR(%s): the \"%s\"-exchange is not in idle state, "
324 "are you missing a get or wait?", routine_name, exchange->
name);
327 xt_redist_a_exchange(
339 xt_request_wait(&(exchange->
request));
346 "ERROR(%s): the \"%s\"-exchange is in an invalid state",
347 routine_name, exchange->
name);
349 switch (exchange->
state) {
355 xt_redist_a_exchange(
356 exchange->
redist, exchange->
count, (
void const **)send_data,
366 for (
size_t i = 0; i < exchange->
count; ++i)
368 (
void const *)(send_data[i]);
380 int is_async,
char const * routine_name) {
383 if (exchange->
redist != NULL) {
395 "ERROR(%s): the \"%s\"-exchange is not in idle state, "
396 "internal error?", routine_name, exchange->
name);
405 xt_request_wait(&(exchange->
request));
412 "ERROR(%s): the \"%s\"-exchange is not in idle state, "
413 "internal error?", routine_name, exchange->
name);
416 void const ** send_data =
421 xt_redist_a_exchange(
422 exchange->
redist, exchange->
count, send_data, (
void **)recv_data,
426 xt_redist_s_exchange(
427 exchange->
redist, exchange->
count, send_data, (
void **)recv_data);
444 xt_request_wait(&(exchange->
request));
455 xt_request_wait(&(exchange->
request));
462 "ERROR(%s): the \"%s\"-exchange is in an invalid state",
463 routine_name, exchange->
name);
465 switch (exchange->
state) {
470 void const ** send_data =
475 xt_redist_a_exchange(
477 (
void **)recv_data, &(exchange->
request));
480 xt_redist_s_exchange(
492 "ERROR(%s): the \"%s\"-exchange is in an invalid state, "
493 "is there a put missing?", routine_name, exchange->
name);
497 for (
size_t i = 0; i < exchange->
count; ++i)
512 char const * routine_name) {
514 exchange, recv_data, 0, routine_name);
519 char const * routine_name) {
521 exchange, recv_data, 1, routine_name);
526 double const ** send_data_,
double ** recv_data_,
527 char const * routine_name) {
530 if (exchange->
redist != NULL) {
534 xt_request_wait(&(exchange->
request));
541 "the \"%s\"-exchange is not in idle state, are you missing a get or wait?",
542 routine_name, exchange->
name);
544 void const ** send_data =
546 (
void const **)(send_data_):(
void const **)(exchange->
dummy_buffer);
550 xt_redist_s_exchange(
551 exchange->
redist, exchange->
count, send_data, recv_data);
559 "the \"%s\"-exchange is not in idle state",
560 routine_name, exchange->
name);
573 if (exchange == NULL)
return;
580 free(exchange->
name);
582 if (exchange->
redist != NULL) {
583 xt_request_wait(&(exchange->
request));
584 xt_redist_delete(exchange->
redist);
#define YAC_ASSERT(exp, msg)
int yac_interpolation_exchange_is_target(struct yac_interpolation_exchange *exchange)
Query whether the current process participates as target.
static Xt_redist combine_redists(Xt_redist *redists, size_t num_redists, size_t collection_size)
static void do_empty_exchange(struct yac_interpolation_exchange *exchange, int is_put, char const *routine_name)
static struct yac_interpolation_exchange * yac_interpolation_exchange_new_(Xt_redist redist, size_t count, char const *name, int with_frac_mask)
void yac_interpolation_exchange_execute_get_async(struct yac_interpolation_exchange *exchange, double **recv_data, char const *routine_name)
Execute the get phase asynchronously.
void yac_interpolation_exchange_inc_ref_count(struct yac_interpolation_exchange *exchange)
Increase the reference count of an exchange object.
enum YAC_INTERP_EXCH_TEST_STATUS yac_interpolation_exchange_put_test(struct yac_interpolation_exchange *exchange, char const *routine_name)
Test whether the put phase has completed.
struct yac_interpolation_exchange * yac_interpolation_exchange_copy(struct yac_interpolation_exchange *exchange)
Create a deep copy of an interpolation exchange.
void yac_interpolation_exchange_delete(struct yac_interpolation_exchange *exchange, char const *routine_name)
Delete an interpolation exchange and release resources.
static void yac_interpolation_exchange_execute_get_(struct yac_interpolation_exchange *exchange, double **recv_data, int is_async, char const *routine_name)
void yac_interpolation_exchange_execute_get(struct yac_interpolation_exchange *exchange, double **recv_data, char const *routine_name)
Execute the get phase and receive target data synchronously.
void yac_interpolation_exchange_wait(struct yac_interpolation_exchange *exchange, char const *routine_name)
Wait for completion of pending put/get phases.
enum YAC_INTERP_EXCH_TEST_STATUS yac_interpolation_exchange_get_test(struct yac_interpolation_exchange *exchange, char const *routine_name)
Test whether the get phase has completed.
void yac_interpolation_exchange_execute_put(struct yac_interpolation_exchange *exchange, double const **send_data, char const *routine_name)
Execute only the put phase asynchronously.
@ EXCHANGE_UNSET
exchange is source and/or target
struct yac_interpolation_exchange * yac_interpolation_exchange_new(Xt_redist *redists, size_t num_fields, size_t collection_size, int with_frac_mask, char const *name)
Create a new interpolation exchange object.
int yac_interpolation_exchange_with_frac_mask(struct yac_interpolation_exchange *exchange)
Query whether the exchange has fractional mask support.
void yac_interpolation_exchange_execute(struct yac_interpolation_exchange *exchange, double const **send_data_, double **recv_data_, char const *routine_name)
Execute the full exchange (put + get) synchronously.
enum YAC_INTERP_EXCH_STATUS yac_interpolation_exchange_status(struct yac_interpolation_exchange *exchange, char const *routine_name)
@ EXCHANGE_WAIT_GET
contains valid put data, but is not yet communicated
@ EXCHANGE_WAIT_PUT
exchange is currently not in use
@ EXCHANGE_ACTIVE
contains valid get data, but is not yet communicated
int yac_interpolation_exchange_is_source(struct yac_interpolation_exchange *exchange)
Query whether the current process participates as source.
Interpolation exchange object for temporary buffers and MPI exchanges.
YAC_INTERP_EXCH_TEST_STATUS
Status returned by test routines.
@ YAC_INTERP_EXCH_INCOMPLETE
Operation still in progress.
@ YAC_INTERP_EXCH_COMPLETE
No ongoing operation.
YAC_INTERP_EXCH_STATUS
Status of an interpolation exchange.
@ YAC_INTERP_EXCH_ACTIVE
Exchange is active.
@ YAC_INTERP_EXCH_WAIT_PUT
Waiting for put phase completion.
@ YAC_INTERP_EXCH_WAIT_GET
Waiting for get phase completion.
@ YAC_INTERP_EXCH_IDLE
No ongoing exchange.
#define xcalloc(nmemb, size)
enum empty_exchange_state empty_state
enum exchange_state state
void const ** temp_send_buffer
#define YAC_ASSERT_F(exp, format,...)