19static void utest_default_values(
void);
20static void utest_setters_and_getters(
void);
21static void utest_copy(
void);
22static void utest_delete_null(
void);
23static void utest_compare(
void);
24static void utest_pack_unpack(
void);
30 utest_default_values();
31 utest_setters_and_getters();
42static void utest_default_values(
void) {
47 if (gen_config == NULL)
PUT_ERR(
"config is NULL after construction");
50 PUT_ERR(
"default reorder should be YAC_MAPPING_ON_SRC");
56 PUT_ERR(
"wrong default frac_mask_fallback_value");
59 PUT_ERR(
"wrong default scaling_factor");
62 PUT_ERR(
"wrong default scaling_summand");
65 PUT_ERR(
"default exchanger name should be NULL");
70static void utest_setters_and_getters(
void) {
78 PUT_ERR(
"set/get reorder failed");
87 PUT_ERR(
"set collection_size failed");
94 gen_config, non_cont_coll_sel);
98 PUT_ERR(
"set/get collection_selection failed");
105 PUT_ERR(
"set/get frac_mask_fallback_value failed");
110 PUT_ERR(
"set/get scaling_factor failed");
115 PUT_ERR(
"set/get scaling_summand failed");
118 const char *
name =
"custom_exchanger";
122 PUT_ERR(
"set/get yaxt_exchanger_name failed");
127static void utest_copy(
void) {
137 const char *
name =
"copy_exchanger";
148 PUT_ERR(
"reorder mismatch in copy");
153 PUT_ERR(
"collection_selection mismatch in copy");
157 PUT_ERR(
"frac_mask_fallback_value mismatch in copy");
161 PUT_ERR(
"scaling_factor mismatch in copy");
165 PUT_ERR(
"scaling_summand mismatch in copy");
170 PUT_ERR(
"yaxt_exchanger_name pointer mismatch in copy");
179 if (null_copy != NULL)
180 PUT_ERR(
"copy of NULL config should be NULL");
183static void utest_delete_null(
void) {
188static void utest_compare(
void) {
192 PUT_ERR(
"yac_interpolation_gen_config_compare(NULL, NULL) failed");
199 PUT_ERR(
"yac_interpolation_gen_config_compare(a, NULL) failed");
202 PUT_ERR(
"yac_interpolation_gen_config_compare(a, NULL) failed");
217 size_t collection_sizes[] = {1,3};
219 NUM_COLLECTION_SIZES =
220 sizeof(collection_sizes) /
sizeof(collection_sizes[0])};
222 double frac_mask_values[] = {0.0, NAN};
223 enum {NUM_FRAC_MASK_VALUES =
224 sizeof(frac_mask_values) /
sizeof(frac_mask_values[0])};
226 double scaling_factors[] = {-1.0, 1.0};
227 enum {NUM_SCALING_FACTORS =
228 sizeof(scaling_factors) /
sizeof(scaling_factors[0])};
230 double scaling_summands[] = {0.0, 1.0};
231 enum {NUM_SCALING_SUMMANDS =
232 sizeof(scaling_summands) /
sizeof(scaling_summands[0])};
234 const char *exchanger_names[] = {NULL,
"irecv_isend"};
235 enum {NUM_EXCHANGER_NAMES =
236 sizeof(exchanger_names) /
sizeof(exchanger_names[0])};
244 for (
size_t col_a = 0; col_a < NUM_COLLECTION_SIZES; ++col_a) {
246 a, collection_sizes[col_a]);
248 for (
size_t col_b = 0; col_b < NUM_COLLECTION_SIZES; ++col_b) {
250 b, collection_sizes[col_b]);
252 for (
size_t frac_a = 0; frac_a < NUM_FRAC_MASK_VALUES; ++frac_a) {
254 a, frac_mask_values[frac_a]);
256 for (
size_t frac_b = 0; frac_b < NUM_FRAC_MASK_VALUES; ++frac_b) {
258 b, frac_mask_values[frac_b]);
260 for (
size_t scale_a = 0; scale_a < NUM_SCALING_FACTORS; ++scale_a) {
262 a, scaling_factors[scale_a]);
264 for (
size_t scale_b = 0; scale_b < NUM_SCALING_FACTORS; ++scale_b) {
266 b, scaling_factors[scale_b]);
268 for (
size_t sum_a = 0; sum_a < NUM_SCALING_SUMMANDS; ++sum_a) {
270 a, scaling_summands[sum_a]);
272 for (
size_t sum_b = 0; sum_b < NUM_SCALING_SUMMANDS; ++sum_b) {
274 b, scaling_summands[sum_b]);
276 for (
size_t exch_a = 0; exch_a < NUM_EXCHANGER_NAMES; ++exch_a) {
278 a, exchanger_names[exch_a]);
280 for (
size_t exch_b = 0; exch_b < NUM_EXCHANGER_NAMES; ++exch_b) {
282 b, exchanger_names[exch_b]);
288 (reorder_a == reorder_b) &&
290 (frac_a == frac_b) &&
291 (scale_a == scale_b) &&
297 PUT_ERR(
"identical configurations compare nonzero");
300 PUT_ERR(
"different configurations compare equal");
302 PUT_ERR(
"antisymmetry property failed");
324static void utest_pack_unpack(
void) {
326 MPI_Comm
comm = MPI_COMM_SELF;
337 .frac_mask_fallback_value = 1.0,
338 .scaling_factor = 1.0,
339 .scaling_summand = 0.0,
340 .collection_size = 3,
341 .yaxt_exchanger_name = NULL},
343 .frac_mask_fallback_value = 1.0,
344 .scaling_factor = 1.0,
345 .scaling_summand = 0.0,
346 .collection_size = 5,
347 .yaxt_exchanger_name =
"irecv_isend"}};
348 enum {
NUM_TESTS =
sizeof(test_cases) /
sizeof(test_cases[0]) };
370 pack_size > 0,
"utest_pack_unpack_config: pack_size must be positive");
376 orig,
buffer, (
int)pack_size, &position, comm);
378 int unpack_position = 0;
381 buffer, (
int)pack_size, &unpack_position, comm);
#define YAC_ASSERT(exp, msg)
void yac_collection_selection_delete(struct yac_collection_selection *collection_selection)
Delete a collection selection object.
int yac_collection_selection_compare(struct yac_collection_selection const *a, struct yac_collection_selection const *b)
Compare two collection selections.
struct yac_collection_selection * yac_collection_selection_new(size_t collection_size, size_t const *selection_indices)
Create a new collection selection.
yac_interp_weights_reorder_type
@ YAC_MAPPING_ON_TGT
weights will be applied at target processes
@ YAC_MAPPING_ON_SRC
weights will be applied at source processes
double const YAC_FRAC_MASK_NO_VALUE
void yac_interpolation_gen_config_set_reorder(struct yac_interpolation_gen_config *config, enum yac_interp_weights_reorder_type reorder)
Set the reordering strategy for interpolation weights.
void yac_interpolation_gen_config_set_collection_size(struct yac_interpolation_gen_config *config, size_t collection_size)
Set the number of contiguous fields (starting at "0") in the field collection.
enum yac_interp_weights_reorder_type yac_interpolation_gen_config_get_reorder(struct yac_interpolation_gen_config const *config)
Get the configured reordering strategy.
int yac_interpolation_gen_config_compare(struct yac_interpolation_gen_config const *a, struct yac_interpolation_gen_config const *b)
Compare two interpolation configuration structures.
double yac_interpolation_gen_config_get_frac_mask_fallback_value(struct yac_interpolation_gen_config const *config)
Get the configured fractional mask fallback value.
void yac_interpolation_gen_config_set_collection_selection(struct yac_interpolation_gen_config *config, struct yac_collection_selection const *collection_selection)
Set the collection selection of source field in the source field collection.
void yac_interpolation_gen_config_set_scaling_factor(struct yac_interpolation_gen_config *config, double scaling_factor)
Set the multiplicative scaling factor.
double yac_interpolation_gen_config_get_scaling_factor(struct yac_interpolation_gen_config const *config)
Get the configured scaling factor.
struct yac_collection_selection const * yac_interpolation_gen_config_get_collection_selection(struct yac_interpolation_gen_config const *config)
Get the configured collection selection.
size_t yac_interpolation_gen_config_get_pack_size(struct yac_interpolation_gen_config const *cfg, MPI_Comm comm)
Get the MPI packing size of an interpolation generation configuration.
void yac_interpolation_gen_config_set_yaxt_exchanger_name(struct yac_interpolation_gen_config *config, char const *name)
Set the name of the Yaxt exchanger.
const char * yac_interpolation_gen_config_get_yaxt_exchanger_name(struct yac_interpolation_gen_config const *config)
Get the configured Yaxt exchanger name.
void yac_interpolation_gen_config_delete(struct yac_interpolation_gen_config *config)
Release a interpolation generation configuration structure allocated by yac_interpolation_gen_config_...
void yac_interpolation_gen_config_set_frac_mask_fallback_value(struct yac_interpolation_gen_config *config, double frac_mask_fallback_value)
Set the fractional mask fallback value.
struct yac_interpolation_gen_config * yac_interpolation_gen_config_copy(struct yac_interpolation_gen_config const *src)
Create a copy of an interpolation generation configuration.
struct yac_interpolation_gen_config * yac_interpolation_gen_config_new(void)
Allocate and initialise an interpolation generation configuration structure.
void yac_interpolation_gen_config_pack(struct yac_interpolation_gen_config const *cfg, void *buffer, int buffer_size, int *position, MPI_Comm comm)
Pack an interpolation generation configuration into an MPI buffer.
void yac_interpolation_gen_config_set_scaling_summand(struct yac_interpolation_gen_config *config, double scaling_summand)
Set the additive scaling summand.
double yac_interpolation_gen_config_get_scaling_summand(struct yac_interpolation_gen_config const *config)
Get the configured scaling summand.
struct yac_interpolation_gen_config * yac_interpolation_gen_config_unpack(void const *buffer, int buffer_size, int *position, MPI_Comm comm)
Unpack an interpolation generation configuration from an MPI buffer.
Configuration structure for interpolation generation.
char * yaxt_exchanger_name
double frac_mask_fallback_value
enum yac_interp_weights_reorder_type reorder
enum yac_interp_weights_reorder_type reorder_types[]