24#define YAC_RAD (0.01745329251994329576923690768489)
26#define MAX_COLLECTION_SIZE (10)
31static void utest_target_main(
34static void utest_source_main(
37int main(
int argc,
char *argv[]) {
40 PUT_ERR(
"wrong number of arguments\n");
48 PUT_ERR(
"invalid argument (has to be either \"src\" or \"tgt\")\n");
54 xt_initialize(MPI_COMM_WORLD);
56 int comm_rank, comm_size;
57 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
58 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
59 MPI_Barrier(MPI_COMM_WORLD);
62 PUT_ERR(
"ERROR: wrong number of processes");
70 int tgt_flag = comm_rank < 2;
73 MPI_Comm_split(MPI_COMM_WORLD, tgt_flag, 0, &
split_comm);
75 if (tgt_flag) utest_target_main(
split_comm, reorder_type);
76 else utest_source_main(
split_comm, reorder_type);
108static void utest_source_main(
112 MPI_Comm_rank(source_comm, &my_source_rank);
117 size_t local_start[2][2] = {{0,0},{3,0}};
118 size_t local_count[2][2] = {{3,4},{2,4}};
124 utest_generate_basic_grid_data_reg2d(
126 local_start[my_source_rank], local_count[my_source_rank],
with_halo);
137 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
139 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
175 src_data[collection_idx] =
xmalloc(1 *
sizeof(**src_data));
176 src_data[collection_idx][0] =
178 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
179 src_data[collection_idx][0][i] =
181 ((double)(
grid_data.vertex_ids[i]) + (double)(collection_idx * 30)):
242 free(src_data[collection_idx][0]);
243 free(src_data[collection_idx]);
274static void utest_target_main(
278 MPI_Comm_rank(target_comm, &my_target_rank);
283 size_t local_start[2][2] = {{0,0},{3,0}};
284 size_t local_count[2][2] = {{3,3},{3,3}};
290 utest_generate_basic_grid_data_reg2d(
292 local_start[my_target_rank], local_count[my_target_rank],
with_halo);
303 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
305 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
338 target_data[i] = target_field[i];
354 for (
size_t k = 0; k < 2; ++k) {
357 for (
unsigned j = 0; j < 16; ++j)
358 target_field[i][j] = -1;
366 double ref_target_data[2][16] = {{3.5,4.5,5.5,6.5,
369 21.5,22.5,23.5,24.5},
373 24.5,25.5,1337,1337}};
376 for (
unsigned j = 0; j < 16; ++j) {
377 if ((utest_double_are_equal(ref_target_data[my_target_rank][j], -1.0)) ||
378 (utest_double_are_equal(ref_target_data[my_target_rank][j], 1337.0))) {
379 if (utest_double_are_unequal(target_data[i][j],
380 ref_target_data[my_target_rank][j]))
381 PUT_ERR(
"error in interpolated data on target side\n");
383 if (utest_double_are_unequal(
385 ref_target_data[my_target_rank][j] + (
double)(i * 30)))
386 PUT_ERR(
"error in interpolated data on target side\n");
392 for (
int i = 0;
i < 2; ++
i)
404 interpolation_nan[0] =
410 for (
size_t k = 0; k < 2; ++k) {
413 for (
unsigned j = 0; j < 16; ++j)
414 target_field[i][j] = -1;
425 double ref_nan_covered[2][16] = {{3.5,4.5,5.5,6.5,
428 21.5,22.5,23.5,24.5},
432 24.5,25.5,-1.0,-1.0}};
434 int nan_fallback_mask[2][16] = {{0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0},
435 {0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1}};
438 for (
unsigned j = 0; j < 16; ++j) {
439 if (nan_fallback_mask[my_target_rank][j]) {
440 if (!isnan(target_data[i][j]))
441 PUT_ERR(
"wrong interpolation result for NaN fixed fallback\n");
442 }
else if (!utest_double_are_equal(
443 ref_nan_covered[my_target_rank][j], -1.0)) {
444 if (utest_double_are_unequal(
446 ref_nan_covered[my_target_rank][j] + (
double)(i * 30)))
447 PUT_ERR(
"wrong interpolation result for NaN fixed fallback\n");
453 for (
int i = 0;
i < 2; ++
i)
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
struct yac_basic_grid * yac_basic_grid_empty_new(char const *name)
void yac_basic_grid_delete(struct yac_basic_grid *grid)
void yac_dist_grid_pair_delete(struct yac_dist_grid_pair *grid_pair)
struct yac_dist_grid_pair * yac_dist_grid_pair_new(struct yac_basic_grid *grid_a, struct yac_basic_grid *grid_b, MPI_Comm comm)
void yac_interp_grid_delete(struct yac_interp_grid *interp_grid)
struct yac_interp_grid * yac_interp_grid_new(struct yac_dist_grid_pair *grid_pair, char const *src_grid_name, char const *tgt_grid_name, size_t num_src_fields, struct yac_interp_field const *src_fields, struct yac_interp_field const tgt_field)
void yac_interp_method_delete(struct interp_method **method)
Delete an interpolation stack and free its resources (but not the pointer array).
struct yac_interp_weights * yac_interp_method_do_search(struct interp_method **method, struct yac_interp_grid *interp_grid)
Perform weight computation using given interpolation stack and grid.
struct interp_method * yac_interp_method_avg_new(enum yac_interp_avg_weight_type weight_type, int partial_coverage)
@ YAC_INTERP_AVG_ARITHMETIC
struct interp_method * yac_interp_method_fixed_new(double value)
struct yac_interpolation * yac_interp_weights_get_interpolation(struct yac_interp_weights *weights, enum yac_interp_weights_reorder_type reorder, size_t collection_size, double frac_mask_fallback_value, double scaling_factor, double scaling_summand, char const *yaxt_exchanger_name, int is_source, int is_target)
void yac_interp_weights_delete(struct yac_interp_weights *weights)
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
struct yac_interpolation * yac_interpolation_copy(struct yac_interpolation *interp)
Create a deep copy of an interpolation object.
void yac_interpolation_delete(struct yac_interpolation *interp)
Free an interpolation object and release all resources.
void yac_interpolation_execute_get(struct yac_interpolation *interp, double **tgt_field)
Complete interpolation and write results to the target field (get phase).
void yac_interpolation_execute_put(struct yac_interpolation *interp, double ***src_fields)
Provide source field data and start asynchronous execution of interpolation (put phase).
double const YAC_FRAC_MASK_NO_VALUE
enum yac_location location
struct yac_interp_field tgt_field
struct yac_dist_grid_pair * grid_pair
struct yac_interp_field src_fields[]
static MPI_Comm split_comm
char const grid_name_tgt[]
#define MAX_COLLECTION_SIZE
char const grid_name_src[]