MISR Toolkit  1.5.1
H5FDpublic.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  * Programmer: Robb Matzke <matzke@llnl.gov>
16  * Monday, July 26, 1999
17  */
18 #ifndef _H5FDpublic_H
19 #define _H5FDpublic_H
20 
21 #include "H5public.h"
22 #include "H5Fpublic.h" /*for H5F_close_degree_t */
23 
24 #define H5_HAVE_VFL 1 /*define a convenient app feature test*/
25 #define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */
26 
27 /* Types of allocation requests: see H5Fpublic.h */
28 typedef enum H5F_mem_t H5FD_mem_t;
29 
30 /* Map "fractal heap" header blocks to 'ohdr' type file memory, since its
31  * a fair amount of work to add a new kind of file memory and they are similar
32  * enough to object headers and probably too minor to deserve their own type.
33  *
34  * Map "fractal heap" indirect blocks to 'ohdr' type file memory, since they
35  * are similar to fractal heap header blocks.
36  *
37  * Map "fractal heap" direct blocks to 'lheap' type file memory, since they
38  * will be replacing local heaps.
39  *
40  * Map "fractal heap" 'huge' objects to 'draw' type file memory, since they
41  * represent large objects that are directly stored in the file.
42  *
43  * -QAK
44  */
45 #define H5FD_MEM_FHEAP_HDR H5FD_MEM_OHDR
46 #define H5FD_MEM_FHEAP_IBLOCK H5FD_MEM_OHDR
47 #define H5FD_MEM_FHEAP_DBLOCK H5FD_MEM_LHEAP
48 #define H5FD_MEM_FHEAP_HUGE_OBJ H5FD_MEM_DRAW
49 
50 /* Map "free space" header blocks to 'ohdr' type file memory, since its
51  * a fair amount of work to add a new kind of file memory and they are similar
52  * enough to object headers and probably too minor to deserve their own type.
53  *
54  * Map "free space" serialized sections to 'lheap' type file memory, since they
55  * are similar enough to local heap info.
56  *
57  * -QAK
58  */
59 #define H5FD_MEM_FSPACE_HDR H5FD_MEM_OHDR
60 #define H5FD_MEM_FSPACE_SINFO H5FD_MEM_LHEAP
61 
62 /* Map "shared object header message" master table to 'ohdr' type file memory,
63  * since its a fair amount of work to add a new kind of file memory and they are
64  * similar enough to object headers and probably too minor to deserve their own
65  * type.
66  *
67  * Map "shared object header message" indices to 'btree' type file memory,
68  * since they are similar enough to B-tree nodes.
69  *
70  * -QAK
71  */
72 #define H5FD_MEM_SOHM_TABLE H5FD_MEM_OHDR
73 #define H5FD_MEM_SOHM_INDEX H5FD_MEM_BTREE
74 
75 /*
76  * A free-list map which maps all types of allocation requests to a single
77  * free list. This is useful for drivers that don't really care about
78  * keeping different requests segregated in the underlying file and which
79  * want to make most efficient reuse of freed memory. The use of the
80  * H5FD_MEM_SUPER free list is arbitrary.
81  */
82 #define H5FD_FLMAP_SINGLE { \
83  H5FD_MEM_SUPER, /*default*/ \
84  H5FD_MEM_SUPER, /*super*/ \
85  H5FD_MEM_SUPER, /*btree*/ \
86  H5FD_MEM_SUPER, /*draw*/ \
87  H5FD_MEM_SUPER, /*gheap*/ \
88  H5FD_MEM_SUPER, /*lheap*/ \
89  H5FD_MEM_SUPER /*ohdr*/ \
90 }
91 
92 /*
93  * A free-list map which segregates requests into `raw' or `meta' data
94  * pools.
95  */
96 #define H5FD_FLMAP_DICHOTOMY { \
97  H5FD_MEM_SUPER, /*default*/ \
98  H5FD_MEM_SUPER, /*super*/ \
99  H5FD_MEM_SUPER, /*btree*/ \
100  H5FD_MEM_DRAW, /*draw*/ \
101  H5FD_MEM_DRAW, /*gheap*/ \
102  H5FD_MEM_SUPER, /*lheap*/ \
103  H5FD_MEM_SUPER /*ohdr*/ \
104 }
105 
106 /*
107  * The default free list map which causes each request type to use it's own
108  * free-list.
109  */
110 #define H5FD_FLMAP_DEFAULT { \
111  H5FD_MEM_DEFAULT, /*default*/ \
112  H5FD_MEM_DEFAULT, /*super*/ \
113  H5FD_MEM_DEFAULT, /*btree*/ \
114  H5FD_MEM_DEFAULT, /*draw*/ \
115  H5FD_MEM_DEFAULT, /*gheap*/ \
116  H5FD_MEM_DEFAULT, /*lheap*/ \
117  H5FD_MEM_DEFAULT /*ohdr*/ \
118 }
119 
120 
121 /* Define VFL driver features that can be enabled on a per-driver basis */
122 /* These are returned with the 'query' function pointer in H5FD_class_t */
123  /*
124  * Defining the H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that
125  * the library will attempt to allocate a larger block for metadata and
126  * then sub-allocate each metadata request from that larger block.
127  */
128 #define H5FD_FEAT_AGGREGATE_METADATA 0x00000001
129  /*
130  * Defining the H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that
131  * the library will attempt to cache metadata as it is written to the file
132  * and build up a larger block of metadata to eventually pass to the VFL
133  * 'write' routine.
134  *
135  * Distinguish between updating the metadata accumulator on writes and
136  * reads. This is particularly (perhaps only, even) important for MPI-I/O
137  * where we guarantee that writes are collective, but reads may not be.
138  * If we were to allow the metadata accumulator to be written during a
139  * read operation, the application would hang.
140  */
141 #define H5FD_FEAT_ACCUMULATE_METADATA_WRITE 0x00000002
142 #define H5FD_FEAT_ACCUMULATE_METADATA_READ 0x00000004
143 #define H5FD_FEAT_ACCUMULATE_METADATA (H5FD_FEAT_ACCUMULATE_METADATA_WRITE|H5FD_FEAT_ACCUMULATE_METADATA_READ)
144  /*
145  * Defining the H5FD_FEAT_DATA_SIEVE for a VFL driver means that
146  * the library will attempt to cache raw data as it is read from/written to
147  * a file in a "data seive" buffer. See Rajeev Thakur's papers:
148  * http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz
149  * http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz
150  */
151 #define H5FD_FEAT_DATA_SIEVE 0x00000008
152  /*
153  * Defining the H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that
154  * the library will attempt to allocate a larger block for "small" raw data
155  * and then sub-allocate "small" raw data requests from that larger block.
156  */
157 #define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010
158  /*
159  * Defining the H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that
160  * the library will ignore the driver info that is encoded in the file
161  * for the VFL driver. (This will cause the driver info to be eliminated
162  * from the file when it is flushed/closed, if the file is opened R/W).
163  */
164 #define H5FD_FEAT_IGNORE_DRVRINFO 0x00000020
165  /*
166  * Defining the H5FD_FEAT_DIRTY_SBLK_LOAD for a VFL driver means that
167  * the library will mark the superblock dirty when the file is opened
168  * R/W. This will cause the driver info to be re-encoded when the file
169  * is flushed/closed.
170  */
171 #define H5FD_FEAT_DIRTY_SBLK_LOAD 0x00000040
172  /*
173  * Defining the H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that
174  * the handle for the VFD (returned with the 'get_handle' callback) is
175  * of type 'int' and is compatible with POSIX I/O calls.
176  */
177 #define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080
178  /*
179  * Defining the H5FD_FEAT_HAS_MPI for a VFL driver means that
180  * the driver makes use of MPI communication and code may retrieve
181  * communicator/rank information from it
182  */
183 #define H5FD_FEAT_HAS_MPI 0x00000100
184  /*
185  * Defining the H5FD_FEAT_ALLOCATE_EARLY for a VFL driver will force
186  * the library to use the H5D_ALLOC_TIME_EARLY on dataset create
187  * instead of the default H5D_ALLOC_TIME_LATE
188  */
189 #define H5FD_FEAT_ALLOCATE_EARLY 0x00000200
190  /*
191  * Defining the H5FD_FEAT_ALLOW_FILE_IMAGE for a VFL driver means that
192  * the driver is able to use a file image in the fapl as the initial
193  * contents of a file.
194  */
195 #define H5FD_FEAT_ALLOW_FILE_IMAGE 0x00000400
196  /*
197  * Defining the H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS for a VFL driver
198  * means that the driver is able to use callbacks to make a copy of the
199  * image to store in memory.
200  */
201 #define H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS 0x00000800
202 
203 /* Forward declaration */
204 typedef struct H5FD_t H5FD_t;
205 
206 /* Class information for each file driver */
207 typedef struct H5FD_class_t {
208  const char *name;
211  hsize_t (*sb_size)(H5FD_t *file);
212  herr_t (*sb_encode)(H5FD_t *file, char *name/*out*/,
213  unsigned char *p/*out*/);
214  herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p);
215  size_t fapl_size;
216  void * (*fapl_get)(H5FD_t *file);
217  void * (*fapl_copy)(const void *fapl);
218  herr_t (*fapl_free)(void *fapl);
219  size_t dxpl_size;
220  void * (*dxpl_copy)(const void *dxpl);
221  herr_t (*dxpl_free)(void *dxpl);
222  H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl,
223  haddr_t maxaddr);
224  herr_t (*close)(H5FD_t *file);
225  int (*cmp)(const H5FD_t *f1, const H5FD_t *f2);
226  herr_t (*query)(const H5FD_t *f1, unsigned long *flags);
227  herr_t (*get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map);
229  herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
230  haddr_t addr, hsize_t size);
233  haddr_t (*get_eof)(const H5FD_t *file);
234  herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void**file_handle);
236  haddr_t addr, size_t size, void *buffer);
238  haddr_t addr, size_t size, const void *buffer);
239  herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, unsigned closing);
240  herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
241  herr_t (*lock)(H5FD_t *file, unsigned char *oid, unsigned lock_type, hbool_t last);
242  herr_t (*unlock)(H5FD_t *file, unsigned char *oid, hbool_t last);
244 } H5FD_class_t;
245 
246 /* A free list is a singly-linked list of address/size pairs. */
247 typedef struct H5FD_free_t {
250  struct H5FD_free_t *next;
251 } H5FD_free_t;
252 
253 /*
254  * The main datatype for each driver. Public fields common to all drivers
255  * are declared here and the driver appends private fields in memory.
256  */
257 struct H5FD_t {
258  hid_t driver_id; /*driver ID for this file */
259  const H5FD_class_t *cls; /*constant class info */
260  unsigned long fileno; /* File 'serial' number */
261  unsigned long feature_flags; /* VFL Driver feature Flags */
262  haddr_t maxaddr; /* For this file, overrides class */
263  haddr_t base_addr; /* Base address for HDF5 data w/in file */
264 
265  /* Space allocation management fields */
266  hsize_t threshold; /* Threshold for alignment */
267  hsize_t alignment; /* Allocation alignment */
268 };
269 
270 /* Define enum for the source of file image callbacks */
271 typedef enum {
281 
282 /* Define structure to hold file image callbacks */
283 typedef struct {
284  void *(*image_malloc)(size_t size, H5FD_file_image_op_t file_image_op,
285  void *udata);
286  void *(*image_memcpy)(void *dest, const void *src, size_t size,
287  H5FD_file_image_op_t file_image_op, void *udata);
288  void *(*image_realloc)(void *ptr, size_t size,
289  H5FD_file_image_op_t file_image_op, void *udata);
290  herr_t (*image_free)(void *ptr, H5FD_file_image_op_t file_image_op,
291  void *udata);
292  void *(*udata_copy)(void *udata);
293  herr_t (*udata_free)(void *udata);
294  void *udata;
296 
297 #ifdef __cplusplus
298 extern "C" {
299 #endif
300 
301 /* Function prototypes */
303 H5_DLL herr_t H5FDunregister(hid_t driver_id);
304 H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id,
305  haddr_t maxaddr);
307 H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2);
308 H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags);
310 H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
311  haddr_t addr, hsize_t size);
315 H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle);
316 H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
317  haddr_t addr, size_t size, void *buf/*out*/);
318 H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
319  haddr_t addr, size_t size, const void *buf);
320 H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing);
321 H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
322 
323 #ifdef __cplusplus
324 }
325 #endif
326 #endif
327 
herr_t(* query)(const H5FD_t *f1, unsigned long *flags)
Definition: H5FDpublic.h:226
herr_t(* unlock)(H5FD_t *file, unsigned char *oid, hbool_t last)
Definition: H5FDpublic.h:242
H5_DLL H5FD_t * H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
herr_t(* close)(H5FD_t *file)
Definition: H5FDpublic.h:224
unsigned int hbool_t
Definition: H5public.h:142
H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type)
herr_t(* dxpl_free)(void *dxpl)
Definition: H5FDpublic.h:221
herr_t(* write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, const void *buffer)
Definition: H5FDpublic.h:237
H5_DLL herr_t H5FDunregister(hid_t driver_id)
hsize_t alignment
Definition: H5FDpublic.h:267
H5FD_file_image_op_t
Definition: H5FDpublic.h:271
haddr_t maxaddr
Definition: H5FDpublic.h:209
#define H5_DLL
Definition: H5api_adpt.h:256
herr_t(* sb_encode)(H5FD_t *file, char *name, unsigned char *p)
Definition: H5FDpublic.h:212
herr_t(* read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, void *buffer)
Definition: H5FDpublic.h:235
int herr_t
Definition: H5public.h:124
unsigned long long hsize_t
Definition: H5public.h:169
struct H5FD_free_t * next
Definition: H5FDpublic.h:250
haddr_t base_addr
Definition: H5FDpublic.h:263
herr_t(* set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr)
Definition: H5FDpublic.h:232
HDFFCLIBAPI intf intf intf intf void * buffer
H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags)
hid_t driver_id
Definition: H5FDpublic.h:258
struct H5FD_class_t H5FD_class_t
herr_t(* flush)(H5FD_t *file, hid_t dxpl_id, unsigned closing)
Definition: H5FDpublic.h:239
H5FD_mem_t fl_map[H5FD_MEM_NTYPES]
Definition: H5FDpublic.h:243
H5_DLL herr_t H5FDclose(H5FD_t *file)
herr_t(* sb_decode)(H5FD_t *f, const char *name, const unsigned char *p)
Definition: H5FDpublic.h:214
uint64_t haddr_t
Definition: H5public.h:182
herr_t(* fapl_free)(void *fapl)
Definition: H5FDpublic.h:218
H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2)
haddr_t(* get_eoa)(const H5FD_t *file, H5FD_mem_t type)
Definition: H5FDpublic.h:231
int(* cmp)(const H5FD_t *f1, const H5FD_t *f2)
Definition: H5FDpublic.h:225
hsize_t size
Definition: H5FDpublic.h:249
herr_t(* get_handle)(H5FD_t *file, hid_t fapl, void **file_handle)
Definition: H5FDpublic.h:234
haddr_t addr
Definition: H5FDpublic.h:248
struct H5FD_free_t H5FD_free_t
haddr_t(* get_eof)(const H5FD_t *file)
Definition: H5FDpublic.h:233
HDFFCLIBAPI intf * size
int hid_t
Definition: H5Ipublic.h:54
const H5FD_class_t * cls
Definition: H5FDpublic.h:259
enum H5F_mem_t H5FD_mem_t
Definition: H5FDpublic.h:28
H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing)
herr_t(* free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size)
Definition: H5FDpublic.h:229
haddr_t maxaddr
Definition: H5FDpublic.h:262
H5F_mem_t
Definition: H5Fpublic.h:120
const char * name
Definition: H5FDpublic.h:208
herr_t(* get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map)
Definition: H5FDpublic.h:227
H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf)
H5_DLL hid_t H5FDregister(const H5FD_class_t *cls)
unsigned long fileno
Definition: H5FDpublic.h:260
hsize_t threshold
Definition: H5FDpublic.h:266
unsigned long feature_flags
Definition: H5FDpublic.h:261
HDFFCLIBAPI intf intf intf * type
size_t dxpl_size
Definition: H5FDpublic.h:219
HDFFCLIBAPI intf intf * flags
H5F_close_degree_t fc_degree
Definition: H5FDpublic.h:210
H5F_close_degree_t
Definition: H5Fpublic.h:95
herr_t(* lock)(H5FD_t *file, unsigned char *oid, unsigned lock_type, hbool_t last)
Definition: H5FDpublic.h:241
herr_t(* truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing)
Definition: H5FDpublic.h:240
size_t fapl_size
Definition: H5FDpublic.h:215
hsize_t(* sb_size)(H5FD_t *file)
Definition: H5FDpublic.h:211
H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf)
H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa)
HDFFCLIBAPI intf ptr[][4]
H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size)
H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle)
H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing)
H5_DLL haddr_t H5FDget_eof(H5FD_t *file)
HDFFCLIBAPI intf * buf
haddr_t(* alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size)
Definition: H5FDpublic.h:228
H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size)

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:52