This source file includes following definitions.
- main
- run_test
- print_usage
- print_test_params
- setup_predefined
1
2
3
4
5
6
7 #include "../adio/include/adio.h"
8 #include "../adio/include/adioi.h"
9 #include "../adio/include/adio_extern.h"
10 #include "mpi.h"
11
12 #define PREDEF_TESTS 5
13 #define MAX_OFF_LENS 4
14
15 typedef struct {
16 ADIO_Offset offset;
17 int count;
18 int type_blocklens[MAX_OFF_LENS];
19 int type_indices[MAX_OFF_LENS];
20 MPI_Datatype type_oldtypes[MAX_OFF_LENS];
21 int type_count;
22
23 ADIO_Offset correct_st_offset;
24 ADIO_Offset correct_end_offset;
25 } test_param_t;
26
27 int run_test (test_param_t *test);
28 int setup_predefined (test_param_t *tests_arr, int count);
29 int print_usage (void);
30 int print_test_params (test_param_t *test);
31
32 int main (int argc, char **argv) {
33 int rank;
34 int run_test_number = 0;
35 int failed;
36 int while_condition;
37 int i;
38
39 test_param_t predefined_tests[PREDEF_TESTS];
40
41 MPI_Init (&argc, &argv);
42 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
43
44 if (argc != 1) {
45 if (!rank) {
46 printf ("Use only one process\n");
47 print_usage ();
48 }
49 MPI_Finalize();
50 return 1;
51 }
52 i = 1;
53 while (i < argc) {
54 if (!strcmp (argv[i], "-A")) {
55 run_test_number = 0;
56 i++;
57 }
58 else if (!strcmp (argv[i], "-T")) {
59 run_test_number = atoi (argv[i+1]);
60 if ((run_test_number > PREDEF_TESTS) || (run_test_number < 1)) {
61 if (!rank)
62 printf ("Invalid test number, only %d tests\n",
63 PREDEF_TESTS);
64 MPI_Finalize ();
65 return 1;
66 }
67 i += 2;
68 }
69 else {
70 if (!rank) {
71 printf ("Invalid Argument: %s\n", argv[i]);
72 print_usage ();
73 }
74 i++;
75 }
76 }
77
78 setup_predefined (predefined_tests, PREDEF_TESTS);
79
80 if (!run_test_number) {
81 i = 0;
82 while_condition = PREDEF_TESTS;
83 }
84 else {
85 i = run_test_number - 1;
86 while_condition = run_test_number;
87 }
88 while (i < while_condition) {
89 printf ("***** Test %d *****\n", i+1);
90 failed = run_test (&predefined_tests[i]);
91 printf ("******************\n");
92 i++;
93 }
94
95 MPI_Finalize ();
96
97 return 0;
98 }
99
100 int run_test (test_param_t *test) {
101 ADIO_Offset st_offset, end_offset;
102 MPI_File fh;
103 int is_contig;
104 int ind_err = 0, exp_err = 0;
105
106 MPI_Datatype filetype;
107
108 MPI_Type_struct (test->type_count, test->type_blocklens,
109 test->type_indices, test->type_oldtypes, &filetype);
110 MPI_Type_commit (&filetype);
111
112 MPI_File_open (MPI_COMM_WORLD, "test_file.txt" , MPI_MODE_RDWR,
113 MPI_INFO_NULL, &fh);
114
115 MPI_File_set_view (fh, 0, MPI_BYTE, filetype, "native", MPI_INFO_NULL);
116
117 MPI_File_seek (fh, test->offset, MPI_SEEK_SET);
118 ADIOI_Calc_bounds ((ADIO_File) fh, test->count, MPI_BYTE, ADIO_INDIVIDUAL,
119 test->offset, &st_offset, &end_offset);
120
121 ind_err = 0;
122 if (st_offset != test->correct_st_offset) {
123 printf ("Individual st_offset = %lld end_offset = %lld\n",
124 st_offset, end_offset);
125 ind_err = 1;
126 }
127 if (end_offset != test->correct_end_offset) {
128 printf ("Individual st_offset = %lld end_offset = %lld\n",
129 st_offset, end_offset);
130 ind_err = 1;
131 }
132 MPI_File_close (&fh);
133 if (ind_err)
134 printf ("Individual Calc FAILED\n");
135
136 MPI_File_open (MPI_COMM_WORLD, "test_file.txt" , MPI_MODE_RDWR,
137 MPI_INFO_NULL, &fh);
138
139 if (!is_contig)
140 MPI_File_set_view (fh, 0, MPI_BYTE, filetype, "native", MPI_INFO_NULL);
141
142 MPI_File_seek (fh, 0, MPI_SEEK_SET);
143 ADIOI_Calc_bounds ((ADIO_File) fh, test->count, MPI_BYTE,
144 ADIO_EXPLICIT_OFFSET, test->offset, &st_offset,
145 &end_offset);
146
147 exp_err = 0;
148 if (st_offset != test->correct_st_offset) {
149 printf ("Explicit st_offset = %lld end_offset = %lld\n",
150 st_offset, end_offset);
151 exp_err = 1;
152 }
153 if (end_offset != test->correct_end_offset) {
154 printf ("Explicit st_offset = %lld end_offset = %lld\n",
155 st_offset, end_offset);
156 exp_err = 1;
157 }
158 if (exp_err)
159 printf ("Explicit Calc FAILED\n");
160
161 MPI_File_close (&fh);
162
163 if (!is_contig)
164 MPI_Type_free (&filetype);
165
166 return (exp_err || ind_err);
167 }
168
169 int print_usage ()
170 {
171 printf (
172 "Usage:\n"
173 " io_bounds_test -A -T <test #>\n");
174 }
175
176 int print_test_params (test_param_t *test)
177 {
178 int i;
179 printf (
180 "I/O offset: %lld\n"
181 "bytes: %d\n"
182 "Filetype [n](disp, lens, type):\n",
183 test->offset, test->count);
184
185 for (i=0; i<test->type_count; i++) {
186 printf (
187 " [%d](%lld, %d, ",
188 i,
189 test->type_blocklens[i],
190 test->type_indices[i]);
191 if (test->type_oldtypes[i] == MPI_BYTE) {
192 printf ( "%s)\n", "MPI_BYTE");
193 }
194 else if (test->type_oldtypes[i] == MPI_UB) {
195 printf ( "%s)\n", "MPI_UB");
196 }
197 else if (test->type_oldtypes[i] == MPI_LB) {
198 printf ( "%s)\n", "MPI_LB");
199 }
200 }
201 printf (
202 "Expected Start offset: %lld\n"
203 "Expected End offset: %lld\n",
204 test->correct_st_offset,
205 test->correct_end_offset);
206 }
207
208 int setup_predefined (test_param_t *tests_arr, int count)
209 {
210 int i;
211 for (i=0; i < PREDEF_TESTS; i++) {
212 switch (i)
213 {
214 case 0:
215 tests_arr[i].offset = 0;
216 tests_arr[i].count = 0;
217 tests_arr[i].type_count = 0;
218 tests_arr[i].type_indices[0] = 0;
219 tests_arr[i].type_blocklens[0] = 0;
220 tests_arr[i].type_oldtypes[0] = MPI_BYTE;
221 tests_arr[i].type_indices[1] = 0;
222 tests_arr[i].type_blocklens[1] = 0;
223 tests_arr[i].type_oldtypes[1] = MPI_BYTE;
224 tests_arr[i].type_indices[2] = 0;
225 tests_arr[i].type_blocklens[2] = 0;
226 tests_arr[i].type_oldtypes[2] = MPI_BYTE;
227 tests_arr[i].type_indices[3] = 0;
228 tests_arr[i].type_blocklens[3] = 0;
229 tests_arr[i].type_oldtypes[3] = MPI_BYTE;
230 break;
231 case 1:
232 tests_arr[i].offset = 0;
233 tests_arr[i].count = 0;
234 tests_arr[i].type_count = 0;
235 tests_arr[i].type_indices[0] = 0;
236 tests_arr[i].type_blocklens[0] = 0;
237 tests_arr[i].type_oldtypes[0] = MPI_BYTE;
238 tests_arr[i].type_indices[1] = 0;
239 tests_arr[i].type_blocklens[1] = 0;
240 tests_arr[i].type_oldtypes[1] = MPI_BYTE;
241 tests_arr[i].type_indices[2] = 0;
242 tests_arr[i].type_blocklens[2] = 0;
243 tests_arr[i].type_oldtypes[2] = MPI_BYTE;
244 tests_arr[i].type_indices[3] = 0;
245 tests_arr[i].type_blocklens[3] = 0;
246 tests_arr[i].type_oldtypes[3] = MPI_BYTE;
247 break;
248 case 2:
249 tests_arr[i].offset = 0;
250 tests_arr[i].count = 0;
251 tests_arr[i].type_count = 0;
252 tests_arr[i].type_indices[0] = 0;
253 tests_arr[i].type_blocklens[0] = 0;
254 tests_arr[i].type_oldtypes[0] = MPI_BYTE;
255 tests_arr[i].type_indices[1] = 0;
256 tests_arr[i].type_blocklens[1] = 0;
257 tests_arr[i].type_oldtypes[1] = MPI_BYTE;
258 tests_arr[i].type_indices[2] = 0;
259 tests_arr[i].type_blocklens[2] = 0;
260 tests_arr[i].type_oldtypes[2] = MPI_BYTE;
261 tests_arr[i].type_indices[3] = 0;
262 tests_arr[i].type_blocklens[3] = 0;
263 tests_arr[i].type_oldtypes[3] = MPI_BYTE;
264 break;
265 case 3:
266 tests_arr[i].offset = 0;
267 tests_arr[i].count = 0;
268 tests_arr[i].type_count = 0;
269 tests_arr[i].type_indices[0] = 0;
270 tests_arr[i].type_blocklens[0] = 0;
271 tests_arr[i].type_oldtypes[0] = MPI_BYTE;
272 tests_arr[i].type_indices[1] = 0;
273 tests_arr[i].type_blocklens[1] = 0;
274 tests_arr[i].type_oldtypes[1] = MPI_BYTE;
275 tests_arr[i].type_indices[2] = 0;
276 tests_arr[i].type_blocklens[2] = 0;
277 tests_arr[i].type_oldtypes[2] = MPI_BYTE;
278 tests_arr[i].type_indices[3] = 0;
279 tests_arr[i].type_blocklens[3] = 0;
280 tests_arr[i].type_oldtypes[3] = MPI_BYTE;
281 break;
282 case 4:
283 tests_arr[i].offset = 0;
284 tests_arr[i].count = 0;
285 tests_arr[i].type_count = 0;
286 tests_arr[i].type_indices[0] = 0;
287 tests_arr[i].type_blocklens[0] = 0;
288 tests_arr[i].type_oldtypes[0] = MPI_BYTE;
289 tests_arr[i].type_indices[1] = 0;
290 tests_arr[i].type_blocklens[1] = 0;
291 tests_arr[i].type_oldtypes[1] = MPI_BYTE;
292 tests_arr[i].type_indices[2] = 0;
293 tests_arr[i].type_blocklens[2] = 0;
294 tests_arr[i].type_oldtypes[2] = MPI_BYTE;
295 tests_arr[i].type_indices[3] = 0;
296 tests_arr[i].type_blocklens[3] = 0;
297 tests_arr[i].type_oldtypes[3] = MPI_BYTE;
298 break;
299 }
300 }
301 return 0;
302 }