#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <mpi.h>
#include <yaxt.h>
#include "tests.h"
#include "test_redist_common.h"
int main(void) {
{
enum { src_slice_len = 5, dst_slice_len = 3 };
Xt_xmap xmap = build_odd_selection_xmap(src_slice_len);
static const double src_data[] = {1,2,3,4,5};
double dst_data[] = {-1,-1,-1};
MPI_Aint src_extent = (MPI_Aint)(sizeof(src_data)),
dst_extent = (MPI_Aint)(sizeof(dst_data));
int displacements[1] = {0};
displacements);
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
static const double ref_dst_data[] = {1,3,5};
check_redist(redist_repeat, src_data,
sizeof(dst_data), dst_data, ref_dst_data);
}
{
enum { src_slice_len = 5, dst_slice_len = (src_slice_len+1)/2 };
Xt_xmap xmap = build_odd_selection_xmap(src_slice_len);
enum { num_repetitions = 3 };
static const double src_data[num_repetitions][src_slice_len]
= {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15}};
double dst_data[num_repetitions][dst_slice_len];
MPI_Aint src_extent =
(MPI_Aint)((size_t)(src_data[1] - src_data[0]) * sizeof (double));
MPI_Aint dst_extent =
(MPI_Aint)((size_t)(dst_data[1] - dst_data[0]) * sizeof (double));
int displacements[num_repetitions] = {0, 1, 2};
num_repetitions, displacements);
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
{
for (size_t j = 0; j < num_repetitions; ++j)
for (size_t i = 0; i < dst_slice_len; ++i)
dst_data[j][i] = -1.0;
static const double ref_dst_data[num_repetitions][dst_slice_len]
= {{1,3,5},{6,8,10},{11,13,15}};
check_redist(redist_repeat, src_data,
sizeof (dst_data), dst_data, ref_dst_data);
}
{
for (size_t j = 0; j < num_repetitions; ++j)
for (size_t i = 0; i < dst_slice_len; ++i)
dst_data[j][i] = -1.0;
static const double ref_dst_data[num_repetitions][dst_slice_len]
= {{1,3,5},{6,8,10},{11,13,15}};
check_redist(redist_repeat, src_data,
sizeof (dst_data), dst_data, ref_dst_data);
}
}
{
enum { src_slice_len = 5, dst_slice_len = (src_slice_len+1)/2 };
Xt_xmap xmap = build_odd_selection_xmap(src_slice_len);
enum { num_repetitions = 3 };
static const double src_data[num_repetitions][src_slice_len]
= {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15}};
double dst_data[num_repetitions][dst_slice_len];
MPI_Aint src_extent =
(MPI_Aint)((size_t)(src_data[1] - src_data[0]) * sizeof (double));
MPI_Aint dst_extent =
(MPI_Aint)((size_t)(dst_data[1] - dst_data[0]) * sizeof (double));
int src_displacements[num_repetitions] = {0, 1, 2};
int dst_displacements[num_repetitions] = {2, 1, 0};
num_repetitions, src_displacements,
dst_displacements);
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
{
for (size_t j = 0; j < num_repetitions; ++j)
for (size_t i = 0; i < dst_slice_len; ++i)
dst_data[j][i] = -1.0;
static const double ref_dst_data[num_repetitions][dst_slice_len]
= {{11,13,15},{6,8,10},{1,3,5}};
check_redist(redist_repeat, src_data,
sizeof (dst_data), dst_data, ref_dst_data);
}
}
{
enum { src_slice_len = 5, dst_slice_len = (src_slice_len+1)/2 };
Xt_xmap xmap = build_odd_selection_xmap(src_slice_len);
MPI_Aint src_extent = (MPI_Aint)(5 * sizeof (double));
MPI_Aint dst_extent = (MPI_Aint)(3 * sizeof (double));
int displacements[3] = {0, 2, 4};
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
{
static const double src_data[5][5]
= {{1,2,3,4,5},{-1},{6,7,8,9,10},{-1},{11,12,13,14,15}};
double dst_data[5][3]
= {{-1,-1,-1},{-1,-1,-1},{-1,-1,-1},{-1,-1,-1},{-1,-1,-1}};
static const double ref_dst_data[5][3]
= {{1,3,5},{-1,-1,-1},{6,8,10},{-1,-1,-1},{11,13,15}};
check_redist(redist_repeat, src_data,
sizeof (dst_data), dst_data, ref_dst_data);
}
}
{
enum { npt = 9 };
Xt_xmap xmap = build_odd_selection_xmap(6);
static const int src_pos[npt] = {1,2,3,4,5,6,7,8,9};
static const int dst_pos[npt] = {0,2,4,6,8,10,12,14,16};
double src_data[npt], dst_data[npt];
static const double ref_dst_data[npt]
= {102.0, 103.0, 104.0, 105.0, 106.0, 107.0, -1.0, -1.0, -1.0};
for(int i = 0; i<npt; i++) {
src_data[i] = 100+i+1;
dst_data[i] = -1;
}
for(int i=0; i<npt; i++)
if (dst_data[i] != ref_dst_data[i]) {
PUT_ERR("error in xt_redist_repeat\n");
break;
}
for(int i = 0; i<npt; i++)
dst_data[i] = -1;
MPI_Aint src_extent = (MPI_Aint)(1 * sizeof (double));
MPI_Aint dst_extent = (MPI_Aint)(1 * sizeof (double));
int displacements[2] = {0,1};
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
check_redist(redist_repeat, src_data,
sizeof (dst_data), dst_data, ref_dst_data);
}
MPI_Finalize();
return TEST_EXIT_CODE;
}