|
YAC 3.20.0
Yet Another Coupler
|
Utility macros and functions for interpolation operators. This file contains utility macros for target field computation in interpolation operators, as well as internal functions for the direct interpolation operator. More...
#include <math.h>#include <yaxt.h>#include "utils_common.h"#include "ppm/ppm_xfuncs.h"#include "interpolation/interpolation_internal.h"#include "interpolation/interp_grid_internal.h"#include "instrument_internal.h"

Go to the source code of this file.
Data Structures | |
| struct | yac_interpolation_buffer |
Macros | |
| #define | NO_SCALING(RESULT) (RESULT) |
| No scaling: | |
| #define | MULT(RESULT) ((RESULT) * scale_factor) |
| Multiplicative scaling: | |
| #define | ADD(RESULT) ((RESULT) + scale_summand) |
| Additive scaling: | |
| #define | MULT_ADD(RESULT) ((RESULT) * scale_factor + scale_summand) |
| Combined multiplicative and additive scaling: | |
| #define | FRAC_MASK_TOL (1e-12) |
| #define | COMPUTE_FIELD_STENCIL_FRAC_WGT(TGT_POS, WEIGHT, SCALE) |
| #define | COMPUTE_FIELD_STENCIL_FRAC_NOWGT(TGT_POS, SCALE) |
| #define | COMPUTE_FIELD_STENCIL_NOFRAC_(TGT_POS, WEIGHT, SCALE) |
| #define | COMPUTE_FIELD_DIRECT_FRAC(SCALE) |
| #define | COMPUTE_FIELD_DIRECT_NOFRAC(SCALE) |
| #define | COMPUTE_FIELD_STENCIL_FRAC(SCALE) |
| #define | COMPUTE_FIELD_STENCIL_NOFRAC(SCALE) |
| #define | COMPUTE_FIELD(COMPUTE_FIELD_FRAC, COMPUTE_FIELD_NOFRAC) |
| #define | CHECK_WITH_FRAC_MASK() |
Assert that a local with_frac_mask flag is consistent with the frac_mask_fallback_value that was passed to the constructor. | |
| #define | YAC_INTERP_GRID_ASSERT_F(INTERP_GRID, EXP, FMT, ...) |
| #define | YAC_INTERP_GRID_ASSERT(INTERP_GRID, EXP, MSG) YAC_INTERP_GRID_ASSERT_F(INTERP_GRID, EXP, MSG "%s", "") |
| #define | YAC_INTERP_GRID_FIELD_ASSERT_F(INTERP_GRID, EXP, FMT, ...) |
| #define | YAC_INTERP_GRID_FIELD_ASSERT(INTERP_GRID, EXP, MSG) YAC_INTERP_GRID_FIELD_ASSERT_F(INTERP_GRID, EXP, MSG "%s", "") |
| #define | CHECK_INTERP_GRID_HAS_SRC_FIELDS(INTERP_GRID) |
| #define | CHECK_INTERP_GRID_SRC_FIELD_IDX_VALID(INTERP_GRID, SRC_FIELD_IDX) |
| #define | CHECK_INTERP_GRID_SRC_FIELD_LOCATION_CORNER_CELL_EDGE(INTERP_GRID, LOCATION) |
| #define | CHECK_INTERP_GRID_NUM_SRC_FIELDS_SINGLE(INTERP_GRID) |
| #define | CHECK_INTERP_GRID_SRC_FIELD_IS_CELL(INTERP_GRID, SRC_FIELD_IDX) |
| #define | CHECK_INTERP_GRID_TGT_FIELD_IS_CELL(INTERP_GRID) |
Enumerations | |
| enum | yac_interpolation_buffer_type { SEND_BUFFER , RECV_BUFFER } |
Functions | |
| static void | compute_tgt_field_stencil (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 using stencil-based summation of source data (sparse-matrix-vector multiply), optionally applying fractional masking and scaling. | |
| static void | compute_tgt_field_direct (double const *restrict **src_fields, double const *restrict **src_frac_masks, double *restrict *tgt_field, size_t *restrict tgt_buffer_sizes, size_t num_src_fields, size_t collection_size, double frac_mask_fallback_value, double scale_factor, double scale_summand) |
| Copy source field values to target buffers, optionally applying fractional masking and scaling. | |
| 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) |
| struct yac_interpolation_buffer | yac_interpolation_buffer_init_2 (Xt_redist *redists, size_t *min_buffer_sizes, size_t num_fields, size_t collection_size, enum yac_interpolation_buffer_type type) |
| struct yac_interpolation_buffer | yac_interpolation_buffer_copy (struct yac_interpolation_buffer buffer, size_t num_fields, size_t collection_size) |
| void | yac_interpolation_buffer_free (struct yac_interpolation_buffer *buffer) |
Utility macros and functions for interpolation operators. This file contains utility macros for target field computation in interpolation operators, as well as internal functions for the direct interpolation operator.
Definition in file interpolation_utils.h.
| #define CHECK_INTERP_GRID_HAS_SRC_FIELDS | ( | INTERP_GRID | ) |
Definition at line 741 of file interpolation_utils.h.
| #define CHECK_INTERP_GRID_NUM_SRC_FIELDS_SINGLE | ( | INTERP_GRID | ) |
Definition at line 762 of file interpolation_utils.h.
| #define CHECK_INTERP_GRID_SRC_FIELD_IDX_VALID | ( | INTERP_GRID, | |
| SRC_FIELD_IDX ) |
Definition at line 746 of file interpolation_utils.h.
| #define CHECK_INTERP_GRID_SRC_FIELD_IS_CELL | ( | INTERP_GRID, | |
| SRC_FIELD_IDX ) |
Definition at line 770 of file interpolation_utils.h.
| #define CHECK_INTERP_GRID_SRC_FIELD_LOCATION_CORNER_CELL_EDGE | ( | INTERP_GRID, | |
| LOCATION ) |
Definition at line 753 of file interpolation_utils.h.
| #define CHECK_INTERP_GRID_TGT_FIELD_IS_CELL | ( | INTERP_GRID | ) |
Definition at line 777 of file interpolation_utils.h.
| #define CHECK_WITH_FRAC_MASK | ( | ) |
Assert that a local with_frac_mask flag is consistent with the frac_mask_fallback_value that was passed to the constructor.
This macro is intended to be placed at the top of execute callbacks that carry a pre-checked with_frac_mask member. It guards against cases where a different fallback value is supplied at execution time than was used when the operator was constructed.
Definition at line 699 of file interpolation_utils.h.
| #define YAC_INTERP_GRID_ASSERT | ( | INTERP_GRID, | |
| EXP, | |||
| MSG ) YAC_INTERP_GRID_ASSERT_F(INTERP_GRID, EXP, MSG "%s", "") |
Definition at line 719 of file interpolation_utils.h.
| #define YAC_INTERP_GRID_ASSERT_F | ( | INTERP_GRID, | |
| EXP, | |||
| FMT, | |||
| ... ) |
Definition at line 712 of file interpolation_utils.h.
| #define YAC_INTERP_GRID_FIELD_ASSERT | ( | INTERP_GRID, | |
| EXP, | |||
| MSG ) YAC_INTERP_GRID_FIELD_ASSERT_F(INTERP_GRID, EXP, MSG "%s", "") |
Definition at line 733 of file interpolation_utils.h.
| #define YAC_INTERP_GRID_FIELD_ASSERT_F | ( | INTERP_GRID, | |
| EXP, | |||
| FMT, | |||
| ... ) |
Definition at line 722 of file interpolation_utils.h.
| Enumerator | |
|---|---|
| SEND_BUFFER | |
| RECV_BUFFER | |
Definition at line 787 of file interpolation_utils.h.
|
inlinestatic |
Copy source field values to target buffers, optionally applying fractional masking and scaling.
This is the direct (1-to-1, no stencil) variant of compute_tgt_field_stencil. It is used for interpolation operators that perform a point-to-point copy (e.g. direct and raw-exchange operators). This routine will copy the source field values into a buffer whose contents will then be directly copied to the target field buffers, without any further processing on the target side. In case scaling and/or fractional masking is requested, the source field values will be pre-processed before being copied to the send buffer.
| [in] | src_fields | Local source field data. dimensions: [collection_size][num_src_fields][points]. When fractional masking is enabled, each value must already be pre-multiplied by the corresponding fractional mask value (i.e. Fs_i * f_i, not Fs_i). |
| [in] | src_frac_masks | Local source fractional mask. (same structure as src_fields; values are expected to be in the range of [0.0;1.0]; ignored when frac_mask_fallback_value is YAC_FRAC_MASK_NO_VALUE). |
| [out] | tgt_field | Output buffers. dimensions: [collection_size * num_src_fields][points]. |
| [in] | tgt_buffer_sizes | Byte size of each target field buffer (length = num_src_fields). |
| [in] | num_src_fields | Number of source fields. |
| [in] | collection_size | Number of field collections. |
| [in] | frac_mask_fallback_value | Fallback value, which is applied to a target point if the sum of associated fractional mask values is below FRAC_MASK_TOL, i.e. effectively zero. Pass YAC_FRAC_MASK_NO_VALUE to disable fractional masking. |
| [in] | scale_factor | Multiplicative scaling factor. Not applied, if the frac_mask_fallback_value is assigned to a target. |
| [in] | scale_summand | Additive scaling summand. Not applied, if the frac_mask_fallback_value is assigned to a target. |
Definition at line 657 of file interpolation_utils.h.

