1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #ifndef OMPI_C_BINDINGS_H
23 #define OMPI_C_BINDINGS_H
24
25 #include "ompi_config.h"
26 #include "mpi.h"
27 #include "ompi/datatype/ompi_datatype.h"
28
29
30
31
32 #include "opal/runtime/opal_cr.h"
33
34 BEGIN_C_DECLS
35
36
37
38
39
40
41
42
43
44
45
46
47 #define OMPI_CHECK_DATATYPE_FOR_SEND( RC, DDT, COUNT ) \
48 do { \
49 \
50 if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
51 else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
52 else if( !opal_datatype_is_committed(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
53 else if( !opal_datatype_is_valid(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
54 } while (0)
55
56 #define OMPI_CHECK_DATATYPE_FOR_RECV( RC, DDT, COUNT ) \
57 do { \
58 \
59 if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
60 else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
61 else if( !opal_datatype_is_committed(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
62 \
63 else if( !opal_datatype_is_valid(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
64 } while (0)
65
66 #define OMPI_CHECK_DATATYPE_FOR_ONE_SIDED( RC, DDT, COUNT ) \
67 do { \
68 \
69 if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
70 else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
71 else if( !opal_datatype_is_committed(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
72 else if( opal_datatype_is_overlapped(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
73 else if( !opal_datatype_is_valid(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
74 } while(0)
75
76 #define OMPI_CHECK_DATATYPE_FOR_VIEW( RC, DDT, COUNT ) \
77 do { \
78 \
79 if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
80 else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
81 else if( !opal_datatype_is_committed(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
82 \
83 else if( !opal_datatype_is_valid(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \
84 else if( !ompi_datatype_is_monotonic((DDT)) ) (RC) = MPI_ERR_TYPE; \
85 } while (0)
86
87
88
89
90
91 #define OMPI_CHECK_USER_BUFFER(RC, BUFFER, DDT, COUNT) \
92 do { \
93 if ( NULL == (BUFFER) && 0 < (COUNT) && MPI_SUCCESS == (RC) ) { \
94 if ( (DDT)->super.flags & OPAL_DATATYPE_FLAG_PREDEFINED ) { \
95 (RC) = MPI_ERR_BUFFER; \
96 } else { \
97 size_t size = 0; \
98 ptrdiff_t true_lb = 0; \
99 ptrdiff_t true_extended = 0; \
100 ompi_datatype_type_size((DDT), &size); \
101 ompi_datatype_get_true_extent((DDT), &true_lb, &true_extended); \
102 if ( 0 < size && 0 == true_lb ) { \
103 (RC) = MPI_ERR_BUFFER; \
104 } \
105 } \
106 } \
107 } while (0)
108
109 END_C_DECLS
110
111 #endif