YetAnotherCoupler 3.2.0_a
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
interpolation_utils.h File Reference
#include <math.h>
#include "utils_common.h"
#include "ppm/ppm_xfuncs.h"
Include dependency graph for interpolation_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  yac_interpolation_buffer
 

Macros

#define FRAC_MASK_TOL   (1e-12)
 
#define COMPUTE_TGT_FIELD_WGT_FRAC_(TGT_POS, WEIGHT, SCALE)
 
#define COMPUTE_TGT_FIELD_WGT_NOFRAC_(TGT_POS, WEIGHT, SCALE)
 
#define COMPUTE_TGT_FIELD_WGT(COMPUTE, SCALE)
 
#define COMPUTE_TGT_FIELD_WGT_FRAC(SCALE)    COMPUTE_TGT_FIELD_WGT(COMPUTE_TGT_FIELD_WGT_FRAC_, SCALE)
 
#define COMPUTE_TGT_FIELD_WGT_NOFRAC(SCALE)    COMPUTE_TGT_FIELD_WGT(COMPUTE_TGT_FIELD_WGT_NOFRAC_, SCALE)
 
#define NO_SCALING(RESULT)   (RESULT)
 
#define MULT(RESULT)   ((RESULT) * scale_factor)
 
#define ADD(RESULT)   ((RESULT) + scale_summand)
 
#define MULT_ADD(RESULT)   ((RESULT) * scale_factor + scale_summand)
 
#define COMPUTE_FIELD(COMPUTE_FIELD_FRAC, COMPUTE_FIELD_NOFRAC)
 
#define COMPUTE_TGT_FIELD_FRAC(SCALE)
 
#define COMPUTE_TGT_FIELD_NOFRAC(SCALE)
 
#define CHECK_WITH_FRAC_MASK(ROUTINE)
 

Enumerations

enum  yac_interpolation_buffer_type { SEND_BUFFER , RECV_BUFFER }
 

Functions

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)
 
static void compute_tgt_field (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)
 
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)
 

Macro Definition Documentation

◆ ADD

#define ADD (   RESULT)    ((RESULT) + scale_summand)

◆ CHECK_WITH_FRAC_MASK

#define CHECK_WITH_FRAC_MASK (   ROUTINE)
Value:
with_frac_mask == (frac_mask_fallback_value != YAC_FRAC_MASK_NO_VALUE), \
"ERROR(%s) " \
"with_frac_mask does not match value provided to constructor\n" \
"(frac_mask_fallback_value = %lf with_frac_mask = %d " \
"with_frac_mask(constructor) %d)", (ROUTINE), \
frac_mask_fallback_value, \
frac_mask_fallback_value != YAC_FRAC_MASK_NO_VALUE, with_frac_mask)
double const YAC_FRAC_MASK_NO_VALUE
#define YAC_ASSERT_F(exp, format,...)
Definition yac_assert.h:18

Definition at line 223 of file interpolation_utils.h.

◆ COMPUTE_FIELD

#define COMPUTE_FIELD (   COMPUTE_FIELD_FRAC,
  COMPUTE_FIELD_NOFRAC 
)
Value:
{ \
if (frac_mask_fallback_value != YAC_FRAC_MASK_NO_VALUE) { \
if (scale_factor == 1.0) { \
if (scale_summand == 0.0) COMPUTE_FIELD_FRAC(NO_SCALING) \
else COMPUTE_FIELD_FRAC(ADD) \
} else { \
if (scale_summand == 0.0) COMPUTE_FIELD_FRAC(MULT) \
else COMPUTE_FIELD_FRAC(MULT_ADD) \
} \
} else { \
if (scale_factor == 1.0) { \
if (scale_summand == 0.0) COMPUTE_FIELD_NOFRAC(NO_SCALING) \
else COMPUTE_FIELD_NOFRAC(ADD) \
} else { \
if (scale_summand == 0.0) COMPUTE_FIELD_NOFRAC(MULT) \
else COMPUTE_FIELD_NOFRAC(MULT_ADD) \
} \
} \
}
#define ADD(RESULT)
#define NO_SCALING(RESULT)
#define MULT(RESULT)
#define MULT_ADD(RESULT)

◆ COMPUTE_TGT_FIELD_FRAC

#define COMPUTE_TGT_FIELD_FRAC (   SCALE)
Value:
{ \
for (size_t i = 0; i < collection_size; ++i) { \
for (size_t j = 0; j < num_src_fields; ++j) { \
memcpy(tgt_field[i * num_src_fields + j], \
src_fields[i][j], tgt_buffer_sizes[j]); \
size_t const tgt_count = \
tgt_buffer_sizes[j] / sizeof(***src_fields); \
{ \
YAC_OMP_FOR \
for (size_t k = 0; k < tgt_count; ++k) { \
if (src_frac_masks[i][j][k] != 0.0) \
tgt_field[i * num_src_fields + j][k] = \
SCALE( \
tgt_field[i * num_src_fields + j][k] / \
src_frac_masks[i][j][k]); \
else \
tgt_field[i * num_src_fields + j][k] = \
frac_mask_fallback_value; \
} \
} \
} \
} \
}
#define YAC_OMP_PARALLEL

