#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <assert.h>
#include <stdbool.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
static void
int main(int argc, char **argv) {
int comm_size;
Xt_config config = redist_exchanger_option(&argc, &argv);
if (comm_size > 1) {
}
MPI_Finalize();
return TEST_EXIT_CODE;
}
static void
size_t size_a, size_t size_b, size_t size_all,
const Xt_int *index_vector_b);
static void
{
int comm_size, comm_rank;
int comm_size_sq = comm_size * comm_size;
{
int local_size[2] = {comm_size,comm_size};
= {{0, (
Xt_int)(comm_rank*comm_size)},
{(
Xt_int)comm_size, (
Xt_int)(comm_size_sq-(comm_rank+1)*comm_size)}};
for (size_t i = 0; i < 2; ++i)
local_start[i]);
for (size_t i = 0; i < 2; ++i)
}
{
assert(comm_size - 1 <= INT_MAX / 2 / comm_size_sq);
.stride = 1, .nstrides = 2*comm_size_sq};
}
{
assert(comm_size <= INT_MAX / 2 / comm_size_sq);
.nstrides = 2*comm_size_sq*comm_size};
}
size_t size_a = 2*(size_t)comm_size*(size_t)comm_size,
size_b = 2*(size_t)comm_size*(size_t)comm_size,
size_all = size_a * (size_t)comm_size;
Xt_int *src =
xmalloc(
sizeof (*src) * (size_a + size_b + size_all));
Xt_int *index_vector_a = src, *index_vector_b = src + size_a;
for (size_t i = 0; i < 4; ++i) {
}
Xt_int *dst =
xmalloc(
sizeof (*dst) * (size_a + size_b + 2 * size_all));
Xt_int *results_1 = dst, *results_2 = dst + size_b,
*results_3 = dst + size_b + size_a,
*results_4 = dst + size_a + size_b + size_all;
MPI_Aint src_displacements[4]
= {0, (MPI_Aint)(size_a *
sizeof(
Xt_int)),
0, (MPI_Aint)(size_a *
sizeof(
Xt_int))};
MPI_Aint dst_displacements[4]
= {0, (MPI_Aint)((
size_t)(results_2 - results_1) *
sizeof(
Xt_int)),
(MPI_Aint)((size_t)(results_3 - results_1) *
sizeof(
Xt_int)),
(MPI_Aint)((
size_t)(results_4 - results_1) *
sizeof(
Xt_int))};
redists, 4, src_displacements, dst_displacements, comm, config);
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
for (size_t i = 0; i < 4; ++i)
test_transpose_gather(redist, dst, src, size_a, size_b, size_all,
index_vector_a, index_vector_b);
test_transpose_gather(redist_copy, dst, src, size_a, size_b, size_all,
index_vector_a, index_vector_b);
free(src);
free(dst);
}
static void
size_t size_a, size_t size_b, size_t size_all,
{
for (int sync_mode = 0; sync_mode < 2; ++sync_mode) {
fill_array_xt_int(dst, NULL, size_b + size_a + 2 * size_all);
exchange1_func_ptr exchange1_func
exchange1_func(redist, src, dst);
Xt_int *results_1 = dst, *results_2 = dst + size_b,
*results_3 = dst + size_b + size_a,
*results_4 = dst + size_a + size_b + size_all;
bool mismatch = false;
for (size_t i = 0; i < size_b; ++i)
mismatch |= (results_1[i] != index_vector_b[i]);
if (mismatch)
PUT_ERR("error on xt_redist_s_exchange\n");
mismatch = false;
for (size_t i = 0; i < size_a; ++i)
mismatch |= (results_2[i] != index_vector_a[i]);
if (mismatch)
PUT_ERR("error on xt_redist_s_exchange\n");
mismatch = false;
for (size_t i = 0; i < size_all; ++i)
mismatch |= (results_3[i] != (int)i);
if (mismatch)
PUT_ERR("error on xt_redist_s_exchange\n");
mismatch = false;
for (size_t i = 0; i < size_all; ++i)
mismatch |= (results_4[i] != (int)i);
if (mismatch)
PUT_ERR("error on xt_redist_s_exchange\n");
}
}
static void
{
int comm_size, comm_rank;
enum { numExch = 2, };
enum { partSize = 5, };
Xt_int src_indices_[partSize], dst_indices_[numExch][partSize];
for (
Xt_int i = 0; i < partSize; ++i) {
src_indices_[i] = (
Xt_int)(comm_rank * partSize + i);
dst_indices_[0][i] = (
Xt_int)((src_indices_[i] + 1)
% ((
Xt_int)comm_size*partSize));
dst_indices_[1][i] = (
Xt_int)((temp < 0)?(comm_size * partSize - 1):temp);
}
for (size_t i = 0; i < numExch; ++i) {
}
for (size_t i = 0; i < numExch; ++i) {
}
MPI_Aint src_displacements[numExch] = {0, 0},
ofs = (MPI_Aint)((
size_t)(results[0]-results[1])*
sizeof(
Xt_int)),
dst_displacements[numExch] = {0, ofs};
redists, numExch, src_displacements, dst_displacements, comm, config);
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
for (int sync_mode = 0; sync_mode < 2; ++sync_mode) {
fill_array_xt_int(results, NULL, 2 * partSize);
exchange1_func_ptr exchange1_func
exchange1_func(redist, (void*)src_indices_, (void*)results[1]);
bool mismatch = false;
for (int i = 0; i < partSize; ++i)
mismatch |= (results[1][i] != dst_indices_[0][i]
|| results[0][i] != dst_indices_[1][i]);
if (mismatch)
PUT_ERR("error on xt_redist_s_exchange\n");
}
}
add versions of standard API functions not returning on error
void xt_config_delete(Xt_config config)
void xt_initialize(MPI_Comm default_comm)
void xt_idxlist_get_indices(Xt_idxlist idxlist, Xt_int *indices)
void xt_idxlist_delete(Xt_idxlist idxlist)
Xt_idxlist xt_idxlist_collection_new(Xt_idxlist *idxlists, int num_idxlists)
Xt_idxlist xt_idxsection_new(Xt_int start, int num_dimensions, const Xt_int global_size[num_dimensions], const int local_size[num_dimensions], const Xt_int local_start[num_dimensions])
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)
#define xt_mpi_call(call, comm)
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)
void xt_redist_s_exchange1(Xt_redist redist, const void *src_data, void *dst_data)
Xt_redist xt_redist_collection_static_custom_new(Xt_redist *redists, int num_redists, const MPI_Aint src_displacements[num_redists], const MPI_Aint dst_displacements[num_redists], MPI_Comm comm, Xt_config config)
Xt_redist xt_redist_p2p_new(Xt_xmap xmap, MPI_Datatype datatype)
void xt_xmap_delete(Xt_xmap xmap)
Xt_xmap xt_xmap_all2all_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist, MPI_Comm comm)