This source file includes following definitions.
- MPI_Type_create_subarray
1
2
3
4
5
6
7 #include "mpioimpl.h"
8
9 #ifdef HAVE_WEAK_SYMBOLS
10
11 #if defined(HAVE_PRAGMA_WEAK)
12 #pragma weak MPI_Type_create_subarray = PMPI_Type_create_subarray
13 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
14 #pragma _HP_SECONDARY_DEF PMPI_Type_create_subarray MPI_Type_create_subarray
15 #elif defined(HAVE_PRAGMA_CRI_DUP)
16 #pragma _CRI duplicate MPI_Type_create_subarray as PMPI_Type_create_subarray
17
18 #endif
19
20
21 #define MPIO_BUILD_PROFILING
22 #include "mpioprof.h"
23 #endif
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 int MPI_Type_create_subarray(int ndims, int *array_of_sizes,
42 int *array_of_subsizes, int *array_of_starts,
43 int order, MPI_Datatype oldtype,
44 MPI_Datatype *newtype)
45 {
46 MPI_Aint extent, lb, size_with_aint;
47 int i, err, error_code;
48 MPI_Offset size_with_offset;
49
50
51 if (ndims <= 0) {
52 error_code = MPIO_Err_create_code(MPI_SUCCESS,
53 MPIR_ERR_RECOVERABLE,
54 myname, __LINE__, MPI_ERR_ARG,
55 "Invalid ndims argument", 0);
56 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
57 }
58 if (array_of_sizes <= (int *) 0) {
59 error_code = MPIO_Err_create_code(MPI_SUCCESS,
60 MPIR_ERR_RECOVERABLE,
61 myname, __LINE__, MPI_ERR_ARG,
62 "Invalid array_of_sizes argument",
63 0);
64 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
65 }
66 if (array_of_subsizes <= (int *) 0) {
67 error_code = MPIO_Err_create_code(MPI_SUCCESS,
68 MPIR_ERR_RECOVERABLE,
69 myname, __LINE__, MPI_ERR_ARG,
70 "Invalid array_of_subsizes argument",
71 0);
72 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
73 }
74 if (array_of_starts <= (int *) 0) {
75 error_code = MPIO_Err_create_code(MPI_SUCCESS,
76 MPIR_ERR_RECOVERABLE,
77 myname, __LINE__, MPI_ERR_ARG,
78 "Invalid array_of_starts argument",
79 0);
80 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
81 }
82
83 for (i=0; i<ndims; i++) {
84 if (array_of_sizes[i] <= 0) {
85 error_code = MPIO_Err_create_code(MPI_SUCCESS,
86 MPIR_ERR_RECOVERABLE,
87 myname, __LINE__, MPI_ERR_ARG,
88 "Invalid size argument", 0);
89 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
90 }
91 if (array_of_subsizes[i] <= 0) {
92 error_code = MPIO_Err_create_code(MPI_SUCCESS,
93 MPIR_ERR_RECOVERABLE,
94 myname, __LINE__, MPI_ERR_ARG,
95 "Invalid subsize argument", 0);
96 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
97 }
98 if (array_of_starts[i] < 0) {
99 error_code = MPIO_Err_create_code(MPI_SUCCESS,
100 MPIR_ERR_RECOVERABLE,
101 myname, __LINE__, MPI_ERR_ARG,
102 "Invalid start argument", 0);
103 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
104 }
105 if (array_of_subsizes[i] > array_of_sizes[i]) {
106 error_code = MPIO_Err_create_code(MPI_SUCCESS,
107 MPIR_ERR_RECOVERABLE,
108 myname, __LINE__, MPI_ERR_ARG,
109 "Invalid subsize argument", 0);
110 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
111 }
112 if (array_of_starts[i] > (array_of_sizes[i] - array_of_subsizes[i])) {
113 error_code = MPIO_Err_create_code(MPI_SUCCESS,
114 MPIR_ERR_RECOVERABLE,
115 myname, __LINE__, MPI_ERR_ARG,
116 "Invalid start argument", 0);
117 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
118 }
119 }
120
121
122
123 if (oldtype == MPI_DATATYPE_NULL) {
124 error_code = MPIO_Err_create_code(MPI_SUCCESS,
125 MPIR_ERR_RECOVERABLE,
126 myname, __LINE__, MPI_ERR_ARG,
127 "Invalid type argument", 0);
128 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
129 }
130
131 MPI_Type_get_extent(oldtype, &lb, &extent);
132
133
134
135
136 size_with_aint = extent;
137 for (i=0; i<ndims; i++) size_with_aint *= array_of_sizes[i];
138 size_with_offset = extent;
139 for (i=0; i<ndims; i++) size_with_offset *= array_of_sizes[i];
140 if (size_with_aint != size_with_offset) {
141 error_code = MPIO_Err_create_code(MPI_SUCCESS,
142 MPIR_ERR_RECOVERABLE,
143 myname, __LINE__, MPI_ERR_ARG,
144 "Invalid size argument", 0);
145 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
146 }
147
148 if (order != MPI_ORDER_FORTRAN && order != MPI_ORDER_C) {
149 error_code = MPIO_Err_create_code(MPI_SUCCESS,
150 MPIR_ERR_RECOVERABLE,
151 myname, __LINE__, MPI_ERR_ARG,
152 "Invalid order argument", 0);
153 return MPIO_Err_return_comm(MPI_COMM_SELF, error_code);
154 }
155
156
157 err = ADIO_Type_create_subarray(ndims,
158 array_of_sizes,
159 array_of_subsizes,
160 array_of_starts,
161 order,
162 oldtype,
163 newtype);
164
165 if (err != MPI_SUCCESS) {
166 error_code = MPIO_Err_create_code(MPI_SUCCESS,
167 MPIR_ERR_RECOVERABLE,
168 myname, __LINE__, err,
169 "Internal error", 0);
170 }
171
172
173 return MPI_SUCCESS;
174 }