diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-02-19 18:19:48 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-02-19 18:19:48 (GMT) |
commit | b24130dcf051e6f569612c0a9b13d2168c6213c0 (patch) | |
tree | 607e5fc4db5da70f6584c9567f28ef9b88faeae1 /src/H5C.c | |
parent | 5b8d25d3c6db32d04213978500dca99dd1794d77 (diff) | |
download | hdf5-b24130dcf051e6f569612c0a9b13d2168c6213c0.zip hdf5-b24130dcf051e6f569612c0a9b13d2168c6213c0.tar.gz hdf5-b24130dcf051e6f569612c0a9b13d2168c6213c0.tar.bz2 |
[svn-r290] Changes since 19980206
----------------------
./configure.in
./src/H5Fprivate.h
./src/H5Fsec2.c
We now detect and use lseek64() on systems that have it (e.g.,
Irix64) and are able to generate >2GB files on Irix XFS file
systems (and anything else that supports large files). This
change also removed some warning messages from the Irix `-64'
compiler.
> $ ls -l istore.h5
> -rw-r--r-- 1 matzke meshtv 8605436856 Feb 17 14:03 istore.h5
./configure.in
./src/H5Fprivate.h
./src/H5Fstdio.h
We now detect and use fseek64() on systems that have it (e.g.,
Irix64) and are able to generate >2GB files on Irix XFS file
systems (and anything else that supports large files). This
change also removed some warning messages from the Iris `-64'
compiler.
./src/H5E.c
./src/H5Epublic.h
Added the H5E_OVERFLOW error to signal file address overflow.
./src/H5Fpublic.h
./examples/h5_chunk_read.c
./examples/h5_compound.c
./examples/h5_extend_write.c
./examples/h5_group.c
./examples/h5_read.c
./examples/h5_write.c
./html/Datasets.html
./html/Files.html
./html/H5.api.html
./html/H5.intro.html
./html/H5.sample_code.html
./html/ph5example.c
./html/review1.html
./test/cmpd_dset.c
./test/dsets.c
./test/extend.c
./test/tfile.c
./test/th5p.c
./test/theap.c
./test/tohdr.c
./test/tstab.c
./testpar/phdf5.c
Renamed file access constants to follow the naming scheme.
Also changed the base names a little to be more accurate as to
what they do. The old names H5ACC_WRITE and H5ACC_OVERWRITE
will temporarily work.
H5ACC_DEFAULT --> H5F_ACC_RDONLY for H5Fopen()
H5ACC_DEFAULT --> H5F_ACC_EXCL for H5Fcreate()
H5ACC_WRITE --> H5F_ACC_RDWR
H5ACC_OVERWRITE --> H5F_ACC_TRUNC
Albert or Kim: The H5ACC_INDEPENDENT and H5ACC_COLLECTIVE
macros in H5Fpublic.h should be an enum typedef and have names
more like H5F_MPIO_INDEPENDENT and H5F_MPIO_COLLECTIVE. Also
change the access_mode argument of H5Cset_mpio().
H5Fcreate() and H5Fopen() are more strict now about which
flags are acceptable for the operation.
./src/H5Fprivate.h
./src/H5F.c
./src/H5C.c
Changed the file access template to make it more general. A
union contains a struct for each type of low-level driver and
the default template is initialized at run-time.
./src/H5Fpublic.h
./src/H5F.c
Added H5Fget_access_template() and cleaned up
H5Fget_create_template().
./src/H5C.c
The H5Cset_mpi() no longer trashes the file access template
when an error is detected. We check for errors and *then*
update the file access template.
Added H5C_close() so Albert and Kim have a place to release
the MPI communicator and info from the file access property
list.
Kim or Albert: I notice in H5Cset_mpi() you copy the MPI
communicator. Do you need to do something similar in
H5C_copy()?
./src/H5F.c
Added more error checking for the file creation and access
property lists because it used to be possible to make the
library dump core by swapping the creation and access property
list ID numbers of H5Fcreate().
./test/istore.c
./test/tfile.c
./test/th5p.c
./test/theap.c
./test/tohdr.c
./test/tstab.c
./testpar/testphdf5.c
One must pass H5C_DEFAULT as the file creation or access
property list in order to get the default property list. It
is no longer possible to pass zero or any other arbitrary bad
object ID.
./src/H5Fcore.c
./src/H5Ffamly.c
./src/H5Flow.c
./src/H5Fmpio.c
./src/H5Fsec2.c
./src/H5Fsplit.c
./src/H5Fstdio.c
./src/H5MF.c
The file access property list is passed to all H5F_low_...()
functions and to the drivers.
./src/H5Fcore.c
The block size can be set at run time on a per-file basis
instead of at compile time across all files. The "5000 items in
a group test" now takes 1.6 seconds.
./src/H5private.h
Removed inclusion of mpi.h and mpio.h since they're included
from H5public.h.
./src/H5Cpublic.h
./src/H5C.c
Added H5Cset_stdio(), H5Cset_sec2(), H5Cset_core(),
H5Cset_split(), and H5Cset_family() in addition to the
H5Cset_mpio() that Kim and Albert already wrote. We still
need the H5Cget_driver() and an H5Cget...() counterpart for
each of those functions. The split and family drivers still
need a little work but I'm checking this in anyway.
Diffstat (limited to 'src/H5C.c')
-rw-r--r-- | src/H5C.c | 378 |
1 files changed, 350 insertions, 28 deletions
@@ -58,6 +58,16 @@ H5C_init_interface(void) FUNC_ENTER(H5C_init_interface, FAIL); + /* + * Make sure the file creation and file access default templates are + * initialized since this might be done at run-time instead of compile + * time. + */ + if (H5F_init_interface ()<0) { + HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL, + "unable to initialize H5F and H5C interfaces"); + } + assert(H5C_NCLASSES <= H5_TEMPLATE_MAX - H5_TEMPLATE_0); /* @@ -66,14 +76,15 @@ H5C_init_interface(void) * atom groups aren't. */ for (i = 0; i < H5C_NCLASSES; i++) { - status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i), H5A_TEMPID_HASHSIZE, 0, NULL); - if (status < 0) - ret_value = FAIL; + status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i), + H5A_TEMPID_HASHSIZE, 0, NULL); + if (status < 0) ret_value = FAIL; } if (ret_value < 0) { HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group"); } + /* * Register cleanup function. */ @@ -81,6 +92,7 @@ H5C_init_interface(void) HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to install atexit function"); } + FUNC_LEAVE(ret_value); } @@ -194,7 +206,7 @@ H5Ccreate(H5C_class_t type) hid_t H5C_create(H5C_class_t type, void *tmpl) { - hid_t ret_value = FAIL; + hid_t ret_value = FAIL; FUNC_ENTER(H5C_create, FAIL); @@ -203,10 +215,11 @@ H5C_create(H5C_class_t type, void *tmpl) assert(tmpl); /* Atomize the new template */ - if ((ret_value = H5A_register((group_t)(H5_TEMPLATE_0 + type), tmpl)) < 0) { + if ((ret_value=H5A_register((group_t)(H5_TEMPLATE_0+type), tmpl)) < 0) { HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "can't register template"); } + FUNC_LEAVE(ret_value); } @@ -226,21 +239,79 @@ H5C_create(H5C_class_t type, void *tmpl) herr_t H5Cclose(hid_t tid) { - void *tmpl = NULL; + H5C_class_t type; + void *tmpl = NULL; FUNC_ENTER(H5Cclose, FAIL); - /* Chuck the object! :-) */ - if (NULL == (tmpl = H5A_remove(tid))) { - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to remove atom"); + /* Check arguments */ + if ((type=H5Cget_class (tid))<0 || + NULL==(tmpl=H5A_object (tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); } + + /* + * Chuck the object! This will fail when the reference count reaches zero + * since there is no free func registered for the property list groups. + */ + if (H5A_dec_ref (tid)<0) { + H5ECLEAR; + H5C_close (type, tmpl); + } + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5C_close + * + * Purpose: Closes a template and frees the memory associated with the + * template. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, February 18, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_close (H5C_class_t type, void *tmpl) +{ + FUNC_ENTER (H5C_close, FAIL); + + /* Check args */ + assert (tmpl); + + /* Some templates may need to do special things */ + switch (type) { + case H5C_FILE_ACCESS: #ifdef LATER - /* this is for file access template too. Need to free the COMM and INFO objects too. */ -#endif - H5MM_xfree(tmpl); + /* Need to free the COMM and INFO objects too. */ +#endif + break; + + case H5C_FILE_CREATE: + case H5C_DATASET_CREATE: + case H5C_DATASET_XFER: + /*nothing to do*/ + break; + + default: + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "unknown property list class"); + } + /* Free the template struct and return */ + H5MM_xfree(tmpl); FUNC_LEAVE(SUCCEED); } + /*------------------------------------------------------------------------- * Function: H5Cget_class @@ -857,6 +928,235 @@ H5Cget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ ) FUNC_LEAVE(tmpl->chunk_ndims); } + + +/*------------------------------------------------------------------------- + * Function: H5Cset_stdio + * + * Purpose: Set the low level file driver to use the functions declared + * in the stdio.h file: fopen(), fseek() or fseek64(), fread(), + * fwrite(), and fclose(). + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_stdio (hid_t tid) +{ + H5F_access_t *tmpl = NULL; + + FUNC_ENTER (H5Cset_stdio, FAIL); + + /* Check arguments */ + if (H5C_FILE_ACCESS != H5Cget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_STDIO; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cset_sec2 + * + * Purpose: Set the low-level file driver to use the functions declared + * in the unistd.h file: open(), lseek() or lseek64(), read(), + * write(), and close(). + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_sec2 (hid_t tid) +{ + H5F_access_t *tmpl = NULL; + + FUNC_ENTER (H5Cset_sec2, FAIL); + + /* Check arguments */ + if (H5C_FILE_ACCESS != H5Cget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_SEC2; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cset_core + * + * Purpose: Set the low-level file driver to use malloc() and free(). + * This driver is restricted to temporary files which are not + * larger than the amount of virtual memory available. The + * INCREMENT argument determines the file block size and memory + * will be allocated in multiples of INCREMENT bytes. A liberal + * INCREMENT results in fewer calls to realloc() and probably + * less memory fragmentation. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_core (hid_t tid, size_t increment) +{ + H5F_access_t *tmpl = NULL; + + FUNC_ENTER (H5Cset_core, FAIL); + + /* Check arguments */ + if (H5C_FILE_ACCESS != H5Cget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + if (increment<1) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "increment must be positive"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_CORE; + tmpl->u.core.increment = increment; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cset_split + * + * Purpose: Set the low-level driver to split meta data from raw data, + * storing meta data in one file and raw data in another file. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_split (hid_t tid, hid_t meta_tid, hid_t raw_tid) +{ + H5F_access_t *tmpl = NULL; + H5F_access_t *meta_tmpl = NULL; + H5F_access_t *raw_tmpl = NULL; + + FUNC_ENTER (H5Cset_split, FAIL); + + /* Check arguments */ + if (H5C_FILE_ACCESS != H5Cget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + if (H5C_DEFAULT!=meta_tid && + (H5C_FILE_ACCESS != H5Cget_class(meta_tid) || + NULL == (tmpl = H5A_object(meta_tid)))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + if (H5C_DEFAULT!=raw_tid && + (H5C_FILE_ACCESS != H5Cget_class(raw_tid) || + NULL == (tmpl = H5A_object(raw_tid)))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_SPLIT; + tmpl->u.split.meta_access = H5C_copy (H5C_FILE_ACCESS, meta_tmpl); + tmpl->u.split.raw_access = H5C_copy (H5C_FILE_ACCESS, raw_tmpl); + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cset_family + * + * Purpose: Sets the low-level driver to stripe the hdf5 address space + * across a family of files. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_family (hid_t tid, hid_t memb_tid) +{ + + H5F_access_t *tmpl = NULL; + H5F_access_t *memb_tmpl = NULL; + + FUNC_ENTER (H5Cset_family, FAIL); + + /* Check arguments */ + if (H5C_FILE_ACCESS != H5Cget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + if (H5C_DEFAULT!=memb_tid && + (H5C_FILE_ACCESS != H5Cget_class(memb_tid) || + NULL == (tmpl = H5A_object(memb_tid)))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_FAMILY; + tmpl->u.fam.memb_access = H5C_copy (H5C_FILE_ACCESS, memb_tmpl); + + FUNC_LEAVE (SUCCEED); +} + + #ifdef HAVE_PARALLEL /*------------------------------------------------------------------------- @@ -903,12 +1203,18 @@ H5Cget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ ) * * Modifications: * + * Robb Matzke, 18 Feb 1998 + * Check all arguments before the template is updated so we don't leave + * the template in a bad state if something goes wrong. Also, the + * template data type changed to allow more generality so all the + * mpi-related stuff is in the `u.mpi' member. The `access_mode' will + * contain only mpi-related flags defined in H5Fpublic.h. + * *------------------------------------------------------------------------- */ herr_t H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) { - int i; H5F_access_t *tmpl = NULL; MPI_Comm lcomm; int mrc; /* MPI return code */ @@ -919,31 +1225,47 @@ H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) if (H5C_FILE_ACCESS != H5Cget_class(tid) || NULL == (tmpl = H5A_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); + "not a file access template"); } + switch (access_mode){ case H5ACC_INDEPENDENT: - /* fall through to next case */ case H5ACC_COLLECTIVE: - tmpl->access_mode = access_mode; - break; + /* okay */ + break; default: - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unknown access_mode"); + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid mpio access mode"); } - /* store a duplicate copy of comm so that user may freely modify comm after this */ - /* call. */ #ifdef LATER - /* need to verify comm and info contain sensible information */ - /* need to duplicate info too but don't know a quick way to do it now. */ + /* + * Need to verify comm and info contain sensible information. + */ #endif - if ((mrc = MPI_Comm_dup(comm, &lcomm)) != MPI_SUCCESS) + + + /* + * Everything looks good. Now go ahead and modify the access template. + */ + tmpl->driver = H5F_LOW_MPIO; + tmpl->u.mpio.access_mode = access_mode; + + /* + * Store a duplicate copy of comm so that user may freely modify comm + * after this call. + */ + if ((mrc = MPI_Comm_dup(comm, &lcomm)) != MPI_SUCCESS) { HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "failure to duplicate communicator"); - tmpl->comm = comm; - tmpl->info = info; + } + tmpl->u.mpio.comm = comm; + +#ifdef LATER + /* Need to duplicate info too but don't know a quick way to do it now */ +#endif + tmpl->u.mpio.info = info; FUNC_LEAVE(SUCCEED); } @@ -1038,8 +1360,8 @@ H5C_copy (H5C_class_t type, const void *src) break; case H5C_FILE_ACCESS: - HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL, - "file access properties are not implemented yet"); + size = sizeof(H5F_access_t); + break; case H5C_DATASET_CREATE: size = sizeof(H5D_create_t); |