-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathadios_bp_v1.h
370 lines (303 loc) · 12.1 KB
/
adios_bp_v1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
/*
* ADIOS is freely available under the terms of the BSD license described
* in the COPYING file in the top level directory of this source distribution.
*
* Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved.
*/
#ifndef ADIOS_BP_V1_H
#define ADIOS_BP_V1_H
#include "stdint.h"
#include "unistd.h"
#include "public/adios_types.h"
#include "core/adios_transport_hooks.h"
#include "core/qhashtbl.h"
#include "public/adios_version.h" // ADIOS_VERSION_BP_FORMAT
#define ADIOS_VERSION_NUM_MASK 0x000000FF
#define ADIOS_VERSION_HAVE_SUBFILE 0x00000100
#define ADIOS_VERSION_HAVE_TIME_INDEX_CHARACTERISTIC 0x00000200
enum ADIOS_CHARACTERISTICS
{
adios_characteristic_value = 0
,adios_characteristic_min = 1 // This is no longer used. Used to read in older bp file format
,adios_characteristic_max = 2 // This is no longer used. Used to read in older bp file format
,adios_characteristic_offset = 3
,adios_characteristic_dimensions = 4
,adios_characteristic_var_id = 5
,adios_characteristic_payload_offset = 6
,adios_characteristic_file_index = 7
,adios_characteristic_time_index = 8
,adios_characteristic_bitmap = 9
,adios_characteristic_stat = 10
,adios_characteristic_transform_type = 11
};
#ifndef ADIOS_STAT_LENGTH
#define ADIOS_STAT_LENGTH 7
#endif
// NCSU - Adding statistics
enum ADIOS_STAT
{
adios_statistic_min = 0
,adios_statistic_max = 1
,adios_statistic_cnt = 2
,adios_statistic_sum = 3
,adios_statistic_sum_square = 4
,adios_statistic_hist = 5
,adios_statistic_finite = 6
};
struct adios_bp_buffer_struct_v1
{
int f; // the file handle
uint64_t file_size;
uint32_t version;
char * allocated_buff_ptr; // initial alloc for aligning on 8-byte boundary
char * buff;
uint64_t length;
uint64_t offset; // buffer_offset
enum ADIOS_FLAG change_endianness;
off_t file_offset;
uint64_t end_of_pgs; // where the last process group ends
uint64_t pg_index_offset; // process groups index starts
uint64_t pg_size; // process groups index size
uint64_t vars_index_offset; // vars index start
uint64_t vars_size; // vars index size
uint64_t attrs_index_offset; // attributes index start
uint64_t attrs_size; // attributes index size
uint64_t read_pg_offset;
uint64_t read_pg_size;
};
struct adios_index_process_group_struct_v1
{
char * group_name;
enum ADIOS_FLAG adios_host_language_fortran;
uint32_t process_id;
char * time_index_name;
uint32_t time_index;
uint64_t offset_in_file;
int is_time_aggregated;
struct adios_index_process_group_struct_v1 * next;
};
struct adios_index_characteristic_dims_struct_v1
{
uint8_t count;
uint64_t * dims; // each 3 uint64_t represents one dimension (l, g, o)
};
// NCSU - Generic data for all statistics
struct adios_index_characteristics_stat_struct
{
void * data;
};
// NCSU - Structure for histogram
struct adios_index_characteristics_hist_struct
{
double min; //minimum value of histogram ** for when we use complex variables
double max; //maximum value of histogram
uint32_t num_breaks; //number of break points for the histogram
uint32_t * frequencies; //array of frequencies for the histogram
double * breaks; //breaks array for the histogram, output this to gnuplot
};
struct adios_index_characteristic_transform_struct {
uint8_t transform_type;
enum ADIOS_DATATYPES pre_transform_type;
struct adios_index_characteristic_dims_struct_v1 pre_transform_dimensions;
uint16_t transform_metadata_len;
void *transform_metadata;
};
struct adios_index_characteristic_struct_v1
{
uint64_t offset; // beginning of the var or attr entry
struct adios_index_characteristic_dims_struct_v1 dims;
uint32_t var_id;
void * value;
uint64_t payload_offset; // beginning of the var or attr payload
uint32_t file_index; // subfile index
uint32_t time_index;
uint32_t bitmap;
struct adios_index_characteristics_stat_struct ** stats;
// NCSU ALACRITY-ADIOS - Adding transform-related fields
/*
uint8_t transform_type;
enum ADIOS_DATATYPES pre_transform_type;
struct adios_index_characteristic_dims_struct_v1 pre_transform_dimensions;
uint16_t transform_metadata_len;
void *transform_metadata;
*/
struct adios_index_characteristic_transform_struct transform;
};
struct adios_index_var_struct_v1
{
uint32_t id;
char * group_name;
char * var_name;
char * var_path;
enum ADIOS_DATATYPES type;
uint64_t characteristics_count;
uint64_t characteristics_allocated;
struct adios_index_characteristic_struct_v1 * characteristics;
struct adios_index_var_struct_v1 * next;
};
struct adios_index_attribute_struct_v1
{
uint32_t id;
char * group_name;
char * attr_name;
char * attr_path;
enum ADIOS_DATATYPES type;
int nelems; // number of elements of type 'type'
uint64_t characteristics_count;
uint64_t characteristics_allocated;
struct adios_index_characteristic_struct_v1 * characteristics;
struct adios_index_attribute_struct_v1 * next;
};
/* Struct to hold the 3 main pointers of the index:
* group, variable and attribute indices
*/
struct adios_index_struct_v1
{
struct adios_index_process_group_struct_v1 * pg_root;
struct adios_index_process_group_struct_v1 * pg_tail;
struct adios_index_var_struct_v1 * vars_root;
struct adios_index_var_struct_v1 * vars_tail;
struct adios_index_attribute_struct_v1 * attrs_root;
struct adios_index_attribute_struct_v1 * attrs_tail;
qhashtbl_t *hashtbl_vars; // to speed up merging lists
qhashtbl_t *hashtbl_attrs; // to speed up merging lists
};
struct adios_method_info_struct_v1
{
enum ADIOS_IO_METHOD id;
char * parameters;
struct adios_method_info_struct_v1 * next;
};
struct adios_dimension_item_struct_v1
{
uint64_t rank;
uint32_t var_id;
enum ADIOS_FLAG is_time_index;
};
struct adios_dimension_struct_v1
{
struct adios_dimension_item_struct_v1 dimension;
struct adios_dimension_item_struct_v1 global_dimension;
struct adios_dimension_item_struct_v1 local_offset;
struct adios_dimension_struct_v1 * next;
};
struct adios_process_group_header_struct_v1
{
enum ADIOS_FLAG host_language_fortran;
char * name;
uint32_t coord_var_id;
char * time_index_name;
uint32_t time_index;
uint8_t methods_count;
struct adios_method_info_struct_v1 * methods;
};
struct adios_vars_header_struct_v1
{
uint32_t count;
uint64_t length;
};
struct adios_attributes_header_struct_v1
{
uint32_t count;
uint64_t length;
};
struct adios_var_header_struct_v1
{
uint32_t id;
char * name;
char * path;
enum ADIOS_DATATYPES type;
enum ADIOS_FLAG is_dim;
struct adios_dimension_struct_v1 * dims;
struct adios_index_characteristic_struct_v1 characteristics;
uint64_t payload_size;
};
struct adios_var_payload_struct_v1
{
void * payload;
};
struct adios_attribute_struct_v1
{
uint32_t id;
char * name;
char * path;
enum ADIOS_FLAG is_var;
uint32_t var_id;
enum ADIOS_DATATYPES type;
int nelems; // number of elements of type 'type'
uint32_t length; // length of attribute value = nelems*sizeof(type)
// does not include '\0' in a string attribute (so memory
// used by a string attribute is length+1)
void * value;
};
void adios_shared_buffer_free (struct adios_bp_buffer_struct_v1 * b);
void adios_buffer_struct_init (struct adios_bp_buffer_struct_v1 * b);
void adios_buffer_struct_clear (struct adios_bp_buffer_struct_v1 * b);
void * adios_dupe_data_scalar (enum ADIOS_DATATYPES type, void * in);
// buff must be 4 bytes
int adios_parse_version (struct adios_bp_buffer_struct_v1 * b
,uint32_t * version
);
// buff must be 16 bytes
int adios_parse_index_offsets_v1 (struct adios_bp_buffer_struct_v1 * b);
int adios_parse_process_group_index_v1 (struct adios_bp_buffer_struct_v1 * b,
struct adios_index_process_group_struct_v1 ** pg_root,
struct adios_index_process_group_struct_v1 ** pg_tail
);
int adios_parse_vars_index_v1 (struct adios_bp_buffer_struct_v1 * b
,struct adios_index_var_struct_v1 ** vars_root
,qhashtbl_t *hashtbl_vars
,struct adios_index_var_struct_v1 ** vars_tail
);
int adios_parse_attributes_index_v1 (struct adios_bp_buffer_struct_v1 * b
,struct adios_index_attribute_struct_v1 ** attrs_root
);
int adios_parse_process_group_header_v1 (struct adios_bp_buffer_struct_v1 * b
,struct adios_process_group_header_struct_v1 * pg_header
);
int adios_parse_vars_header_v1 (struct adios_bp_buffer_struct_v1 * b
,struct adios_vars_header_struct_v1 * vars_header
);
int adios_parse_var_data_header_v1 (struct adios_bp_buffer_struct_v1 * b
,struct adios_var_header_struct_v1 * var_header
);
int adios_parse_var_data_payload_v1 (struct adios_bp_buffer_struct_v1 * b
,struct adios_var_header_struct_v1 * var_header
,struct adios_var_payload_struct_v1 * var_payload
,uint64_t payload_size
);
int adios_parse_attributes_header_v1 (struct adios_bp_buffer_struct_v1 * b
,struct adios_attributes_header_struct_v1 * attrs_header
);
int adios_parse_attribute_v1 (struct adios_bp_buffer_struct_v1 * b
,struct adios_attribute_struct_v1 * attribute
);
int adios_clear_process_group_header_v1 (
struct adios_process_group_header_struct_v1 * pg_header);
int adios_clear_var_header_v1 (struct adios_var_header_struct_v1 * var_header);
int adios_clear_attribute_v1 (struct adios_attribute_struct_v1 * attribute);
// ****************************************************************************
// functions from adios_posix.c used for file reading
void adios_init_buffer_read_version (struct adios_bp_buffer_struct_v1 * b);
void adios_posix_read_version (struct adios_bp_buffer_struct_v1 * b);
void adios_init_buffer_read_index_offsets ( struct adios_bp_buffer_struct_v1 * b);
void adios_posix_read_index_offsets (struct adios_bp_buffer_struct_v1 * b);
void adios_init_buffer_read_process_group_index ( struct adios_bp_buffer_struct_v1 * b);
void adios_posix_read_process_group_index (struct adios_bp_buffer_struct_v1 * b);
void adios_init_buffer_read_process_group (struct adios_bp_buffer_struct_v1 * b);
void adios_init_buffer_read_vars_index (struct adios_bp_buffer_struct_v1 * b);
void adios_posix_read_vars_index (struct adios_bp_buffer_struct_v1 * b);
void adios_init_buffer_read_attributes_index
(struct adios_bp_buffer_struct_v1 * b);
void adios_posix_read_attributes_index (struct adios_bp_buffer_struct_v1 * b);
void adios_init_buffer_read_procss_group (struct adios_bp_buffer_struct_v1 * b);
uint64_t adios_posix_read_process_group (struct adios_bp_buffer_struct_v1 * b);
int adios_posix_open_read_internal (const char * filename
,const char * base_path
,struct adios_bp_buffer_struct_v1 * b
);
void adios_posix_close_internal (struct adios_bp_buffer_struct_v1 * b);
// ADIOS statistics related functions
uint64_t adios_get_stat_size (void * data, enum ADIOS_DATATYPES type, enum ADIOS_STAT stat_id);
uint8_t adios_get_stat_set_count (enum ADIOS_DATATYPES type);
#endif