#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mpi.h>
#include <yaxt.h>
#include "tests.h"
#include "ctest_common.h"
#include "test_redist_common.h"
static void
int main(int argc, char **argv) {
Xt_config config = redist_exchanger_option(&argc, &argv);
{
static const Xt_int src_index_list[] = {5,67,4,5,13,9,2,1,0,96,13,12,1,3};
enum { src_num = sizeof(src_index_list) / sizeof(src_index_list[0]) };
static const Xt_int dst_index_list[] = {5,4,3,96,1,5,4,5,4,3,13,2,1};
enum { dst_num = sizeof(dst_index_list) / sizeof(dst_index_list[0]) };
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
static const double src_data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13};
static const double ref_dst_data[] = {0,2,13,9,7,0,2,0,2,13,4,6,7};
enum { num_ref_values = sizeof(ref_dst_data) / sizeof(ref_dst_data[0]) };
double dst_data[dst_num];
check_redist(redist, src_data, num_ref_values, dst_data,
fill_array_double, NULL, ref_dst_data, MPI_DOUBLE, MPI_DOUBLE);
check_redist(redist_copy, src_data, num_ref_values, dst_data,
fill_array_double, NULL, ref_dst_data, MPI_DOUBLE, MPI_DOUBLE);
}
{
static const Xt_int src_index_list[] = {5,67,4,5,13,9,2,1,0,96,13,12,1,3};
enum { src_num = sizeof(src_index_list) / sizeof(src_index_list[0]) };
static const Xt_int dst_index_list[] = {5,4,3,96,1,5,4,5,4,3,13,2,1};
enum { dst_num = sizeof(dst_index_list) / sizeof(dst_index_list[0]) };
int src_pos[src_num];
int dst_pos[dst_num];
for (int i = 0; i < src_num; i++)
src_pos[i] = i;
for (int i = 0; i < dst_num; i++)
dst_pos[i] = dst_num-1-i;
xmap, src_pos, dst_pos, MPI_DOUBLE, config);
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
static const double src_data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13};
assert(sizeof(src_data)/sizeof(src_data[0]) == src_num);
static const double ref_dst_data[] = {7,6,4,13,2,0,2,0,7,9,13,2,0};
double dst_data[dst_num];
check_redist(redist, src_data, dst_num, dst_data,
fill_array_double, NULL, ref_dst_data, MPI_DOUBLE, MPI_DOUBLE);
check_redist(redist_copy, src_data, dst_num, dst_data,
fill_array_double, NULL, ref_dst_data, MPI_DOUBLE, MPI_DOUBLE);
}
MPI_Finalize();
return TEST_EXIT_CODE;
}
static void
check_offset_extents_redist(
Xt_redist redist,
size_t src_num,
size_t dst_num,
static void
{
static const Xt_int src_index_list[] = {5,67,4,5,13,9,2,1,0,96,13,12,1,3};
enum { src_num = sizeof(src_index_list) / sizeof(src_index_list[0]) };
static const Xt_int dst_index_list[] = {5,4,3,96,1,5,4,5,4,3,13,2,1};
enum { dst_num = sizeof(dst_index_list) / sizeof(dst_index_list[0]) };
{
src_pos[1] = { { .start = 0, .size = src_num, .stride = 1 } },
dst_pos[1] = { { .start = dst_num - 1, .size = dst_num, .stride = -1 } };
xmap, sizeof (src_pos)/sizeof (src_pos[0]), src_pos,
sizeof (dst_pos)/sizeof (dst_pos[0]), dst_pos, MPI_LONG, config);
check_offset_extents_redist(redist, src_num, dst_num, comm);
}
{
src_pos[1] = { { .start = (MPI_Aint)0,
.
size = src_num, .
stride = (MPI_Aint)
sizeof (long) } },
dst_pos[1] = { { .start = (MPI_Aint)((dst_num - 1)*sizeof (long)),
.size = dst_num, .stride = -(MPI_Aint)(sizeof (long)) }};
xmap, sizeof (src_pos)/sizeof (src_pos[0]), src_pos,
sizeof (dst_pos)/sizeof (dst_pos[0]), dst_pos, MPI_LONG, config);
check_offset_extents_redist(redist, src_num, dst_num, comm);
}
}
static void
check_offset_extents_redist(
Xt_redist redist,
size_t src_num,
size_t dst_num,
{
(void)src_num;
comm))
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
static const long src_data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13};
assert(sizeof(src_data)/sizeof(src_data[0]) == src_num);
static const long ref_dst_data[] = {7,6,4,13,2,0,2,0,7,9,13,2,0};
assert(sizeof(ref_dst_data)/sizeof(ref_dst_data[0]) == dst_num);
long dst_data[sizeof(ref_dst_data)/sizeof(ref_dst_data[0])];
check_redist(redist, src_data, dst_num, dst_data,
fill_array_long, NULL, ref_dst_data, MPI_LONG, MPI_LONG);
check_redist(redist_copy, src_data, dst_num, dst_data,
fill_array_long, NULL, ref_dst_data, MPI_LONG, MPI_LONG);
}
struct Xt_config_ * Xt_config
void xt_config_delete(Xt_config config)
void xt_initialize(MPI_Comm default_comm)
struct Xt_xmap_ * Xt_xmap
struct Xt_idxlist_ * Xt_idxlist
struct Xt_redist_ * Xt_redist
void xt_idxlist_delete(Xt_idxlist idxlist)
Xt_idxlist xt_idxvec_new(const Xt_int *idxlist, int num_indices)
void xt_redist_delete(Xt_redist redist)
Xt_redist xt_redist_copy(Xt_redist redist)
MPI_Comm xt_redist_get_MPI_Comm(Xt_redist redist)
Xt_redist xt_redist_p2p_custom_new(Xt_xmap xmap, MPI_Datatype datatype, Xt_config config)
Xt_redist xt_redist_p2p_off_custom_new(Xt_xmap xmap, const int *src_offsets, const int *dst_offsets, MPI_Datatype datatype, Xt_config config)
Xt_redist xt_redist_p2p_aext_custom_new(Xt_xmap xmap, int num_src_ext, const struct Xt_aoffset_ext src_extents[], int num_dst_ext, const struct Xt_aoffset_ext dst_extents[], MPI_Datatype datatype, Xt_config config)
Xt_redist xt_redist_p2p_ext_custom_new(Xt_xmap xmap, int num_src_ext, const struct Xt_offset_ext src_extents[], int num_dst_ext, const struct Xt_offset_ext dst_extents[], MPI_Datatype datatype, Xt_config config)
void xt_xmap_delete(Xt_xmap xmap)
Xt_xmap xt_xmap_all2all_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist, MPI_Comm comm)