#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <mpi.h>
#include <yaxt.h>
#define VERBOSE
#include "tests.h"
#include "ctest_common.h"
#include "test_xmap_common.h"
static void
test_xmap1(xmap_constructor new_xmap,
static void
test_xmap2(xmap_constructor new_xmap,
MPI_Comm comm);
static int my_rank;
int
xt_xmap_self_test_main(int *argc, char ***argv,
xmap_constructor new_xmap)
{
for (size_t i = 0; i < 2; ++i) {
static const int lsizes[2] = { 7, 1023 };
for (size_t j = 0; j < 2; ++j)
test_xmap1(new_xmap, lsizes[j], comms[i]);
test_xmap2(new_xmap, comms[i]);
}
MPI_Comm_free(&comms[1]);
MPI_Finalize();
return TEST_EXIT_CODE;
}
static void
assert_xmap_is_to_self(
Xt_xmap xmap)
{
PUT_ERR("error in xt_xmap_get_num_destinations\n");
PUT_ERR("error in xt_xmap_get_num_sources\n");
int rank;
if (rank != my_rank)
PUT_ERR("error in xt_xmap_get_destination_ranks\n");
if (rank != my_rank)
PUT_ERR("error in xt_xmap_get_source_ranks\n");
}
void
test_self_xmap_construct_idxvec(
const Xt_int *src_index_list,
int num_src_indices,
const Xt_int *dst_index_list,
int num_dst_indices,
xmap_constructor new_xmap,
MPI_Comm comm)
{
test_self_xmap_construct(src_idxlist, dst_idxlist, new_xmap, comm);
}
void
test_self_xmap_construct_idxstripes(
const struct Xt_stripe *src_indices,
int num_src_stripes,
const struct Xt_stripe *dst_indices,
int num_dst_stripes,
xmap_constructor new_xmap,
MPI_Comm comm)
{
test_self_xmap_construct(src_idxlist, dst_idxlist, new_xmap, comm);
}
void
xmap_constructor new_xmap,
MPI_Comm comm)
{
Xt_xmap xmap = new_xmap(src_idxlist, dst_idxlist, comm);
assert_xmap_is_to_self(xmap);
assert_xmap_is_to_self(xmap_copy);
}
static inline void shift_idx(
Xt_int idx[],
int num,
int offset) {
for (int i=0; i<num; i++) {
idx[i] = (
Xt_int)(idx[i] + my_rank * offset);
}
}
static void
test_xmap1(xmap_constructor new_xmap,
{
src_stripe.stride = 1;
dst_stripe.nstrides = lsize;
dst_stripe.start = (
Xt_int)(src_stripe.start + lsize - 1);
dst_stripe.stride = -1;
test_self_xmap_construct_idxstripes(&src_stripe, 1, &dst_stripe, 1,
new_xmap, comm);
}
static void
test_xmap2(xmap_constructor new_xmap,
MPI_Comm comm)
{
Xt_int src_indices[] = {5,67,4,5,13,9,2,1,0,96,13,12,1,3};
enum { num_src_indices = sizeof(src_indices) / sizeof(src_indices[0]) };
shift_idx(src_indices, num_src_indices, 100);
Xt_int dst_indices[] = {5,4,3,96,1,5,4,5,4,3,13,2,1};
enum { num_dst_indices = sizeof(dst_indices) / sizeof(dst_indices[0]) };
shift_idx(dst_indices, num_dst_indices, 100);
test_self_xmap_construct_idxvec(src_indices, num_src_indices,
dst_indices, num_dst_indices,
new_xmap, comm);
}
void xt_initialize(MPI_Comm default_comm)
struct Xt_xmap_ * Xt_xmap
struct Xt_idxlist_ * Xt_idxlist
void xt_idxlist_delete(Xt_idxlist idxlist)
Xt_idxlist xt_idxstripes_new(struct Xt_stripe const *stripes, int num_stripes)
Xt_idxlist xt_idxvec_new(const Xt_int *idxlist, int num_indices)
void xt_mpi_comm_mark_exclusive(MPI_Comm comm)
void xt_xmap_delete(Xt_xmap xmap)
int xt_xmap_get_num_destinations(Xt_xmap xmap)
Xt_xmap xt_xmap_copy(Xt_xmap xmap)
int xt_xmap_get_num_sources(Xt_xmap xmap)
void xt_xmap_get_source_ranks(Xt_xmap xmap, int *ranks)
void xt_xmap_get_destination_ranks(Xt_xmap xmap, int *ranks)