#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 "test_redist_common.h"
static void
size_t size_a, size_t size_b, size_t size_all,
const Xt_int *index_vector_b);
int main(void) {
int rank, size;
if (size > 1) {
{
{
int local_size[2] = {size,size};
local_start[0]);
local_start[1]);
}
{
assert(size - 1 <= INT_MAX / 2 / size / size);
.stride = 1, .nstrides = 2*size*size};
}
{
assert(size <= INT_MAX / 2 / size / size);
.nstrides = 2*size*size*size};
}
size_t size_a = 2*(size_t)size*(size_t)size,
size_b = 2*(size_t)size*(size_t)size,
size_all = size_a * (size_t)size;
Xt_int *src = malloc(
sizeof (*src) * (size_a + size_b + size_all));
Xt_int *index_vector_a = src, *index_vector_b = src + size_a;
if (!src) {
perror("could not allocate exchange source temporary");
abort();
}
for (size_t i = 0; i < 4; ++i) {
}
Xt_int *dst = malloc(
sizeof (*dst) * (size_a + size_b + 2 * size_all));
if (!dst) {
perror("could not allocate exchange results temporary");
abort();
}
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))};
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);
}
{
Xt_int src_indices_[5], dst_indices_[2][5];
for (
Xt_int i = 0; i < 5; ++i) {
src_indices_[i] = (
Xt_int)(rank * 5 + i);
dst_indices_[0][i] = (
Xt_int)((src_indices_[i] + 1) % (size * 5));
dst_indices_[1][i] = (
Xt_int)((temp < 0)?(size * 5 - 1):temp);
}
Xt_int results_1[5] = {-1,-1,-1,-1,-1}, results_2[5] = {-1,-1,-1,-1,-1};
MPI_Aint src_displacements[2] = {0, 0};
MPI_Aint dst_displacements[2]
= {0, (MPI_Aint)((
size_t)(results_2-results_1)*
sizeof(
Xt_int))};
PUT_ERR("error in xt_redist_get_MPI_Comm\n");
for (int i = 0; i < 5; ++i) {
if (results_1[i] != dst_indices_[0][i])
PUT_ERR("error on xt_redist_s_exchange\n");
if (results_2[i] != dst_indices_[1][i])
PUT_ERR("error on xt_redist_s_exchange\n");
}
}
}
MPI_Finalize();
return TEST_EXIT_CODE;
}
static void
size_t size_a, size_t size_b, size_t size_all,
{
memset(dst, 0, size_b + size_a + 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;
for (size_t i = 0; i < size_b; ++i)
if (results_1[i] != index_vector_b[i])
PUT_ERR("error on xt_redist_s_exchange\n");
for (size_t i = 0; i < size_a; ++i)
if (results_2[i] != index_vector_a[i])
PUT_ERR("error on xt_redist_s_exchange\n");
for (size_t i = 0; i < size_all; ++i)
if (results_3[i] != (int)i)
PUT_ERR("error on xt_redist_s_exchange\n");
for (size_t i = 0; i < size_all; ++i)
if (results_4[i] != (int)i)
PUT_ERR("error on xt_redist_s_exchange\n");
}