Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the size of partial shared malloc tests.
[simgrid.git] / teshsuite / smpi / mpich3-test / include / mpitest.h
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2001 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #ifndef MPITEST_H_INCLUDED
8 #define MPITEST_H_INCLUDED
9
10 #include <string.h>
11 #include "mpitestconf.h"
12
13 /*
14  * Init and finalize test
15  */
16 void MTest_Init(int *, char ***);
17 void MTest_Init_thread(int *, char ***, int, int *);
18 void MTest_Finalize(int);
19 void MTestPrintError(int);
20 void MTestPrintErrorMsg(const char[], int);
21 void MTestPrintfMsg(int, const char[], ...);
22 void MTestError(const char[]);
23 int MTestReturnValue(int);
24
25 /*
26  * Utilities
27  */
28 void MTestSleep(int);
29 void MTestGetDbgInfo(int *dbgflag, int *verbose);
30
31 /*
32  * This structure contains the information used to test datatypes
33  * buf is set to null when an MTestDatatype is created; the
34  * InitBuf routine will allocate (if necessary) and initialize
35  * the data.  InitBuf may be called multiple times (this is particularly
36  * important for recv bufs), in which case the buffer will only
37  * be allocated if it has not already been created.
38  */
39 typedef struct _MTestDatatype {
40     MPI_Datatype datatype;
41     void *buf;                  /* buffer to use in communication */
42     MPI_Aint count;             /* count to use for this datatype */
43     int isBasic;                /* true if the type is predefined */
44     int printErrors;            /* true if errors should be printed
45                                  * (used by the CheckBuf routines) */
46     /* The following is optional data that is used by some of
47      * the derived datatypes */
48     int nblock, *index;
49     /* stride, and blksize are in bytes */
50     MPI_Aint stride, blksize, *displ_in_bytes;
51     int *displs, basesize;
52     MPI_Datatype *old_datatypes;
53     /* used in subarray */
54     int arr_sizes[2], arr_subsizes[2], arr_starts[2], order;
55
56     void *(*InitBuf) (struct _MTestDatatype *);
57     void *(*FreeBuf) (struct _MTestDatatype *);
58     int (*CheckBuf) (struct _MTestDatatype *);
59 } MTestDatatype;
60
61 /* The max value of count must be very large to ensure that we
62  *  reach the long message algorithms. (The maximal count or block length
63  *  can be generated by 256K count is 4K or 32Kbytes respectively) */
64 #define MTEST_DATATYPE_FOR_EACH_COUNT(count) \
65         for (count = 1; count <= 262144; count *= 128)
66
67 /* Setup the full version of datatype tests.
68  * It generate tests for all basic datatypes and all derived datatypes except darray. */
69 void MTestInitFullDatatypes(void);
70
71 /* Setup the minimum version of datatype tests.
72  * It generate tests for all basic datatypes, vector and indexed. */
73 void MTestInitMinDatatypes(void);
74
75 /* Setup the basic version of datatype tests.
76  * It generate tests for all basic datatypes. */
77 void MTestInitBasicDatatypes(void);
78
79 int MTestCheckRecv(MPI_Status *, MTestDatatype *);
80 int MTestGetDatatypes(MTestDatatype *, MTestDatatype *, MPI_Aint);
81 void MTestResetDatatypes(void);
82 void MTestFreeDatatype(MTestDatatype *);
83 const char *MTestGetDatatypeName(MTestDatatype *);
84 int MTestGetDatatypeIndex(void);
85
86 int MTestGetIntracomm(MPI_Comm *, int);
87 int MTestGetIntracommGeneral(MPI_Comm *, int, int);
88 int MTestGetIntercomm(MPI_Comm *, int *, int);
89 int MTestGetComm(MPI_Comm *, int);
90 int MTestTestIntercomm(MPI_Comm intercomm);
91 int MTestTestIntracomm(MPI_Comm intracomm);
92 int MTestTestComm(MPI_Comm comm);
93 const char *MTestGetIntracommName(void);
94 const char *MTestGetIntercommName(void);
95 void MTestFreeComm(MPI_Comm *);
96
97 int MTestSpawnPossible(int *);
98
99 #ifdef HAVE_MPI_WIN_CREATE
100 int MTestGetWin(MPI_Win *, int);
101 const char *MTestGetWinName(void);
102 void MTestFreeWin(MPI_Win *);
103 #endif
104
105 /* These macros permit overrides via:
106  *     make CPPFLAGS='-DMTEST_MPI_VERSION=X -DMTEST_MPI_SUBVERSION=Y'
107  * where X and Y are the major and minor versions of the MPI standard that is
108  * being tested.  The override should work similarly if added to the CPPFLAGS at
109  * configure time. */
110 #ifndef MTEST_MPI_VERSION
111 #define MTEST_MPI_VERSION MPI_VERSION
112 #endif
113 #ifndef MTEST_MPI_SUBVERSION
114 #define MTEST_MPI_SUBVERSION MPI_SUBVERSION
115 #endif
116
117 /* Makes it easier to conditionally compile test code for a particular minimum
118  * version of the MPI Standard.  Right now there is only a MIN flavor but it
119  * would be easy to add MAX or EXACT flavors if they become necessary at some
120  * point.  Example usage:
121  ------8<-------
122 #if MTEST_HAVE_MIN_MPI_VERSION(2,2)
123 ... test for some feature that is only available in MPI-2.2 or later ...
124 #endif
125  ------8<-------
126  */
127 #define MTEST_HAVE_MIN_MPI_VERSION(major_,minor_) \
128     ((MTEST_MPI_VERSION == (major_) && MTEST_MPI_SUBVERSION >= (minor_)) ||   \
129     (MTEST_MPI_VERSION > (major_)))
130
131 /* useful for avoid valgrind warnings about padding bytes */
132 #define MTEST_VG_MEM_INIT(addr_, size_) \
133 do {                                    \
134     memset(addr_, 0, size_);            \
135 } while (0)
136
137 #endif