SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
sion_generic.c
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2019 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
15 #define _XOPEN_SOURCE 700
16 
17 #include <stdlib.h>
18 #include <stdio.h>
19 #include <stdarg.h>
20 #include <string.h>
21 #include <time.h>
22 
23 #include <sys/time.h>
24 
25 #include <sys/types.h>
26 #include <fcntl.h>
27 
28 #include <unistd.h>
29 
30 #include "sion.h"
31 #include "sion_debug.h"
32 #include "sion_error_handler.h"
33 #include "sion_internal.h"
34 #include "sion_fd.h"
35 #include "sion_filedesc.h"
36 #include "sion_printts.h"
37 #include "sion_flags.h"
38 
39 #include "sion_generic_internal.h"
40 #include "sion_generic_apidesc.h"
41 #include "sion_generic_mapped.h"
42 #include "sion_generic_buddy.h"
43 #include "sion_generic.h"
44 
45 
46 int sion_generic_create_api( char *name ) {
47  int apiid = SION_ID_UNDEF;
48  _sion_generic_apidesc *sion_apidesc;
49 
50  sion_apidesc=_sion_generic_alloc_apidesc();
51  if(!sion_apidesc) {
52  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"_sion_generic_create_api: problems to alloc apidesc, aborting ...\n"));
53  }
54  _sion_generic_init_apidesc(sion_apidesc);
55 
56  if (name == NULL) {
57  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"_sion_generic_create_api: name for API not given, aborting ...\n"));
58  }
59 
60  sion_apidesc->name=strdup(name);
61 
62  apiid = _sion_newvcd(sion_apidesc,SION_APIDESCRIPTOR);
63  sion_apidesc->aid=apiid;
64  sion_apidesc->level=SION_GENERIC_API_LEVEL_NONE;
65 
66  DPRINTFP((2, "_sion_generic_create_api", _SION_DEFAULT_RANK, "API created with name %s apiid=%d\n", sion_apidesc->name, apiid));
67 
68  return(apiid);
69 }
70 
71 int sion_generic_free_api( int aid ) {
72  _sion_generic_apidesc *sion_apidesc;
73  int rc = SION_SUCCESS;
74 
75  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
76  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_free_api: invalid sion_apidesc %d", aid));
77  }
78  _sion_freevcd(aid);
79  rc=_sion_generic_free_apidesc(sion_apidesc);
80 
81  return(rc);
82 }
83 
84 int sion_generic_register_create_local_commgroup_cb(int aid, int create_lcg_cb(void **, void *, int, int, int, int, int, int)) {
85  _sion_generic_apidesc *sion_apidesc;
86  int rc = SION_SUCCESS;
87 
88  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
89  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_create_local_commgroup_cb: invalid sion_apidesc %d", aid));
90  }
91 
92  if(sion_apidesc->create_lcg_cb!=NULL) {
93  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_create_local_commgroup_cb: update_cb already registered for apiid=%d", aid));
94  }
95  sion_apidesc->create_lcg_cb=create_lcg_cb;
96 
97  _sion_generic_update_api_level(sion_apidesc);
98 
99  DPRINTFP((2, "sion_generic_register_create_local_commgroup_cb", _SION_DEFAULT_RANK, "create_lcg_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
100 
101  return(rc);
102 }
103 
104 int sion_generic_register_free_local_commgroup_cb(int aid, int free_lcg_cb(void *)) {
105  _sion_generic_apidesc *sion_apidesc;
106  int rc = SION_SUCCESS;
107 
108  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
109  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_free_local_commgroup_cb: invalid sion_apidesc %d", aid));
110  }
111 
112  if(sion_apidesc->free_lcg_cb!=NULL) {
113  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_free_local_commgroup_cb: update_cb already registered for apiid=%d", aid));
114  }
115  sion_apidesc->free_lcg_cb=free_lcg_cb;
116 
117  _sion_generic_update_api_level(sion_apidesc);
118 
119  DPRINTFP((2, "sion_generic_register_free_local_commgroup_cb", _SION_DEFAULT_RANK, "free_lcg_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
120 
121  return(rc);
122 }
123 
124 
125 int sion_generic_register_barrier_cb(int aid, int barrier_cb(void *)) {
126  _sion_generic_apidesc *sion_apidesc;
127  int rc = SION_SUCCESS;
128 
129  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
130  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_barrier_cb: invalid sion_apidesc %d", aid));
131  }
132 
133  if(sion_apidesc->barrier_cb!=NULL) {
134  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_barrier_cb: barrier_cb already registered for apiid=%d", aid));
135  }
136  sion_apidesc->barrier_cb=barrier_cb;
137 
138  _sion_generic_update_api_level(sion_apidesc);
139 
140  DPRINTFP((2, "sion_generic_register_barrier_cb", _SION_DEFAULT_RANK, "barrier_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
141 
142  return(rc);
143 }
144 
145 int sion_generic_register_bcastr_cb(int aid, int bcastr_cb(void *,void *, int,int,int)) {
146  _sion_generic_apidesc *sion_apidesc;
147  int rc = SION_SUCCESS;
148 
149  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
150  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_bcastr_cb: invalid sion_apidesc %d", aid));
151  }
152 
153  if(sion_apidesc->bcastr_cb!=NULL) {
154  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_bcastr_cb: bcastr_cb already registered for apiid=%d", aid));
155  }
156  sion_apidesc->bcastr_cb=bcastr_cb;
157 
158  _sion_generic_update_api_level(sion_apidesc);
159 
160  DPRINTFP((2, "sion_generic_register_bcastr_cb", _SION_DEFAULT_RANK, "bcastr_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
161 
162  return(rc);
163 }
164 
165 int sion_generic_register_gatherr_cb(int aid, int gatherr_cb(void *,void *,void *, int,int,int)) {
166  _sion_generic_apidesc *sion_apidesc;
167  int rc = SION_SUCCESS;
168 
169  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
170  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_gatherr_cb: invalid sion_apidesc %d", aid));
171  }
172 
173  if(sion_apidesc->gatherr_cb!=NULL) {
174  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_gatherr_cb: gatherr_cb already registered for apiid=%d", aid));
175  }
176  sion_apidesc->gatherr_cb=gatherr_cb;
177 
178  _sion_generic_update_api_level(sion_apidesc);
179 
180  DPRINTFP((2, "sion_generic_register_gatherr_cb", _SION_DEFAULT_RANK, "gatherr_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
181 
182  return(rc);
183 }
184 
185 int sion_generic_register_gathervr_cb(int aid, int gathervr_cb(void *,void *,void *, int, int *, int, int)) {
186  _sion_generic_apidesc *sion_apidesc;
187  int rc = SION_SUCCESS;
188 
189  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
190  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_gathervr_cb: invalid sion_apidesc %d", aid));
191  }
192 
193  if(sion_apidesc->gathervr_cb!=NULL) {
194  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_gathervr_cb: gathervr_cb already registered for apiid=%d", aid));
195  }
196  sion_apidesc->gathervr_cb=gathervr_cb;
197 
198  _sion_generic_update_api_level(sion_apidesc);
199 
200  DPRINTFP((2, "sion_generic_register_gathervr_cb", _SION_DEFAULT_RANK, "gathervr_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
201 
202  return(rc);
203 }
204 
205 int sion_generic_register_scatterr_cb(int aid, int scatterr_cb(void *,void *,void *, int,int,int)) {
206  _sion_generic_apidesc *sion_apidesc;
207  int rc = SION_SUCCESS;
208 
209  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
210  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_scatterr_cb: invalid sion_apidesc %d", aid));
211  }
212 
213  if(sion_apidesc->scatterr_cb!=NULL) {
214  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_scatterr_cb: scatterr_cb already registered for apiid=%d", aid));
215  }
216  sion_apidesc->scatterr_cb=scatterr_cb;
217 
218  _sion_generic_update_api_level(sion_apidesc);
219 
220  DPRINTFP((2, "sion_generic_register_scatterr_cb", _SION_DEFAULT_RANK, "scatterr_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
221 
222  return(rc);
223 }
224 
225 int sion_generic_register_scattervr_cb(int aid, int scattervr_cb(void *,void *,void *, int, int *, int, int)) {
226  _sion_generic_apidesc *sion_apidesc;
227  int rc = SION_SUCCESS;
228 
229  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
230  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_scattervr_cb: invalid sion_apidesc %d", aid));
231  }
232 
233  if(sion_apidesc->scattervr_cb!=NULL) {
234  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_scattervr_cb: scattervr_cb already registered for apiid=%d", aid));
235  }
236  sion_apidesc->scattervr_cb=scattervr_cb;
237 
238  _sion_generic_update_api_level(sion_apidesc);
239 
240  DPRINTFP((2, "sion_generic_register_scattervr_cb", _SION_DEFAULT_RANK, "scattervr_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
241 
242  return(rc);
243 }
244 
245 int sion_generic_register_gather_and_execute_cb(int aid, int gather_execute_cb(const void *, sion_int64*, int, sion_int64,
246  void *, int, int, int, int,
247  int process_cb(const void *,sion_int64 *, int))) {
248  _sion_generic_apidesc *sion_apidesc;
249  int rc = SION_SUCCESS;
250 
251  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
252  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_gather_and_execute_cb: invalid sion_apidesc %d", aid));
253  }
254 
255  if(sion_apidesc->gather_execute_cb!=NULL) {
256  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_gather_and_execute_cb: scattervr_cb already registered for apiid=%d", aid));
257  }
258  sion_apidesc->gather_execute_cb=gather_execute_cb;
259 
260  _sion_generic_update_api_level(sion_apidesc);
261 
262  DPRINTFP((2, "sion_generic_register_gather_and_execute_cb", _SION_DEFAULT_RANK, "gather_execute_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
263 
264  return(rc);
265 }
266 
267 int sion_generic_register_execute_and_scatter_cb(int aid, int execute_scatter_cb(void *, sion_int64*, int, sion_int64,
268  void *, int, int, int, int,
269  int process_cb(void *,sion_int64 *, int))) {
270  _sion_generic_apidesc *sion_apidesc;
271  int rc = SION_SUCCESS;
272 
273  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
274  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_execute_and_scatter_cb: invalid sion_apidesc %d", aid));
275  }
276 
277  if(sion_apidesc->execute_scatter_cb!=NULL) {
278  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_execute_and_scatter_cb: scattervr_cb already registered for apiid=%d", aid));
279  }
280  sion_apidesc->execute_scatter_cb=execute_scatter_cb;
281 
282  DPRINTFP((2, "sion_generic_register_execute_and_scatter_cb", _SION_DEFAULT_RANK, "gather_execute_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
283 
284  return(rc);
285 }
286 
287 int sion_generic_register_get_multi_filename_cb(int aid, char *get_multi_filename_cb(const char *,int)) {
288  _sion_generic_apidesc *sion_apidesc;
289  int rc=0;
290 
291  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
292  return(_sion_errorprint(-1,_SION_ERROR_RETURN,"sion_generic_register_get_multi_filename_cb: invalid sion_apidesc %d", aid));
293  }
294 
295  if(sion_apidesc->get_multi_filename_cb!=NULL) {
296  return(_sion_errorprint(-1,_SION_ERROR_RETURN,"sion_generic_register_get_multi_filename_cb: get_multi_filename_cb already registered for apiid=%d", aid));
297  }
298  sion_apidesc->get_multi_filename_cb=get_multi_filename_cb;
299 
300  _sion_generic_update_api_level(sion_apidesc);
301 
302  DPRINTFP((2, "sion_generic_register_get_multi_filename_cb", -1, "get_multi_filename_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
303 
304  return(rc);
305 }
306 
307 int sion_generic_register_get_capability_cb(int aid, int get_capability_cb(void *)) {
308  _sion_generic_apidesc *sion_apidesc;
309  int rc = SION_SUCCESS;
310 
311  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
312  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_get_capability_cb: invalid sion_apidesc %d", aid));
313  }
314 
315  if(sion_apidesc->get_capability_cb!=NULL) {
316  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"sion_generic_register_get_capability_cb: get_capability_cb already registered for apiid=%d", aid));
317  }
318  sion_apidesc->get_capability_cb=get_capability_cb;
319 
320  _sion_generic_update_api_level(sion_apidesc);
321 
322  DPRINTFP((2, "sion_generic_register_get_capability_cb", _SION_DEFAULT_RANK, "get_capability_cb registered for apiid=%s (%d)\n", sion_apidesc->name, aid));
323 
324  return(rc);
325 }
326 
327 
352  const char* fname,
353  const char* file_mode,
354  sion_int64* chunksize,
355  sion_int32* fsblksize,
356  void* gcommgroup,
357  int grank,
358  int gsize,
359  int* filenumber,
360  int* numfiles,
361  const int* lrank,
362  const int* lsize,
363  FILE** fileptr,
364  char** newfname
365  )
366 {
367  int rc, sid = SION_ID_UNDEF;
368  sion_int32 lfsblksize;
369  sion_int64 lchunksize;
370  int help_globalrank;
371  char *nfname=NULL,*lprefix=NULL;
372  _sion_filedesc *sion_filedesc;
373  _sion_generic_apidesc *sion_apidesc;
374  _sion_generic_gendata *sion_gendata;
375  _sion_flags_store* flags_store = NULL;
376 
377  /* */ DPRINTFTS(grank, "enter sion_generic_paropen");
378  DPRINTFP((1, "sion_generic_paropen", grank, "enter generic parallel open of FILE %s (global: %d of %d, local: %d of %d, file: %d of %d )\n",
379  fname, grank, gsize, *lrank, *lsize, *filenumber, *numfiles));
380 
381  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
382  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_register_scattervr_cb: invalid sion_apidesc %d", aid));
383  }
384 
385  if ( (sion_apidesc->level!=SION_GENERIC_API_LEVEL_STD) &&
386  (sion_apidesc->level!=SION_GENERIC_API_LEVEL_FULL) ) {
387  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: API %s not correctly initalized, aborting",sion_apidesc->name));
388  }
389 
390  /* check parameters */
391  if ( (grank < 0 ) || (grank >= gsize) ) {
392  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: global rank %d not valid (0..%d)",grank,gsize));
393  }
394 
395 #ifdef HACK_SCALASCA
396  /* hack for scalasca */
397  if(strstr(fname,".def")!=NULL) {
398  lfsblksize=65536;
399  lchunksize=65536;
400  } else {
401 #endif
402  lfsblksize=*fsblksize;
403  lchunksize=*chunksize;
404 #ifdef HACK_SCALASCA
405  }
406 #endif
407  DPRINTFP((1, "sion_generic_paropen", grank, "setting fsblksize = %d for file %s\n", lfsblksize, fname));
408 
409  /* create data container */
410  sion_gendata=_sion_generic_alloc_gendata();
411  if(!sion_gendata) {
412  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: problems to alloc gendata, aborting ...\n"));
413  }
414  _sion_generic_init_gendata(sion_gendata);
415 
416  sion_gendata->aid=aid;
417  sion_gendata->apidesc=sion_apidesc;
418  sion_gendata->comm_data_global=gcommgroup;
419  sion_gendata->comm_data_local=NULL;
420  sion_gendata->grank=grank;
421  sion_gendata->gsize=gsize;
422 
423  flags_store = _sion_parse_flags(file_mode);
424  if ( ! flags_store ) {
425  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: could not parse file mode in %s, aborting ...\n", file_mode));
426  }
427 
428  if (flags_store->mask&_SION_FMODE_WRITE) {
429 
430 
431  if (lrank == NULL) {
432  _sion_flags_destroy_store(&flags_store);
433  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: No lrank variable given"));
434  }
435  if (lsize == NULL) {
436  _sion_flags_destroy_store(&flags_store);
437  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: No lsize variable given"));
438  }
439  if ( !_sion_flags_get(flags_store, "collmsa") && ((*lrank < 0 ) || (*lrank >= *lsize)) ) {
440  _sion_flags_destroy_store(&flags_store);
441  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: local rank %d not valid (0..%d)",*lrank,*lsize));
442  }
443  sion_gendata->lrank=*lrank;
444  sion_gendata->lsize=*lsize;
445 
446  if (filenumber == NULL) {
447  _sion_flags_destroy_store(&flags_store);
448  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: No filenumber variable given"));
449  }
450  if (numfiles == NULL) {
451  _sion_flags_destroy_store(&flags_store);
452  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: No numfiles variable given"));
453  }
454  if ( !_sion_flags_get(flags_store, "collmsa") && ((*filenumber < 0 ) || (*filenumber >= *numfiles)) ) {
455  _sion_flags_destroy_store(&flags_store);
456  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: file number %d not valid (0..%d)",*filenumber,*numfiles));
457  }
458  sion_gendata->filenumber=*filenumber;
459  sion_gendata->numfiles=*numfiles;
460  if (_sion_flags_get(flags_store, "collmsa")) {
461  if (SION_SUCCESS != _sion_generic_renumber_collmsa(sion_gendata, flags_store)) {
462  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: error in MSA aware collective renumbering, aborting ...\n"));
463  }
464  }
465 
466  lprefix = calloc(SION_FILENAME_LENGTH,1);
467  if (lprefix == NULL) {
468  _sion_flags_destroy_store(&flags_store);
469  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: cannot allocate temporary memory of size %lu (lprefix), aborting ...\n", (unsigned long) SION_FILENAME_LENGTH));
470  }
471 
472  strcpy(lprefix, fname);
473 
474  } else if (flags_store->mask&_SION_FMODE_READ) {
475  /* file mode READ */
476 
477  DPRINTFP((1, "sion_generic_paropen", grank, "READ: buddy=%d\n", flags_store->mask&_SION_FMODE_BUDDY));
478 
479  /* get number of files and filenumber */
480  if(! (flags_store->mask&_SION_FMODE_BUDDY) ) {
481 
482  rc = _sion_generic_get_and_distribute_info_from_file(sion_gendata, fname);
483  if (_sion_flags_get(flags_store, "collmsa") && (sion_gendata->numfiles == 1)) {
484  if (SION_SUCCESS != _sion_generic_renumber_collmsa(sion_gendata, flags_store)) {
485  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: error in MSA aware collective renumbering, aborting ...\n"));
486  }
487  }
488  *numfiles=sion_gendata->numfiles;
489  *filenumber=sion_gendata->filenumber;
490  if(rc != SION_SUCCESS) {
491  _sion_flags_destroy_store(&flags_store);
492  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: error in _sion_generic_get_and_distribute_info_from_file"));
493  }
494 
495  } else {
496  /* buddy will determine file layout later, but need local commgroup to optimize file operations */
497 
498  sion_gendata->lrank=*lrank;
499  sion_gendata->lsize=*lsize;
500 
501  if (filenumber == NULL) return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: No filenumber variable given"));
502  if (numfiles == NULL) return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: No numfiles variable given"));
503  if ( (*filenumber < 0 ) || (*filenumber >= *numfiles) ) {
504  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: file number %d not valid (0..%d)",*filenumber,*numfiles));
505  }
506  sion_gendata->filenumber=*filenumber;
507  sion_gendata->numfiles=*numfiles;
508 
509  }
510 
511 
512  } else {
513  _sion_flags_destroy_store(&flags_store);
514  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: unknown file mode"));
515  }
516 
517  /* generate local commgroup according to information from file (read) or parameter (write) */
518  rc=sion_apidesc->create_lcg_cb(&sion_gendata->comm_data_local,sion_gendata->comm_data_global,
519  sion_gendata->grank,sion_gendata->gsize,
520  sion_gendata->lrank,sion_gendata->lsize,
521  sion_gendata->filenumber,sion_gendata->numfiles);
522  if(rc) {
523  _sion_flags_destroy_store(&flags_store);
524  if(lprefix) free(lprefix);
525  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_paropen_generic: error in create_local_commgroup callback function"));
526  }
527 
528  /* set up parameters of call to generic open */
529  nfname=(sion_apidesc->get_multi_filename_cb?sion_apidesc->get_multi_filename_cb:_sion_get_multi_filename)(fname,sion_gendata->filenumber);
530  help_globalrank=sion_gendata->grank;
531 
532 
533  sid = _sion_newvcd(NULL,SION_FILEDESCRIPTOR);
534 
535  if(! (flags_store->mask&_SION_FMODE_BUDDY) ) {
536 
537  /* STANDARD */
538  DPRINTFP((1, "sion_generic_paropen", grank, "call parallel open of %d files (current name %s) in %s mode\n", sion_gendata->numfiles, nfname, file_mode));
539  rc=_sion_paropen_generic_one_file(sid, nfname, flags_store, lprefix, &sion_gendata->numfiles, &sion_gendata->filenumber, &lchunksize, &lfsblksize,
540  sion_gendata->lrank, sion_gendata->lsize, &help_globalrank,
541  _SION_INTERNAL_FLAG_NORMAL, fileptr, sion_gendata, NULL);
542  DPRINTFP((1, "sion_generic_paropen", sion_gendata->grank, "leave parallel open of %d files in %s mode #tasks=%d sid=%d globalrank=%d\n", sion_gendata->numfiles,
543  file_mode, sion_gendata->lsize, sid, sion_gendata->grank));
544 
545  } else {
546 
547  /* branch BUDDY Checkpointing */
548  DPRINTFP((1, "sion_generic_paropen", grank, "call parallel buddy open of %d files (current name %s) in %s mode\n", sion_gendata->numfiles, nfname, file_mode));
549  rc=_sion_paropen_generic_buddy(sid, fname, flags_store, lprefix, &sion_gendata->numfiles, &sion_gendata->filenumber, &lchunksize, &lfsblksize,
550  sion_gendata->lrank, sion_gendata->lsize, &help_globalrank,
551  fileptr, sion_gendata);
552  DPRINTFP((1, "sion_generic_paropen", sion_gendata->grank, "leave parallel buddy open of %d files in %s mode #tasks=%d sid=%d globalrank=%d rc=%d\n", sion_gendata->numfiles,
553  file_mode, sion_gendata->lsize, sid, sion_gendata->grank, rc));
554 
555  }
556 
557  _sion_flags_destroy_store(&flags_store);
558 
559  /* test sid and get internal data structure */
560  if ((rc<0) || (sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
561  DPRINTFP((1, "sion_generic_paropen", sion_gendata->grank, "invalid rc %d or sion_filedesc %d", rc, sid));
562  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen: invalid rc %d or sion_filedesc %d", rc, sid));
563  }
564 
565  /* store additional data */
566  sion_filedesc->dataptr=sion_gendata;
567 
568  if(newfname!=NULL) {
569  *newfname=nfname;
570  } else {
571  if(nfname) free(nfname);
572  }
573 
574  /* OUTPUT parameters */
575  *fsblksize = lfsblksize;
576  *chunksize = lchunksize;
577 
578  /* Bug? */
579 
580  DPRINTFP((64, "sion_generic_paropen", grank, "lprefix=%s (%x)\n", lprefix,lprefix));
581  if(lprefix) free(lprefix);
582 
583  DPRINTFP((1, "sion_generic_paropen", grank, "leave parallel open of file %s sid=%d\n", fname, sid));
584  /* */ DPRINTFTS(-1, "leave sion_generic_paropen");
585 
586  return (sid);
587 }
588 
589 
590 int sion_generic_parclose(int sid) {
591  ONLY_DEBUG(int grank);
592  int mapping_size=0, rc=SION_SUCCESS;
593  sion_int32 *mapping=NULL;
594  _sion_filedesc *sion_filedesc;
595  _sion_generic_gendata *sion_gendata;
596  _sion_generic_apidesc *sion_apidesc;
597 
598 
599  /* */ DPRINTFTS(-1, "enter sion_generic_parclose");
600 
601  if ( (sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
602  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_parclose: invalid sion_filedesc %d", sid));
603  }
604  sion_gendata=sion_filedesc->dataptr;
605  sion_apidesc=sion_gendata->apidesc;
606 
607  ONLY_DEBUG(grank=sion_gendata->grank);
608 
609  DPRINTFP((1, "sion_generic_parclose", grank, "enter parallel close of sid %d (%d file)\n", sid, sion_filedesc->nfiles));
610 
611  /* collect mapping information on rank 0 of first file, mapping=NULL for all others */
612  _sion_generic_collect_mapping(sion_filedesc,&mapping_size,&mapping);
613 
614  if(! sion_filedesc->usebuddy ) {
615  rc = _sion_parclose_generic( sid, sion_filedesc->rank, sion_filedesc->ntasks, mapping_size, mapping, _SION_INTERNAL_FLAG_NORMAL,
616  sion_gendata, NULL );
617  } else {
618  rc = _sion_parclose_generic_buddy( sid, sion_filedesc->rank, sion_filedesc->ntasks, mapping_size, mapping, sion_gendata );
619  }
620 
621 
622  if (sion_apidesc->free_lcg_cb && sion_gendata->comm_data_local) {
623  sion_apidesc->free_lcg_cb(sion_gendata->comm_data_local);
624  }
625  _SION_SAFE_FREE(mapping, NULL);
626 
627  _sion_freevcd(sid);
628 
629  sion_apidesc->barrier_cb(sion_gendata->comm_data_global);
630 
631  _SION_SAFE_FREE(sion_gendata, NULL);
632 
633  DPRINTFP((1, "sion_generic_parclose", grank, "leave parallel close of sid %d\n", sid));
634  /* */ DPRINTFTS(-1, "leave sion_generic_parclose");
635 
636  return (rc);
637 }
638 
639 
640 int sion_generic_paropen_mapped(int aid,
641  char *fname,
642  const char *file_mode,
643  int *numFiles,
644  void *gcommgroup,
645  int grank,
646  int gsize,
647  int *nlocaltasks,
648  int **globalranks,
649  sion_int64 **chunksizes,
650  int **mapping_filenrs,
651  int **mapping_lranks,
652  sion_int32 *fsblksize,
653  FILE **fileptr )
654 {
655  int rc, sid = SION_ID_UNDEF;
656  char *lprefix=NULL;
657  _sion_filedesc *sion_filedesc;
658  _sion_generic_apidesc *sion_apidesc;
659  _sion_generic_gendata *sion_gendata;
660  _sion_flags_store* flags_store = NULL;
661 
662  /* */ DPRINTFTS(grank, "enter sion_generic_paropen_mapped");
663  DPRINTFP((1, "sion_generic_paropen_mapped", grank, "enter generic parallel mapped open of file %s (global: %d of %d, nlocaltasks %d)\n",
664  fname, grank, gsize, *nlocaltasks));
665 
666  if ( (aid<0) || (_sion_vcdtype(aid) != SION_APIDESCRIPTOR) || !(sion_apidesc = _sion_vcdtovcon(aid))) {
667  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_register_scattervr_cb: invalid sion_apidesc %d", aid));
668  }
669 
670  if ((!sion_apidesc->create_lcg_cb) || (!sion_apidesc->free_lcg_cb) || (!sion_apidesc->barrier_cb) || (!sion_apidesc->bcastr_cb) ||
671  (!sion_apidesc->gatherr_cb) || (!sion_apidesc->gathervr_cb) || (!sion_apidesc->scatterr_cb) || (!sion_apidesc->scattervr_cb) ) {
672  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen_mapped: API %s not correctly initalized, aborting",sion_apidesc->name));
673  }
674 
675  /* check parameters */
676  if ( (grank < 0 ) || (grank >= gsize) ) {
677  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen_mapped: global rank %d not valid (0..%d)",grank,gsize));
678  }
679 
680  /* create data container */
681  sion_gendata=_sion_generic_alloc_gendata();
682  if(!sion_gendata) {
683  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen_mapped: problems to alloc gendata, aborting ...\n"));
684  }
685  _sion_generic_init_gendata(sion_gendata);
686 
687  sion_gendata->aid=aid;
688  sion_gendata->apidesc=sion_apidesc;
689  sion_gendata->comm_data_global=gcommgroup;
690  sion_gendata->grank=grank;
691  sion_gendata->gsize=gsize;
692  sion_gendata->lrank=-1;
693  sion_gendata->lsize=-1;
694  sion_gendata->filenumber=-1;
695  sion_gendata->numfiles=-1;
696  sion_gendata->comm_data_local=NULL;
697 
698  flags_store = _sion_parse_flags(file_mode);
699  if ( ! flags_store ) {
700  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen_mapped: could not parse file mode in %s, aborting ...\n", file_mode));
701  }
702 
703  if (flags_store->mask&_SION_FMODE_WRITE) {
704 
705 
706 
707 
708  lprefix = calloc(SION_FILENAME_LENGTH,1);
709  if (lprefix == NULL) {
710  _sion_flags_destroy_store(&flags_store);
711  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen_mapped: cannot allocate temporary memory of size %lu (lprefix), aborting ...\n", (unsigned long) SION_FILENAME_LENGTH));
712  }
713  strcpy(lprefix, fname);
714 
715  } else if (flags_store->mask&_SION_FMODE_READ) {
716  /* file mode READ */
717  /* nothing to do here so far, filenumbers and mapping will be determined by in generic routine */
718 
719  } else {
720  _sion_flags_destroy_store(&flags_store);
721  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen_mapped: unknown file mode"));
722  }
723 
724  sid = _sion_newvcd(NULL,SION_FILEDESCRIPTOR);
725 
726  DPRINTFP((1, "sion_generic_paropen_mapped", grank, "enter parallel mapped open in %s mode\n", file_mode));
727  rc=_sion_paropen_mapped_generic(sid, fname, flags_store->mask, lprefix,
728  numFiles, nlocaltasks, globalranks, chunksizes, mapping_filenrs, mapping_lranks,
729  fsblksize, grank, gsize, _SION_INTERNAL_FLAG_NORMAL,
730  fileptr, sion_gendata);
731  sion_gendata->numfiles=*numFiles;
732  DPRINTFP((1, "sion_generic_paropen_mapped", sion_gendata->grank, "leave parallel open of %d files in %s mode #tasks=%d sid=%d globalrank=%d\n", sion_gendata->numfiles,
733  file_mode, sion_gendata->lsize, sid, sion_gendata->grank));
734 
735  _sion_flags_destroy_store(&flags_store);
736 
737  /* test sid again and get internal data structure */
738  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
739  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_paropen_mapped: invalid sion_filedesc %d", sid));
740  }
741 
742  /* store additional data */
743  sion_filedesc->dataptr=sion_gendata;
744 
745  /* Bug? */
746 
747  DPRINTFP((1, "sion_generic_paropen_mapped", grank, "lprefix=%s (%x)\n", lprefix,lprefix));
748  if(lprefix) free(lprefix);
749 
750  DPRINTFP((1, "sion_generic_paropen_mapped", grank, "leave parallel open of file %s sid=%d\n", fname, sid));
751  /* */ DPRINTFTS(-1, "leave sion_generic_paropen_mapped");
752 
753  return (rc);
754 }
755 
756 
757 int sion_generic_parclose_mapped(int sid)
758 {
759  int grank, gsize, rc;
760  _sion_filedesc *sion_filedesc;
761  _sion_generic_gendata *sion_gendata;
762 
763  /* */ DPRINTFTS(-1, "enter sion_generic_parclose_mapped");
764  if ( (sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
765  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_parclose_mapped: invalid sion_filedesc %d", sid));
766  }
767  sion_gendata=sion_filedesc->dataptr;
768 
769  grank=sion_gendata->grank;
770  gsize=sion_gendata->gsize;
771 
772  DPRINTFP((1, "sion_generic_parclose_mapped", grank, "enter parallel close of sid %d\n", sid));
773 
774  DPRINTFP((1, "sion_generic_parclose_mapped", grank, "closing %d file(s)\n", sion_filedesc->nfiles));
775 
776  rc = _sion_parclose_mapped_generic(sid, grank, gsize,sion_gendata);
777 
778  _sion_freevcd(sid);
779 
780  _sion_generic_free_gendata(sion_gendata);
781 
782  DPRINTFP((1, "sion_generic_parclose_mapped", grank, "leave parallel close of sid %d\n", sid));
783  /* */ DPRINTFTS(-1, "leave sion_generic_parclose_mapped");
784 
785  return (rc);
786 }
787 
788 
789 int _sion_generic_get_and_distribute_info_from_file( _sion_generic_gendata *sion_gendata, const char *fname)
790 {
791  int sid = -1, ntasks = -1, nfiles = -1, t = 0;
792  int rc = SION_SUCCESS;
793  FILE *fileptr;
794  sion_int32 fsblksize;
795  int *tasksinfile;
796  int mapping_size = -1;
797  sion_int32 *mapping = NULL;
798  sion_int32 lpos[2];
799  _sion_generic_apidesc *sion_apidesc;
800 
801  sion_apidesc=sion_gendata->apidesc;
802 
803  if(sion_gendata->grank == 0) {
804  /* open and get mapping of sion file */
805  DPRINTFP((1, "_sion_generic_get_and_distribute_info_from_file", sion_gendata->grank, "before open\n"));
806  sid=_sion_open_read(fname,_SION_FMODE_READ|_SION_FMODE_ANSI,_SION_READ_MASTER_ONLY_OF_MULTI_FILES,
807  &ntasks,&nfiles,NULL,&fsblksize,NULL,&fileptr);
808  /* sid = sion_open(fname, "br", &ntasks, &nfiles, &chunksizes, &fsblksize, &globalranks, &fileptr); */
809  if(sid>=0) {
810  DPRINTFP((1, "_sion_generic_get_and_distribute_info_from_file", sion_gendata->grank, "after open\n"));
811  rc=sion_get_mapping(sid,&mapping_size,&mapping,&sion_gendata->numfiles);
812  DPRINTFP((1, "_sion_generic_get_and_distribute_info_from_file", sion_gendata->grank, "sion file %d files\n", sion_gendata->numfiles));
813  } else {
814  sion_gendata->numfiles=-1;
815  }
816  }
817 
818  /* each task has to know if more than file was used in sion file */
819  sion_apidesc->bcastr_cb(&sion_gendata->numfiles, sion_gendata->comm_data_global, _SION_INT32, 1, 0);
820 
821  if((sion_gendata->grank == 0) && (sion_gendata->numfiles>1)) {
822  if(mapping_size!=sion_gendata->gsize) {
823  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"_sion_generic_get_and_distribute_info_from_file: Incorrect sum of ntasks of files %d <> %d\n", mapping_size, sion_gendata->gsize));
824  }
825  }
826 
827  if(sion_gendata->numfiles<0) {
828  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"_sion_generic_get_and_distribute_info_from_file: could not get numfiles from sion file\n"));
829  }
830 
831  if(sion_gendata->numfiles>1) {
832  DPRINTFP((1, "_sion_generic_get_and_distribute_info_from_file", sion_gendata->grank, "before scatter\n"));
833  if(sion_gendata->grank==0) {
834  for(t=0;t<mapping_size;t++) {
835  DPRINTFP((1, "_sion_generic_get_and_distribute_info_from_file", sion_gendata->grank, " %d -> (%d,%d)\n",t,mapping[t*2],mapping[t*2+1]));
836  }
837  }
838 
839  sion_apidesc->scatterr_cb(mapping, lpos, sion_gendata->comm_data_global, _SION_INT32, 2, 0);
840  sion_gendata->filenumber=lpos[0];
841  sion_gendata->lrank =lpos[1];
842  DPRINTFP((1, "_sion_generic_get_and_distribute_info_from_file", sion_gendata->grank, "after scatter filenum+lrank (%d,%d)\n",sion_gendata->filenumber,sion_gendata->lrank));
843 
844  if(sion_gendata->grank==0) {
845  tasksinfile = (int *) malloc(sion_gendata->numfiles * sizeof(int));
846  if (tasksinfile == NULL) {
847  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"_sion_generic_get_and_distribute_info_from_file: Cannot allocate memory for tasksinfile counter vector"));
848  }
849  for(t=0;t<sion_gendata->numfiles;t++) tasksinfile[t]=0; /* init counter */
850  for(t=0;t<mapping_size;t++) tasksinfile[ mapping[t*2] ]++; /* count tasks in file */
851  for(t=0;t<mapping_size;t++) mapping[t*2+1]=tasksinfile[ mapping[t*2] ]; /* set 2nd value of mapping to lsize */
852  }
853  sion_apidesc->scatterr_cb(mapping, lpos, sion_gendata->comm_data_global, _SION_INT32, 2, 0);
854  sion_gendata->lsize =lpos[1];
855  DPRINTFP((1, "_sion_generic_get_and_distribute_info_from_file", sion_gendata->grank, "after scatter lsize (%d, %d of %d)\n",sion_gendata->filenumber, sion_gendata->lrank, sion_gendata->lsize));
856 
857  if(sion_gendata->grank==0) {
858  if(tasksinfile) free(tasksinfile);
859  }
860  /* WARNING: mapping file of sion file is now destroyed and should not be used until close */
861 
862  } else {
863  sion_gendata->filenumber=0;
864  sion_gendata->lrank = sion_gendata->grank;
865  sion_gendata->lsize = sion_gendata->gsize;
866  DPRINTFP((1, "_sion_generic_get_and_distribute_info_from_file", sion_gendata->grank, "only one file -> filenumber=%d lRank=%d\n",sion_gendata->filenumber,sion_gendata->lrank));
867  }
868 
869  if(sion_gendata->grank == 0) {
870  /* frees also mapping vector */
871  if (sid>=0) _sion_close_sid(sid);
872  }
873 
874  return(rc);
875 }
876 
877 int sion_generic_parreinit(int sid, sion_int64 chunksize ) {
878  int grank, gsize, rc;
879  _sion_filedesc *sion_filedesc;
880  _sion_generic_gendata *sion_gendata;
881 
882  if ( (sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
883  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN,"sion_generic_parreinit: invalid sion_filedesc %d", sid));
884  }
885  sion_gendata=sion_filedesc->dataptr;
886 
887  grank=sion_gendata->grank;
888  gsize=sion_gendata->gsize;
889 
890  DPRINTFP((1, "sion_generic_parreinit", grank, "enter parallel reinit of sid %d\n", sid));
891 
892  rc = _sion_parreinit_generic(sid, chunksize, grank, gsize, sion_gendata);
893 
894  DPRINTFP((1, "sion_generic_parreinit", grank, "leave parallel reinit of sid %d\n", sid));
895 
896  return(rc);
897 }
int sion_get_mapping(int sid, int *mapping_size, sion_int32 **mapping, int *numfiles)
Returns pointers to the internal field mapping.
Definition: sion_common.c:219
void * _sion_vcdtovcon(int sid)
Definition: sion_fd.c:53
int _sion_vcdtype(int sid)
Definition: sion_fd.c:58
int _sion_newvcd(void *data, int type)
Definition: sion_fd.c:43
int _sion_freevcd(int sid)
Definition: sion_fd.c:48
#define SION_APIDESCRIPTOR
Definition: sion_fd.h:18
#define SION_FILEDESCRIPTOR
Definition: sion_fd.h:17
_sion_flags_store * _sion_parse_flags(const char *flags)
Parse flags and return a flags store with key value pairs.
Definition: sion_flags.c:326
int sion_generic_paropen(int aid, const char *fname, const char *file_mode, sion_int64 *chunksize, sion_int32 *fsblksize, void *gcommgroup, int grank, int gsize, int *filenumber, int *numfiles, const int *lrank, const int *lsize, FILE **fileptr, char **newfname)
Open a sion file a generic interface.
Definition: sion_generic.c:351
int _sion_generic_free_apidesc(_sion_generic_apidesc *sion_apidesc)
free apidesc structure
int _sion_generic_free_gendata(_sion_generic_gendata *sion_gendata)
Free sion gendata description.
int _sion_generic_init_apidesc(_sion_generic_apidesc *sion_apidesc)
Initialize the sion api description.
int _sion_generic_update_api_level(_sion_generic_apidesc *sion_apidesc)
Update API level.
_sion_generic_gendata * _sion_generic_alloc_gendata(void)
Allocates memory for internal sion api data structure needed for each SION file.
int _sion_generic_init_gendata(_sion_generic_gendata *sion_gendata)
Initialize the sion file description.
_sion_generic_apidesc * _sion_generic_alloc_apidesc(void)
Allocates memory for internal sion api desc structure.
int _sion_parclose_generic(int sid, int rank, int ntasks, int mapping_size, sion_int32 *mapping, int flag, _sion_generic_gendata *sion_gendata, _sion_generic_buddy *buddy_data)
Internal function to close parallel opened SION file.
int _sion_generic_renumber_collmsa(_sion_generic_gendata *comm, _sion_flags_store *flags)
Splits a Communicator in numfiles different communicators.
int _sion_parreinit_generic(int sid, sion_int64 chunksize, int rank, int ntasks, _sion_generic_gendata *sion_gendata)
change chunksize for an already opened SION file (write)
int _sion_paropen_generic_one_file(int sid, char *fname, _sion_flags_store *flags_store, char *prefix, int *numFiles, int *filenumber, sion_int64 *chunksize, sion_int32 *fsblksize, int rank, int ntasks, int *globalrank, int flag, FILE **fileptr, _sion_generic_gendata *sion_gendata, _sion_generic_buddy *buddy_data)
Generic parallel open of one direct access file.
int _sion_paropen_mapped_generic(int sid, char *fname, sion_int64 file_mode_flags, char *prefix, int *numFiles, int *nlocaltasks, int **globalranks, sion_int64 **chunksizes, int **mapping_filenrs, int **mapping_lranks, sion_int32 *fsblksize, int rank, int ntasks, int flag, FILE **fileptr, _sion_generic_gendata *sion_gendata)
Generic parallel open of one direct access file. Mapping sion files to environment with less tasks.
char * _sion_get_multi_filename(const char *fname, int filenumber)
generates the multi filename
int _sion_open_read(const char *fname, sion_int64 file_mode_flags, int read_all, int *ntasks, int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize, int **globalranks, FILE **fileptr)
internal sion serial open function for reading on one or more files
Sion Time Stamp Header.
Sion File Descriptor Structure.
Definition: sion_filedesc.h:79