20 double *** src_fields,
double *** src_frac_masks,
double ** tgt_field,
21 double frac_mask_fallback_value,
double scale_factor,
double scale_summand);
24 double *** src_fields,
double *** src_frac_masks,
25 int is_target,
double frac_mask_fallback_value,
26 double scale_factor,
double scale_summand);
29 double frac_mask_fallback_value,
double scale_factor,
double scale_summand);
32 double frac_mask_fallback_value,
double scale_factor,
double scale_summand);
246 size_t tgt_count,
size_t * prefix_num_src_per_tgt,
double * weights,
247 size_t * src_field_idx,
size_t * src_idx,
size_t num_src_fields,
248 int with_frac_mask,
int * ref_count) {
251 xmalloc(1 *
sizeof(*mvp_at_src));
290 Xt_redist * halo_redists,
size_t tgt_count,
size_t * num_src_per_tgt,
291 double * weights,
size_t * src_field_idx,
size_t * src_idx,
292 size_t num_src_fields, Xt_redist result_redist_,
int with_frac_mask) {
297 size_t total_num_src = 0;
298 size_t * prefix_num_src_per_tgt =
299 xmalloc((tgt_count + 1) *
sizeof(*prefix_num_src_per_tgt));
300 for (
size_t i = 0; i < tgt_count; ++i) {
301 prefix_num_src_per_tgt[i] = total_num_src;
302 total_num_src += num_src_per_tgt[i];
304 prefix_num_src_per_tgt[tgt_count] = total_num_src;
307 for (
size_t i = 0; i < total_num_src; ++i) {
309 (src_field_idx[i] == SIZE_MAX) || (src_field_idx[i] < num_src_fields),
310 "ERROR(yac_interp_operator_sum_mvp_at_src_new): "
311 "invalid src_field_idx value "
312 "(has to be either SIZE_MAX or < num_src_fields(= %zu))"
313 "src_field_idx[%zu] = %zu", num_src_fields, i, src_field_idx[i]);
318 collection_selection,
320 halo_redists, num_src_fields,
325 halo_redists, num_src_fields,
329 tgt_count, prefix_num_src_per_tgt,
330 (weights != NULL)?
COPY_DATA(weights, total_num_src):NULL,
333 num_src_fields, with_frac_mask, NULL);
356 double *** src_fields,
double *** src_frac_masks,
double ** tgt_field,
357 double frac_mask_fallback_value,
double scale_factor,
double scale_summand) {
365 "yac_interp_operator_sum_mvp_at_src_execute");
377 size_t const * collection_indices =
383 if (collection_indices != NULL) {
385 double *** temp_src_fields =
392 temp_src_fields[i][j] = src_fields[collection_indices[i]][j];
394 src_fields = temp_src_fields;
396 if (src_frac_masks != NULL) {
397 double *** temp_src_frac_masks =
399 temp_src_frac_masks[0] =
403 temp_src_frac_masks[i] = temp_src_frac_masks[0] + i *
num_src_fields;
405 temp_src_frac_masks[i][j] =
406 src_frac_masks[collection_indices[i]][j];
408 src_frac_masks = temp_src_frac_masks;
423 src_frac_masks[i][j];
427 sum_mvp_at_src->
src2halo, (
double const **)temp_src_fields,
428 halo_buffers,
"yac_interp_operator_sum_mvp_at_src_execute");
431 (
double const * restrict **)src_fields,
433 (
double const * restrict *)halo_buffers,
434 (
double const * restrict *)(
436 results, NULL, sum_mvp_at_src->
tgt_count,
440 frac_mask_fallback_value, scale_factor, scale_summand);
442 if (sum_mvp_at_src->
is_source && (collection_indices != NULL)) {
445 if (src_frac_masks != NULL) {
446 free(src_frac_masks[0]);
447 free(src_frac_masks);
454 sum_mvp_at_src->
result2tgt, (
double const **)results, tgt_field,
455 "yac_interp_operator_sum_mvp_at_src_execute");
460 double *** src_fields,
double *** src_frac_masks,
int is_target,
461 double frac_mask_fallback_value,
double scale_factor,
double scale_summand) {
478 "yac_interp_operator_sum_mvp_at_src_execute_put") ==
482 "yac_interp_operator_sum_mvp_at_src_execute_put");
490 size_t const * collection_indices =
495 if (collection_indices != NULL) {
497 double *** temp_src_fields =
504 temp_src_fields[i][j] = src_fields[collection_indices[i]][j];
506 src_fields = temp_src_fields;
508 if (src_frac_masks != NULL) {
509 double *** temp_src_frac_masks =
511 temp_src_frac_masks[0] =
515 temp_src_frac_masks[i] = temp_src_frac_masks[0] + i *
num_src_fields;
517 temp_src_frac_masks[i][j] =
518 src_frac_masks[collection_indices[i]][j];
520 src_frac_masks = temp_src_frac_masks;
535 src_frac_masks[i][j];
540 sum_mvp_at_src->
src2halo, (
double const **)temp_src_fields, halo_buffers,
541 "yac_interp_operator_sum_mvp_at_src_execute_put");
546 (
double const * restrict **)src_fields,
548 (
double const * restrict *)halo_buffers,
549 (
double const * restrict *)(
551 results, NULL, sum_mvp_at_src->
tgt_count,
555 scale_factor, scale_summand);
557 if (collection_indices != NULL) {
560 if (src_frac_masks != NULL) {
561 free(src_frac_masks[0]);
562 free(src_frac_masks);
567 sum_mvp_at_src->
result2tgt, (
double const **)results,
568 "yac_interp_operator_sum_mvp_at_src_execute_put");
573 double frac_mask_fallback_value,
double scale_factor,
double scale_summand) {
575 UNUSED(frac_mask_fallback_value);
584 "yac_interp_operator_sum_mvp_at_src_execute_get");
589 double frac_mask_fallback_value,
double scale_factor,
double scale_summand) {
591 UNUSED(frac_mask_fallback_value);
601 "yac_interp_operator_sum_mvp_at_src_execute_get_async") ==
605 "yac_interp_operator_sum_mvp_at_src_execute_get_async");
609 "yac_interp_operator_sum_mvp_at_src_execute_get_async");
622 "yac_interp_operator_sum_mvp_at_src_execute_put_test") ==
636 "yac_interp_operator_sum_mvp_at_src_execute_get_test") ==
648 "yac_interp_operator_sum_mvp_at_src_execute_wait");
682 if (interp == NULL)
return;
688 sum_mvp_at_src->
result2tgt,
"yac_interp_operator_sum_mvp_at_src_delete");
691 sum_mvp_at_src->
src2halo,
"yac_interp_operator_sum_mvp_at_src_delete");
703 free(sum_mvp_at_src);
size_t yac_collection_selection_get_collection_size(struct yac_collection_selection const *collection_selection)
Get the size of the collection selection.
size_t const * yac_collection_selection_get_indices(struct yac_collection_selection const *collection_selection)
Get explicit selection indices if non-contiguous.
void yac_collection_selection_delete(struct yac_collection_selection *collection_selection)
Delete a collection selection object.
struct yac_collection_selection * yac_collection_selection_copy(const struct yac_collection_selection *collection_selection)
Selection of indices from a collection.
struct yac_interp_operator * yac_interp_operator_sum_mvp_at_src_new(struct yac_collection_selection const *collection_selection, Xt_redist *halo_redists, size_t tgt_count, size_t *num_src_per_tgt, double *weights, size_t *src_field_idx, size_t *src_idx, size_t num_src_fields, Xt_redist result_redist_, int with_frac_mask)
Create a sum (weighted or unweighted) interpolation operator computed on the source processes.
static void yac_interp_operator_sum_mvp_at_src_execute_get_async(struct yac_interp_operator *interp, double **tgt_field, double frac_mask_fallback_value, double scale_factor, double scale_summand)
static struct yac_interp_operator * yac_interp_operator_sum_mvp_at_src_new_(struct yac_collection_selection const *collection_selection, struct yac_interpolation_buffer halo_data, struct yac_interpolation_buffer result_data, struct yac_interpolation_exchange *src2halo, struct yac_interpolation_exchange *result2tgt, size_t tgt_count, size_t *prefix_num_src_per_tgt, double *weights, size_t *src_field_idx, size_t *src_idx, size_t num_src_fields, int with_frac_mask, int *ref_count)
Internal constructor for the "sum_mvp_at_src" interpolation operator.
static enum YAC_INTERP_TEST_STATUS yac_interp_operator_sum_mvp_at_src_execute_get_test(struct yac_interp_operator *interp)
static struct yac_interp_operator_vtable const interpolation_sum_mvp_at_src_vtable
static void yac_interp_operator_sum_mvp_at_src_execute_wait(struct yac_interp_operator *interp)
static void yac_interp_operator_sum_mvp_at_src_execute_put(struct yac_interp_operator *interp, double ***src_fields, double ***src_frac_masks, int is_target, double frac_mask_fallback_value, double scale_factor, double scale_summand)
static void yac_interp_operator_sum_mvp_at_src_delete(struct yac_interp_operator *interp)
static void yac_interp_operator_sum_mvp_at_src_execute_get(struct yac_interp_operator *interp, double **tgt_field, double frac_mask_fallback_value, double scale_factor, double scale_summand)
static void yac_interp_operator_sum_mvp_at_src_execute(struct yac_interp_operator *interp, double ***src_fields, double ***src_frac_masks, double **tgt_field, double frac_mask_fallback_value, double scale_factor, double scale_summand)
static struct yac_interp_operator * yac_interp_operator_sum_mvp_at_src_copy(struct yac_interp_operator *interp)
static enum YAC_INTERP_TEST_STATUS yac_interp_operator_sum_mvp_at_src_execute_put_test(struct yac_interp_operator *interp)
static int yac_interp_operator_sum_mvp_at_src_is_source(struct yac_interp_operator *interp)
static int yac_interp_operator_sum_mvp_at_src_is_target(struct yac_interp_operator *interp)
Weighted/unweighted sum operator at source in YAC.
int yac_interpolation_exchange_is_target(struct yac_interpolation_exchange *exchange)
Query whether the current process participates as target.
void yac_interpolation_exchange_execute_get_async(struct yac_interpolation_exchange *exchange, double **recv_data, char const *routine_name)
Execute the get phase asynchronously.
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.
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.
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.
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)
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_COMPLETE
No ongoing operation.
@ YAC_INTERP_EXCH_ACTIVE
Exchange is active.
struct yac_interpolation_buffer yac_interpolation_buffer_copy(struct yac_interpolation_buffer src, size_t num_fields, size_t collection_size)
void yac_interpolation_buffer_free(struct yac_interpolation_buffer *buffer)
struct yac_interpolation_buffer yac_interpolation_buffer_init(Xt_redist *redists, size_t num_fields, size_t collection_size, enum yac_interpolation_buffer_type type)
static void compute_tgt_field_wgt(double const *restrict **src_fields, double const *restrict **src_frac_masks, double const *restrict *remote_src_fields, double const *restrict *remote_src_frac_masks, double *restrict *tgt_field, size_t const *restrict tgt_pos, size_t tgt_count, size_t const *restrict prefix_num_src_per_tgt, double const *restrict weights, size_t const *restrict src_field_idx, size_t const *restrict src_idx, size_t num_src_fields, size_t collection_size, double frac_mask_fallback_value, double scale_factor, double scale_summand)
Compute target field values optionally using weighted sums of source data and optionally applying fra...
#define CHECK_WITH_FRAC_MASK(ROUTINE)
#define xcalloc(nmemb, size)
struct yac_interpolation_buffer halo_data
struct yac_collection_selection * collection_selection
double ** src_fields_buffer
size_t * prefix_num_src_per_tgt
struct yac_interpolation_buffer result_data
struct yac_interpolation_exchange * result2tgt
struct yac_interp_operator_vtable const * vtable
struct yac_interpolation_exchange * src2halo
Virtual function table for interpolation operators.
int(* is_source)(struct yac_interp_operator *interp)
Abstract interpolation operator type.
#define COPY_DATA(data, count)
#define YAC_ASSERT_F(exp, format,...)