#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdbool.h>
#include <mpi.h>
#include <yaxt.h>
#include "tests.h"
#include "ctest_common.h"
#define FIXED_MPI_ON_BLIZZARD
#ifdef FIXED_MPI_ON_BLIZZARD
static int
test_datatype_int(MPI_Datatype datatype, int recv_count, const int *send_data,
const int *ref_recv_data) {
int recv_data[recv_count];
MPI_Status status;
xt_mpi_call(MPI_Sendrecv(CAST_MPI_SEND_BUF(send_data), 1, datatype, 0, 0,
recv_data, recv_count, MPI_INT, 0, 0,
bool mismatch = false;
for (int i = 0; i < recv_count; ++i)
mismatch |= (recv_data[i] != ref_recv_data[i]);
return mismatch;
}
#else
static int
test_datatype_int(MPI_Datatype datatype, int recv_count, const int *send_data,
const int *ref_recv_data) {
int recv_data[recv_count];
MPI_Status status;
MPI_Request request;
xt_mpi_call(MPI_Send(CAST_MPI_SEND_BUF(send_data), 1, datatype, 0, 0,
bool mismatch = false;
for (int i = 0; i < recv_count; ++i)
mismatch |= (recv_data[i] != ref_recv_data[i]);
return mismatch;
}
#endif
int main(int argc, char **argv) {
{
enum { count = 0 };
static const int displacements[1] = { 0 };
static const int blocklengths[1] = { 0 };
MPI_Datatype old_type = MPI_INT;
MPI_Datatype datatype
if (datatype != MPI_DATATYPE_NULL)
PUT_ERR("error in xt_mpi_generate_datatype (count == 0)\n");
if (datatype != MPI_DATATYPE_NULL)
PUT_ERR("error in xt_mpi_generatxt_mpi_generate_datatype_blocke_datatype"
" (count == 0)\n");
}
{
{
enum { count = 1 };
static const int displacements[count] = {0};
static const int blocklengths[count] = {1};
MPI_Datatype old_type = MPI_INT;
static const int send_data[3] = { 123, 234, 345 };
static const int ref_recv_data[1] = { 123 };
MPI_Datatype datatype
if (test_datatype_int(datatype, count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
datatype
if (test_datatype_int(datatype, count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by"
" xt_mpi_generate_datatype_block\n");
}
{
enum { count = 1 };
static const int displacements[count] = { 1 };
static const int blocklengths[count] = { 1 };
MPI_Datatype old_type = MPI_INT;
static const int send_data[3] = { 123, 234, 345 };
static const int ref_recv_data[count] = { 234 };
MPI_Datatype datatype
if (test_datatype_int(datatype, count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
datatype
if (test_datatype_int(datatype, count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
{
MPI_Datatype datatype;
enum {
element_count = 2,
block_count = 1,
};
static const int element_displacements[element_count] = {0,1};
static const int block_displacements[block_count] = {0};
static const int blocklengths[block_count] = {2};
MPI_Datatype old_type = MPI_INT;
static const int send_data[3] = { 123, 234, 345 };
static const int ref_recv_data[element_count] = { 123, 234 };
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
blocklengths, block_count,
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
{
enum {
element_count = 2,
block_count = 1,
};
static const int element_displacements[element_count] = {1,2};
static const int block_displacements[block_count] = {1};
static int blocklengths[block_count] = {2};
MPI_Datatype old_type = MPI_INT;
static const int send_data[3] = { 123, 234, 345 };
static const int ref_recv_data[element_count] = { 234, 345 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
blocklengths,
block_count, old_type,
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
}
{
{
enum {
element_count = 3,
block_count = 3,
};
static const int element_displacements[element_count] = { 0, 2, 4 };
static const int block_displacements[block_count] = { 0, 2, 4 };
static const int blocklengths[block_count] = { 1, 1, 1 };
MPI_Datatype old_type = MPI_INT;
static const int send_data[5] = { 123, 234, 345, 456, 567 };
static const int ref_recv_data[3] = { 123, 345, 567 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
blocklengths, block_count,
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
{
enum {
element_count = 6,
block_count = 3,
};
static const int element_displacements[element_count]
= { 0, 1, 3, 4, 6, 7 };
static const int block_displacements[block_count] = { 0, 3, 6 };
static const int blocklengths[block_count] = { 2, 2, 2 };
MPI_Datatype old_type = MPI_INT;
static const int send_data[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
static const int ref_recv_data[element_count] = { 0, 1, 3, 4, 6, 7 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype\n");
blocklengths, block_count,
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
{
enum {
element_count = 6,
block_count = 3,
};
static const int element_displacements[element_count]
= { 1, 2, 4, 5, 7, 8};
static const int block_displacements[block_count] = { 1, 4, 7};
static const int blocklengths[block_count] = { 2, 2, 2 };
MPI_Datatype old_type = MPI_INT;
static const int send_data[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
static const int ref_recv_data[element_count] = { 1, 2, 4, 5, 7, 8 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
datatype
blocklengths, block_count,
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
{
enum {
element_count = 6,
block_count = 3,
};
static const int element_displacements[element_count]
= { 7, 8, 4, 5, 1, 2 };
static const int block_displacements[block_count] = { 7, 4, 1 };
static const int blocklengths[block_count] = { 2, 2, 2 };
MPI_Datatype old_type = MPI_INT;
static const int send_data[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
static const int ref_recv_data[element_count] = { 7, 8, 4, 5, 1, 2 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
blocklengths, block_count,
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
{
enum {
element_count = 6,
block_count = 3,
};
static const int element_displacements[element_count]
= { 0, 1, 3, 4, 7, 8 };
static const int block_displacements[block_count] = { 0, 3, 7 };
static const int blocklengths[block_count] = { 2, 2, 2 };
MPI_Datatype old_type = MPI_INT;
static const int send_data[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
static const int ref_recv_data[element_count] = { 0, 1, 3, 4, 7, 8 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
blocklengths, block_count,
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
{
enum {
element_count = 9,
block_count = 3,
};
static const int element_displacements[element_count]
= { 0, 1, 3, 4, 5, 7, 8, 9, 10 };
static const int block_displacements[block_count] = { 0, 3, 7 };
static const int blocklengths[block_count] = { 2, 3, 4 };
MPI_Datatype old_type = MPI_INT;
static const int send_data[11] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
static const int ref_recv_data[element_count]
= { 0, 1, 3, 4, 5, 7, 8, 9, 10 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
blocklengths, block_count,
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by "
"xt_mpi_generate_datatype_block\n");
}
}
{
enum { element_count = 4 };
static const int element_displacements[element_count] = { 2, 4, 7, 9 };
MPI_Datatype old_type = MPI_INT;
static const int send_data[]
= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29 };
static const int ref_recv_data[element_count] = { 2, 4, 7, 9 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
}
{
enum { element_count = 8 };
static const int element_displacements[element_count]
= { 1, 4, 7, 10, 11, 14, 17, 20};
MPI_Datatype old_type = MPI_INT;
static const int send_data[]
= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29 };
static const int ref_recv_data[element_count]
= { 1, 4, 7, 10, 11, 14, 17, 20};
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
}
{
enum { element_count = 14 };
static const int element_displacements[element_count]
= {14,13,12,11,10,9,8,7,6,5,4,3,2,1};
MPI_Datatype old_type = MPI_INT;
static const int send_data[]
= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29 };
static const int ref_recv_data[element_count]
= { 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
MPI_Datatype datatype
if (test_datatype_int(datatype, element_count, send_data, ref_recv_data))
PUT_ERR("error in datatype generated by xt_mpi_generate_datatype\n");
}
return TEST_EXIT_CODE;
}
int MPI_Type_free(MPI_Datatype *datatype)
void xt_initialize(MPI_Comm default_comm)
MPI_Datatype xt_mpi_generate_datatype(int const *displacements, int count, MPI_Datatype old_type, MPI_Comm comm)
#define xt_mpi_call(call, comm)
MPI_Datatype xt_mpi_generate_datatype_block(const int *displacements, const int *blocklengths, int count, MPI_Datatype old_type, MPI_Comm comm)