44 Xt_redist * redists,
size_t num_redists,
size_t collection_size) {
47 if (redists != NULL) {
48 int redists_are_null = redists[0] == NULL;
49 for (
size_t i = 1; i < num_redists; ++i)
51 redists_are_null == (redists[i] == NULL),
52 "ERROR(combine_redists): invalid argument")
53 if (redists_are_null)
return NULL;
58 if (collection_size == 1) {
59 if (num_redists == 1)
return xt_redist_copy(redists[0]);
62 xt_redist_collection_new(
63 redists, (
int)(num_redists * collection_size), -1,
64 xt_redist_get_MPI_Comm(redists[0]));
67 Xt_redist * redists_buffer =
68 xmalloc(collection_size * num_redists *
sizeof(*redists_buffer));
69 for (
size_t i = 0; i < collection_size; ++i)
70 for (
size_t j = 0; j < num_redists; ++j)
71 redists_buffer[i * num_redists + j] = redists[j];
73 xt_redist_collection_new(
74 redists_buffer, (
int)(num_redists * collection_size), -1,
75 xt_redist_get_MPI_Comm(redists[0]));
83 char const * routine_name) {
87 "ERROR(%s): state of exchange \"%s\" is inconsistent",
88 routine_name, exchange->
name);
110 exchange->
request = XT_REQUEST_NULL;
115 (
redist != NULL) && (xt_redist_get_num_send_msg(
redist) > 0);
117 (
redist != NULL) && (xt_redist_get_num_recv_msg(
redist) > 0);
133 Xt_redist * redists,
size_t num_fields,
size_t collection_size,
134 int with_frac_mask,
char const *
name) {
136 if (with_frac_mask) collection_size *= 2;
150 (exchange->
redist == NULL)?NULL:xt_redist_copy(exchange->
redist),
172 "the \"%s\"-exchange is currently in wait state (are you missing a get?)",
173 routine_name, exchange->
name);
176 "the \"%s\"-exchange is currently in wait state (are you missing a put?)",
177 routine_name, exchange->
name);
181 xt_request_wait(&(exchange->
request));
194 "ERROR(%s): invalid exchange state", routine_name);
196 switch (exchange->
state) {
205 xt_request_test(&(exchange->
request), &flag);
220 "ERROR(%s): invalid exchange state", routine_name);
222 switch (exchange->
state) {
231 xt_request_test(&(exchange->
request), &flag);
246 "ERROR(%s): invalid exchange state", routine_name);
248 switch (exchange->
state) {
263 char const * routine_name) {
266 if (exchange->
redist != NULL) {
278 "ERROR(%s): the \"%s\"-exchange is not in idle state, "
279 "internal error?", routine_name, exchange->
name);
290 "ERROR(%s): the \"%s\"-exchange is invalid state, "
291 "internal error?", routine_name, exchange->
name);
300 xt_request_wait(&(exchange->
request));
307 "ERROR(%s): the \"%s\"-exchange is not in idle state, "
308 "are you missing a get or wait?", routine_name, exchange->
name);
311 xt_redist_a_exchange(
323 xt_request_wait(&(exchange->
request));
330 "ERROR(%s): the \"%s\"-exchange is in an invalid state",
331 routine_name, exchange->
name);
333 switch (exchange->
state) {
339 xt_redist_a_exchange(
340 exchange->
redist, exchange->
count, (
void const **)send_data,
350 for (
size_t i = 0; i < exchange->
count; ++i)
352 (
void const *)(send_data[i]);
364 int is_async,
char const * routine_name) {
367 if (exchange->
redist != NULL) {
379 "ERROR(%s): the \"%s\"-exchange is not in idle state, "
380 "internal error?", routine_name, exchange->
name);
389 xt_request_wait(&(exchange->
request));
396 "ERROR(%s): the \"%s\"-exchange is not in idle state, "
397 "internal error?", routine_name, exchange->
name);
400 void const ** send_data =
405 xt_redist_a_exchange(
406 exchange->
redist, exchange->
count, send_data, (
void **)recv_data,
410 xt_redist_s_exchange(
411 exchange->
redist, exchange->
count, send_data, (
void **)recv_data);
428 xt_request_wait(&(exchange->
request));
439 xt_request_wait(&(exchange->
request));
446 "ERROR(%s): the \"%s\"-exchange is in an invalid state",
447 routine_name, exchange->
name);
449 switch (exchange->
state) {
454 void const ** send_data =
459 xt_redist_a_exchange(
461 (
void **)recv_data, &(exchange->
request));
464 xt_redist_s_exchange(
476 "ERROR(%s): the \"%s\"-exchange is in an invalid state, "
477 "is there a put missing?", routine_name, exchange->
name);
481 for (
size_t i = 0; i < exchange->
count; ++i)
496 char const * routine_name) {
498 exchange, recv_data, 0, routine_name);
503 char const * routine_name) {
505 exchange, recv_data, 1, routine_name);
510 double const ** send_data_,
double ** recv_data_,
511 char const * routine_name) {
514 if (exchange->
redist != NULL) {
518 xt_request_wait(&(exchange->
request));
525 "the \"%s\"-exchange is not in idle state, are you missing a get or wait?",
526 routine_name, exchange->
name);
528 void const ** send_data =
530 (
void const **)(send_data_):(
void const **)(exchange->
dummy_buffer);
534 xt_redist_s_exchange(
535 exchange->
redist, exchange->
count, send_data, recv_data);
543 "the \"%s\"-exchange is not in idle state",
544 routine_name, exchange->
name);
554 free(exchange->
name);
556 if (exchange->
redist != NULL) {
557 xt_request_wait(&(exchange->
request));
558 xt_redist_delete(exchange->
redist);
int yac_interpolation_exchange_put_test(struct yac_interpolation_exchange *exchange, char const *routine_name)
int yac_interpolation_exchange_is_target(struct yac_interpolation_exchange *exchange)
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)
void yac_interpolation_exchange_execute_get_async(struct yac_interpolation_exchange *exchange, double **recv_data, char const *routine_name)
struct yac_interpolation_exchange * yac_interpolation_exchange_copy(struct yac_interpolation_exchange *exchange)
void yac_interpolation_exchange_delete(struct yac_interpolation_exchange *exchange, char const *routine_name)
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)
void yac_interpolation_exchange_wait(struct yac_interpolation_exchange *exchange, char const *routine_name)
void yac_interpolation_exchange_execute_put(struct yac_interpolation_exchange *exchange, double const **send_data, char const *routine_name)
@ 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)
void yac_interpolation_exchange_execute(struct yac_interpolation_exchange *exchange, double const **send_data_, double **recv_data_, char const *routine_name)
static struct yac_interpolation_exchange * yac_interpolation_exchange_new_(Xt_redist redist, size_t count, char const *name)
enum YAC_INTERP_EXCH_STATUS yac_interpolation_exchange_status(struct yac_interpolation_exchange *exchange, char const *routine_name)
int yac_interpolation_exchange_get_test(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)
@ YAC_INTERP_EXCH_WAIT_PUT
@ YAC_INTERP_EXCH_WAIT_GET
#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,...)
#define YAC_ASSERT(exp, msg)