SIONlib  1.7.1
Scalable I/O library for parallel access to task-local files
sion_generic_apidesc.c
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2016 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
9 
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include <stdarg.h>
17 #include <string.h>
18 
19 #include "sion.h"
20 #include "sion_internal.h"
21 #include "sion_debug.h"
22 #include "sion_error_handler.h"
23 #include "sion_generic_apidesc.h"
24 
30  _sion_generic_apidesc *sion_apidesc;
31 
32  sion_apidesc = (_sion_generic_apidesc *) malloc(sizeof(_sion_generic_apidesc));
33  if (sion_apidesc == NULL) {
34  _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"cannot allocate apidescriptor structure of size %lu (sion_apidesc), aborting ...\n", (unsigned long) sizeof(_sion_generic_apidesc));
35  return(NULL);
36  }
37 
38  return(sion_apidesc);
39 }
40 
48 {
49 
50  int rc = SION_SUCCESS;
51 
52  if (sion_apidesc == NULL) {
53  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"_sion_generic_init_apidesc: cannot initalized, data structure is not allocated, aborting ...\n"));
54  }
55  sion_apidesc->aid = -1;
56  sion_apidesc->name = NULL;
57  sion_apidesc->level=SION_GENERIC_API_LEVEL_NONE;
58  sion_apidesc->create_lcg_cb = NULL;
59  sion_apidesc->free_lcg_cb = NULL;
60  sion_apidesc->barrier_cb = NULL;
61  sion_apidesc->bcastr_cb = NULL;
62  sion_apidesc->gatherr_cb = NULL;
63  sion_apidesc->gathervr_cb = NULL;
64  sion_apidesc->scatterr_cb = NULL;
65  sion_apidesc->scattervr_cb = NULL;
66  sion_apidesc->gather_execute_cb = NULL;
67  sion_apidesc->execute_scatter_cb = NULL;
68  sion_apidesc->get_multi_filename_cb = NULL;
69  sion_apidesc->get_capability_cb = NULL;
70  return(rc);
71 
72 }
73 
81 {
82 
83  int rc = SION_SUCCESS;
84 
85  if (sion_apidesc == NULL) {
86  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"_sion_generic_free_apidesc: cannot free, data structure is not allocated, aborting ...\n"));
87  }
88 
89  if (sion_apidesc->name) free(sion_apidesc->name);
90 
91  free(sion_apidesc);
92 
93  return(rc);
94 
95 }
96 
97 
103  _sion_generic_gendata *sion_gendata;
104 
105  sion_gendata = (_sion_generic_gendata *) malloc(sizeof(_sion_generic_gendata));
106  if (sion_gendata == NULL) {
107  _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"cannot allocate gendata structure of size %lu (sion_gendata), aborting ...\n", (unsigned long) sizeof(_sion_generic_gendata));
108  return(NULL);
109  }
110 
111  return(sion_gendata);
112 }
113 
121 {
122 
123  int rc = SION_SUCCESS;
124 
125  if (sion_gendata == NULL) {
126  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"_sion_generic_init_gendata: cannot initalized, data structure is not allocated, aborting ...\n"));
127  }
128  sion_gendata->apidesc = NULL;
129  sion_gendata->aid = -1;
130  sion_gendata->comm_data_global = NULL;
131  sion_gendata->comm_data_local = NULL;
132 
133  return(rc);
134 
135 }
136 
144 {
145 
146  int rc = SION_SUCCESS;
147 
148  if (sion_gendata == NULL) {
149  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"_sion_generic_free_gendata: cannot free, data structure is not allocated, aborting ...\n"));
150  }
151  free(sion_gendata);
152 
153  return(rc);
154 
155 }
156 
157 
165 {
166 
167  int rc = SION_SUCCESS;
168 
169  if (sion_apidesc == NULL) {
170  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"_sion_generic_update_api_level: cannot update data structure, it is not allocated, aborting ...\n"));
171  }
172 
173  if (
174  (sion_apidesc->create_lcg_cb) &&
175  (sion_apidesc->free_lcg_cb) &&
176  (sion_apidesc->barrier_cb) &&
177  (sion_apidesc->bcastr_cb) &&
178  (sion_apidesc->gatherr_cb) &&
179  (sion_apidesc->gathervr_cb) &&
180  (sion_apidesc->scatterr_cb) &&
181  (sion_apidesc->scattervr_cb)
182  ) {
183  sion_apidesc->level=SION_GENERIC_API_LEVEL_STD;
184 
185  if (
186  (sion_apidesc->gather_execute_cb) &&
187  (sion_apidesc->execute_scatter_cb) &&
188  (sion_apidesc->get_capability_cb)
189  ) {
190  sion_apidesc->level=SION_GENERIC_API_LEVEL_FULL;
191  }
192  }
193 
194  return(rc);
195 
196 }
_sion_generic_gendata * _sion_generic_alloc_gendata()
Allocates memory for internal sion api data structure needed for each SION file.
int _sion_generic_free_apidesc(_sion_generic_apidesc *sion_apidesc)
free apidesc structure
_sion_generic_apidesc * _sion_generic_alloc_apidesc()
Allocates memory for internal sion api desc structure.
int _sion_generic_update_api_level(_sion_generic_apidesc *sion_apidesc)
Update API level.
int _sion_generic_init_apidesc(_sion_generic_apidesc *sion_apidesc)
Initialize the sion api description.
int _sion_generic_free_gendata(_sion_generic_gendata *sion_gendata)
Free sion gendata description.
int _sion_generic_init_gendata(_sion_generic_gendata *sion_gendata)
Initialize the sion file description.