◆ COMPUTE_TGT_FIELD_NOFRAC

#define COMPUTE_TGT_FIELD_NOFRAC (   SCALE)
Value:
{ \
for (size_t i = 0; i < collection_size; ++i) { \
for (size_t j = 0; j < num_src_fields; ++j) { \
memcpy(tgt_field[i * num_src_fields + j], \
src_fields[i][j], tgt_buffer_sizes[j]); \
size_t const tgt_count = \
tgt_buffer_sizes[j] / sizeof(***src_fields); \
{ \
YAC_OMP_FOR \
for (size_t k = 0; k < tgt_count; ++k) \
tgt_field[i * num_src_fields + j][k] = \
SCALE(tgt_field[i * num_src_fields + j][k]); \
} \
} \
} \
}

◆ COMPUTE_TGT_FIELD_WGT

#define COMPUTE_TGT_FIELD_WGT (   COMPUTE,
  SCALE 
)
Value:
{ \
if (weights != NULL) { \
if (tgt_pos != NULL) COMPUTE(tgt_pos[i], weights[k], SCALE) \
else COMPUTE(i, weights[k], SCALE) \
} else { \
if (tgt_pos != NULL) COMPUTE(tgt_pos[i], 1.0, SCALE) \
else COMPUTE(i, 1.0, SCALE) \
} \
}

◆ COMPUTE_TGT_FIELD_WGT_FRAC

#define COMPUTE_TGT_FIELD_WGT_FRAC (   SCALE)     COMPUTE_TGT_FIELD_WGT(COMPUTE_TGT_FIELD_WGT_FRAC_, SCALE)

◆ COMPUTE_TGT_FIELD_WGT_FRAC_

#define COMPUTE_TGT_FIELD_WGT_FRAC_ (   TGT_POS,
  WEIGHT,
  SCALE 
)

◆ COMPUTE_TGT_FIELD_WGT_NOFRAC

#define COMPUTE_TGT_FIELD_WGT_NOFRAC (   SCALE)     COMPUTE_TGT_FIELD_WGT(COMPUTE_TGT_FIELD_WGT_NOFRAC_, SCALE)

◆ COMPUTE_TGT_FIELD_WGT_NOFRAC_

#define COMPUTE_TGT_FIELD_WGT_NOFRAC_ (   TGT_POS,
  WEIGHT,
  SCALE 
)
Value:
{ \
for (size_t l = 0; l < collection_size; ++l) { \
double const * restrict * curr_local_field_data = \
src_fields?src_fields[l]:NULL; \
double const * restrict curr_remote_field_data = \
remote_src_fields[l * num_src_fields]; \
double * restrict curr_tgt_field = tgt_field[l]; \
{ \
YAC_OMP_FOR \
for (size_t i = 0; i < tgt_count; ++i) { \
double result = 0.0; \
size_t const k_bound = prefix_num_src_per_tgt[i+1]; \
for (size_t k = prefix_num_src_per_tgt[i]; k < k_bound; ++k) { \
double const * restrict src_field_data; \
if (src_field_idx[k] == SIZE_MAX) { \
src_field_data = curr_remote_field_data; \
} else { \
src_field_data = curr_local_field_data[src_field_idx[k]]; \
} \
result += src_field_data[src_idx[k]] * (WEIGHT); \
} \
curr_tgt_field[(TGT_POS)] = SCALE(result); \
} \
} \
} \
}

◆ FRAC_MASK_TOL

#define FRAC_MASK_TOL   (1e-12)

◆ MULT

#define MULT (   RESULT)    ((RESULT) * scale_factor)

◆ MULT_ADD

#define MULT_ADD (   RESULT)    ((RESULT) * scale_factor + scale_summand)

◆ NO_SCALING

#define NO_SCALING (   RESULT)    (RESULT)

Enumeration Type Documentation

◆ yac_interpolation_buffer_type

Enumerator
SEND_BUFFER 
RECV_BUFFER 

Definition at line 233 of file interpolation_utils.h.

Function Documentation

◆ compute_tgt_field()

static void compute_tgt_field ( 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 
)
inlinestatic

Definition at line 156 of file interpolation_utils.h.

Here is the caller graph for this function:

◆ compute_tgt_field_wgt()

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 
)
inlinestatic

Definition at line 13 of file interpolation_utils.h.

Here is the caller graph for this function:

◆ yac_interpolation_buffer_copy()

struct yac_interpolation_buffer yac_interpolation_buffer_copy ( struct yac_interpolation_buffer  buffer,
size_t  num_fields,
size_t  collection_size 
)

Definition at line 115 of file interpolation_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_interpolation_buffer_free()

void yac_interpolation_buffer_free ( struct yac_interpolation_buffer buffer)

Definition at line 126 of file interpolation_utils.c.

Here is the caller graph for this function:

◆ yac_interpolation_buffer_init()

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 87 of file interpolation_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_interpolation_buffer_init_2()

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 99 of file interpolation_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function: