H5Dpkg.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 /*
00017  * Programmer:  Quincey Koziol <koziol@ncsa.uiuc.edu>
00018  *              Monday, April 14, 2003
00019  *
00020  * Purpose:     This file contains declarations which are visible only within
00021  *              the H5D package.  Source files outside the H5D package should
00022  *              include H5Dprivate.h instead.
00023  */
00024 #ifndef H5D_PACKAGE
00025 #error "Do not include this file outside the H5D package!"
00026 #endif
00027 
00028 #ifndef _H5Dpkg_H
00029 #define _H5Dpkg_H
00030 
00031 /* Get package's private header */
00032 #include "H5Dprivate.h"
00033 
00034 /* Other private headers needed by this file */
00035 #include "H5Gprivate.h"         /* Groups                               */
00036 #include "H5Oprivate.h"         /* Object headers                       */
00037 #include "H5Sprivate.h"         /* Dataspaces                           */
00038 #include "H5SLprivate.h"        /* Skip lists                           */
00039 #include "H5Tprivate.h"         /* Datatypes                            */
00040 
00041 /**************************/
00042 /* Package Private Macros */
00043 /**************************/
00044 
00045 /* The number of reserved IDs in dataset ID group */
00046 #define H5D_RESERVED_ATOMS  0
00047 
00048 /* Set the minimum object header size to create objects with */
00049 #define H5D_MINHDR_SIZE 256
00050 
00051 /* [Simple] Macro to construct a H5D_io_info_t from it's components */
00052 #define H5D_BUILD_IO_INFO_WRT(io_info, ds, dxpl_c, dxpl_i, str, buf)    \
00053     (io_info)->dset = ds;                                               \
00054     (io_info)->dxpl_cache = dxpl_c;                                     \
00055     (io_info)->dxpl_id = dxpl_i;                                        \
00056     (io_info)->store = str;                                             \
00057     (io_info)->op_type = H5D_IO_OP_WRITE;                               \
00058     (io_info)->u.wbuf = buf
00059 #define H5D_BUILD_IO_INFO_RD(io_info, ds, dxpl_c, dxpl_i, str, buf)     \
00060     (io_info)->dset = ds;                                               \
00061     (io_info)->dxpl_cache = dxpl_c;                                     \
00062     (io_info)->dxpl_id = dxpl_i;                                        \
00063     (io_info)->store = str;                                             \
00064     (io_info)->op_type = H5D_IO_OP_READ;                                \
00065     (io_info)->u.rbuf = buf
00066 
00067 #define H5D_CHUNK_HASH(D, ADDR) H5F_addr_hash(ADDR, (D)->cache.chunk.nslots)
00068 
00069 
00070 /****************************/
00071 /* Package Private Typedefs */
00072 /****************************/
00073 
00074 /* Typedef for datatype information for raw data I/O operation */
00075 typedef struct H5D_type_info_t {
00076     /* Initial values */
00077     const H5T_t *mem_type;              /* Pointer to memory datatype */
00078     const H5T_t *dset_type;             /* Pointer to dataset datatype */
00079     H5T_path_t *tpath;                  /* Datatype conversion path */
00080     hid_t src_type_id;                  /* Source datatype ID */
00081     hid_t dst_type_id;                  /* Destination datatype ID */
00082 
00083     /* Computed/derived values */
00084     size_t src_type_size;               /* Size of source type  */
00085     size_t dst_type_size;               /* Size of destination type*/
00086     size_t max_type_size;               /* Size of largest source/destination type */
00087     hbool_t is_conv_noop;               /* Whether the type conversion is a NOOP */
00088     hbool_t is_xform_noop;              /* Whether the data transform is a NOOP */
00089     const H5T_subset_info_t *cmpd_subset;   /* Info related to the compound subset conversion functions */
00090     H5T_bkg_t need_bkg;                 /* Type of background buf needed */
00091     size_t request_nelmts;              /* Requested strip mine */
00092     uint8_t *tconv_buf;                 /* Datatype conv buffer */
00093     hbool_t tconv_buf_allocated;        /* Whether the type conversion buffer was allocated */
00094     uint8_t *bkg_buf;                   /* Background buffer    */
00095     hbool_t bkg_buf_allocated;          /* Whether the background buffer was allocated */
00096 } H5D_type_info_t;
00097 
00098 /* Forward declaration of structs used below */
00099 struct H5D_io_info_t;
00100 struct H5D_chunk_map_t;
00101 
00102 /* Function pointers for I/O on particular types of dataset layouts */
00103 typedef herr_t (*H5D_layout_new_func_t)(H5F_t *f, hid_t dapl_id, hid_t dxpl_id,
00104     H5D_t *dset, const H5P_genplist_t *dc_plist);
00105 typedef hbool_t (*H5D_layout_is_space_alloc_func_t)(const H5O_layout_t *layout);
00106 typedef herr_t (*H5D_layout_io_init_func_t)(const struct H5D_io_info_t *io_info,
00107     const H5D_type_info_t *type_info,
00108     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
00109     struct H5D_chunk_map_t *cm);
00110 typedef herr_t (*H5D_layout_read_func_t)(struct H5D_io_info_t *io_info,
00111     const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space,
00112     const H5S_t *mem_space, struct H5D_chunk_map_t *fm);
00113 typedef herr_t (*H5D_layout_write_func_t)(struct H5D_io_info_t *io_info,
00114     const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space,
00115     const H5S_t *mem_space, struct H5D_chunk_map_t *fm);
00116 typedef ssize_t (*H5D_layout_readvv_func_t)(const struct H5D_io_info_t *io_info,
00117     size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[],
00118     size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]);
00119 typedef ssize_t (*H5D_layout_writevv_func_t)(const struct H5D_io_info_t *io_info,
00120     size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[],
00121     size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]);
00122 typedef herr_t (*H5D_layout_io_term_func_t)(const struct H5D_chunk_map_t *cm);
00123 
00124 /* Typedef for grouping layout I/O routines */
00125 typedef struct H5D_layout_ops_t {
00126     H5D_layout_new_func_t new;          /* Layout constructor for new datasets */
00127     H5D_layout_is_space_alloc_func_t is_space_alloc;    /* Query routine to determine if storage is allocated */
00128     H5D_layout_io_init_func_t io_init;  /* I/O initialization routine */
00129     H5D_layout_read_func_t ser_read;    /* High-level I/O routine for reading data in serial */
00130     H5D_layout_write_func_t ser_write;  /* High-level I/O routine for writing data in serial */
00131 #ifdef H5_HAVE_PARALLEL
00132     H5D_layout_read_func_t par_read;    /* High-level I/O routine for reading data in parallel */
00133     H5D_layout_write_func_t par_write;  /* High-level I/O routine for writing data in parallel */
00134 #endif /* H5_HAVE_PARALLEL */
00135     H5D_layout_readvv_func_t readvv;    /* Low-level I/O routine for reading data */
00136     H5D_layout_writevv_func_t writevv;  /* Low-level I/O routine for writing data */
00137     H5D_layout_io_term_func_t io_term;  /* I/O shutdown routine */
00138 } H5D_layout_ops_t;
00139 
00140 /* Function pointers for either multiple or single block I/O access */
00141 typedef herr_t (*H5D_io_single_read_func_t)(const struct H5D_io_info_t *io_info,
00142     const H5D_type_info_t *type_info,
00143     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
00144 typedef herr_t (*H5D_io_single_write_func_t)(const struct H5D_io_info_t *io_info,
00145     const H5D_type_info_t *type_info,
00146     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
00147 
00148 /* Typedef for raw data I/O framework info */
00149 typedef struct H5D_io_ops_t {
00150     H5D_layout_read_func_t multi_read;          /* High-level I/O routine for reading data */
00151     H5D_layout_write_func_t multi_write;        /* High-level I/O routine for writing data */
00152     H5D_io_single_read_func_t single_read;      /* I/O routine for reading single block */
00153     H5D_io_single_write_func_t single_write;    /* I/O routine for writing single block */
00154 } H5D_io_ops_t;
00155 
00156 /* Typedefs for dataset storage information */
00157 typedef struct {
00158     haddr_t dset_addr;      /* Address of dataset in file */
00159     hsize_t dset_size;      /* Total size of dataset in file */
00160 } H5D_contig_storage_t;
00161 
00162 typedef struct {
00163     hsize_t index;          /* "Index" of chunk in dataset (must be first for TBBT routines) */
00164     hsize_t *offset;        /* Chunk's coordinates in elements */
00165 } H5D_chunk_storage_t;
00166 
00167 typedef struct {
00168     void *buf;              /* Buffer for compact dataset */
00169     hbool_t *dirty;         /* Pointer to dirty flag to mark */
00170 } H5D_compact_storage_t;
00171 
00172 typedef union H5D_storage_t {
00173     H5D_contig_storage_t contig; /* Contiguous information for dataset */
00174     H5D_chunk_storage_t chunk;  /* Chunk information for dataset */
00175     H5D_compact_storage_t compact; /* Compact information for dataset */
00176     H5O_efl_t   efl;            /* External file list information for dataset */
00177 } H5D_storage_t;
00178 
00179 /* Typedef for raw data I/O operation info */
00180 typedef struct H5D_io_info_t {
00181     H5D_t *dset;                /* Pointer to dataset being operated on */
00182 #ifndef H5_HAVE_PARALLEL
00183     const
00184 #endif /* H5_HAVE_PARALLEL */
00185         H5D_dxpl_cache_t *dxpl_cache; /* Pointer to cached DXPL info */
00186     hid_t dxpl_id;              /* Original DXPL ID */
00187 #ifdef H5_HAVE_PARALLEL
00188     MPI_Comm comm;              /* MPI communicator for file */
00189     hbool_t using_mpi_vfd;      /* Whether the file is using an MPI-based VFD */
00190     struct {
00191         H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request (H5D_XFER_IO_XFER_MODE_NAME) */
00192         H5FD_mpio_collective_opt_t coll_opt_mode; /* Parallel transfer with independent IO or collective IO with this mode */
00193         H5D_io_ops_t io_ops;    /* I/O operation function pointers */
00194     } orig;
00195 #endif /* H5_HAVE_PARALLEL */
00196     H5D_storage_t *store;       /* Dataset storage info */
00197     H5D_layout_ops_t layout_ops;    /* Dataset layout I/O operation function pointers */
00198     H5D_io_ops_t io_ops;        /* I/O operation function pointers */
00199     enum {
00200         H5D_IO_OP_READ,         /* Read operation */
00201         H5D_IO_OP_WRITE         /* Write operation */
00202     } op_type;
00203     union {
00204         void *rbuf;             /* Pointer to buffer for read */
00205         const void *wbuf;       /* Pointer to buffer to write */
00206     } u;
00207 } H5D_io_info_t;
00208 
00209 
00210 /******************/
00211 /* Chunk typedefs */
00212 /******************/
00213 
00214 /* Typedef for chunked dataset index operation info */
00215 typedef struct H5D_chk_idx_info_t {
00216     H5F_t *f;                   /* File pointer for operation */
00217     hid_t dxpl_id;              /* DXPL ID for operation */
00218     H5O_layout_t *layout;       /* Layout info for chunks */
00219 } H5D_chk_idx_info_t;
00220 
00221 /*
00222  * "Generic" chunk record.  Each chunk is keyed by the minimum logical
00223  * N-dimensional coordinates and the datatype size of the chunk.
00224  * The fastest-varying dimension is assumed to reference individual bytes of
00225  * the array, so a 100-element 1-D array of 4-byte integers would really be a
00226  * 2-D array with the slow varying dimension of size 100 and the fast varying
00227  * dimension of size 4 (the storage dimensionality has very little to do with
00228  * the real dimensionality).
00229  *
00230  * The chunk's file address, filter mask and size on disk are not key values.
00231  */
00232 typedef struct H5D_chunk_rec_t {
00233     uint32_t    nbytes;                         /* Size of stored data  */
00234     hsize_t     offset[H5O_LAYOUT_NDIMS];       /* Logical offset to start*/
00235     unsigned    filter_mask;                    /* Excluded filters     */
00236     haddr_t     chunk_addr;                     /* Address of chunk in file */
00237 } H5D_chunk_rec_t;
00238 
00239 /*
00240  * Common data exchange structure for indexed storage nodes.  This structure is
00241  * passed through the indexing layer to the methods for the objects
00242  * to which the index points.
00243  */
00244 typedef struct H5D_chunk_common_ud_t {
00245     /* downward */
00246     const H5O_layout_t *mesg;                   /*layout message        */
00247     const hsize_t *offset;                      /*logical offset of chunk*/
00248 } H5D_chunk_common_ud_t;
00249 
00250 /* B-tree callback info for various operations */
00251 typedef struct H5D_chunk_ud_t {
00252     H5D_chunk_common_ud_t common;       /* Common info for B-tree user data (must be first) */
00253 
00254     /* Upward */
00255     uint32_t    nbytes;                 /*size of stored data   */
00256     unsigned    filter_mask;            /*excluded filters      */
00257     haddr_t     addr;                   /*file address of chunk */
00258 } H5D_chunk_ud_t;
00259 
00260 /* Typedef for "generic" chunk callbacks */
00261 typedef int (*H5D_chunk_cb_func_t)(const H5D_chunk_rec_t *chunk_rec,
00262     void *udata);
00263 
00264 /* Typedefs for chunk operations */
00265 typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info);
00266 typedef herr_t (*H5D_chunk_create_func_t)(const H5D_chk_idx_info_t *idx_info);
00267 typedef hbool_t (*H5D_chunk_is_space_alloc_func_t)(const H5O_layout_t *layout);
00268 typedef herr_t (*H5D_chunk_insert_func_t)(const H5D_chk_idx_info_t *idx_info,
00269     H5D_chunk_ud_t *udata);
00270 typedef herr_t (*H5D_chunk_get_addr_func_t)(const H5D_chk_idx_info_t *idx_info,
00271     H5D_chunk_ud_t *udata);
00272 typedef int (*H5D_chunk_iterate_func_t)(const H5D_chk_idx_info_t *idx_info,
00273     H5D_chunk_cb_func_t chunk_cb, void *chunk_udata);
00274 typedef herr_t (*H5D_chunk_remove_func_t)(const H5D_chk_idx_info_t *idx_info,
00275     H5D_chunk_common_ud_t *udata);
00276 typedef herr_t (*H5D_chunk_delete_func_t)(const H5D_chk_idx_info_t *idx_info);
00277 typedef herr_t (*H5D_chunk_copy_setup_func_t)(const H5D_chk_idx_info_t *idx_info_src,
00278     const H5D_chk_idx_info_t *idx_info_dst);
00279 typedef herr_t (*H5D_chunk_copy_shutdown_func_t)(H5O_layout_t *layout_src,
00280     H5O_layout_t *layout_dst);
00281 typedef herr_t (*H5D_chunk_size_func_t)(const H5D_chk_idx_info_t *idx_info,
00282     hsize_t *idx_size);
00283 typedef herr_t (*H5D_chunk_reset_func_t)(H5O_layout_t *layout);
00284 typedef herr_t (*H5D_chunk_dump_func_t)(const H5D_chk_idx_info_t *idx_info,
00285     FILE *stream);
00286 typedef herr_t (*H5D_chunk_dest_func_t)(const H5D_chk_idx_info_t *idx_info);
00287 
00288 /* Typedef for grouping chunk I/O routines */
00289 typedef struct H5D_chunk_ops_t {
00290     H5D_chunk_init_func_t init;             /* Routine to initialize indexing information in memory */
00291     H5D_chunk_create_func_t create;         /* Routine to create chunk index */
00292     H5D_chunk_is_space_alloc_func_t is_space_alloc;    /* Query routine to determine if storage/index is allocated */
00293     H5D_chunk_insert_func_t insert;         /* Routine to insert a chunk into an index */
00294     H5D_chunk_get_addr_func_t get_addr;     /* Routine to retrieve address of chunk in file */
00295     H5D_chunk_iterate_func_t iterate;       /* Routine to iterate over chunks */
00296     H5D_chunk_remove_func_t remove;         /* Routine to remove a chunk from an index */
00297     H5D_chunk_delete_func_t delete;         /* Routine to delete index & all chunks from file*/
00298     H5D_chunk_copy_setup_func_t copy_setup; /* Routine to perform any necessary setup for copying chunks */
00299     H5D_chunk_copy_shutdown_func_t copy_shutdown; /* Routine to perform any necessary shutdown for copying chunks */
00300     H5D_chunk_size_func_t size;             /* Routine to get size of indexing information */
00301     H5D_chunk_reset_func_t reset;           /* Routine to reset indexing information */
00302     H5D_chunk_dump_func_t dump;             /* Routine to dump indexing information */
00303     H5D_chunk_dest_func_t dest;             /* Routine to destroy indexing information in memory */
00304 } H5D_chunk_ops_t;
00305 
00306 /* Structure holding information about a chunk's selection for mapping */
00307 typedef struct H5D_chunk_info_t {
00308     hsize_t index;              /* "Index" of chunk in dataset */
00309     uint32_t chunk_points;      /* Number of elements selected in chunk */
00310     hsize_t coords[H5O_LAYOUT_NDIMS];   /* Coordinates of chunk in file dataset's dataspace */
00311     H5S_t *fspace;              /* Dataspace describing chunk & selection in it */
00312     unsigned fspace_shared;     /* Indicate that the file space for a chunk is shared and shouldn't be freed */
00313     H5S_t *mspace;              /* Dataspace describing selection in memory corresponding to this chunk */
00314     unsigned mspace_shared;     /* Indicate that the memory space for a chunk is shared and shouldn't be freed */
00315 } H5D_chunk_info_t;
00316 
00317 /* Main structure holding the mapping between file chunks and memory */
00318 typedef struct H5D_chunk_map_t {
00319     H5O_layout_t *layout;       /* Dataset layout information*/
00320     hsize_t nelmts;             /* Number of elements selected in file & memory dataspaces */
00321 
00322     const H5S_t *file_space;    /* Pointer to the file dataspace */
00323     unsigned f_ndims;           /* Number of dimensions for file dataspace */
00324     hsize_t f_dims[H5O_LAYOUT_NDIMS];   /* File dataspace dimensions */
00325 
00326     const H5S_t *mem_space;     /* Pointer to the memory dataspace */
00327     H5S_t *mchunk_tmpl;         /* Dataspace template for new memory chunks */
00328     H5S_sel_iter_t mem_iter;    /* Iterator for elements in memory selection */
00329     unsigned m_ndims;           /* Number of dimensions for memory dataspace */
00330     H5S_sel_type msel_type;     /* Selection type in memory */
00331 
00332     H5SL_t *sel_chunks;         /* Skip list containing information for each chunk selected */
00333 
00334     H5S_t  *single_space;       /* Dataspace for single chunk */
00335     H5D_chunk_info_t *single_chunk_info;  /* Pointer to single chunk's info */
00336     hbool_t use_single;         /* Whether I/O is on a single element */
00337 
00338     hsize_t last_index;         /* Index of last chunk operated on */
00339     H5D_chunk_info_t *last_chunk_info;  /* Pointer to last chunk's info */
00340 
00341     hsize_t chunks[H5O_LAYOUT_NDIMS];   /* Number of chunks in each dimension */
00342     hsize_t chunk_dim[H5O_LAYOUT_NDIMS];    /* Size of chunk in each dimension */
00343     hsize_t down_chunks[H5O_LAYOUT_NDIMS];   /* "down" size of number of chunks in each dimension */
00344 
00345 #ifdef H5_HAVE_PARALLEL
00346     hsize_t total_chunks;       /* Number of chunks covered by dataspace */
00347     H5D_chunk_info_t **select_chunk;    /* Store the information about whether this chunk is selected or not */
00348 #endif /* H5_HAVE_PARALLEL */
00349 } H5D_chunk_map_t;
00350 
00351 /* Cached information about a particular chunk */
00352 typedef struct H5D_chunk_cached_t{
00353     hbool_t     valid;                          /*whether cache info is valid*/
00354     hsize_t     offset[H5O_LAYOUT_NDIMS];       /*logical offset to start*/
00355     uint32_t    nbytes;                         /*size of stored data   */
00356     unsigned    filter_mask;                    /*excluded filters      */
00357     haddr_t     addr;                           /*file address of chunk */
00358 } H5D_chunk_cached_t;
00359 
00360 /* The raw data chunk cache */
00361 typedef struct H5D_rdcc_t {
00362     struct {
00363         unsigned        ninits; /* Number of chunk creations            */
00364         unsigned        nhits;  /* Number of cache hits                 */
00365         unsigned        nmisses;/* Number of cache misses               */
00366         unsigned        nflushes;/* Number of cache flushes             */
00367     } stats;
00368     size_t              nbytes_max; /* Maximum cached raw data in bytes */
00369     size_t              nslots; /* Number of chunk slots allocated      */
00370     double      w0;     /* Chunk preemption policy          */
00371     struct H5D_rdcc_ent_t *head; /* Head of doubly linked list          */
00372     struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list          */
00373     size_t              nbytes_used; /* Current cached raw data in bytes */
00374     int         nused;  /* Number of chunk slots in use         */
00375     H5D_chunk_cached_t last;    /* Cached copy of last chunk information */
00376     struct H5D_rdcc_ent_t **slot; /* Chunk slots, each points to a chunk*/
00377     H5SL_t *sel_chunks;     /* Skip list containing information for each chunk selected */
00378     H5S_t  *single_space;    /* Dataspace for single element I/O on chunks */
00379     H5D_chunk_info_t *single_chunk_info;  /* Pointer to single chunk's info */
00380 } H5D_rdcc_t;
00381 
00382 /* The raw data contiguous data cache */
00383 typedef struct H5D_rdcdc_t {
00384     unsigned char *sieve_buf;   /* Buffer to hold data sieve buffer */
00385     haddr_t sieve_loc;          /* File location (offset) of the data sieve buffer */
00386     size_t sieve_size;          /* Size of the data sieve buffer used (in bytes) */
00387     size_t sieve_buf_size;      /* Size of the data sieve buffer allocated (in bytes) */
00388     unsigned sieve_dirty;       /* Flag to indicate that the data sieve buffer is dirty */
00389 } H5D_rdcdc_t;
00390 
00391 /*
00392  * A dataset is made of two layers, an H5D_t struct that is unique to
00393  * each instance of an opened datset, and a shared struct that is only
00394  * created once for a given dataset.  Thus, if a dataset is opened twice,
00395  * there will be two IDs and two H5D_t structs, both sharing one H5D_shared_t.
00396  */
00397 typedef struct H5D_shared_t {
00398     size_t              fo_count;       /* Reference count */
00399     hid_t               type_id;        /* ID for dataset's datatype    */
00400     H5T_t              *type;           /* Datatype for this dataset     */
00401     H5S_t              *space;          /* Dataspace of this dataset    */
00402     hbool_t             space_dirty;    /* Whether the dataspace info needs to be flushed to the file */
00403     hbool_t             layout_dirty;   /* Whether the layout info needs to be flushed to the file */
00404     hid_t               dcpl_id;        /* Dataset creation property id */
00405     H5D_dcpl_cache_t    dcpl_cache;     /* Cached DCPL values */
00406     H5O_layout_t        layout;         /* Data layout                  */
00407     hbool_t             checked_filters;/* TRUE if dataset passes can_apply check */
00408 
00409     /* Buffered/cached information for types of raw data storage*/
00410     struct {
00411         H5D_rdcdc_t     contig;         /* Information about contiguous data */
00412                                         /* (Note that the "contig" cache
00413                                          * information can be used by a chunked
00414                                          * dataset in certain circumstances)
00415                                          */
00416         H5D_rdcc_t      chunk;          /* Information about chunked data */
00417     } cache;
00418 } H5D_shared_t;
00419 
00420 struct H5D_t {
00421     H5O_loc_t           oloc;           /* Object header location       */
00422     H5G_name_t          path;           /* Group hierarchy path         */
00423     H5D_shared_t        *shared;        /* cached information from file */
00424 };
00425 
00426 /* Enumerated type for allocating dataset's storage */
00427 typedef enum {
00428     H5D_ALLOC_CREATE,           /* Dataset is being created */
00429     H5D_ALLOC_OPEN,             /* Dataset is being opened */
00430     H5D_ALLOC_EXTEND,           /* Dataset's dataspace is being extended */
00431     H5D_ALLOC_WRITE             /* Dataset is being extended */
00432 } H5D_time_alloc_t;
00433 
00434 
00435 /* Typedef for dataset creation operation */
00436 typedef struct {
00437     hid_t type_id;              /* Datatype for dataset */
00438     const H5S_t *space;         /* Dataspace for dataset */
00439     hid_t dcpl_id;              /* Dataset creation property list */
00440     hid_t dapl_id;              /* Dataset access property list */
00441 } H5D_obj_create_t;
00442 
00443 /* Typedef for filling a buffer with a fill value */
00444 typedef struct H5D_fill_buf_info_t {
00445     hbool_t     alloc_vl_during_refill; /* Whether to allocate VL-datatype fill buffer during refill */
00446     H5MM_allocate_t fill_alloc_func;    /* Routine to call for allocating fill buffer */
00447     void        *fill_alloc_info;       /* Extra info for allocation routine */
00448     H5MM_free_t fill_free_func;         /* Routine to call for freeing fill buffer */
00449     void        *fill_free_info;        /* Extra info for free routine */
00450     H5T_path_t *fill_to_mem_tpath;      /* Datatype conversion path for converting the fill value to the memory buffer */
00451     H5T_path_t *mem_to_dset_tpath;      /* Datatype conversion path for converting the memory buffer to the dataset elements */
00452     const H5O_fill_t *fill;             /* Pointer to fill value */
00453     void       *fill_buf;               /* Fill buffer */
00454     size_t      fill_buf_size;          /* Size of fill buffer */
00455     hbool_t     use_caller_fill_buf;    /* Whether the caller provided the fill buffer */
00456     void       *bkg_buf;                /* Background conversion buffer */
00457     size_t      bkg_buf_size;           /* Size of background buffer */
00458     H5T_t      *mem_type;               /* Pointer to memory datatype */
00459     const H5T_t *file_type;             /* Pointer to file datatype */
00460     hid_t       mem_tid;                /* ID for memory version of disk datatype */
00461     hid_t       file_tid;               /* ID for disk datatype */
00462     size_t      mem_elmt_size, file_elmt_size;       /* Size of element in memory and on disk */
00463     size_t      max_elmt_size;          /* Max. size of memory or file datatype */
00464     size_t      elmts_per_buf;          /* # of elements that fit into a buffer */
00465     hbool_t     has_vlen_fill_type;     /* Whether the datatype for the fill value has a variable-length component */
00466 } H5D_fill_buf_info_t;
00467 
00468 /* Internal data structure for computing variable-length dataset's total size */
00469 typedef struct {
00470     hid_t dataset_id;   /* ID of the dataset we are working on */
00471     hid_t fspace_id;    /* ID of the file dataset's dataspace we are working on */
00472     hid_t mspace_id;    /* ID of the memory dataset's dataspace we are working on */
00473     void *fl_tbuf;      /* Ptr to the temporary buffer we are using for fixed-length data */
00474     void *vl_tbuf;      /* Ptr to the temporary buffer we are using for VL data */
00475     hid_t xfer_pid;     /* ID of the dataset xfer property list */
00476     hsize_t size;       /* Accumulated number of bytes for the selection */
00477 } H5D_vlen_bufsize_t;
00478 
00479 /* Raw data chunks are cached.  Each entry in the cache is: */
00480 typedef struct H5D_rdcc_ent_t {
00481     hbool_t     locked;         /*entry is locked in cache              */
00482     hbool_t     dirty;          /*needs to be written to disk?          */
00483     hsize_t     offset[H5O_LAYOUT_NDIMS]; /*chunk name                  */
00484     uint32_t    rd_count;       /*bytes remaining to be read            */
00485     uint32_t    wr_count;       /*bytes remaining to be written         */
00486     haddr_t     chunk_addr;     /*address of chunk in file              */
00487     uint32_t    chunk_size;     /*size of a chunk                       */
00488     size_t      alloc_size;     /*amount allocated for the chunk        */
00489     uint8_t     *chunk;         /*the unfiltered chunk data             */
00490     unsigned    idx;            /*index in hash table                   */
00491     struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list       */
00492     struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list   */
00493 } H5D_rdcc_ent_t;
00494 typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */
00495 
00496 
00497 /*****************************/
00498 /* Package Private Variables */
00499 /*****************************/
00500 extern H5D_dxpl_cache_t H5D_def_dxpl_cache;
00501 
00502 /* Storage layout class I/O operations */
00503 H5_DLLVAR const H5D_layout_ops_t H5D_LOPS_CONTIG[1];
00504 H5_DLLVAR const H5D_layout_ops_t H5D_LOPS_EFL[1];
00505 H5_DLLVAR const H5D_layout_ops_t H5D_LOPS_COMPACT[1];
00506 H5_DLLVAR const H5D_layout_ops_t H5D_LOPS_CHUNK[1];
00507 
00508 /* Chunked layout operations */
00509 H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_BTREE[1];
00510 
00511 
00512 /******************************/
00513 /* Package Private Prototypes */
00514 /******************************/
00515 
00516 H5_DLL H5D_t *H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space,
00517     hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id);
00518 H5_DLL H5D_t *H5D_create_named(const H5G_loc_t *loc, const char *name,
00519     hid_t type_id, const H5S_t *space, hid_t lcpl_id, hid_t dcpl_id,
00520     hid_t dapl_id, hid_t dxpl_id);
00521 H5_DLL herr_t H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation,
00522     hid_t dxpl_id);
00523 H5_DLL herr_t H5D_alloc_storage(H5D_t *dset, hid_t dxpl_id, H5D_time_alloc_t time_alloc,
00524     hbool_t full_overwrite);
00525 H5_DLL hsize_t H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id);
00526 H5_DLL haddr_t H5D_get_offset(const H5D_t *dset);
00527 H5_DLL herr_t H5D_iterate(void *buf, hid_t type_id, const H5S_t *space,
00528     H5D_operator_t op, void *operator_data);
00529 H5_DLL void * H5D_vlen_get_buf_size_alloc(size_t size, void *info);
00530 H5_DLL herr_t H5D_vlen_get_buf_size(void *elem, hid_t type_id, unsigned ndim,
00531     const hsize_t *point, void *op_data);
00532 H5_DLL herr_t H5D_check_filters(H5D_t *dataset);
00533 H5_DLL herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
00534 H5_DLL herr_t H5D_get_dxpl_cache(hid_t dxpl_id, H5D_dxpl_cache_t **cache);
00535 
00536 /* Functions that perform direct serial I/O operations */
00537 H5_DLL herr_t H5D_select_read(const H5D_io_info_t *io_info,
00538     const H5D_type_info_t *type_info,
00539     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
00540 H5_DLL herr_t H5D_select_write(const H5D_io_info_t *io_info,
00541     const H5D_type_info_t *type_info,
00542     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
00543 
00544 /* Functions that perform scatter-gather serial I/O operations */
00545 H5_DLL herr_t H5D_scatter_mem(const void *_tscat_buf,
00546     const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts,
00547     const H5D_dxpl_cache_t *dxpl_cache, void *_buf);
00548 H5_DLL herr_t H5D_scatgath_read(const H5D_io_info_t *io_info,
00549     const H5D_type_info_t *type_info,
00550     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
00551 H5_DLL herr_t H5D_scatgath_write(const H5D_io_info_t *io_info,
00552     const H5D_type_info_t *type_info,
00553     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
00554 
00555 /* Functions that operate on contiguous storage */
00556 H5_DLL herr_t H5D_contig_alloc(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout);
00557 H5_DLL herr_t H5D_contig_fill(H5D_t *dset, hid_t dxpl_id);
00558 H5_DLL haddr_t H5D_contig_get_addr(const H5D_t *dset);
00559 H5_DLL herr_t H5D_contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
00560     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
00561     H5D_chunk_map_t *fm);
00562 H5_DLL herr_t H5D_contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
00563     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
00564     H5D_chunk_map_t *fm);
00565 H5_DLL ssize_t H5D_contig_readvv(const H5D_io_info_t *io_info,
00566     size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[],
00567     size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]);
00568 H5_DLL ssize_t H5D_contig_writevv(const H5D_io_info_t *io_info,
00569     size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[],
00570     size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]);
00571 H5_DLL herr_t H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_t *f_dst,
00572     H5O_layout_t *layout_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info, hid_t dxpl_id);
00573 
00574 /* Functions that operate on chunked dataset storage */
00575 H5_DLL htri_t H5D_chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr,
00576     hbool_t write_op);
00577 H5_DLL herr_t H5D_chunk_cinfo_cache_reset(H5D_chunk_cached_t *last);
00578 H5_DLL herr_t H5D_chunk_create(H5D_t *dset /*in,out*/, hid_t dxpl_id);
00579 H5_DLL herr_t H5D_chunk_init(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, const H5D_t *dset);
00580 H5_DLL hbool_t H5D_chunk_is_space_alloc(const H5O_layout_t *layout);
00581 H5_DLL herr_t H5D_chunk_get_info(const H5D_t *dset, hid_t dxpl_id,
00582     const hsize_t *chunk_offset, H5D_chunk_ud_t *udata);
00583 H5_DLL void *H5D_chunk_lock(const H5D_io_info_t *io_info,
00584     H5D_chunk_ud_t *udata, hbool_t relax, unsigned *idx_hint/*in,out*/);
00585 H5_DLL herr_t H5D_chunk_unlock(const H5D_io_info_t *io_info,
00586     const H5D_chunk_ud_t *udata, hbool_t dirty, unsigned idx_hint, void *chunk,
00587     uint32_t naccessed);
00588 H5_DLL herr_t H5D_chunk_flush(H5D_t *dset, hid_t dxpl_id, unsigned flags);
00589 H5_DLL herr_t H5D_chunk_allocated(H5D_t *dset, hid_t dxpl_id, hsize_t *nbytes);
00590 H5_DLL herr_t H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite);
00591 H5_DLL herr_t H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id,
00592     const hsize_t *old_dims);
00593 #ifdef H5_HAVE_PARALLEL
00594 H5_DLL herr_t H5D_chunk_addrmap(const H5D_io_info_t *io_info,
00595     haddr_t chunk_addr[], const hsize_t down_chunks[]);
00596 #endif /* H5_HAVE_PARALLEL */
00597 H5_DLL herr_t H5D_chunk_update_cache(H5D_t *dset, hid_t dxpl_id);
00598 H5_DLL herr_t H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src,
00599     H5F_t *f_dst, H5O_layout_t *layout_dst, H5T_t *src_dtype,
00600     H5O_copy_t *cpy_info, H5O_pline_t *pline, hid_t dxpl_id);
00601 H5_DLL herr_t H5D_chunk_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout,
00602     hsize_t *btree_size);
00603 H5_DLL herr_t H5D_chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream);
00604 H5_DLL herr_t H5D_chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset);
00605 #ifdef H5D_CHUNK_DEBUG
00606 H5_DLL herr_t H5D_chunk_stats(const H5D_t *dset, hbool_t headers);
00607 #endif /* H5D_CHUNK_DEBUG */
00608 
00609 /* Functions that operate on compact dataset storage */
00610 H5_DLL herr_t H5D_compact_fill(H5D_t *dset, hid_t dxpl_id);
00611 H5_DLL herr_t H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src,
00612     H5F_t *f_dst, H5O_layout_t *layout_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info, hid_t dxpl_id);
00613 
00614 /* Functions that perform fill value operations on datasets */
00615 H5_DLL herr_t H5D_fill(const void *fill, const H5T_t *fill_type, void *buf,
00616     const H5T_t *buf_type, const H5S_t *space, hid_t dxpl_id);
00617 H5_DLL herr_t H5D_fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf,
00618     hbool_t alloc_vl_during_refill,
00619     H5MM_allocate_t alloc_func, void *alloc_info,
00620     H5MM_free_t free_func, void *free_info,
00621     const H5O_fill_t *fill, const H5T_t *dset_type, hid_t dset_type_id,
00622     size_t nelmts, size_t min_buf_size, hid_t dxpl_id);
00623 H5_DLL herr_t H5D_fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts,
00624     hid_t dxpl_id);
00625 H5_DLL herr_t H5D_fill_release(H5D_fill_buf_info_t *fb_info);
00626 H5_DLL herr_t H5D_fill_term(H5D_fill_buf_info_t *fb_info);
00627 
00628 #ifdef H5_HAVE_PARALLEL
00629 
00630 #ifdef H5S_DEBUG
00631 #ifndef H5Dmpio_DEBUG
00632 #define H5Dmpio_DEBUG
00633 #endif /*H5Dmpio_DEBUG*/
00634 #endif/*H5S_DEBUG*/
00635 /* MPI-IO function to read, it will select either regular or irregular read */
00636 H5_DLL herr_t H5D_mpio_select_read(const H5D_io_info_t *io_info,
00637     const H5D_type_info_t *type_info,
00638     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
00639 
00640 /* MPI-IO function to write, it will select either regular or irregular read */
00641 H5_DLL herr_t H5D_mpio_select_write(const H5D_io_info_t *io_info,
00642     const H5D_type_info_t *type_info,
00643     hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space);
00644 
00645 /* MPI-IO functions to handle contiguous collective IO */
00646 H5_DLL herr_t H5D_contig_collective_read(H5D_io_info_t *io_info,
00647     const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space,
00648     const H5S_t *mem_space, H5D_chunk_map_t *fm);
00649 H5_DLL herr_t H5D_contig_collective_write(H5D_io_info_t *io_info,
00650     const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space,
00651     const H5S_t *mem_space, H5D_chunk_map_t *fm);
00652 
00653 /* MPI-IO functions to handle chunked collective IO */
00654 H5_DLL herr_t H5D_chunk_collective_read(H5D_io_info_t *io_info,
00655     const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space,
00656     const H5S_t *mem_space, H5D_chunk_map_t *fm);
00657 H5_DLL herr_t H5D_chunk_collective_write(H5D_io_info_t *io_info,
00658     const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space,
00659     const H5S_t *mem_space, H5D_chunk_map_t *fm);
00660 
00661 /* MPI-IO function to check if a direct I/O transfer is possible between
00662  * memory and the file */
00663 H5_DLL htri_t H5D_mpio_opt_possible(const H5D_io_info_t *io_info,
00664     const H5S_t *file_space, const H5S_t *mem_space,
00665     const H5D_type_info_t *type_info, const H5D_chunk_map_t *fm);
00666 
00667 #endif /* H5_HAVE_PARALLEL */
00668 
00669 /* Testing functions */
00670 #ifdef H5D_TESTING
00671 H5_DLL herr_t H5D_layout_version_test(hid_t did, unsigned *version);
00672 H5_DLL herr_t H5D_layout_contig_size_test(hid_t did, hsize_t *size);
00673 H5_DLL herr_t H5D_current_cache_size_test(hid_t did, size_t *nbytes_used, int *nused);
00674 #endif /* H5D_TESTING */
00675 
00676 #endif /*_H5Dpkg_H*/
00677