Test for stencil duplication.
#include <limits.h>
#include <mpi.h>
#include <yaxt.h>
#include "tests.h"
#include "dist_grid_utils.h"
generate_dummy_grid_data(
size_t local_num_cells, size_t global_num_cells, size_t num_cells_offset);
MPI_Init(NULL, NULL);
xt_initialize(MPI_COMM_WORLD);
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
if (comm_size != 3) {
PUT_ERR("This test requires 3 processes\n");
xt_finalize();
MPI_Finalize();
return TEST_EXIT_CODE;
}
generate_dummy_grid_data(5, 15, comm_rank * 5);
yac_int tgts_global_ids[3][5] = {{0,1,2,5,6},{7,8,9},{-1}};
int tgts_ranks[3][5] = {{0,0,0,1,1},{1,1,1},{-1}};
uint64_t tgts_orig_poses[3][5] = {{0,1,2,0,1},{2,3,4},{UINT64_MAX}};
int srcs_ranks[3][5] = {{1,1,1,1,2},{2,2,2},{-1}};
uint64_t srcs_orig_poses[3][5] = {{0,1,2,3,0},{1,2,3},{UINT64_MAX}};
size_t num_tgts[3] = {5, 3, 0};
tgts.
count = num_tgts[comm_rank];
for (
size_t i = 0; i < tgts.
count; ++i) {
srcs[i].data.count = 1;
srcs[i].data.data.single.rank = srcs_ranks[comm_rank][i];
srcs[i].data.data.single.orig_pos = srcs_orig_poses[comm_rank][i];
}
yac_int tgt_orig_global_id[3][4] = {{8,9},{-1},{0,1,8,9}};
size_t tgt_duplicated_idx[3][4] = {{3,4},{SIZE_MAX},{0,1,3,4}};
size_t nbr_duplicated[3] = {2,0,4};
weights, grid, tgt_orig_global_id[comm_rank],
tgt_duplicated_idx[comm_rank], nbr_duplicated[comm_rank],
YAC_LOC_CELL);
double src_field_data[3][4] =
{{-1, -1, -1, -1}, {0, 1, 2, 3}, {4, 5, 6, 7}};
double ** src_fields[1] = {(double*[1]){src_field_data[comm_rank]}};
double * tgt_field[1] = {(double[5]){-1,-1,-1,-1,-1}};
double ref_tgt_field[3][5] =
{{0,1,2,6,7}, {3,4,5,6,7}, {0,1,-1,6,7}};
for (size_t i = 0; i < 5; ++i)
if (ref_tgt_field[comm_rank][i] != tgt_field[0][i])
PUT_ERR("ERROR in yac_duplicate_stencils");
xt_finalize();
MPI_Finalize();
return TEST_EXIT_CODE;
}
generate_dummy_grid_data(
size_t local_num_cells, size_t global_num_cells, size_t num_cells_offset) {
double coordinates_x[global_num_cells + 1];
double coordinates_y[2] = {0.0, 1.0};
size_t local_start[2] = {num_cells_offset, 0};
size_t local_count[2] = {local_num_cells, 1};
for (size_t i = 0; i <= global_num_cells; ++i) coordinates_x[i] = (double)i;
return
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y,
num_cells, local_start, local_count, 0);
}
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
void yac_basic_grid_delete(struct yac_basic_grid *grid)
int main(int argc, char **argv)
void yac_duplicate_stencils(struct yac_interp_weights *weights, struct yac_basic_grid *tgt_grid, yac_int *tgt_orig_global_id, size_t *tgt_duplicated_idx, size_t nbr_duplicated, enum yac_location location)
void yac_interp_weights_delete(struct yac_interp_weights *weights)
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)
void yac_interp_weights_add_direct(struct yac_interp_weights *weights, struct remote_points *tgts, 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)
@ YAC_MAPPING_ON_SRC
weights will be appied at source processes
void yac_interpolation_execute(struct yac_interpolation *interp, double ***src_fields, double **tgt_field)
void yac_interpolation_delete(struct yac_interpolation *interp)
double const YAC_FRAC_MASK_NO_VALUE
union remote_point_infos::@46 data
struct remote_point_info single
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