|
inlinestatic |
Compute target field values using stencil-based summation of source data (sparse-matrix-vector multiply), optionally applying fractional masking and scaling.
This routine accumulates contributions from multiple source points per target point using a prefix-sum encoded stencil.
If no weights are provided, all source contributions are weighted equally (unweighted sum).
This routine can also optionally apply fractional masking and scaling.
The user has to provide the locally available source field. All source field data required from other processes has to be gathered by the user beforehand and provided in the dedicated buffers.
| [in] | src_fields | Local source field data. dimensions: [collection_size][num_src_fields][local_points]. When fractional masking is enabled, each value must already be pre-multiplied by the corresponding fractional mask value (i.e. Fs_i * f_i, not Fs_i). |
| [in] | src_frac_masks | Local source fractional mask. (same structure as src_fields; values are expected to be in the range of [0.0;1.0]; ignored when frac_mask_fallback_value is YAC_FRAC_MASK_NO_VALUE). |
| [in] | remote_src_fields | Received source field contributions from other ranks dimensions: [collection_size][required_remote_points]. Received source data of all fields of each collection is expected to be in a single contiguous buffer, therefore this argument is missing the "num_src_fields" dimension. Same pre-multiplication requirement as src_fields applies. |
| [in] | remote_src_frac_masks | Received fractional masks for remote source data (same structure as remote_src_fields; values are expected to be in the range of [0.0;1.0]; ignored when frac_mask_fallback_value is YAC_FRAC_MASK_NO_VALUE). |
| [out] | tgt_field | Output buffers. dimensions: [collection_size][tgt_points]. |
| [in] | tgt_pos | Indices of target points to be computed (length = tgt_count). |
| [in] | tgt_count | Number of target points to be computed. |
| [in] | prefix_num_src_per_tgt | Prefix-sum array encoding the number of source contributions per target.Length = tgt_count + 1Where: prefix_num_src_per_tgt[i+1] - prefix_num_src_per_tgt[i] gives the number of sources for i'th target point. |
| [in] | weights | Interpolation weights for each source contribution. If NULL, all contributions are weighted equally (unweighted sum). |
| [in] | src_field_idx | Source field index for each contribution.SIZE_MAX indicates that the contribution originates from remote process gathered in remote_src_fields and remote_src_frac_masks |
| [in] | src_idx | Source index within the chosen source field. In case of remote data ( src_field_idx == SIZE_MAX), it is the index in the contiguous buffer containing received data for all source fields of a collection. |
| [in] | num_src_fields | Number of source fields. |
| [in] | collection_size | Number of field collections. |
| [in] | frac_mask_fallback_value | Fallback value, which is applied to a target point if the sum of associated fractional mask values is below FRAC_MASK_TOL, i.e. effectively zero. Pass YAC_FRAC_MASK_NO_VALUE to disable fractional masking. |
| [in] | scale_factor | Scaling factor applied to the final weighted sum. Not applied, if the frac_mask_fallback_value is assigned to a target. |
| [in] | scale_summand | Summand added to the scaled result. Not applied, if the frac_mask_fallback_value is assigned to a target. |
Definition at line 582 of file interpolation_utils.h.

| struct yac_interpolation_buffer yac_interpolation_buffer_copy | ( | struct yac_interpolation_buffer | buffer, |
| size_t | num_fields, | ||
| size_t | collection_size ) |
Definition at line 116 of file interpolation_utils.c.


| 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 ) |
Definition at line 88 of file interpolation_utils.c.


| struct yac_interpolation_buffer yac_interpolation_buffer_init_2 | ( | Xt_redist * | redists, |
| size_t * | min_buffer_sizes, | ||
| size_t | num_fields, | ||
| size_t | collection_size, | ||
| enum yac_interpolation_buffer_type | type ) |
Definition at line 100 of file interpolation_utils.c.

