This source file includes following definitions.
- ADIOI_Calc_file_realms
- ADIOI_Calc_file_realms_user_size
- ADIOI_Calc_file_realms_aar
- ADIOI_Calc_file_realms_fsize
- ADIOI_Create_fr_simpletype
- ADIOI_Verify_fr
- ADIOI_Agg_idx
- align_fr
1
2
3
4
5
6
7 #include "adio.h"
8 #include "adio_extern.h"
9 #ifdef AGGREGATION_PROFILE
10 #include "mpe.h"
11 #endif
12 #include <assert.h>
13
14
15 void ADIOI_Calc_file_realms_user_size (ADIO_File fd, int fr_size,
16 int nprocs_for_coll,
17 ADIO_Offset *file_realm_st_offs,
18 MPI_Datatype *file_realm_types);
19 void ADIOI_Calc_file_realms_aar (ADIO_File fd, int nprocs_for_coll,
20 int pfr_enabled,
21 ADIO_Offset min_st_offset,
22 ADIO_Offset max_end_offset,
23 ADIO_Offset *file_realm_st_offs,
24 MPI_Datatype *file_realm_types);
25 void ADIOI_Calc_file_realms_fsize (ADIO_File fd,
26 int nprocs_for_coll,
27 ADIO_Offset max_end_offset,
28 ADIO_Offset *file_realm_st_offs,
29 MPI_Datatype *file_realm_types);
30 void ADIOI_Create_fr_simpletype (int size, int nprocs_for_coll,
31 MPI_Datatype *simpletype);
32 static void align_fr (int fr_size, ADIO_Offset fr_off, int alignment,
33 int *aligned_fr_size, ADIO_Offset *aligned_fr_off);
34 void ADIOI_Verify_fr (int nprocs_for_coll, ADIO_Offset *file_realm_st_offs,
35 MPI_Datatype *file_realm_types);
36
37 void ADIOI_Calc_file_realms (ADIO_File fd, ADIO_Offset min_st_offset,
38 ADIO_Offset max_end_offset)
39 {
40 int nprocs_for_coll;
41 int file_realm_calc_type;
42
43 MPI_Datatype *file_realm_types = NULL;
44 ADIO_Offset *file_realm_st_offs = NULL;
45
46 #ifdef AGGREGATION_PROFILE
47 MPE_Log_event (5004, 0, NULL);
48 #endif
49 #ifdef DEBUG
50 printf ("ADIOI_Calc_file_realms\n");
51 #endif
52
53 nprocs_for_coll = fd->hints->cb_nodes;
54 file_realm_calc_type = fd->hints->cb_fr_type;
55
56
57 if (fd->hints->cb_pfr != ADIOI_HINT_ENABLE) {
58 fd->file_realm_st_offs = NULL;
59 fd->file_realm_types = NULL;
60 }
61
62 if (nprocs_for_coll == 1) {
63
64
65 if (fd->file_realm_st_offs == NULL)
66 {
67 file_realm_st_offs = (ADIO_Offset *)
68 ADIOI_Malloc (sizeof(ADIO_Offset));
69 file_realm_types = (MPI_Datatype *)
70 ADIOI_Malloc (sizeof(MPI_Datatype));
71 }
72 else
73 {
74 file_realm_st_offs = fd->file_realm_st_offs;
75 file_realm_types = fd->file_realm_types;
76 }
77 *file_realm_st_offs = min_st_offset;
78 MPI_Type_contiguous ((max_end_offset - min_st_offset + 1), MPI_BYTE,
79 file_realm_types);
80 MPI_Type_commit (file_realm_types);
81 ADIOI_Add_contig_flattened (*file_realm_types);
82 }
83 else if (fd->file_realm_st_offs == NULL) {
84 file_realm_st_offs = (ADIO_Offset *)
85 ADIOI_Malloc (nprocs_for_coll * sizeof(ADIO_Offset));
86 file_realm_types = (MPI_Datatype *)
87 ADIOI_Malloc (nprocs_for_coll * sizeof(MPI_Datatype));
88
89 if (file_realm_calc_type == ADIOI_FR_AAR) {
90 ADIOI_Calc_file_realms_aar (fd, nprocs_for_coll,
91 fd->hints->cb_pfr,
92 min_st_offset, max_end_offset,
93 file_realm_st_offs, file_realm_types);
94
95
96 ADIOI_Flatten_datatype (file_realm_types[0]);
97 }
98 else if (file_realm_calc_type == ADIOI_FR_FSZ) {
99 ADIOI_Calc_file_realms_fsize (fd, nprocs_for_coll, max_end_offset,
100 file_realm_st_offs,
101 file_realm_types);
102
103
104 ADIOI_Flatten_datatype (file_realm_types[0]);
105 }
106 else if (file_realm_calc_type == ADIOI_FR_USR_REALMS) {
107
108
109
110
111 }
112 else if (file_realm_calc_type > 0) {
113 ADIOI_Calc_file_realms_user_size (fd, file_realm_calc_type,
114 nprocs_for_coll,
115 file_realm_st_offs,
116 file_realm_types);
117
118
119 ADIOI_Flatten_datatype (file_realm_types[0]);
120 }
121 }
122 fd->file_realm_st_offs = file_realm_st_offs;
123 fd->file_realm_types = file_realm_types;
124 #ifdef AGGREGATION_PROFILE
125 MPE_Log_event (5005, 0, NULL);
126 #endif
127 }
128
129 void ADIOI_Calc_file_realms_user_size (ADIO_File fd, int fr_size,
130 int nprocs_for_coll,
131 ADIO_Offset *file_realm_st_offs,
132 MPI_Datatype *file_realm_types)
133 {
134 int i;
135 int aligned_fr_size;
136 ADIO_Offset aligned_fr_off;
137 MPI_Datatype simpletype;
138
139 align_fr(fr_size, 0, fd->hints->cb_fr_alignment, &aligned_fr_size,
140 &aligned_fr_off);
141 fr_size = aligned_fr_size;
142 ADIOI_Create_fr_simpletype (fr_size, nprocs_for_coll, &simpletype);
143
144 if (fd->hints->cb_pfr == ADIOI_HINT_ENABLE)
145 file_realm_st_offs[0] = 0;
146 else
147 file_realm_st_offs[0] = aligned_fr_off;
148 file_realm_types[0] = simpletype;
149 #ifdef DEBUG
150 printf ("file_realm[0] = (%lld, %d)\n", file_realm_st_offs[0],
151 fr_size);
152 #endif
153
154 for (i=1; i < nprocs_for_coll; i++)
155 {
156 file_realm_st_offs[i] = file_realm_st_offs[i-1] + fr_size;
157 file_realm_types[i] = simpletype;
158 #ifdef DEBUG
159 printf ("file_realm[%d] = (%lld, %d)\n", i, file_realm_st_offs[i],
160 aligned_fr_size);
161 #endif
162 }
163 }
164
165
166
167 void ADIOI_Calc_file_realms_aar (ADIO_File fd, int nprocs_for_coll, int cb_pfr,
168 ADIO_Offset min_st_offset,
169 ADIO_Offset max_end_offset,
170 ADIO_Offset *file_realm_st_offs,
171 MPI_Datatype *file_realm_types)
172 {
173 int fr_size, aligned_fr_size, i;
174 MPI_Datatype simpletype;
175 ADIO_Offset aligned_start_off;
176 char value[9];
177
178 fr_size = (max_end_offset - min_st_offset + nprocs_for_coll) /
179 nprocs_for_coll;
180 align_fr(fr_size, min_st_offset, fd->hints->cb_fr_alignment,
181 &aligned_fr_size, &aligned_start_off);
182 fr_size = aligned_fr_size;
183 ADIOI_Create_fr_simpletype (fr_size, nprocs_for_coll, &simpletype);
184 if (cb_pfr == ADIOI_HINT_ENABLE)
185 file_realm_st_offs[0] = 0;
186 else
187 file_realm_st_offs[0] = aligned_start_off;
188 file_realm_types[0] = simpletype;
189
190 #ifdef DEBUG
191 printf ("file_realm[0] = (%lld, %d)\n", file_realm_st_offs[0],
192 fr_size);
193 #endif
194 for (i=1; i < nprocs_for_coll; i++)
195 {
196 file_realm_st_offs[i] = file_realm_st_offs[i-1] + fr_size;
197 file_realm_types[i] = simpletype;
198 #ifdef DEBUG
199 printf ("file_realm[%d] = (%lld, %d)\n", i, file_realm_st_offs[i],
200 fr_size);
201 #endif
202 }
203 if (fd->hints->cb_pfr == ADIOI_HINT_ENABLE) {
204 sprintf (value, "%d", fr_size);
205 ADIOI_Info_set (fd->info, "romio_cb_fr_type", value);
206 }
207 }
208
209 void ADIOI_Calc_file_realms_fsize (ADIO_File fd, int nprocs_for_coll,
210 ADIO_Offset max_end_offset,
211 ADIO_Offset *file_realm_st_offs,
212 MPI_Datatype *file_realm_types)
213 {
214 int fr_size, aligned_fr_size, error_code, i;
215 int fsize;
216 ADIO_Offset aligned_fr_off;
217 ADIO_Fcntl_t fcntl_struct;
218 MPI_Datatype simpletype;
219
220 ADIO_Fcntl (fd, ADIO_FCNTL_GET_FSIZE, &fcntl_struct, &error_code);
221
222
223 fsize = ADIOI_MAX (fcntl_struct.fsize, max_end_offset+1);
224 fr_size = (fsize + nprocs_for_coll - 1) / nprocs_for_coll;
225 align_fr(fr_size, 0, fd->hints->cb_fr_alignment,
226 &aligned_fr_size, &aligned_fr_off);
227 ADIOI_Create_fr_simpletype (fr_size, nprocs_for_coll, &simpletype);
228
229 for (i=0; i < nprocs_for_coll; i++)
230 {
231 file_realm_st_offs[i] = fr_size * i;
232 file_realm_types[i] = simpletype;
233 }
234 }
235
236
237 void ADIOI_Create_fr_simpletype (int size, int nprocs_for_coll,
238 MPI_Datatype *simpletype)
239 {
240 int count=1, blocklens[1];
241 MPI_Aint indices[1];
242 MPI_Datatype old_types[1];
243 MPI_Datatype inttype;
244
245 blocklens[0] = size;
246 indices[0] = 0;
247 old_types[0] = MPI_BYTE;
248
249 MPI_Type_create_struct (count, blocklens, indices, old_types, &inttype);
250 MPI_Type_create_resized (inttype, 0, size*nprocs_for_coll, simpletype);
251 MPI_Type_free (&inttype);
252
253 MPI_Type_commit (simpletype);
254 }
255
256
257 void ADIOI_Verify_fr (int nprocs_for_coll, ADIO_Offset *file_realm_st_offs,
258 MPI_Datatype *file_realm_types)
259 {
260 }
261
262 int ADIOI_Agg_idx (int rank, ADIO_File fd) {
263 int i, cb_nodes, *ranklist;
264 cb_nodes = fd->hints->cb_nodes;
265 ranklist = fd->hints->ranklist;
266
267 for (i=0; i<cb_nodes; i++) {
268 if (ranklist[i])
269 return i;
270 }
271 return -1;
272 }
273
274 static void align_fr (int fr_size, ADIO_Offset fr_off, int alignment,
275 int *aligned_fr_size, ADIO_Offset *aligned_fr_off) {
276 *aligned_fr_off = fr_off - (fr_off % alignment);
277 *aligned_fr_size = ((fr_off + fr_size) / alignment) * alignment -
278 *aligned_fr_off;
279 if ((fr_off + fr_size) % alignment)
280 *aligned_fr_size += alignment;
281
282 assert(!((*aligned_fr_off % alignment) ||
283 (*aligned_fr_size % alignment)));
284 }