|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
/* Warning - this test will fail for MPI_PROD & maybe MPI_SUM
|
|
Packit Service |
c5cf8c |
* if more than 10 MPI processes are used. Loss of precision
|
|
Packit Service |
c5cf8c |
* will occur as the number of processors is increased.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_STDINT_H
|
|
Packit Service |
c5cf8c |
#include <stdint.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int count, size, rank;
|
|
Packit Service |
c5cf8c |
int errs;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
struct int_test {
|
|
Packit Service |
c5cf8c |
int a;
|
|
Packit Service |
c5cf8c |
int b;
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
struct long_test {
|
|
Packit Service |
c5cf8c |
long a;
|
|
Packit Service |
c5cf8c |
int b;
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
struct short_test {
|
|
Packit Service |
c5cf8c |
short a;
|
|
Packit Service |
c5cf8c |
int b;
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
struct float_test {
|
|
Packit Service |
c5cf8c |
float a;
|
|
Packit Service |
c5cf8c |
int b;
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
struct double_test {
|
|
Packit Service |
c5cf8c |
double a;
|
|
Packit Service |
c5cf8c |
int b;
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define mpi_op2str(op) \
|
|
Packit Service |
c5cf8c |
((op == MPI_SUM) ? "MPI_SUM" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_PROD) ? "MPI_PROD" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_MAX) ? "MPI_MAX" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_MIN) ? "MPI_MIN" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_LOR) ? "MPI_LOR" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_LXOR) ? "MPI_LXOR" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_LAND) ? "MPI_LAND" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_BOR) ? "MPI_BOR" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_BAND) ? "MPI_BAND" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_BXOR) ? "MPI_BXOR" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_MAXLOC) ? "MPI_MAXLOC" : \
|
|
Packit Service |
c5cf8c |
(op == MPI_MINLOC) ? "MPI_MINLOC" : \
|
|
Packit Service |
c5cf8c |
"MPI_NO_OP")
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* calloc to avoid spurious valgrind warnings when "type" has padding bytes */
|
|
Packit Service |
c5cf8c |
#define DECL_MALLOC_IN_OUT_SOL(type) \
|
|
Packit Service |
c5cf8c |
type *in, *out, *sol; \
|
|
Packit Service |
c5cf8c |
in = (type *) calloc(count, sizeof(type)); \
|
|
Packit Service |
c5cf8c |
out = (type *) calloc(count, sizeof(type)); \
|
|
Packit Service |
c5cf8c |
sol = (type *) calloc(count, sizeof(type));
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define SET_INDEX_CONST(arr, val) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
int i; \
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) \
|
|
Packit Service |
c5cf8c |
arr[i] = val; \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define SET_INDEX_SUM(arr, val) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
int i; \
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) \
|
|
Packit Service |
c5cf8c |
arr[i] = i + val; \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define SET_INDEX_FACTOR(arr, val) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
int i; \
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) \
|
|
Packit Service |
c5cf8c |
arr[i] = i * (val); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define SET_INDEX_POWER(arr, val) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
int i, j; \
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) { \
|
|
Packit Service |
c5cf8c |
(arr)[i] = 1; \
|
|
Packit Service |
c5cf8c |
for (j = 0; j < (val); j++) \
|
|
Packit Service |
c5cf8c |
arr[i] *= i; \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define ERROR_CHECK_AND_FREE(lerrcnt, mpi_type, mpi_op) \
|
|
Packit Service |
c5cf8c |
do { \
|
|
Packit Service |
c5cf8c |
char name[MPI_MAX_OBJECT_NAME] = {0}; \
|
|
Packit Service |
c5cf8c |
int len = 0; \
|
|
Packit Service |
c5cf8c |
if (lerrcnt) { \
|
|
Packit Service |
c5cf8c |
MPI_Type_get_name(mpi_type, name, &len;; \
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "(%d) Error for type %s and op %s\n", \
|
|
Packit Service |
c5cf8c |
rank, name, mpi_op2str(mpi_op)); \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
free(in); free(out); free(sol); \
|
|
Packit Service |
c5cf8c |
} while (0)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* The logic on the error check on MPI_Allreduce assumes that all
|
|
Packit Service |
c5cf8c |
MPI_Allreduce routines return a failure if any do - this is sufficient
|
|
Packit Service |
c5cf8c |
for MPI implementations that reject some of the valid op/datatype pairs
|
|
Packit Service |
c5cf8c |
(and motivated this addition, as some versions of the IBM MPI
|
|
Packit Service |
c5cf8c |
failed in just this way).
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#define ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
int i, rc, lerrcnt = 0; \
|
|
Packit Service |
c5cf8c |
rc = MPI_Allreduce(in, out, count, mpi_type, mpi_op, MPI_COMM_WORLD); \
|
|
Packit Service |
c5cf8c |
if (rc) { lerrcnt++; errs++; MTestPrintError(rc); } \
|
|
Packit Service |
c5cf8c |
else { \
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) { \
|
|
Packit Service |
c5cf8c |
if (out[i] != sol[i]) { \
|
|
Packit Service |
c5cf8c |
errs++; \
|
|
Packit Service |
c5cf8c |
lerrcnt++; \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
ERROR_CHECK_AND_FREE(lerrcnt, mpi_type, mpi_op); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define STRUCT_ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
int i, rc, lerrcnt = 0; \
|
|
Packit Service |
c5cf8c |
rc = MPI_Allreduce(in, out, count, mpi_type, mpi_op, MPI_COMM_WORLD); \
|
|
Packit Service |
c5cf8c |
if (rc) { lerrcnt++; errs++; MTestPrintError(rc); } \
|
|
Packit Service |
c5cf8c |
else { \
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) { \
|
|
Packit Service |
c5cf8c |
if ((out[i].a != sol[i].a) || (out[i].b != sol[i].b)) { \
|
|
Packit Service |
c5cf8c |
errs++; \
|
|
Packit Service |
c5cf8c |
lerrcnt++; \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
ERROR_CHECK_AND_FREE(lerrcnt, mpi_type, mpi_op); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define SET_INDEX_STRUCT_CONST(arr, val, el) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
int i; \
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) \
|
|
Packit Service |
c5cf8c |
arr[i].el = val; \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define SET_INDEX_STRUCT_SUM(arr, val, el) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
int i; \
|
|
Packit Service |
c5cf8c |
for (i = 0; i < count; i++) \
|
|
Packit Service |
c5cf8c |
arr[i].el = i + (val); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define sum_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(in, 0); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_FACTOR(sol, size); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(out, 0); \
|
|
Packit Service |
c5cf8c |
ALLREDUCE_AND_FREE(mpi_type, MPI_SUM, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define prod_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(in, 0); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_POWER(sol, size); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(out, 0); \
|
|
Packit Service |
c5cf8c |
ALLREDUCE_AND_FREE(mpi_type, MPI_PROD, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define max_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(in, rank); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(sol, size - 1); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(out, 0); \
|
|
Packit Service |
c5cf8c |
ALLREDUCE_AND_FREE(mpi_type, MPI_MAX, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define min_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(in, rank); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(sol, 0); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(out, 0); \
|
|
Packit Service |
c5cf8c |
ALLREDUCE_AND_FREE(mpi_type, MPI_MIN, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define const_test(type, mpi_type, mpi_op, val1, val2, val3) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(in, (val1)); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(sol, (val2)); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(out, (val3)); \
|
|
Packit Service |
c5cf8c |
ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define lor_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_LOR, (rank & 0x1), (size > 1), 0)
|
|
Packit Service |
c5cf8c |
#define lor_test2(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_LOR, 0, 0, 0)
|
|
Packit Service |
c5cf8c |
#define lxor_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_LXOR, (rank == 1), (size > 1), 0)
|
|
Packit Service |
c5cf8c |
#define lxor_test2(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_LXOR, 0, 0, 0)
|
|
Packit Service |
c5cf8c |
#define lxor_test3(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_LXOR, 1, (size & 0x1), 0)
|
|
Packit Service |
c5cf8c |
#define land_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_LAND, (rank & 0x1), 0, 0)
|
|
Packit Service |
c5cf8c |
#define land_test2(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_LAND, 1, 1, 0)
|
|
Packit Service |
c5cf8c |
#define bor_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_BOR, (rank & 0x3), ((size < 3) ? size - 1 : 0x3), 0)
|
|
Packit Service |
c5cf8c |
#define bxor_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_BXOR, (rank == 1) * 0xf0, (size > 1) * 0xf0, 0)
|
|
Packit Service |
c5cf8c |
#define bxor_test2(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_BXOR, 0, 0, 0)
|
|
Packit Service |
c5cf8c |
#define bxor_test3(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
const_test(type, mpi_type, MPI_BXOR, ~0, (size &0x1) ? ~0 : 0, 0)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define band_test1(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
if (rank == size-1) { \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(in, 0); \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
else { \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(in, ~0); \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(sol, 0); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(out, 0); \
|
|
Packit Service |
c5cf8c |
ALLREDUCE_AND_FREE(mpi_type, MPI_BAND, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define band_test2(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
if (rank == size-1) { \
|
|
Packit Service |
c5cf8c |
SET_INDEX_SUM(in, 0); \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
else { \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(in, 0); \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(sol, 0); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_CONST(out, 0); \
|
|
Packit Service |
c5cf8c |
ALLREDUCE_AND_FREE(mpi_type, MPI_BAND, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define maxloc_test(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_SUM(in, rank, a); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_CONST(in, rank, b); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_SUM(sol, size - 1, a); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_CONST(sol, size - 1, b); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_CONST(out, 0, a); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_CONST(out, -1, b); \
|
|
Packit Service |
c5cf8c |
STRUCT_ALLREDUCE_AND_FREE(mpi_type, MPI_MAXLOC, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define minloc_test(type, mpi_type) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
DECL_MALLOC_IN_OUT_SOL(type); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_SUM(in, rank, a); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_CONST(in, rank, b); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_SUM(sol, 0, a); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_CONST(sol, 0, b); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_CONST(out, 0, a); \
|
|
Packit Service |
c5cf8c |
SET_INDEX_STRUCT_CONST(out, -1, b); \
|
|
Packit Service |
c5cf8c |
STRUCT_ALLREDUCE_AND_FREE(mpi_type, MPI_MINLOC, in, out, sol); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
|
|
Packit Service |
c5cf8c |
#define test_types_set_mpi_2_2_integer(op,post) do { \
|
|
Packit Service |
c5cf8c |
op##_test##post(int8_t, MPI_INT8_T); \
|
|
Packit Service |
c5cf8c |
op##_test##post(int16_t, MPI_INT16_T); \
|
|
Packit Service |
c5cf8c |
op##_test##post(int32_t, MPI_INT32_T); \
|
|
Packit Service |
c5cf8c |
op##_test##post(int64_t, MPI_INT64_T); \
|
|
Packit Service |
c5cf8c |
op##_test##post(uint8_t, MPI_UINT8_T); \
|
|
Packit Service |
c5cf8c |
op##_test##post(uint16_t, MPI_UINT16_T); \
|
|
Packit Service |
c5cf8c |
op##_test##post(uint32_t, MPI_UINT32_T); \
|
|
Packit Service |
c5cf8c |
op##_test##post(uint64_t, MPI_UINT64_T); \
|
|
Packit Service |
c5cf8c |
op##_test##post(MPI_Aint, MPI_AINT); \
|
|
Packit Service |
c5cf8c |
op##_test##post(MPI_Offset, MPI_OFFSET); \
|
|
Packit Service |
c5cf8c |
} while (0)
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#define test_types_set_mpi_2_2_integer(op,post) do { } while (0)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if MTEST_HAVE_MIN_MPI_VERSION(3,0)
|
|
Packit Service |
c5cf8c |
#define test_types_set_mpi_3_0_integer(op,post) do { \
|
|
Packit Service |
c5cf8c |
op##_test##post(MPI_Count, MPI_COUNT); \
|
|
Packit Service |
c5cf8c |
} while (0)
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#define test_types_set_mpi_3_0_integer(op,post) do { } while (0)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define test_types_set1(op, post) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
op##_test##post(int, MPI_INT); \
|
|
Packit Service |
c5cf8c |
op##_test##post(long, MPI_LONG); \
|
|
Packit Service |
c5cf8c |
op##_test##post(short, MPI_SHORT); \
|
|
Packit Service |
c5cf8c |
op##_test##post(unsigned short, MPI_UNSIGNED_SHORT); \
|
|
Packit Service |
c5cf8c |
op##_test##post(unsigned, MPI_UNSIGNED); \
|
|
Packit Service |
c5cf8c |
op##_test##post(unsigned long, MPI_UNSIGNED_LONG); \
|
|
Packit Service |
c5cf8c |
op##_test##post(unsigned char, MPI_UNSIGNED_CHAR); \
|
|
Packit Service |
c5cf8c |
test_types_set_mpi_2_2_integer(op,post); \
|
|
Packit Service |
c5cf8c |
test_types_set_mpi_3_0_integer(op,post); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define test_types_set2(op, post) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
test_types_set1(op, post); \
|
|
Packit Service |
c5cf8c |
op##_test##post(float, MPI_FLOAT); \
|
|
Packit Service |
c5cf8c |
op##_test##post(double, MPI_DOUBLE); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define test_types_set3(op, post) \
|
|
Packit Service |
c5cf8c |
{ \
|
|
Packit Service |
c5cf8c |
op##_test##post(unsigned char, MPI_BYTE); \
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Make sure that we test complex and double complex, even if long
|
|
Packit Service |
c5cf8c |
double complex is not available */
|
|
Packit Service |
c5cf8c |
#if defined(USE_LONG_DOUBLE_COMPLEX)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if MTEST_HAVE_MIN_MPI_VERSION(2,2) && defined(HAVE_FLOAT__COMPLEX) \
|
|
Packit Service |
c5cf8c |
&& defined(HAVE_DOUBLE__COMPLEX) \
|
|
Packit Service |
c5cf8c |
&& defined(HAVE_LONG_DOUBLE__COMPLEX)
|
|
Packit Service |
c5cf8c |
#define test_types_set4(op, post) \
|
|
Packit Service |
c5cf8c |
do { \
|
|
Packit Service |
c5cf8c |
op##_test##post(float _Complex, MPI_C_FLOAT_COMPLEX); \
|
|
Packit Service |
c5cf8c |
op##_test##post(double _Complex, MPI_C_DOUBLE_COMPLEX); \
|
|
Packit Service |
c5cf8c |
if (MPI_C_LONG_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) { \
|
|
Packit Service |
c5cf8c |
op##_test##post(long double _Complex, MPI_C_LONG_DOUBLE_COMPLEX); \
|
|
Packit Service |
c5cf8c |
} \
|
|
Packit Service |
c5cf8c |
} while (0)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#define test_types_set4(op, post) do { } while (0)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if MTEST_HAVE_MIN_MPI_VERSION(2,2) && defined(HAVE_FLOAT__COMPLEX) \
|
|
Packit Service |
c5cf8c |
&& defined(HAVE_DOUBLE__COMPLEX)
|
|
Packit Service |
c5cf8c |
#define test_types_set4(op, post) \
|
|
Packit Service |
c5cf8c |
do { \
|
|
Packit Service |
c5cf8c |
op##_test##post(float _Complex, MPI_C_FLOAT_COMPLEX); \
|
|
Packit Service |
c5cf8c |
op##_test##post(double _Complex, MPI_C_DOUBLE_COMPLEX); \
|
|
Packit Service |
c5cf8c |
} while (0)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#define test_types_set4(op, post) do { } while (0)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* defined(USE_LONG_DOUBLE_COMPLEX) */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if MTEST_HAVE_MIN_MPI_VERSION(2,2) && defined(HAVE__BOOL)
|
|
Packit Service |
c5cf8c |
#define test_types_set5(op, post) \
|
|
Packit Service |
c5cf8c |
do { \
|
|
Packit Service |
c5cf8c |
op##_test##post(_Bool, MPI_C_BOOL); \
|
|
Packit Service |
c5cf8c |
} while (0)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#define test_types_set5(op, post) do { } while (0)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (size < 2) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "At least 2 processes required\n");
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Set errors return so that we can provide better information
|
|
Packit Service |
c5cf8c |
* should a routine reject one of the operand/datatype pairs */
|
|
Packit Service |
c5cf8c |
MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
count = 10;
|
|
Packit Service |
c5cf8c |
/* Allow an argument to override the count.
|
|
Packit Service |
c5cf8c |
* Note that the product tests may fail if the count is very large.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
if (argc >= 2) {
|
|
Packit Service |
c5cf8c |
count = atoi(argv[1]);
|
|
Packit Service |
c5cf8c |
if (count <= 0) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Invalid count argument %s\n", argv[1]);
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set2(sum, 1);
|
|
Packit Service |
c5cf8c |
test_types_set2(prod, 1);
|
|
Packit Service |
c5cf8c |
test_types_set2(max, 1);
|
|
Packit Service |
c5cf8c |
test_types_set2(min, 1);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set1(lor, 1);
|
|
Packit Service |
c5cf8c |
test_types_set1(lor, 2);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set1(lxor, 1);
|
|
Packit Service |
c5cf8c |
test_types_set1(lxor, 2);
|
|
Packit Service |
c5cf8c |
test_types_set1(lxor, 3);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set1(land, 1);
|
|
Packit Service |
c5cf8c |
test_types_set1(land, 2);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set1(bor, 1);
|
|
Packit Service |
c5cf8c |
test_types_set1(band, 1);
|
|
Packit Service |
c5cf8c |
test_types_set1(band, 2);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set1(bxor, 1);
|
|
Packit Service |
c5cf8c |
test_types_set1(bxor, 2);
|
|
Packit Service |
c5cf8c |
test_types_set1(bxor, 3);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set3(bor, 1);
|
|
Packit Service |
c5cf8c |
test_types_set3(band, 1);
|
|
Packit Service |
c5cf8c |
test_types_set3(band, 2);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set3(bxor, 1);
|
|
Packit Service |
c5cf8c |
test_types_set3(bxor, 2);
|
|
Packit Service |
c5cf8c |
test_types_set3(bxor, 3);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set4(sum, 1);
|
|
Packit Service |
c5cf8c |
test_types_set4(prod, 1);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
test_types_set5(lor, 1);
|
|
Packit Service |
c5cf8c |
test_types_set5(lor, 2);
|
|
Packit Service |
c5cf8c |
test_types_set5(lxor, 1);
|
|
Packit Service |
c5cf8c |
test_types_set5(lxor, 2);
|
|
Packit Service |
c5cf8c |
test_types_set5(lxor, 3);
|
|
Packit Service |
c5cf8c |
test_types_set5(land, 1);
|
|
Packit Service |
c5cf8c |
test_types_set5(land, 2);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
maxloc_test(struct int_test, MPI_2INT);
|
|
Packit Service |
c5cf8c |
maxloc_test(struct long_test, MPI_LONG_INT);
|
|
Packit Service |
c5cf8c |
maxloc_test(struct short_test, MPI_SHORT_INT);
|
|
Packit Service |
c5cf8c |
maxloc_test(struct float_test, MPI_FLOAT_INT);
|
|
Packit Service |
c5cf8c |
maxloc_test(struct double_test, MPI_DOUBLE_INT);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
minloc_test(struct int_test, MPI_2INT);
|
|
Packit Service |
c5cf8c |
minloc_test(struct long_test, MPI_LONG_INT);
|
|
Packit Service |
c5cf8c |
minloc_test(struct short_test, MPI_SHORT_INT);
|
|
Packit Service |
c5cf8c |
minloc_test(struct float_test, MPI_FLOAT_INT);
|
|
Packit Service |
c5cf8c |
minloc_test(struct double_test, MPI_DOUBLE_INT);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|