39#define FALLBACK_VALUE (-1.0)
40#define FIXED_VALUE (999.0)
43static void utest_get_basic_grid_data(
44 char * filename,
size_t *
num_cells,
size_t * num_vertices,
46static int utest_check_fixed_results(
51static int utest_check_direct_results(
55 double *** src_data,
double *** src_frac_masks,
double ** tgt_data);
56static int utest_check_results_ref(
58 double * src_data,
double * tgt_data,
double * ref_tgt_data,
size_t tgt_size,
59 int is_active_src,
int is_active_tgt);
61static void utest_get_basic_weight_file_info(
64 MPI_Comm comm,
char const * msg,
char const * source,
int line);
66 "test_interp_weights_parallel_on_existing.nc";
68static void utest_interpolation_execute_raw(
73static void utest_interpolation_execute_frac_raw(
76 size_t collection_size,
double *** src_fields,
double *** src_frac_masks,
80 utest_generate_dummy_grid_data(
81 size_t
num_cells, size_t global_num_cells, size_t num_cells_offset);
85int main(
int argc,
char** argv) {
89 xt_initialize(MPI_COMM_WORLD);
91 int comm_rank, comm_size;
92 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
93 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
96 PUT_ERR(
"This test requires 5 processes\n");
106 size_t reorder_type_count =
119 int is_src = comm_rank < 3;
127 SRC_PROC_COUNT * TGT_PROC_COUNT *
128 (SRC_PROC_COUNT + TGT_PROC_COUNT) * 2,
130 SRC_PROC_COUNT * TGT_PROC_COUNT * 2,
133 double wsum_weights[3*LOCAL_SIZE];
134 double sum_weights[3*LOCAL_SIZE];
135 double direct_weights[LOCAL_SIZE];
136 size_t wsum_num_src_per_tgt[LOCAL_SIZE];
137 size_t direct_num_src_per_tgt[LOCAL_SIZE];
139 default_tgts->
data =
xmalloc(LOCAL_SIZE *
sizeof(*default_tgts->
data));
142 xmalloc(3 * LOCAL_SIZE *
sizeof(*wsum_srcs));
144 xmalloc(LOCAL_SIZE *
sizeof(*direct_srcs));
146 default_tgts->
count = LOCAL_SIZE;
147 for (
size_t i = 0;
i < LOCAL_SIZE; ++
i) {
148 for (
size_t j = 0; j < 3; ++j) {
149 wsum_weights[3 *
i + j] = (double)(j+1);
150 sum_weights[3 *
i + j] = 1.0;
152 direct_weights[
i] = 1.0;
153 wsum_num_src_per_tgt[
i] = 3;
154 direct_num_src_per_tgt[
i] = 1;
160 (int)(tgt_global_id & 1) + (int)SRC_PROC_COUNT;
162 (uint64_t)(tgt_global_id / 2);
164 for (
size_t j = 0; j < 3; ++j) {
167 wsum_srcs[3 *
i + j].
global_id = src_global_id;
170 (int)src_global_id % (
int)SRC_PROC_COUNT;
172 (uint64_t)(src_global_id / SRC_PROC_COUNT);
175 yac_int src_global_id = tgt_global_id;
179 (int)src_global_id % (
int)SRC_PROC_COUNT;
181 (uint64_t)(src_global_id / SRC_PROC_COUNT);
187 (is_src)?
xmalloc((GLOBAL_SIZE / SRC_PROC_COUNT) *
sizeof(*out_data)):NULL;
189 for (
size_t i = 0;
i < GLOBAL_SIZE / SRC_PROC_COUNT; ++
i)
190 out_data[i] = (
double)((
yac_int)comm_rank + i * SRC_PROC_COUNT);
192 (is_src)?NULL:
xmalloc((GLOBAL_SIZE / TGT_PROC_COUNT) * sizeof(*in_data));
193 double * ref_in_data =
194 (is_src)?NULL:
xmalloc((GLOBAL_SIZE / TGT_PROC_COUNT) * sizeof(*ref_in_data));
197 utest_generate_dummy_grid_data(
198 GLOBAL_SIZE / ((is_src)?SRC_PROC_COUNT:TGT_PROC_COUNT), GLOBAL_SIZE,
199 (size_t)comm_rank - ((is_src)?0:SRC_PROC_COUNT));
215 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
217 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
238 for (
size_t i = 0;
i < (1 << (2 * (SRC_PROC_COUNT + TGT_PROC_COUNT))); ++
i) {
241 int max_weight_type = 0;
243 for (
size_t j = 0; j < SRC_PROC_COUNT + TGT_PROC_COUNT; ++j) {
250 size_t * num_src_per_tgt;
258 num_src_per_tgt = NULL;
264 num_src_per_tgt = direct_num_src_per_tgt;
270 num_src_per_tgt = wsum_num_src_per_tgt;
276 num_src_per_tgt = wsum_num_src_per_tgt;
282 for (
int j =
MAX(max_weight_type,
DIRECT); j <= (int)
WSUM; ++j) {
301 weights, tgts, num_src_per_tgt, srcs, w);
305 enum {ACTIVE_TARGET_CONFIG_COUNT = 4};
306 int active_target_configs[ACTIVE_TARGET_CONFIG_COUNT][TGT_PROC_COUNT] =
307 {{0,0},{0,1},{1,0},{1,1}};
309 for (
size_t tgt_config_idx = 0;
310 tgt_config_idx < ACTIVE_TARGET_CONFIG_COUNT; ++tgt_config_idx) {
312 int is_active_src = 0;
313 int is_active_tgt = 0;
321 int tgt_rank = (
yac_int)(comm_rank - (
int)SRC_PROC_COUNT);
322 is_active_tgt = active_target_configs[tgt_config_idx][tgt_rank];
324 for (
size_t k = 0; k < GLOBAL_SIZE / TGT_PROC_COUNT; ++k) {
327 int weight_rank = (int)(tgt_global_id / (
yac_int)LOCAL_SIZE);
335 ref_value = (double)tgt_global_id;
338 ref_value = (double)(((tgt_global_id + 0) % GLOBAL_SIZE) +
339 ((tgt_global_id + 1) % GLOBAL_SIZE) +
340 ((tgt_global_id + 2) % GLOBAL_SIZE));
343 ref_value = (double)(1 * ((tgt_global_id + 0) % GLOBAL_SIZE) +
344 2 * ((tgt_global_id + 1) % GLOBAL_SIZE) +
345 3 * ((tgt_global_id + 2) % GLOBAL_SIZE));
354 if (utest_check_results_ref(
356 out_data, in_data, ref_in_data, GLOBAL_SIZE / TGT_PROC_COUNT,
357 is_active_src, is_active_tgt))
358 PUT_ERR(
"ERROR(yac_interp_weights_add_*): "
359 "invalid interpolation result");
362 MPI_Comm weights_comm =
366 MPI_Comm_compare(weights_comm, MPI_COMM_WORLD, &compare_result);
367 if ((compare_result != MPI_IDENT) &&
368 (compare_result != MPI_CONGRUENT))
369 PUT_ERR(
"ERROR(yac_interp_weights_get_comm): wrong communicator");
383 free(default_tgts->
data);
390 int is_src = comm_rank < 3;
401 int src_ranks[SRC_PROC_COUNT] = {0, 1, 2};
402 int tgt_ranks[TGT_PROC_COUNT] = {3, 4};
403 double wsum_weights[SRC_NUM_POINTS];
404 double sum_weights[SRC_NUM_POINTS];
405 double direct_weights[TGT_NUM_POINTS];
406 size_t wsum_num_src_per_tgt[TGT_NUM_POINTS];
407 size_t direct_num_src_per_tgt[TGT_NUM_POINTS];
409 xmalloc(TGT_NUM_POINTS *
sizeof(*default_tgts));
410 default_tgts->
data =
xmalloc(TGT_NUM_POINTS *
sizeof(*default_tgts->
data));
413 xmalloc(SRC_NUM_POINTS *
sizeof(*wsum_srcs));
415 xmalloc(TGT_NUM_POINTS *
sizeof(*direct_srcs));
417 default_tgts->
count = TGT_NUM_POINTS;
418 for (
size_t tgt_point_idx = 0; tgt_point_idx < TGT_NUM_POINTS;
420 for (
size_t src_point_idx = 0; src_point_idx < SRC_NUM_POINTS;
422 wsum_weights[SRC_NUM_POINTS * tgt_point_idx + src_point_idx] =
423 (double)(src_point_idx+1);
424 sum_weights[SRC_NUM_POINTS * tgt_point_idx + src_point_idx] = 1.0;
426 direct_weights[tgt_point_idx] = 1.0;
427 wsum_num_src_per_tgt[tgt_point_idx] = SRC_NUM_POINTS;
428 direct_num_src_per_tgt[tgt_point_idx] = 1;
432 default_tgts->
data[tgt_point_idx].
data.
count = TGT_PROC_COUNT;
437 for (
size_t tgt_rank_idx = 0; tgt_rank_idx < TGT_PROC_COUNT;
440 rank = tgt_ranks[tgt_rank_idx];
442 orig_pos = tgt_point_idx;
445 for (
size_t src_point_idx = 0; src_point_idx < SRC_NUM_POINTS;
448 wsum_srcs[SRC_NUM_POINTS * tgt_point_idx + src_point_idx].
450 wsum_srcs[SRC_NUM_POINTS * tgt_point_idx + src_point_idx].
451 data.count = SRC_PROC_COUNT;
452 wsum_srcs[SRC_NUM_POINTS * tgt_point_idx + src_point_idx].
455 for (
size_t src_rank_idx = 0; src_rank_idx < SRC_PROC_COUNT;
457 wsum_srcs[SRC_NUM_POINTS * tgt_point_idx + src_point_idx].
458 data.data.multi[src_rank_idx].rank = src_ranks[src_rank_idx];
459 wsum_srcs[SRC_NUM_POINTS * tgt_point_idx + src_point_idx].
460 data.data.multi[src_rank_idx].orig_pos = (uint64_t)src_point_idx;
464 yac_int src_global_id = tgt_global_id;
465 direct_srcs[tgt_point_idx].
global_id = src_global_id;
466 direct_srcs[tgt_point_idx].
data.
count = SRC_PROC_COUNT;
469 for (
size_t src_rank_idx = 0; src_rank_idx < SRC_PROC_COUNT;
472 src_ranks[src_rank_idx];
479 double * out_data = (is_src)?
xmalloc(SRC_NUM_POINTS *
sizeof(*out_data)):NULL;
481 for (
size_t i = 0;
i < SRC_NUM_POINTS; ++
i)
482 out_data[i] = (
double)((
yac_int)comm_rank + i * SRC_PROC_COUNT);
484 (is_src)?NULL:
xmalloc(TGT_NUM_POINTS * sizeof(*in_data));
485 double * ref_in_data =
486 (is_src)?NULL:
xmalloc(TGT_NUM_POINTS * sizeof(*ref_in_data));
489 utest_generate_dummy_grid_data(
490 is_src?SRC_NUM_POINTS:TGT_NUM_POINTS,
491 is_src?SRC_NUM_POINTS:TGT_NUM_POINTS, 0);
507 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
509 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
520 for (
size_t weight_type_idx = 0; weight_type_idx < NUM_WEIGHT_TYPES;
526 size_t * num_src_per_tgt;
538 num_src_per_tgt = NULL;
548 num_src_per_tgt = direct_num_src_per_tgt;
555 num_src_per_tgt = wsum_num_src_per_tgt;
562 num_src_per_tgt = wsum_num_src_per_tgt;
566 weights, tgts, num_src_per_tgt, srcs, w);
570 for (
int active_source_rank = 0; active_source_rank < SRC_PROC_COUNT;
571 ++active_source_rank) {
573 int is_active_src = 0;
574 int is_active_tgt = 0;
578 is_active_src = active_source_rank == comm_rank;
584 for (
size_t tgt_point_idx = 0; tgt_point_idx < TGT_NUM_POINTS;
595 ref_in_data[tgt_point_idx] =
596 (double)(tgt_point_idx + active_source_rank);
599 ref_in_data[tgt_point_idx] =
601 (tgt_point_idx + active_source_rank + 0 * SRC_NUM_POINTS) +
602 (tgt_point_idx + active_source_rank + 1 * SRC_NUM_POINTS) +
603 (tgt_point_idx + active_source_rank + 2 * SRC_NUM_POINTS));
606 ref_in_data[tgt_point_idx] =
608 1 * (tgt_point_idx + active_source_rank + 0 * SRC_NUM_POINTS) +
609 2 * (tgt_point_idx + active_source_rank + 1 * SRC_NUM_POINTS) +
610 3 * (tgt_point_idx + active_source_rank + 2 * SRC_NUM_POINTS));
618 if (utest_check_results_ref(
620 out_data, in_data, ref_in_data, TGT_NUM_POINTS,
621 is_active_src, is_active_tgt))
622 PUT_ERR(
"ERROR(yac_interp_weights_add_*): "
623 "invalid interpolation result");
626 MPI_Comm weights_comm =
630 MPI_Comm_compare(weights_comm, MPI_COMM_WORLD, &compare_result);
631 if ((compare_result != MPI_IDENT) &&
632 (compare_result != MPI_CONGRUENT))
633 PUT_ERR(
"ERROR(yac_interp_weights_get_comm): wrong communicator");
645 for (
size_t tgt_point_idx = 0; tgt_point_idx < TGT_NUM_POINTS;
647 free(direct_srcs[tgt_point_idx].
data.data.multi);
649 for (
size_t src_point_idx = 0; src_point_idx < SRC_NUM_POINTS;
653 SRC_NUM_POINTS * tgt_point_idx + src_point_idx].
data.data.multi);
658 free(default_tgts->
data);
663 int is_src = comm_rank < (comm_size / 2);
665 MPI_Comm local_grid_comm;
666 int local_grid_comm_size;
667 MPI_Comm_split(MPI_COMM_WORLD, is_src, 0, &local_grid_comm);
668 MPI_Comm_size(local_grid_comm, &local_grid_comm_size);
672 setenv(
"YAC_YAXT_EXCHANGER",
"irecv_isend", 1);
675 PUT_ERR(
"ERROR: missing grid file directory");
682 char * grid_filenames[] =
683 {
"icon_grid_R02B01.nc",
"icon_grid_R03B01.nc"};
684 for (
int i = 0;
i < 2; ++
i)
688 malloc(strlen(argv[1]) + strlen(grid_filenames[i]) + 2), argv[1]),
693 filenames[is_src], local_grid_comm);
703 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
705 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
716 size_t num_tgt_cells, num_tgt_vertices, num_tgt_edges;
717 utest_get_basic_grid_data(
718 filenames[0], &num_tgt_cells, &num_tgt_vertices, &num_tgt_edges);
719 size_t num_src_cells, num_src_vertices, num_src_edges;
720 utest_get_basic_grid_data(
721 filenames[1], &num_src_cells, &num_src_vertices, &num_src_edges);
727 yac_int * tgt_global_ids =
xmalloc(count *
sizeof(*tgt_global_ids));
728 size_t * size_t_buffer =
xmalloc(2 * count *
sizeof(*size_t_buffer));
729 size_t * odd_tgt_points = size_t_buffer;
730 size_t * even_tgt_points = size_t_buffer + count;
732 interp_grid, tgt_points, count, tgt_global_ids);
734 size_t odd_count = 0;
735 size_t even_count = 0;
736 for (
size_t i = 0;
i < count; ++
i) {
737 if (tgt_global_ids[i] & 1) odd_tgt_points[odd_count++] =
tgt_points[
i];
738 else even_tgt_points[even_count++] =
tgt_points[
i];
744 interp_grid, odd_tgt_points, odd_count),
749 interp_grid, even_tgt_points, even_count),
750 .count = even_count};
756 free(even_tgts.
data);
758 free(tgt_global_ids);
762 double * field_data =
765 for (
size_t reorder_type = 0; reorder_type < reorder_type_count;
767 if (utest_check_fixed_results(
770 PUT_ERR(
"ERROR(yac_interp_weights_add_fixed): "
771 "invalid interpolation result");
776 "test_interp_weights_parallel_fixed.nc";
791 if (utest_check_fixed_results(
793 PUT_ERR(
"ERROR(yac_interp_weights_add_fixed): "
794 "invalid interpolation result (read from file)");
808 MPI_Comm_free(&local_grid_comm);
810 unsetenv(
"YAC_YAXT_EXCHANGER");
814 int is_src = comm_rank < (comm_size / 2);
816 MPI_Comm local_grid_comm;
817 int local_grid_comm_size;
818 MPI_Comm_split(MPI_COMM_WORLD, is_src, 0, &local_grid_comm);
819 MPI_Comm_size(local_grid_comm, &local_grid_comm_size);
824 PUT_ERR(
"ERROR: missing grid file directory");
831 char * grid_filenames[] =
832 {
"icon_grid_R02B01.nc",
"icon_grid_R03B01.nc"};
833 for (
int i = 0;
i < 2; ++
i)
837 malloc(strlen(argv[1]) + strlen(grid_filenames[i]) + 2), argv[1]),
842 filenames[is_src], local_grid_comm);
852 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
854 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
865 size_t num_tgt_cells, num_tgt_vertices, num_tgt_edges;
866 utest_get_basic_grid_data(
867 filenames[0], &num_tgt_cells, &num_tgt_vertices, &num_tgt_edges);
876 yac_int * tgt_global_ids =
xmalloc(count *
sizeof(*tgt_global_ids));
878 interp_grid, tgt_points, count, tgt_global_ids);
883 interp_grid, 0, tgt_global_ids, count, src_points);
884 free(tgt_global_ids);
889 interp_grid, tgt_points,
count),
894 interp_grid, 0, src_points, count);
904 double *** src_data, *** src_frac_masks, ** tgt_data;
907 src_data =
xmalloc(4 *
sizeof(*src_data));
908 for (
size_t i = 0;
i < 4; ++
i)
909 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
911 for (
size_t collection_idx = 0; collection_idx < 4;
921 src_frac_masks =
xmalloc(4 *
sizeof(*src_frac_masks));
922 for (
size_t i = 0;
i < 4; ++
i)
923 src_frac_masks[i] =
xmalloc(1 *
sizeof(**src_frac_masks));
925 for (
size_t collection_idx = 0; collection_idx < 4;
927 double * src_frac_mask =
930 src_frac_mask[i] = (
grid_data.cell_ids[i]&1)?1.0:0.0;
931 src_frac_masks[collection_idx][0] = src_frac_mask;
935 tgt_data =
xmalloc(4 *
sizeof(*tgt_data));
936 for (
size_t collection_idx = 0; collection_idx < 4;
938 tgt_data[collection_idx] =
941 src_frac_masks = NULL;
945 for (
size_t reorder_type = 0; reorder_type < reorder_type_count;
949 if (utest_check_direct_results(
952 PUT_ERR(
"ERROR(yac_interp_weights_add_direct): "
953 "invalid interpolation result");
958 "test_interp_weights_parallel_direct.nc";
974 if (utest_check_direct_results(
976 src_data, src_frac_masks, tgt_data))
977 PUT_ERR(
"ERROR(yac_interp_weights_add_direct): "
978 "invalid interpolation result (read from file)");
984 for (
size_t collection_idx = 0; collection_idx < 4; ++collection_idx) {
985 free(src_data[collection_idx][0]);
986 free(src_data[collection_idx]);
987 free(src_frac_masks[collection_idx][0]);
988 free(src_frac_masks[collection_idx]);
991 free(src_frac_masks);
993 for (
size_t collection_idx = 0; collection_idx < 4; ++collection_idx)
994 free(tgt_data[collection_idx]);
1005 MPI_Comm_free(&local_grid_comm);
1009 int is_src = comm_rank < (comm_size / 2);
1011 MPI_Comm local_grid_comm;
1012 int local_grid_comm_size;
1013 MPI_Comm_split(MPI_COMM_WORLD, is_src, 0, &local_grid_comm);
1014 MPI_Comm_size(local_grid_comm, &local_grid_comm_size);
1019 PUT_ERR(
"ERROR: missing grid file directory");
1025 char * filenames[2];
1026 char * grid_filenames[] =
1027 {
"icon_grid_R02B01.nc",
"icon_grid_R03B01.nc"};
1028 for (
int i = 0;
i < 2; ++
i)
1032 malloc(strlen(argv[1]) + strlen(grid_filenames[i]) + 2), argv[1]),
1037 filenames[is_src], local_grid_comm);
1047 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
1049 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
1060 size_t num_tgt_cells, num_tgt_vertices, num_tgt_edges;
1061 utest_get_basic_grid_data(
1062 filenames[0], &num_tgt_cells, &num_tgt_vertices, &num_tgt_edges);
1064 if (comm_rank == 0) {
1069 interp_grid, (
size_t[]){0}, 1), .
count = 1};
1073 interp_grid, 0, (
size_t[]){0}, 1);
1091 for (
size_t i = 1;
i <= 16;
i *= 2) {
1108 MPI_Comm_free(&local_grid_comm);
1132 switch (comm_rank) {
1138 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}};
1140 .
data = remote_tgt_points,
1141 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1150 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}}};
1152 .
data = remote_tgt_points,
1153 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1165 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}};
1167 .
data = remote_tgt_points,
1168 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1177 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}};
1179 .
data = remote_tgt_points,
1180 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1184 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}};
1193 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}}};
1195 .
data = remote_tgt_points,
1196 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1200 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}}};
1206 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}}};
1208 .
data = remote_tgt_points,
1209 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1211 size_t num_src_per_tgt[] = {2};
1214 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
1216 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}};
1225 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 6}}}};
1227 .
data = remote_tgt_points,
1228 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1230 size_t num_src_per_tgt[] = {3};
1233 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1235 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
1237 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}};
1243 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 7}}}};
1245 .
data = remote_tgt_points,
1246 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1248 size_t num_src_per_tgt[] = {2};
1251 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1253 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}};
1254 double w[] = {0.5, 0.5};
1263 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 8}}}};
1265 .
data = remote_tgt_points,
1266 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1268 size_t num_src_per_tgt[] = {3};
1271 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}},
1273 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}},
1275 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}}};
1276 double w[] = {0.2, 0.5, 0.4};
1310 switch (comm_rank) {
1314 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 10}}},
1316 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 11}}}
1319 .
data = remote_tgt_points,
1320 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1323 size_t num_stencils_per_tgt[] = {1,2};
1324 size_t stencil_indices[] = {0,1,0};
1325 int stencil_ranks[] = {0,0,1};
1326 double w[] = {1.0,4.0,0.5};
1329 weights, &tgts, num_stencils_per_tgt, stencil_indices,
1337 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 12}}},
1339 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 13}}}
1342 .
data = remote_tgt_points,
1343 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1346 size_t num_stencils_per_tgt[] = {1,2};
1347 size_t stencil_indices[] = {1,0,1};
1348 int stencil_ranks[] = {1,2,1};
1349 double w[] = {0.3,0.5,0.1};
1352 weights, &tgts, num_stencils_per_tgt, stencil_indices,
1360 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 14}}},
1362 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 15}}},
1364 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 16}}}
1367 .
data = remote_tgt_points,
1368 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1371 size_t num_stencils_per_tgt[] = {1,2,3};
1372 size_t stencil_indices[] = {1,1,0,0,0,1};
1373 int stencil_ranks[] = {2,1,3,2,3,2};
1374 double w[] = {0.2,0.1,0.9,0.3,0.3,0.4};
1377 weights, &tgts, num_stencils_per_tgt, stencil_indices,
1385 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 17}}},
1387 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 18}}},
1389 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 19}}},
1391 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 20}}},
1393 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 21}}},
1395 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 22}}}};
1397 .
data = remote_tgt_points,
1398 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1401 size_t num_stencils_per_tgt[] = {1,2,3,2,1,1};
1402 size_t stencil_indices[] = {1,1,1,0,1,0,1,1,1,0};
1403 int stencil_ranks[] = {3,3,1,2,2,4,1,2,1,0};
1404 double w[] = {0.1,0.2,0.8,0.1,0.2,0.3,1.0,1.0,0.5,0.9};
1407 weights, &tgts, num_stencils_per_tgt, stencil_indices,
1415 weights, NULL, NULL, NULL, NULL, NULL);
1425 if (comm_rank == 0) {
1427 double src_field_data[] = {1,2,3,4,5,6,7,8,9,10},
1428 tgt_field_data[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
1429 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
1430 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
1432 {1.0,2.0,3.0,1.0,2.0,3.0+4.0,2.0+3.0+4.0,0.5*2.0+0.5*4.0,
1433 0.2*4.0+0.5*6.0+0.4*5.0,-1,
1434 1.0,9.5,0.3*(1.0),0.5*(2.0)+0.1*(1.0),0.2*(3.0+4.0),
1435 0.1*(1.0)+0.9*(2.0+3.0+4.0),
1436 0.3*(2.0)+0.3*(2.0+3.0+4.0)+0.4*(3.0+4.0),
1437 0.1*(0.5*2.0 + 0.5*4.0),0.2*(0.5*2.0+0.5*4.0)+0.8*(1.0),
1438 0.1*(2.0)+0.2*(3.0+4.0)+0.3*(0.2*4.0+0.5*6.0+0.4*5.0),
1439 1.0*1.0+1.0*(3.0+4.0),0.5*1.0,0.9,-1,-1,-1,-1,-1,-1,-1};
1447 PUT_ERR(
"invalid reference data");
1452 PUT_ERR(
"ERROR in yac_interp_weights_wcopy_weights");
1484 switch (comm_rank) {
1488 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1490 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}}};
1492 .
data = remote_tgt_points,
1493 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1495 size_t num_src_per_tgt[] = {3,3};
1498 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1500 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1506 {{.rank = 0, .orig_pos = 2},{.rank = 1, .orig_pos = 0}}}},
1508 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1510 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 1}}},
1516 {{.rank = 1, .orig_pos = 2},{.rank = 2, .orig_pos = 0}}}}};
1523 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
1525 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}};
1527 .
data = remote_tgt_points,
1528 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1530 size_t num_src_per_tgt[] = {3,3};
1537 {{.rank = 0, .orig_pos = 2},{.rank = 1, .orig_pos = 0}}}},
1539 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 1}}},
1545 {{.rank = 1, .orig_pos = 2},{.rank = 2, .orig_pos = 0}}}},
1547 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1553 {{.rank = 1, .orig_pos = 2},{.rank = 2, .orig_pos = 0}}}},
1555 .data = {.count = 1, .data.single = {.rank = 2, .orig_pos = 2}}}};
1562 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}},
1564 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}}};
1566 .
data = remote_tgt_points,
1567 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1569 size_t num_src_per_tgt[] = {3,3};
1572 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1574 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1580 {{.rank = 0, .orig_pos = 2},{.rank = 1, .orig_pos = 0}}}},
1582 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1584 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 1}}},
1590 {{.rank = 1, .orig_pos = 2},{.rank = 2, .orig_pos = 0}}}}};
1591 double w[] = {0.3,0.4,0.5, 0.1,0.1,0.1};
1598 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 6}}},
1600 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 7}}}};
1602 .
data = remote_tgt_points,
1603 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1605 size_t num_src_per_tgt[] = {3,3};
1612 {{.rank = 0, .orig_pos = 2},{.rank = 1, .orig_pos = 0}}}},
1614 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 1}}},
1620 {{.rank = 1, .orig_pos = 2},{.rank = 2, .orig_pos = 0}}}},
1622 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1628 {{.rank = 1, .orig_pos = 2},{.rank = 2, .orig_pos = 0}}}},
1630 .data = {.count = 1, .data.single = {.rank = 2, .orig_pos = 2}}}};
1631 double w[] = {1.0,1.0,1.0, 1.0,2.0,3.0};
1654 switch (comm_rank) {
1658 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 8}}},
1660 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 9}}},
1662 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 10}}},
1664 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 11}}}};
1666 .
data = remote_tgt_points,
1667 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1670 size_t num_stencils_per_tgt[] = {2,4,4,4};
1671 size_t stencil_indices[] = {0,0, 0,1,0,1, 0,1,0,1, 0,1,0,1};
1672 int stencil_ranks[] = {0,1, 0,0,1,1, 1,1,2,2, 2,2,3,3};
1674 {1.0,1.0, 0.1,0.2,0.3,0.4, 0.2,0.2,0.2,0.2, 0.25,0.25,0.25,0.25};
1677 weights, &tgts, num_stencils_per_tgt, stencil_indices,
1685 weights, NULL, NULL, NULL, NULL, NULL);
1689 for (
size_t i = 0;
i < reorder_type_count; ++
i) {
1696 double src_field_data[3][3] = {{1,2,3},{3,4,5},{5,6,7}};
1698 {src_field_data[0],src_field_data[1],src_field_data[2],NULL,NULL};
1699 double ** src_fields = &(
src_field[comm_rank]);
1700 double tgt_field_data[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
1705 if (comm_rank == 0) {
1712 0.3*1.0+0.4*2.0+0.5*3.0,
1713 0.1*2.0+0.1*4.0+0.1*5.0,
1714 1.0*3.0+1.0*4.0+1.0*5.0,
1715 1.0*1.0+2.0*5.0+3.0*7.0,
1716 1.0*(1.0+2.0+3.0)+1.0*(3.0+4.0+5.0),
1717 0.1*(1.0+2.0+3.0)+0.2*(2.0+4.0+5.0)+
1718 0.3*(3.0+4.0+5.)+0.4*(1.0+5.0+7.0),
1719 0.2*(3.0+4.0+5.0)+0.2*(1.0+5.0+7.0)+
1720 0.2*(0.3*1.0+0.4*2.0+0.5*3.0)+0.2*(0.1*2.0+0.1*4.0+0.1*5.0),
1721 0.25*(0.3*1.0+0.4*2.0+0.5*3.0)+0.25*(0.1*2.0+0.1*4.0+0.1*5.0)+
1722 0.25*(1.0*3.0+1.0*4.0+1.0*5.0)+0.25*(1.0*1.0+2.0*5.0+3.0*7.0)};
1725 PUT_ERR(
"invalid reference data");
1730 PUT_ERR(
"ERROR in yac_interp_weights_wcopy_weights");
1746 if (comm_rank == 0) {
1752 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}};
1754 .
data = remote_tgt_points,
1755 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1757 size_t num_src_per_tgt[] = {1};
1760 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}};
1769 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}}};
1771 .
data = remote_tgt_points,
1772 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1776 size_t num_stencils_per_tgt[] = {1 + 9 *
N};
1777 size_t stencil_indices[1 + 9 *
N];
1778 int stencil_ranks[1 + 9 *
N];
1779 double w[1 + 9 *
N];
1781 for (
size_t i = 0;
i < (1 + 9 *
N); ++
i) {
1782 stencil_indices[
i] = 0;
1783 stencil_ranks[
i] = 0;
1785 for (
int i = 0, k = 0;
i <
N; ++
i)
1786 for (
int j = 0; j < 9; ++j, ++k)
1787 w[k] = pow(10.0, (
double)(-
i));
1788 w[9 *
N] = pow(10.0, (
double)(-
N+1));
1792 weights, &tgts, num_stencils_per_tgt, stencil_indices,
1797 weights, NULL, NULL, NULL, NULL, NULL);
1799 for (
size_t i = 0;
i < reorder_type_count; ++
i) {
1806 double src_field_data[1][1] = {{1}};
1807 double *
src_field[5] = {src_field_data[0],NULL,NULL,NULL,NULL};
1808 double ** src_fields = &(
src_field[comm_rank]);
1814 if (comm_rank == 0) {
1819 PUT_ERR(
"invalid reference data");
1824 PUT_ERR(
"ERROR in yac_interp_weights_wcopy_weights");
1840 switch (comm_rank) {
1868 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1870 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
1872 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}
1875 .
data = remote_tgt_points,
1876 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1878 size_t num_src_per_field_per_tgt[3][3] = {{1,1,1},{2,1,3},{2,0,1}};
1881 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1883 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1885 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
1887 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}},
1889 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}},
1891 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1893 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}}},
1895 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1897 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}},
1899 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
1901 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1903 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}}}};
1905 {srcs_per_field_data[0],
1906 srcs_per_field_data[1],
1907 srcs_per_field_data[2]};
1908 double w[] = {0.3,0.3,1.0, 0.1,0.1,0.2,0.3,0.3,0.3, 1.0,1.0,1.0};
1910 weights, &tgts, &num_src_per_field_per_tgt[0][0],
1911 srcs_per_field, w, 3);
1941 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}},
1943 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}},
1945 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 6}}}
1948 .
data = remote_tgt_points,
1949 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
1951 size_t num_src_per_field_per_tgt[3][3] = {{1,1,1},{2,1,3},{2,0,1}};
1954 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1956 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1958 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
1960 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}},
1962 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}},
1964 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1966 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}}},
1968 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
1970 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}},
1972 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
1974 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
1976 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}}}};
1978 {srcs_per_field_data[0],
1979 srcs_per_field_data[1],
1980 srcs_per_field_data[2]};
1982 weights, &tgts, &num_src_per_field_per_tgt[0][0], srcs_per_field, 3);
2003 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 7}}},
2005 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 8}}},
2007 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 9}}},
2009 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 10}}},
2011 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 11}}}};
2013 .
data = remote_tgt_points,
2014 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2016 size_t src_field_indices[] = {0,2,1,2,2};
2019 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}},
2021 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}},
2023 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}},
2025 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
2027 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}}};
2029 {srcs_per_field_data[0],
2030 srcs_per_field_data[1],
2031 srcs_per_field_data[2]};
2033 weights, &tgts, src_field_indices, srcs_per_field, 3);
2040 for (
size_t i = 0;
i < reorder_type_count; ++
i) {
2044 double scaling_factor = 1.0;
2045 double scaling_summand = 0.0;
2051 yaxt_exchanger_name, 1, 1);
2059 if (comm_rank == 0) {
2061 double src_field_data[3][10] = {{1,2,3,4,5,6,7,8,9,10},
2062 {10,20,30,40,50,60,70,80,90,100},
2063 {100,200,300,400,500,600,700,800,900,1000}};
2064 double tgt_field_data[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
2065 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
2068 {0.3*1.0+0.3*10.0+1.0*100.0,
2070 0.1*2.0+0.1*3.0+0.2*20.0+0.3*400.0+0.3*300.0+0.3*200.0,
2071 1.0*6.0+1.0*3.0+1.0*500.0,
2073 2.0+3.0+20.0+400.0+300.0+200.0,
2080 -1,-1,-1,-1,-1,-1,-1,-1};
2082 {src_field_data[0], src_field_data[1], src_field_data[2]};
2089 PUT_ERR(
"invalid reference data");
2094 PUT_ERR(
"ERROR in multi source field support");
2100 utest_interpolation_execute_raw(
2102 &src_fields, &tgt_field);
2105 PUT_ERR(
"invalid reference data");
2110 PUT_ERR(
"ERROR in multi source field support raw");
2116 utest_interpolation_execute_raw(
2123 interpolation_exchange,
"direct_mf");
2137 switch (comm_rank) {
2144 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}};
2146 .
data = remote_tgt_points,
2147 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2149 size_t src_field_indices[] = {0,0,0};
2152 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}}};
2153 struct remote_point * srcs_per_field[] = {srcs_per_field_data[0]};
2155 weights, &tgts, src_field_indices, srcs_per_field, 1);
2165 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}}};
2167 .
data = remote_tgt_points,
2168 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2170 size_t num_src_per_field_per_tgt[1][1] = {{2}};
2173 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
2175 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}}};
2176 struct remote_point * srcs_per_field[] = {srcs_per_field_data[0]};
2178 weights, &tgts, &num_src_per_field_per_tgt[0][0], srcs_per_field, 1);
2188 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 6}}}};
2190 .
data = remote_tgt_points,
2191 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2193 size_t num_src_per_field_per_tgt[1][1] = {{2}};
2196 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}},
2198 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}}};
2199 struct remote_point * srcs_per_field[] = {srcs_per_field_data[0]};
2200 double w[] = {0.7,0.3};
2202 weights, &tgts, &num_src_per_field_per_tgt[0][0],
2203 srcs_per_field, w, 1);
2211 double scaling_factor = 1.0;
2212 double scaling_summand = 0.0;
2225 if (comm_rank == 0) {
2227 double src_field_data[1][10] = {{1,2,3,4,5,6,7,8,9,10}};
2231 {-1,-1,3.0,-1,1.0+3.0,-1,0.7*6.0+0.3*3.0,-1};
2232 double *
src_field[1] = {src_field_data[0]};
2239 PUT_ERR(
"invalid reference data");
2244 PUT_ERR(
"ERROR in multi source field support");
2249 utest_interpolation_execute_raw(
2251 &src_fields, &tgt_field);
2256 PUT_ERR(
"ERROR in multi source field support");
2262 utest_interpolation_execute_raw(
2269 interpolation_exchange,
"interpolation raw");
2283 switch (comm_rank) {
2294 {.rank = 1, .orig_pos = 2},
2295 {.rank = 2, .orig_pos = 2},
2296 {.rank = 3, .orig_pos = 2},
2297 {.rank = 4, .orig_pos = 2}}}}};
2299 .
data = remote_tgt_points,
2300 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2302 size_t src_field_indices[] = {1};
2306 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 2}}}}};
2308 {srcs_per_field_data[0], srcs_per_field_data[1]};
2310 weights, &tgts, src_field_indices, srcs_per_field, 2);
2325 {.rank = 1, .orig_pos = 4},
2326 {.rank = 2, .orig_pos = 4},
2327 {.rank = 3, .orig_pos = 4},
2328 {.rank = 4, .orig_pos = 4}}}}};
2330 .
data = remote_tgt_points,
2331 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2333 size_t num_src_per_field_per_tgt[2][1] = {{1},{1}};
2336 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 0}}}},
2338 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 2}}}}};
2340 {srcs_per_field_data[0], srcs_per_field_data[1]};
2342 weights, &tgts, &num_src_per_field_per_tgt[0][0], srcs_per_field, 2);
2357 {.rank = 1, .orig_pos = 6},
2358 {.rank = 2, .orig_pos = 6},
2359 {.rank = 3, .orig_pos = 6},
2360 {.rank = 4, .orig_pos = 6}}}}};
2362 .
data = remote_tgt_points,
2363 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2365 size_t num_src_per_field_per_tgt[2][1] = {{1},{1}};
2368 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 5}}}},
2370 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 2}}}}};
2372 {srcs_per_field_data[0],srcs_per_field_data[1]};
2373 double w[] = {0.7,0.3};
2375 weights, &tgts, &num_src_per_field_per_tgt[0][0],
2376 srcs_per_field, w, 2);
2384 double scaling_factor = 1.0;
2385 double scaling_summand = 0.0;
2397 double src_field_data[2][10] =
2398 {{1,2,3,4,5,6,7,8,9,10},{10,20,30,40,50,60,70,80,90,100}};
2402 {-1,-1,30.0,-1,1.0+30.0,-1,0.7*6.0+0.3*30.0,-1};
2403 double *
src_field[2] = {src_field_data[0],src_field_data[1]};
2408 interpolation, (comm_rank == 1)?(&src_fields):NULL, &
tgt_field);
2411 PUT_ERR(
"invalid reference data");
2416 PUT_ERR(
"ERROR in multi source field support");
2421 utest_interpolation_execute_raw(
2423 (comm_rank == 1)?(&src_fields):NULL, &
tgt_field);
2428 PUT_ERR(
"ERROR in multi source field support");
2432 interpolation_exchange,
"interpolation raw");
2445 switch (comm_rank) {
2458 {.rank = 2, .orig_pos = 1},
2459 {.rank = 2, .orig_pos = 2},
2460 {.rank = 1, .orig_pos = 2},
2461 {.rank = 0, .orig_pos = 5},
2462 {.rank = 1, .orig_pos = 4},
2463 {.rank = 2, .orig_pos = 0},
2464 {.rank = 3, .orig_pos = 0},
2465 {.rank = 0, .orig_pos = 3},
2466 {.rank = 4, .orig_pos = 1}}}}};
2468 .
data = remote_tgt_points,
2469 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2471 size_t num_src_per_field_per_tgt[2][1] = {{1},{1}};
2474 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}}},
2476 .data = {.count = 1, .data.single = {.rank = 1, .orig_pos = 2}}}}};
2478 {srcs_per_field_data[0],srcs_per_field_data[1]};
2479 double w[] = {0.7,0.3};
2481 weights, &tgts, &num_src_per_field_per_tgt[0][0],
2482 srcs_per_field, w, 2);
2488 for (
size_t i = 0;
i < reorder_type_count; ++
i) {
2492 double scaling_factor = 1.0;
2493 double scaling_summand = 0.0;
2506 double src_field_data[2][10] =
2507 {{1,2,3,4,5,6,7,8,9,10},{10,20,30,40,50,60,70,80,90,100}};
2510 double ref_target_value = 0.7*2.0 + 0.3*30.0;
2512 {{-1,ref_target_value,-1,ref_target_value,-1,ref_target_value,-1,-1},
2513 {-1,-1,ref_target_value,-1,ref_target_value,-1,-1,-1},
2514 {ref_target_value,ref_target_value,ref_target_value,-1,-1,-1,-1,-1},
2515 {ref_target_value,-1,-1,-1,-1,-1,-1,-1},
2516 {-1,ref_target_value,-1,-1,-1,-1,-1,-1}};
2517 double *
src_field[2] = {(comm_rank==0)?(src_field_data[0]):NULL,
2518 (comm_rank==1)?(src_field_data[1]):NULL};
2523 interpolation, &src_fields, &tgt_field);
2526 PUT_ERR(
"invalid reference data");
2531 PUT_ERR(
"ERROR in multi source field support");
2536 utest_interpolation_execute_raw(
2538 &src_fields, &tgt_field);
2543 PUT_ERR(
"ERROR in multi source field support");
2547 interpolation_exchange,
"interpolation raw");
2569 "test_interp_weights_parallel_empty.nc";
2575 MPI_Barrier(MPI_COMM_WORLD);
2598 "test_interp_weights_parallel_empty.nc";
2604 MPI_Barrier(MPI_COMM_WORLD);
2622 size_t num_src_per_tgt[] = {0};
2628 "test_interp_weights_parallel_empty.nc";
2634 MPI_Barrier(MPI_COMM_WORLD);
2650 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}};
2652 .
data = remote_tgt_points,
2653 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2655 size_t num_src_per_tgt[] = {0};
2661 "test_interp_weights_parallel_empty.nc";
2667 MPI_Barrier(MPI_COMM_WORLD);
2683 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}};
2685 .
data = remote_tgt_points,
2686 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2688 size_t num_src_per_tgt[] = {0};
2694 "test_interp_weights_parallel_empty.nc";
2700 MPI_Barrier(MPI_COMM_WORLD);
2718 size_t num_src_per_tgt[] = {0};
2724 "test_interp_weights_parallel_empty.nc";
2730 MPI_Barrier(MPI_COMM_WORLD);
2745 if (comm_rank == 0) {
2750 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}},
2752 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}}};
2755 .count =
sizeof(
tgt_points) /
sizeof(tgt_points[0]),
2759 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 4}}},
2761 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 5}}}};
2768 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
2770 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
2772 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
2774 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}},
2776 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 6}}},
2778 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 7}}},
2780 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 8}}},
2782 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 9}}}};
2785 .count =
sizeof(
tgt_points) /
sizeof(tgt_points[0]),
2792 "test_interp_weights_parallel_bug_check.nc";
2797 MPI_Barrier(MPI_COMM_WORLD);
2835 if (comm_rank == 0) {
2838 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
2840 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
2842 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
2844 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}};
2846 .
data = remote_tgt_points,
2847 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2849 size_t num_src_per_tgt[] = {4, 4, 4, 4};
2852 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
2854 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
2856 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
2858 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}},
2860 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
2862 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
2864 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
2866 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}},
2868 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
2870 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
2872 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
2874 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}},
2876 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
2878 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}},
2880 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}},
2882 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 3}}}};
2883 double w[] = {0.25, 0.25, 0.25, 0.25,
2884 0.25, 1.e-16, 0.25, 1.e-16,
2885 0.25, 0.25, 0.25, 0.25,
2886 1.e-16, 1.e-16, 1.e-16, 1.e-16};
2895 if (comm_rank == 0) {
2896 double src_field_data[] = {1.0, 2.0, 3.0, 4.0};
2899 0.25 * (1.0 + 2.0 + 3.0 + 4.0),
2901 0.25 * (1.0 + 2.0 + 3.0 + 4.0),
2902 1e-16 * (1.0 + 2.0 + 3.0 + 4.0)
2910 for (
size_t i = 0;
i < 4; ++
i) {
2912 PUT_ERR(
"ERROR: weights incorrectly deleted based on absolute tolerance");
2928 "test_interp_weights_parallel_nan_fixed.nc";
2936 if (comm_rank == 0) {
2939 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}},
2941 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 1}}}};
2943 .
data = remote_tgt_points,
2944 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
2964 utest_generate_dummy_grid_data(
2965 (comm_rank == 0)?2:0, 2, 0);
2976 {{.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX,
2977 .masks_idx = SIZE_MAX}};
2978 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
2980 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX,
2981 .masks_idx = SIZE_MAX};
3012 if (comm_rank == 0) {
3014 for (
size_t i = 0;
i < 2; ++
i)
3016 PUT_ERR(
"wrong NaN fixed value result");
3035 for (
size_t i = 0;
i < tgts.
count; ++
i) {
3042 size_t num_src_per_tgt[2] = {0, 1};
3046 .count = 1, .data = {.single = {.rank = comm_rank, .orig_pos = 0}}}
3048 double w[1] = {2.0};
3053 if (interp_count != 1)
3054 PUT_ERR(
"ERROR(yac_interp_weights_add_wsum): "
3055 "unexpected number of generated stencils");
3059 PUT_ERR(
"ERROR(yac_interp_weights_add_wsum): "
3060 "target with zero sources was not skipped");
3078 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}};
3080 .
data = remote_tgt_points,
3081 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
3093 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 0}}}};
3095 .
data = remote_tgt_points,
3096 .count =
sizeof(remote_tgt_points) /
sizeof(remote_tgt_points[0]),
3098 size_t num_src_per_tgt[] = {1};
3101 .data = {.count = 1, .data.single = {.rank = 0, .orig_pos = 2}}}};
3105 for (
int with_existing_weight_file = 0; with_existing_weight_file < 2;
3106 ++with_existing_weight_file) {
3113 enum {NUM_ON_EXISTING =
sizeof(
on_existing) /
sizeof(on_existing[0])};
3115 for (
size_t on_existing_idx = 0; on_existing_idx < NUM_ON_EXISTING;
3116 ++on_existing_idx) {
3118 if (with_existing_weight_file)
3129 with_existing_weight_file)
3134 MPI_Barrier(MPI_COMM_WORLD);
3137 0, 0, curr_on_existing);
3139 int contains_links = 0;
3140 int contains_fixed = 0;
3142 with_existing_weight_file))
3143 utest_get_basic_weight_file_info(
3146 switch(curr_on_existing) {
3148 if (with_existing_weight_file) {
3150 if (!contains_fixed || contains_links)
3151 PUT_ERR(
"error in yac_interp_weights_write_to_file");
3153 if (contains_fixed || !contains_links)
3154 PUT_ERR(
"error in yac_interp_weights_write_to_file");
3159 if (contains_fixed || !contains_links)
3160 PUT_ERR(
"error in yac_interp_weights_write_to_file");
3164 if (!with_existing_weight_file) {
3166 if (contains_fixed || !contains_links)
3167 PUT_ERR(
"error in yac_interp_weights_write_to_file");
3171 int abort_handler_was_called = 0;
3173 MPI_IN_PLACE, &abort_handler_was_called, 1,
3174 MPI_INT, MPI_MAX, MPI_COMM_WORLD);
3176 if (!abort_handler_was_called)
3177 PUT_ERR(
"error in yac_interp_weights_write_to_file");
3179 MPI_Barrier(MPI_COMM_WORLD);
3188 PUT_ERR(
"internal test error");
3192 MPI_Barrier(MPI_COMM_WORLD);
3201 PUT_ERR(
"internal test error");
3208static int utest_check_fixed_results_(
3211 double * field_data) {
3216 for (
size_t j = 0; j <
grid->num_cells; ++j)
3217 field_data[j] = (
double)1;
3219 for (
size_t j = 0; j <
grid->num_cells; ++j)
3220 field_data[j] = (
double)-3;
3224 src_fields = &field_data;
3234 for (
size_t j = 0; j <
grid->num_cells; ++j) {
3235 if (
grid->core_cell_mask[j]) {
3236 if (
grid->cell_ids[j] & 1) {
3237 if (tgt_field[j] != -1.0) ++err_count;
3239 if (tgt_field[j] != -2.0) ++err_count;
3242 if (tgt_field[j] != -3.0) ++err_count;
3253 double ** src_data_raw;
3254 static double dummy;
3255 int with_frac_mask =
3269 sizeof(*(src_data_raw[k]))):&dummy;
3272 if (with_frac_mask) {
3279 sizeof(*(src_data_raw[k]))):&dummy;
3284 return src_data_raw;
3289 double ** src_data_raw) {
3291 int with_frac_mask =
3297 free(src_data_raw[k]);
3302 free(src_data_raw[k]);
3306#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 24)
3312 double ** src_data_raw,
double ** tgt_field) {
3314#define FRAC_MASK_TOL (1e-12)
3316 int with_frac_mask =
3331 if (with_frac_mask) {
3333 size_t wgt_offset = 0;
3335 double tgt_value = 0.0;
3336 double frac_weight_sum = 0.0;
3337 double weight_sum = 0.0;
3338#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 24)
3343 ++k, ++wgt_offset) {
3359#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 24)
3365 (tgt_value / frac_weight_sum * weight_sum) +
3372 size_t wgt_offset = 0;
3374 double tgt_value = 0.0;
3375#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 24)
3380 ++k, ++wgt_offset) {
3388#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 24)
3400static void utest_interpolation_execute_frac_raw(
3403 size_t collection_size,
double *** src_fields,
double *** src_frac_masks,
3404 double ** tgt_field) {
3406 int with_frac_mask =
3409 double const * src_fields_2d[
3417 src_fields_2d[k] = src_fields?src_fields[i][j]:&dummy;
3421 src_fields_2d[k] = src_frac_masks?src_frac_masks[i][j]:&dummy;
3425 double ** src_data_raw =
3430 interpolation_exchange, src_fields_2d, src_data_raw,
3431 "utest_interpolation_execute_raw");
3441static void utest_interpolation_execute_raw(
3446 utest_interpolation_execute_frac_raw(
3448 src_fields, NULL, tgt_field);
3454 size_t collection_size,
double *** src_fields,
double *** src_frac_masks) {
3456 int with_frac_mask =
3459 double const * src_fields_2d[
3461 static double dummy;
3466 src_fields_2d[k] = src_fields?src_fields[i][j]:&dummy;
3470 src_fields_2d[k] = src_frac_masks?src_frac_masks[i][j]:&dummy;
3475 interpolation_exchange, src_fields_2d,
"interpolation_put_frac_raw");
3494 double ** src_data_raw =
3499 interpolation_exchange, src_data_raw,
"interpolation_get_raw");
3509static int utest_check_fixed_results_raw_(
3517 for (
size_t j = 0; j <
grid->num_cells; ++j)
3518 field_data[j] = (
double)1;
3520 for (
size_t j = 0; j <
grid->num_cells; ++j)
3521 field_data[j] = (
double)-3;
3525 src_fields = &field_data;
3533 utest_interpolation_execute_raw(
3535 &src_fields, &tgt_field);
3538 for (
size_t j = 0; j <
grid->num_cells; ++j) {
3539 if (
grid->core_cell_mask[j]) {
3540 if (
grid->cell_ids[j] & 1) {
3541 if (tgt_field[j] != -1.0) ++err_count;
3543 if (tgt_field[j] != -2.0) ++err_count;
3546 if (tgt_field[j] != -3.0) ++err_count;
3554static int utest_check_fixed_results(
3558 double * field_data) {
3564 double const scaling_factor = 1.0;
3565 double const scaling_summand = 0.0;
3572 yaxt_exchanger_name, 1, 1);
3577 utest_check_fixed_results_(grid, is_src, interpolation, field_data) +
3578 utest_check_fixed_results_(grid, is_src, interpolation_cpy, field_data);
3593 utest_check_fixed_results_raw_(
3597 interpolation_exchange,
"utest_check_fixed_results");
3604static int utest_check_direct_results(
3608 double *** src_fields,
double *** src_frac_masks,
double ** tgt_field) {
3625 yaxt_exchanger_name, 1, 1);
3628 for (
int interp_idx = 0; interp_idx < 2; ++interp_idx) {
3633 for (
size_t k = 0; k <
grid->num_cells; ++k)
3634 tgt_field[collection_idx][k] = -1;
3642 for (
size_t j = 0; j <
grid->num_cells; ++j) {
3643 if (
grid->core_cell_mask[j]) {
3644 if (tgt_field[collection_idx][j] !=
3645 (
double)(
grid->cell_ids[j])) err_count++;
3647 if (tgt_field[collection_idx][j] != -1.0) err_count++;
3658 for (
size_t k = 0; k <
grid->num_cells; ++k)
3659 tgt_field[collection_idx][k] = -1;
3663 for (
size_t j = 0; j <
grid->num_cells; ++j) {
3664 if (
grid->core_cell_mask[j]) {
3665 if (tgt_field[collection_idx][j] !=
3666 (
double)(
grid->cell_ids[j])) err_count++;
3668 if (tgt_field[collection_idx][j] != -1.0) err_count++;
3687 for (
int exchange_type = 0; exchange_type < 2; ++exchange_type) {
3692 for (
size_t k = 0; k <
grid->num_cells; ++k)
3693 tgt_field[collection_idx][k] = -1;
3695 if (exchange_type) {
3696 utest_interpolation_execute_raw(
3698 src_fields, tgt_field);
3713 for (
size_t j = 0; j <
grid->num_cells; ++j) {
3714 if (
grid->core_cell_mask[j]) {
3715 if (tgt_field[collection_idx][j] !=
3716 (
double)(
grid->cell_ids[j])) err_count++;
3718 if (tgt_field[collection_idx][j] != -1.0) err_count++;
3727 interpolation_exchange,
"utest_check_direct_results");
3742 scaling_factor, scaling_summand, yaxt_exchanger_name, 1, 1);
3745 for (
int interp_idx = 0; interp_idx < 2; ++interp_idx) {
3750 for (
size_t k = 0; k <
grid->num_cells; ++k)
3751 tgt_field[collection_idx][k] = -1;
3754 interpolations[interp_idx], src_fields, src_frac_masks, tgt_field);
3759 for (
size_t j = 0; j <
grid->num_cells; ++j) {
3760 if (
grid->core_cell_mask[j]) {
3761 if (
grid->cell_ids[j]&1) {
3762 if (tgt_field[collection_idx][j] !=
3763 (
double)(
grid->cell_ids[j])) err_count++;
3765 if (!isinf(tgt_field[collection_idx][j])) err_count++;
3768 if (tgt_field[collection_idx][j] != -1.0) err_count++;
3780 for (
size_t k = 0; k <
grid->num_cells; ++k)
3781 tgt_field[collection_idx][k] = -1;
3785 for (
size_t j = 0; j <
grid->num_cells; ++j) {
3786 if (
grid->core_cell_mask[j]) {
3787 if (
grid->cell_ids[j]&1) {
3788 if (tgt_field[collection_idx][j] !=
3789 (
double)(
grid->cell_ids[j])) err_count++;
3791 if (!isinf(tgt_field[collection_idx][j])) err_count++;
3794 if (tgt_field[collection_idx][j] != -1.0) err_count++;
3812 for (
int exchange_type = 0; exchange_type < 2; ++exchange_type) {
3817 for (
size_t k = 0; k <
grid->num_cells; ++k)
3818 tgt_field[collection_idx][k] = -1;
3820 if (exchange_type) {
3821 utest_interpolation_execute_frac_raw(
3823 src_fields, src_frac_masks, tgt_field);
3828 src_fields, src_frac_masks);
3838 for (
size_t j = 0; j <
grid->num_cells; ++j) {
3839 if (
grid->core_cell_mask[j]) {
3840 if (
grid->cell_ids[j]&1) {
3841 if (tgt_field[collection_idx][j] !=
3842 (
double)(
grid->cell_ids[j])) err_count++;
3844 if (!isinf(tgt_field[collection_idx][j])) err_count++;
3847 if (tgt_field[collection_idx][j] != -1.0) err_count++;
3856 interpolation_exchange,
"utest_check_direct_results");
3863static void utest_get_basic_grid_data(
3864 char * filename,
size_t *
num_cells,
size_t * num_vertices,
3865 size_t * num_edges) {
3883 utest_generate_dummy_grid_data(
3884 size_t local_num_cells, size_t global_num_cells, size_t num_cells_offset) {
3888 size_t num_cells[2] = {global_num_cells, 1};
3889 size_t local_start[2] = {num_cells_offset, 0};
3890 size_t local_count[2] = {local_num_cells, 1};
3892 for (
size_t i = 0;
i <= global_num_cells; ++
i)
coordinates_x[i] = (
double)
i;
3899static int utest_check_results_ref(
3902 double * tgt_data,
double * ref_tgt_data,
size_t tgt_size,
3903 int is_active_src,
int is_active_tgt) {
3913 double scale_factor;
3914 double scale_summand;
3915 char const * yaxt_exchanger;
3917 } interp_gen_config_params[] = {
3927 sizeof(interp_gen_config_params) /
sizeof(interp_gen_config_params[0])};
3934 for (
size_t config_idx = 0; config_idx < NUM_CONFIGS; ++config_idx) {
3936 double scale_factor = interp_gen_config_params[config_idx].scale_factor;
3937 double scale_summand = interp_gen_config_params[config_idx].scale_summand;
3941 interp_gen_config_params[config_idx].reorder_type);
3943 interp_gen_config, scale_factor);
3945 interp_gen_config, scale_summand);
3948 interp_gen_config_params[config_idx].yaxt_exchanger);
3953 weights, interp_gen_config, is_active_src, is_active_tgt);
3958 weights, interp_gen_config, &interpolation_exchange,
3961 for (
int interp_idx = 0; interp_idx < 2; ++interp_idx) {
3968 for (
size_t k = 0; k < tgt_size; ++k) tgt_data[k] = -1;
3974 for (
size_t j = 0; j < tgt_size; ++j)
3979 (ref_tgt_data[j] * scale_factor +
3980 scale_summand) - tgt_data[j]) <
TOL))))
3987 for (
size_t k = 0; k < tgt_size; ++k) tgt_data[k] = -1;
3990 for (
size_t j = 0; j < tgt_size; ++j)
3994 (fabs((ref_tgt_data[j] * scale_factor + scale_summand) -
3995 tgt_data[j]) <
TOL))))
4007 for (
size_t k = 0; k < tgt_size; ++k) tgt_data[k] = -1;
4009 utest_interpolation_execute_raw(
4011 src_fields, tgt_field);
4014 for (
size_t j = 0; j < tgt_size; ++j)
4018 (fabs((ref_tgt_data[j] * scale_factor + scale_summand) -
4019 tgt_data[j]) <
TOL))))
4024 interpolation_exchange,
"direct_mf");
4039 char att_text[attlen+1];
4040 memset(att_text,
'\0', attlen+1);
4041 YAC_HANDLE_ERROR(nc_get_att_text(ncid, NC_GLOBAL, attribute_name, att_text));
4043 attribute = (strlen(
"TRUE") == attlen) &&
4044 !strncmp(
"TRUE", att_text, attlen);
4047 ((strlen(
"FALSE") == attlen) &&
4048 !strncmp(
"FALSE", att_text, attlen)),
4049 " invalid global %s value %s", attribute_name, att_text);
4054static void utest_get_basic_weight_file_info(
4055 char const *
weight_file_name,
int * contains_links,
int * contains_fixed) {
4057 MPI_Barrier(MPI_COMM_WORLD);
4062 PUT_ERR(
"error in yac_interp_weights_write_to_file");
4063 *contains_fixed = 0;
4064 *contains_links = 0;
4075 MPI_Comm comm,
char const * msg,
char const * source,
int line) {
4082 int abort_handler_was_called = 1;
4084 MPI_IN_PLACE, &abort_handler_was_called, 1,
4085 MPI_INT, MPI_MAX, MPI_COMM_WORLD);
4088 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
4089 MPI_Barrier(MPI_COMM_WORLD);
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
char const * yac_basic_grid_get_name(struct yac_basic_grid *grid)
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)
struct yac_basic_grid_data yac_generate_basic_grid_data_reg2d(double const *global_coords_x, double const *global_coords_y, size_t const num_global_cells_[2], size_t const local_start[2], size_t const local_count[2], int with_halo)
void yac_interp_grid_delete(struct yac_interp_grid *interp_grid)
void yac_interp_grid_get_tgt_points(struct yac_interp_grid *interp_grid, size_t **tgt_indices, size_t *count)
void yac_interp_grid_get_tgt_global_ids(struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, yac_int *tgt_global_ids)
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)
struct remote_point * yac_interp_grid_get_tgt_remote_points(struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count)
struct remote_point * yac_interp_grid_get_src_remote_points(struct yac_interp_grid *interp_grid, size_t src_field_idx, size_t *src_points, size_t count)
void yac_interp_grid_src_global_to_local(struct yac_interp_grid *interp_grid, size_t src_field_idx, yac_int *src_global_ids, size_t count, size_t *src_local_ids)
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_file_new(char const *weight_file_name, enum yac_interp_file_on_missing_file on_missing_file, enum yac_interp_file_on_success on_success)
#define YAC_INTERP_FILE_ON_SUCCESS_DEFAULT
#define YAC_INTERP_FILE_ON_MISSING_FILE_DEFAULT
void yac_interp_weights_add_fixed(struct yac_interp_weights *weights, struct remote_points *tgts, double fixed_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_add_sum_mf(struct yac_interp_weights *weights, struct remote_points *tgts, size_t *num_src_per_field_per_tgt, struct remote_point **srcs_per_field, size_t num_src_fields)
struct yac_interpolation * yac_interp_weights_get_interpolation_ext(struct yac_interp_weights const *weights, struct yac_interpolation_gen_config const *config, int is_source, int is_target)
void yac_interp_weights_add_wsum(struct yac_interp_weights *weights, struct remote_points *tgts, size_t *num_src_per_tgt, struct remote_point *srcs, double *w)
void yac_interp_weights_delete(struct yac_interp_weights *weights)
void yac_interp_weights_get_interpolation_raw(struct yac_interp_weights *weights, size_t collection_size, double frac_mask_fallback_value, double scaling_factor, double scaling_summand, char const *yaxt_exchanger_name, struct yac_interpolation_exchange **interpolation_exchange, struct yac_interp_weights_data *interp_weights_data, int is_source, int is_target)
void yac_interp_weights_data_free(struct yac_interp_weights_data interp_weights_data)
void yac_interp_weights_wcopy_weights(struct yac_interp_weights *weights, struct remote_points *tgts, size_t *num_stencils_per_tgt, size_t *stencil_indices, int *stencil_ranks, double *w)
void yac_interp_weights_add_wsum_mf(struct yac_interp_weights *weights, struct remote_points *tgts, size_t *num_src_per_field_per_tgt, struct remote_point **srcs_per_field, double *w, size_t num_src_fields)
yac_int * yac_interp_weights_get_interp_tgt(struct yac_interp_weights *weights)
MPI_Comm yac_interp_weights_get_comm(struct yac_interp_weights *weights)
void yac_interp_weights_add_direct(struct yac_interp_weights *weights, struct remote_points *tgts, struct remote_point *srcs)
void yac_interp_weights_add_sum(struct yac_interp_weights *weights, struct remote_points *tgts, size_t *num_src_per_tgt, struct remote_point *srcs)
struct yac_interp_weights * yac_interp_weights_new(MPI_Comm comm, enum yac_location tgt_location, enum yac_location *src_locations, size_t num_src_fields)
size_t yac_interp_weights_get_interp_count(struct yac_interp_weights *weights)
void yac_interp_weights_get_interpolation_raw_ext(struct yac_interp_weights const *weights, struct yac_interpolation_gen_config const *config, struct yac_interpolation_exchange **interpolation_exchange, struct yac_interp_weights_data *interp_weights_data, int is_source, int is_target)
void yac_interp_weights_write_to_file(struct yac_interp_weights *weights, char const *filename, char const *src_grid_name, char const *tgt_grid_name, size_t src_grid_size, size_t tgt_grid_size, enum yac_weight_file_on_existing on_existing)
void yac_interp_weights_add_direct_mf(struct yac_interp_weights *weights, struct remote_points *tgts, size_t *src_field_indices, struct remote_point **srcs_per_field, size_t num_src_fields)
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
yac_weight_file_on_existing
@ YAC_WEIGHT_FILE_KEEP
keep existing weight file
@ YAC_WEIGHT_FILE_OVERWRITE
overwrite existing weight file
@ YAC_WEIGHT_FILE_ERROR
error when weight file existis already
struct yac_interpolation * yac_interpolation_copy(struct yac_interpolation *interp)
Create a deep copy of an interpolation object.
void yac_interpolation_execute(struct yac_interpolation *interp, double ***src_fields, double **tgt_field)
Execute interpolation synchronously and write results to the target field.
void yac_interpolation_delete(struct yac_interpolation *interp)
Free an interpolation object and release all resources.
void yac_interpolation_execute_frac(struct yac_interpolation *interp, double ***src_fields, double ***src_frac_masks, double **tgt_field)
Execute interpolation with fractional masks and write results to the target field.
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_frac(struct yac_interpolation *interp, double ***src_fields, double ***src_frac_masks)
Provide source field data with fractional masks and start asynchronous execution of interpolation (pu...
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
void yac_interpolation_exchange_execute_get(struct yac_interpolation_exchange *exchange, double **recv_data, char const *routine)
Execute the get phase and receive target data synchronously.
void yac_interpolation_exchange_execute(struct yac_interpolation_exchange *exchange, double const **send_data_, double **recv_data_, char const *routine)
Execute the full exchange (put + get) synchronously.
void yac_interpolation_exchange_execute_put(struct yac_interpolation_exchange *exchange, double const **send_data, char const *routine)
Execute only the put phase asynchronously.
void yac_interpolation_exchange_delete(struct yac_interpolation_exchange *exchange, char const *routine)
Delete an interpolation exchange and release resources.
Interpolation exchange object for temporary buffers and MPI exchanges.
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.
void yac_interpolation_gen_config_set_scaling_factor(struct yac_interpolation_gen_config *config, double scaling_factor)
Set the multiplicative scaling factor.
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.
void yac_interpolation_gen_config_delete(struct yac_interpolation_gen_config *config)
Release a interpolation generation configuration structure allocated by yac_interpolation_gen_config_...
struct yac_interpolation_gen_config * yac_interpolation_gen_config_new(void)
Allocate and initialise an interpolation generation configuration structure.
void yac_interpolation_gen_config_set_scaling_summand(struct yac_interpolation_gen_config *config, double scaling_summand)
Set the additive scaling summand.
Configuration management for interpolation generation.
#define YAC_FRAC_MASK_VALUE_IS_VALID(value)
Test whether a fractional mask value is valid.
int yac_file_exists(const char *filename)
Check whether a file exists.
void yac_nc_open(const char *path, int omode, int *ncidp)
void yac_nc_inq_dimid(int ncid, char const *name, int *dimidp)
struct yac_basic_grid_data yac_read_icon_basic_grid_data_parallel(const char *filename, MPI_Comm comm)
size_t * num_tgt_per_fixed_value
double frac_mask_fallback_value
single location information of a point
union remote_point_infos::@53 data
struct remote_point_info single
struct remote_point_info * multi
information (global id and location) about a point that
struct remote_point_infos data
structure containing the information (global id and location)
struct remote_point * data
enum yac_location location
struct yac_interp_field tgt_field
struct yac_dist_grid_pair * grid_pair
struct yac_interp_field src_fields[]
double frac_mask_fallback_value
Configuration structure for interpolation generation.
double frac_mask_fallback_value
void set_even_io_rank_list(MPI_Comm comm)
char const * weight_file_name
enum yac_interp_weights_reorder_type reorder_types[]
char const src_grid_name[]
char const tgt_grid_name[]
static double const fixed_value
enum yac_interp_spmap_weight_type weight_types[]
static double tgt_field_data[MAX_COLLECTION_SIZE][NUM_TGT_POINTS]
static double ref_tgt_field_data[MAX_COLLECTION_SIZE][NUM_TGT_POINTS]
static char const * grid_names[2]
static void on_existing_abort_handler(MPI_Comm comm, char const *msg, char const *source, int line)
static void interpolation_put_frac_raw(struct yac_interpolation_exchange *interpolation_exchange, struct yac_interp_weights_data interp_weights_data, size_t collection_size, double ***src_fields, double ***src_frac_masks)
static void interpolation_put_raw(struct yac_interpolation_exchange *interpolation_exchange, struct yac_interp_weights_data interp_weights_data, size_t collection_size, double ***src_fields)
static char const * weight_file_name_on_existing
int get_logical_attribute(int ncid, char const *attribute_name)
static void deallocate_src_data_raw(size_t collection_size, struct yac_interp_weights_data interp_weights_data, double **src_data_raw)
static double ** allocate_src_data_raw(size_t collection_size, struct yac_interp_weights_data interp_weights_data)
static void interpolation_get_raw(struct yac_interpolation_exchange *interpolation_exchange, struct yac_interp_weights_data interp_weights_data, size_t collection_size, double **tgt_field)
static void apply_interp_weights_data(size_t collection_size, struct yac_interp_weights_data interp_weights_data, double **src_data_raw, double **tgt_field)
struct @6 interpolations[]
#define YAC_HANDLE_ERROR(exp)
void(* yac_abort_func)(MPI_Comm comm, const char *msg, const char *source, int line) __attribute__((noreturn))
void yac_restore_default_abort_handler(void)
void yac_set_abort_handler(yac_abort_func custom_abort)
#define YAC_ASSERT_F(exp, format,...)