1 /*
2    (C) 2001 by Argonne National Laboratory.
3        See COPYRIGHT in top-level directory.
4 */
5 #include "mpe_collchk_conf.h"
6 
7 #if defined( STDC_HEADERS ) || defined( HAVE_UNISTD_H )
8 #include <unistd.h>
9 #endif
10 #if defined( STDC_HEADERS ) || defined( HAVE_STRING_H )
11 #include <string.h>
12 #endif
13 #if defined( STDC_HEADERS ) || defined( HAVE_STDLIB_H )
14 #include <stdlib.h>
15 #endif
16 #if defined( STDC_HEADERS ) || defined( HAVE_STDIO_H )
17 #include <stdio.h>
18 #endif
19 
20 #include "mpi.h"
21 
22 #if ! defined( HAVE_MPI_ERR_FNS )
23 int MPI_Add_error_class(int *errorclass);
24 int MPI_Add_error_code(int errorclass, int *errorcode);
25 int MPI_Add_error_string(int errorcode, char *string);
26 int MPI_Comm_call_errhandler(MPI_Comm comm, int errorcode);
27 #endif
28 
29 #if defined( HAVE_MPI_IO )
30 /* file handlers */
31 typedef struct {
32         MPI_File fh;
33         MPI_Comm comm;
34 } CollChk_fh_t;
35 #endif
36 
37 #if defined( HAVE_MPI_RMA )
38 /* windows */
39 typedef struct {
40         MPI_Win win;
41         MPI_Comm comm;
42 } CollChk_win_t;
43 #endif
44 
45 /* the hash struct */
46 typedef struct {
47         unsigned int value;
48         unsigned int count;
49 } CollChk_hash_t;
50 
51 /* Global variables -- start */
52 #if defined( HAVE_MPI_IO )
53 extern CollChk_fh_t *CollChk_fh_list;
54 
55 extern int CollChk_fh_cnt;
56 #endif
57 
58 #if defined( HAVE_MPI_RMA )
59 extern CollChk_win_t *CollChk_win_list;
60 
61 extern int CollChk_win_cnt;
62 #endif
63 
64 /* begin string */
65 extern char CollChk_begin_str[128];
66 
67 extern int     COLLCHK_CALLED_BEGIN;
68 extern int     COLLCHK_ERRORS;
69 extern int     COLLCHK_ERR_NOT_INIT;
70 extern int     COLLCHK_ERR_ROOT ;
71 extern int     COLLCHK_ERR_CALL;
72 extern int     COLLCHK_ERR_OP;
73 extern int     COLLCHK_ERR_INPLACE;
74 extern int     COLLCHK_ERR_DTYPE;
75 extern int     COLLCHK_ERR_HIGH_LOW;
76 extern int     COLLCHK_ERR_LL;
77 extern int     COLLCHK_ERR_TAG;
78 extern int     COLLCHK_ERR_DIMS;
79 extern int     COLLCHK_ERR_GRAPH;
80 extern int     COLLCHK_ERR_AMODE;
81 extern int     COLLCHK_ERR_WHENCE;
82 extern int     COLLCHK_ERR_DATAREP;
83 extern int     COLLCHK_ERR_PREVIOUS_BEGIN;
84 extern int     COLLCHK_ERR_FILE_NOT_OPEN;
85 /* Global variables -- End */
86 
87 
88 #if defined( HAVE_MPI_IO )
89 void CollChk_add_fh( MPI_File fh, MPI_Comm comm );
90 int CollChk_get_fh(MPI_File fh, MPI_Comm *comm);
91 #endif
92 #if defined( HAVE_MPI_RMA )
93 void CollChk_add_win( MPI_Win win, MPI_Comm comm );
94 int CollChk_get_win(MPI_Win win, MPI_Comm *comm);
95 #endif
96 void CollChk_set_begin(char* in);
97 void CollChk_unset_begin(void);
98 int CollChk_check_buff(MPI_Comm comm, const void * buff, char* call);
99 int CollChk_check_dims(MPI_Comm comm, int ndims, const int *dims, char* call);
100 int CollChk_check_graph(MPI_Comm comm, int nnodes, const int *index, const int* edges,
101                         char* call);
102 int CollChk_check_size(MPI_Comm comm, int size, char* call);
103 int CollChk_err_han(char * err_str, int err_code, char * call, MPI_Comm comm);
104 int CollChk_is_init(void);
105 int CollChk_same_amode(MPI_Comm comm, int amode, char* call);
106 int CollChk_same_call(MPI_Comm comm, char* call);
107 int CollChk_same_datarep(MPI_Comm comm, const char* datarep, char *call);
108 
109 int CollChk_hash_equal(const CollChk_hash_t *alpha,
110                        const CollChk_hash_t *beta);
111 void CollChk_dtype_hash(MPI_Datatype type, int cnt, CollChk_hash_t *dt_hash);
112 
113 int CollChk_dtype_bcast(MPI_Comm comm, MPI_Datatype type, int cnt, int root,
114                         char* call);
115 int CollChk_dtype_scatter(MPI_Comm comm,
116                           MPI_Datatype sendtype, int sendcnt,
117                           MPI_Datatype recvtype, int recvcnt,
118                           int root, int are2buffs, char *call);
119 int CollChk_dtype_scatterv(MPI_Comm comm,
120                            MPI_Datatype sendtype, const int *sendcnts,
121                            MPI_Datatype recvtype, int recvcnt,
122                            int root, int are2buffs, char *call);
123 int CollChk_dtype_allgather(MPI_Comm comm,
124                             MPI_Datatype sendtype, int sendcnt,
125                             MPI_Datatype recvtype, int recvcnt,
126                             int are2buffs, char *call);
127 int CollChk_dtype_allgatherv(MPI_Comm comm,
128                              MPI_Datatype sendtype, int sendcnt,
129                              MPI_Datatype recvtype, const int *recvcnts,
130                              int are2buffs, char *call);
131 int CollChk_dtype_alltoallv(MPI_Comm comm,
132                             MPI_Datatype sendtype, const int *sendcnts,
133                             MPI_Datatype recvtype, const int *recvcnts,
134                             char *call);
135 int CollChk_dtype_alltoallw(MPI_Comm comm,
136                             const MPI_Datatype *sendtypes, const int *sendcnts,
137                             const MPI_Datatype *recvtypes, const int *recvcnts,
138                             char *call);
139 
140 int CollChk_same_high_low(MPI_Comm comm, int high_low, char* call);
141 int CollChk_same_int(MPI_Comm comm, int val, char* call, char* check,
142                      char* err_str);
143 int CollChk_same_local_leader(MPI_Comm comm, int ll, char* call);
144 int CollChk_same_op(MPI_Comm comm, MPI_Op op, char* call);
145 int CollChk_same_root(MPI_Comm comm, int root, char* call);
146 int CollChk_same_tag(MPI_Comm comm, int tag, char* call);
147 int CollChk_same_whence(MPI_Comm comm, int whence, char* call);
148 
149 
150 #define COLLCHK_NO_ERROR_STR   "no error"
151 #define COLLCHK_SM_STRLEN      32
152 #define COLLCHK_STD_STRLEN     256
153 #define COLLCHK_LG_STRLEN      1024
154