diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-04-20 23:54:47 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-04-20 23:54:47 (GMT) |
commit | d7573cbc857f5a2a843a42b3ea05cd9d3770208d (patch) | |
tree | f4e7afbb25303fdc587ab5d95b824ea77cb62407 /src | |
parent | ad790bfa3c700de8ac49ebeaeffe0be1a876b6de (diff) | |
download | hdf5-d7573cbc857f5a2a843a42b3ea05cd9d3770208d.zip hdf5-d7573cbc857f5a2a843a42b3ea05cd9d3770208d.tar.gz hdf5-d7573cbc857f5a2a843a42b3ea05cd9d3770208d.tar.bz2 |
[svn-r12292] Purpose:
Code maintenance
Description:
Remove flexible parallel code
Platforms tested:
FreeBSD 4.11 (sleipnir)
Linux 2.4 (heping)
Solaris 2.9 (shanti)
Linux 2.4/64 (mir)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5AC.c | 291 | ||||
-rw-r--r-- | src/H5Bcache.c | 3 | ||||
-rw-r--r-- | src/H5C.c | 2 | ||||
-rw-r--r-- | src/H5D.c | 2 | ||||
-rw-r--r-- | src/H5Distore.c | 6 | ||||
-rw-r--r-- | src/H5Edefin.h | 8 | ||||
-rw-r--r-- | src/H5Einit.h | 32 | ||||
-rw-r--r-- | src/H5Epubgen.h | 14 | ||||
-rw-r--r-- | src/H5Eterm.h | 8 | ||||
-rw-r--r-- | src/H5F.c | 232 | ||||
-rw-r--r-- | src/H5FD.c | 53 | ||||
-rw-r--r-- | src/H5FDfphdf5.c | 1545 | ||||
-rw-r--r-- | src/H5FDfphdf5.h | 122 | ||||
-rw-r--r-- | src/H5FDmpi.h | 3 | ||||
-rw-r--r-- | src/H5FP.c | 513 | ||||
-rw-r--r-- | src/H5FPclient.c | 1180 | ||||
-rw-r--r-- | src/H5FPprivate.h | 349 | ||||
-rw-r--r-- | src/H5FPpublic.h | 35 | ||||
-rw-r--r-- | src/H5FPserver.c | 2121 | ||||
-rw-r--r-- | src/H5Fprivate.h | 1 | ||||
-rw-r--r-- | src/H5Fsuper.c | 7 | ||||
-rw-r--r-- | src/H5config.h.in | 3 | ||||
-rw-r--r-- | src/H5err.txt | 9 | ||||
-rwxr-xr-x | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/Makefile.in | 53 | ||||
-rw-r--r-- | src/hdf5.h | 1 | ||||
-rwxr-xr-x | src/hdf5.lnt | 1 |
27 files changed, 87 insertions, 6515 deletions
@@ -64,11 +64,6 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ -#ifdef H5_HAVE_FPHDF5 -#include "H5FDfphdf5.h" /* FPHDF5 File Driver */ -#include "H5FPprivate.h" /* Flexible PHDF5 */ -#endif /* H5_HAVE_FPHDF5 */ - #define H5AC_DEBUG_DIRTY_BYTES_CREATION 0 /*------------------------------------------------------------------------- @@ -1316,79 +1311,6 @@ H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void * info->is_protected = FALSE; #ifdef H5_HAVE_PARALLEL -#ifdef H5_HAVE_FPHDF5 - /* In the flexible parallel case, the cache is always empty. Thus - * we simply flush and destroy entry we have just received. - */ - { - H5FD_t * lf; - unsigned req_id; - H5FP_status_t status; - - HDassert(f->shared->lf); - - lf = f->shared->lf; - - if ( H5FD_is_fphdf5_driver(lf) ) { - - /* Newly inserted entry are presumed to be dirty */ - info->is_dirty = TRUE; - - /* - * This is the FPHDF5 driver. Grab a lock for this piece of - * metadata from the SAP. Bail-out quickly if we're unable to do - * that. In the case of the FPHDF5 driver, the local cache is - * turned off. We lock the address then write the data to the SAP. - * We do this because the cache is off and thus cannot retain the - * data which has just been added to it. We will get it from the - * SAP as needed in the future. - */ - result = H5FP_request_lock(H5FD_fphdf5_file_id(lf), addr, - H5FP_LOCK_WRITE, TRUE, &req_id, &status); - - if ( result < 0 ) { -#if 0 - HDfprintf(stdout, "H5AC_set: Lock failed.\n"); - /* - * FIXME: Check the status variable. If the lock is got - * by some other process, we can loop and wait or bail - * out of this function - */ - HDfprintf(stderr, - "Couldn't get lock for metadata at address %a\n", - addr); -#endif /* 0 */ - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTLOCK, FAIL, \ - "can't lock data on SAP!") - } - - /* write the metadata to the SAP. */ - - result = (info->type->flush)(f, dxpl_id, TRUE, - info->addr, info); - - if ( result < 0 ) { - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "unable to flush entry") - } - - /* and then release the lock */ - - result = H5FP_request_release_lock(H5FD_fphdf5_file_id(lf), addr, - TRUE, &req_id, &status); - if ( result < 0 ) { - - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTUNLOCK, FAIL, \ - "can't unlock data on SAP!") - } - - HGOTO_DONE(SUCCEED); - } - } -#endif /* H5_HAVE_FPHDF5 */ -#endif /* H5_HAVE_PARALLEL */ - -#ifdef H5_HAVE_PARALLEL if ( NULL != (aux_ptr = f->shared->cache->aux_ptr) ) { result = H5AC_log_inserted_entry(f, @@ -1503,46 +1425,6 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_ad HDassert(H5F_addr_ne(old_addr, new_addr)); #ifdef H5_HAVE_PARALLEL -#ifdef H5_HAVE_FPHDF5 - /* In the flexible parallel case, the cache is always empty. - * Thus H5AC_rename() has nothing to do by definition. - */ - { - H5FD_t * lf; - - HDassert(f->shared->lf); - - lf = f->shared->lf; - - if ( H5FD_is_fphdf5_driver(lf) ) { - - /* We really should mark the target entry as dirty here, but - * the parameter list doesn't give us the information we need - * to do the job easily. - * - * Fortunately, this function is called exactly once in the - * the library, so it may be possible to finesse the issue. - * If not, I'll have to fix this properly. - * - * In any case, don't check this code in without revisiting this - * issue. - * JRM -- 6/6/05 - * - * On reflection, the code was already broken, as there was no - * way to advise the SAP that a renamed entry had changed its - * address, or was dirty. I will not worry about it for now, - * but the matter must be addressed if we ever get serious - * about FPHDF5. - * JRM -- 7/5/05 - */ - - HGOTO_DONE(SUCCEED); - } - } -#endif /* H5_HAVE_FPHDF5 */ -#endif /* H5_HAVE_PARALLEL */ - -#ifdef H5_HAVE_PARALLEL if ( NULL != (aux_ptr = f->shared->cache->aux_ptr) ) { result = H5AC_log_renamed_entry(f->shared->cache, @@ -1657,11 +1539,7 @@ H5AC_protect(H5F_t *f, haddr_t addr, const void *udata1, void *udata2, - H5AC_protect_t -#ifndef H5_HAVE_FPHDF5 - UNUSED -#endif /* H5_HAVE_FPHDF5 */ - rw) + H5AC_protect_t UNUSED rw) { void * thing = NULL; void * ret_value; /* Return value */ @@ -1676,100 +1554,6 @@ H5AC_protect(H5F_t *f, HDassert(type->load); HDassert(H5F_addr_defined(addr)); -#ifdef H5_HAVE_PARALLEL -#ifdef H5_HAVE_FPHDF5 - /* The following code to support flexible parallel is a direct copy - * from the old version of the cache with slight edits. It should - * be viewed with as much suspicion as the rest of the FP code. - * JRM - 5/26/04 - */ - { - H5FD_t * lf; - unsigned req_id; - H5FP_status_t status; - H5AC_info_t * info; - - HDassert(f->shared->lf); - - lf = f->shared->lf; - - if ( H5FD_is_fphdf5_driver(lf) ) { - - /* - * This is the FPHDF5 driver. Grab a lock for this piece of - * metadata from the SAP. Bail-out quickly if we're unable to do - * that. In the case of the FPHDF5 driver, the local cache is - * effectively turned off. We lock the address then load the data - * from the SAP (or file) directly. We do this because at any one - * time the data on the SAP will be different than what's on the - * local process. - */ - if ( H5FP_request_lock(H5FD_fphdf5_file_id(lf), addr, - rw == H5AC_WRITE ? H5FP_LOCK_WRITE : H5FP_LOCK_READ, - TRUE, &req_id, &status) < 0) { -#if 0 - HDfprintf(stdout, "H5AC_protect: Lock failed.\n"); - /* - * FIXME: Check the status variable. If the lock is got - * by some other process, we can loop and wait or bail - * out of this function - */ - HDfprintf(stderr, - "Couldn't get lock for metadata at address %a\n", - addr); -#endif /* 0 */ - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTLOCK, NULL, \ - "can't lock data on SAP!") - } - - /* Load a thing from the SAP. */ - if ( NULL == (thing = type->load(f, dxpl_id, addr, - udata1, udata2)) ) { - -#if 0 - HDfprintf(stdout, - "%s: Load failed. addr = %a, type->id = %d.\n", - "H5AC_protect", - addr, - (int)(type->id)); -#endif /* 0 */ - HCOMMON_ERROR(H5E_CACHE, H5E_CANTLOAD, "unable to load object") - - if (H5FP_request_release_lock(H5FD_fphdf5_file_id(lf), addr, - TRUE, &req_id, &status) < 0) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTUNLOCK, NULL, \ - "can't unlock data on SAP!") - - HGOTO_DONE(NULL) - } - - info = (H5AC_info_t *)thing; - - HDassert(info->is_dirty == FALSE); - - info->addr = addr; - info->type = type; - info->is_protected = TRUE; - - if ( (type->size)(f, thing, &(info->size)) < 0 ) { - - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGETSIZE, NULL, \ - "Can't get size of thing") - } - - HDassert(info->size < H5C_MAX_ENTRY_SIZE); - - info->next = NULL; - info->prev = NULL; - info->aux_next = NULL; - info->aux_prev = NULL; - - HGOTO_DONE(thing) - } - } -#endif /* H5_HAVE_FPHDF5 */ -#endif /* H5_HAVE_PARALLEL */ - thing = H5C_protect(f, dxpl_id, H5AC_noblock_dxpl_id, @@ -1922,79 +1706,6 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, } #ifdef H5_HAVE_PARALLEL -#ifdef H5_HAVE_FPHDF5 - /* The following code to support flexible parallel is a direct copy - * from the old version of the cache with slight edits. It should - * be viewed with as much suspicion as the rest of the FP code. - * JRM - 5/26/04 - */ - { - H5FD_t * lf; - unsigned req_id; - H5FP_status_t status; - - HDassert(f->shared->lf); - - lf = f->shared->lf; - - if ( H5FD_is_fphdf5_driver(lf) ) { - - HDassert( ((H5AC_info_t *)thing)->is_protected ); - - ((H5AC_info_t *)thing)->is_protected = FALSE; - - /* mark the entry as dirty if appropriate. JRM - 6/6/05 */ - ((H5AC_info_t *)thing)->is_dirty |= - (flags & H5AC__DIRTIED_FLAG) ? TRUE : FALSE; - - /* - * FIXME: If the metadata is *really* deleted at this point - * (deleted == TRUE), we need to send a request to the SAP - * telling it to remove that bit of metadata from its cache. - */ - /* the deleted parameter has been replaced with the flags - * parameter. The actual value of deleted is still passed - * in as a bit in flags. If it is needed, it can be extracted - * as follows: - * - * deleted = ( (flags & H5C__DELETED_FLAG) != 0 ); - * - * JRM -- 1/6/05 - */ - if ( H5FP_request_release_lock(H5FD_fphdf5_file_id(lf), addr, - TRUE, &req_id, &status) < 0 ) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTUNLOCK, FAIL, \ - "can't unlock data on SAP!") - - /* Flush a thing to the SAP */ - if ( thing ) { - - if ( ((H5AC_info_t *)thing)->is_dirty ) { - - if ( type->flush(f, dxpl_id, FALSE, addr, thing) < 0 ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "unable to flush object") - } - } - - /* Always clear/delete the object from the local cache */ - if ( type->clear(f, thing, TRUE) < 0 ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, \ - "unable to free object") - - } - } - - /* Exit now. The FPHDF5 stuff is finished. */ - HGOTO_DONE(SUCCEED) - } - } -#endif /* H5_HAVE_FPHDF5 */ -#endif /* H5_HAVE_PARALLEL */ - -#ifdef H5_HAVE_PARALLEL if ( ( dirtied ) && ( ((H5AC_info_t *)thing)->is_dirty == FALSE ) && ( NULL != (aux_ptr = f->shared->cache->aux_ptr) ) ) { diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 443b482..6f8e259 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -80,8 +80,7 @@ const H5AC_class_t H5AC_BT[1] = {{ /*------------------------------------------------------------------------- * Function: H5B_serialize * - * Purpose: Serialize the data structure for writing to disk or - * storing on the SAP (for FPHDF5). + * Purpose: Serialize the data structure for writing to disk. * * Return: Success: SUCCEED * Failure: FAIL @@ -7026,7 +7026,7 @@ H5C_flush_single_entry(H5F_t * f, } /* Sanity check transfer mode */ - HDassert( xfer_mode == H5FD_MPIO_COLLECTIVE || IS_H5FD_FPHDF5(f) ); + HDassert( xfer_mode == H5FD_MPIO_COLLECTIVE ); } #endif /* NDEBUG */ @@ -4068,7 +4068,7 @@ H5D_flush(const H5F_t *f, hid_t dxpl_id, unsigned flags) case H5D_CHUNKED: /* Flush the raw data cache */ - if (H5D_istore_flush(dataset, dxpl_id, flags & (H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLEAR_ONLY)) < 0) + if (H5D_istore_flush(dataset, dxpl_id, flags & H5F_FLUSH_INVALIDATE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush raw data cache") break; diff --git a/src/H5Distore.c b/src/H5Distore.c index bcf5fee..2978f72 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -1352,11 +1352,7 @@ H5D_istore_flush (H5D_t *dset, hid_t dxpl_id, unsigned flags) for (ent=rdcc->head; ent; ent=next) { next = ent->next; - if ((flags&H5F_FLUSH_CLEAR_ONLY)) { - /* Just mark cache entry as clean */ - ent->dirty = FALSE; - } /* end if */ - else if ((flags&H5F_FLUSH_INVALIDATE)) { + if ((flags&H5F_FLUSH_INVALIDATE)) { if (H5D_istore_preempt(&io_info, ent, TRUE )<0) nerrors++; } else { diff --git a/src/H5Edefin.h b/src/H5Edefin.h index f9c4fb5..91b9b9c 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -24,7 +24,6 @@ hid_t H5E_DATASET_g = FAIL; /* Dataset */ hid_t H5E_FUNC_g = FAIL; /* Function entry/exit */ hid_t H5E_STORAGE_g = FAIL; /* Data storage */ hid_t H5E_FILE_g = FAIL; /* File accessability */ -hid_t H5E_FPHDF5_g = FAIL; /* Flexible Parallel HDF5 */ hid_t H5E_SYM_g = FAIL; /* Symbol table */ hid_t H5E_VFL_g = FAIL; /* Virtual File Layer */ hid_t H5E_INTERNAL_g = FAIL; /* Internal error (too specific to document in detail) */ @@ -61,6 +60,7 @@ hid_t H5E_FCNTL_g = FAIL; /* File control (fcntl) failed */ /* Resource errors */ hid_t H5E_NOSPACE_g = FAIL; /* No space available for allocation */ +hid_t H5E_CANTALLOC_g = FAIL; /* Can't allocate space */ hid_t H5E_CANTCOPY_g = FAIL; /* Unable to copy object */ hid_t H5E_CANTFREE_g = FAIL; /* Unable to free object */ hid_t H5E_ALREADYEXISTS_g = FAIL; /* Object already exists */ @@ -93,12 +93,6 @@ hid_t H5E_CANTDELETE_g = FAIL; /* Can't delete message */ hid_t H5E_BADITER_g = FAIL; /* Iteration failed */ hid_t H5E_CANTPACK_g = FAIL; /* Can't pack messages */ -/* FPHDF5 errors */ -hid_t H5E_CANTRECV_g = FAIL; /* Can't receive messages from processes */ -hid_t H5E_CANTSENDMDATA_g = FAIL; /* Can't send metadata message */ -hid_t H5E_CANTCHANGE_g = FAIL; /* Can't register change with server */ -hid_t H5E_CANTALLOC_g = FAIL; /* Can't allocate from file */ - /* System level errors */ hid_t H5E_SYSERRSTR_g = FAIL; /* System error message */ diff --git a/src/H5Einit.h b/src/H5Einit.h index 32f9037..b2ad44e 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -43,11 +43,6 @@ if((msg = H5E_create_msg(cls, H5E_MAJOR, "File accessability"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_FILE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_FPHDF5_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Flexible Parallel HDF5"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_FPHDF5_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_SYM_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Symbol table"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") @@ -207,6 +202,11 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "No space available for allocation"))== HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_NOSPACE_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTALLOC_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't allocate space"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTALLOC_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_CANTCOPY_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to copy object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") @@ -331,28 +331,6 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't pack messages"))==NULL) if((H5E_CANTPACK_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* FPHDF5 errors */ -assert(H5E_CANTRECV_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't receive messages from processes"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTRECV_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTSENDMDATA_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't send metadata message"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTSENDMDATA_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTCHANGE_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't register change with server"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTCHANGE_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_CANTALLOC_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't allocate from file"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_CANTALLOC_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - /* System level errors */ assert(H5E_SYSERRSTR_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MINOR, "System error message"))==NULL) diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index d16c95e..64ccf76 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -27,7 +27,6 @@ #define H5E_FUNC (H5OPEN H5E_FUNC_g) #define H5E_STORAGE (H5OPEN H5E_STORAGE_g) #define H5E_FILE (H5OPEN H5E_FILE_g) -#define H5E_FPHDF5 (H5OPEN H5E_FPHDF5_g) #define H5E_SYM (H5OPEN H5E_SYM_g) #define H5E_VFL (H5OPEN H5E_VFL_g) #define H5E_INTERNAL (H5OPEN H5E_INTERNAL_g) @@ -55,7 +54,6 @@ H5_DLLVAR hid_t H5E_DATASET_g; /* Dataset */ H5_DLLVAR hid_t H5E_FUNC_g; /* Function entry/exit */ H5_DLLVAR hid_t H5E_STORAGE_g; /* Data storage */ H5_DLLVAR hid_t H5E_FILE_g; /* File accessability */ -H5_DLLVAR hid_t H5E_FPHDF5_g; /* Flexible Parallel HDF5 */ H5_DLLVAR hid_t H5E_SYM_g; /* Symbol table */ H5_DLLVAR hid_t H5E_VFL_g; /* Virtual File Layer */ H5_DLLVAR hid_t H5E_INTERNAL_g; /* Internal error (too specific to document in detail) */ @@ -100,6 +98,7 @@ H5_DLLVAR hid_t H5E_FCNTL_g; /* File control (fcntl) failed */ /* Resource errors */ #define H5E_NOSPACE (H5OPEN H5E_NOSPACE_g) +#define H5E_CANTALLOC (H5OPEN H5E_CANTALLOC_g) #define H5E_CANTCOPY (H5OPEN H5E_CANTCOPY_g) #define H5E_CANTFREE (H5OPEN H5E_CANTFREE_g) #define H5E_ALREADYEXISTS (H5OPEN H5E_ALREADYEXISTS_g) @@ -108,6 +107,7 @@ H5_DLLVAR hid_t H5E_FCNTL_g; /* File control (fcntl) failed */ #define H5E_CANTGC (H5OPEN H5E_CANTGC_g) #define H5E_CANTGETSIZE (H5OPEN H5E_CANTGETSIZE_g) H5_DLLVAR hid_t H5E_NOSPACE_g; /* No space available for allocation */ +H5_DLLVAR hid_t H5E_CANTALLOC_g; /* Can't allocate space */ H5_DLLVAR hid_t H5E_CANTCOPY_g; /* Unable to copy object */ H5_DLLVAR hid_t H5E_CANTFREE_g; /* Unable to free object */ H5_DLLVAR hid_t H5E_ALREADYEXISTS_g; /* Object already exists */ @@ -156,16 +156,6 @@ H5_DLLVAR hid_t H5E_CANTDELETE_g; /* Can't delete message */ H5_DLLVAR hid_t H5E_BADITER_g; /* Iteration failed */ H5_DLLVAR hid_t H5E_CANTPACK_g; /* Can't pack messages */ -/* FPHDF5 errors */ -#define H5E_CANTRECV (H5OPEN H5E_CANTRECV_g) -#define H5E_CANTSENDMDATA (H5OPEN H5E_CANTSENDMDATA_g) -#define H5E_CANTCHANGE (H5OPEN H5E_CANTCHANGE_g) -#define H5E_CANTALLOC (H5OPEN H5E_CANTALLOC_g) -H5_DLLVAR hid_t H5E_CANTRECV_g; /* Can't receive messages from processes */ -H5_DLLVAR hid_t H5E_CANTSENDMDATA_g; /* Can't send metadata message */ -H5_DLLVAR hid_t H5E_CANTCHANGE_g; /* Can't register change with server */ -H5_DLLVAR hid_t H5E_CANTALLOC_g; /* Can't allocate from file */ - /* System level errors */ #define H5E_SYSERRSTR (H5OPEN H5E_SYSERRSTR_g) H5_DLLVAR hid_t H5E_SYSERRSTR_g; /* System error message */ diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 4f92303..e6795cf 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -25,7 +25,6 @@ H5E_DATASET_g= H5E_FUNC_g= H5E_STORAGE_g= H5E_FILE_g= -H5E_FPHDF5_g= H5E_SYM_g= H5E_VFL_g= H5E_INTERNAL_g= @@ -63,6 +62,7 @@ H5E_FCNTL_g= /* Resource errors */ H5E_NOSPACE_g= +H5E_CANTALLOC_g= H5E_CANTCOPY_g= H5E_CANTFREE_g= H5E_ALREADYEXISTS_g= @@ -95,12 +95,6 @@ H5E_CANTDELETE_g= H5E_BADITER_g= H5E_CANTPACK_g= -/* FPHDF5 errors */ -H5E_CANTRECV_g= -H5E_CANTSENDMDATA_g= -H5E_CANTCHANGE_g= -H5E_CANTALLOC_g= - /* System level errors */ H5E_SYSERRSTR_g= @@ -27,7 +27,6 @@ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free lists */ -#include "H5FPprivate.h" /* Flexible parallel */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ @@ -1889,127 +1888,35 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d * empty or not. */ if (0==H5FD_get_eof(lf) && (flags & H5F_ACC_RDWR)) { -#ifdef H5_HAVE_FPHDF5 - hsize_t buf_size=0; /* Size of buffer needed to hold superblock info */ -#endif /* H5_HAVE_FPHDF5 */ void *buf=NULL; /* Buffer to hold superblock info */ /* * We've just opened a fresh new file (or truncated one). We need * to create & write the superblock. */ -#ifdef H5_HAVE_FPHDF5 - if (!H5FD_is_fphdf5_driver(lf) || H5FD_fphdf5_is_captain(lf)) { -#endif /* H5_HAVE_FPHDF5 */ - /* Initialize information about the superblock and allocate space for it */ - if (( -#ifdef H5_HAVE_FPHDF5 - buf_size= -#endif /* H5_HAVE_FPHDF5 */ - H5F_init_superblock(file, dxpl_id)) == 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to allocate file superblock") - - /* Create and open the root group */ - /* (This must be after the space for the superblock is allocated in - * the file) - */ - if (H5G_mkroot(file, dxpl_id, NULL)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") - -#ifdef H5_HAVE_FPHDF5 - if (H5FD_is_fphdf5_driver(lf)) { - /* Allocate room for the superblock buffer */ - H5_CHECK_OVERFLOW(buf_size, hsize_t, size_t); - if((buf=H5MM_malloc((size_t)buf_size))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for superblock buffer") - } /* end if */ -#endif /* H5_HAVE_FPHDF5 */ - - /* Write the superblock to the file */ - /* (This must be after the root group is created, since the root - * group's symbol table entry is part of the superblock) - */ - if (H5F_write_superblock(file, dxpl_id, buf) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to write file superblock") + /* Initialize information about the superblock and allocate space for it */ + if (H5F_init_superblock(file, dxpl_id) == 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to allocate file superblock") -#ifdef H5_HAVE_FPHDF5 - } /* end if */ - - /* If this file is using the FPHDF5 driver, broadcast the superblock - * from the captain to the other clients + /* Create and open the root group */ + /* (This must be after the space for the superblock is allocated in + * the file) */ - if (H5FD_is_fphdf5_driver(lf)) { - int mrc; /*MPI return code */ - H5FP_super_t super_info; /* Superblock information */ - - /* Captain sets up the information */ - if (H5FD_fphdf5_is_captain(lf)) { - super_info.addr=shared->super_addr; - super_info.size=buf_size; - } /* end if */ - - /* Broadcast the superblock information */ - if ((mrc = MPI_Bcast(&super_info, 1, H5FP_super, (int)H5FP_capt_barrier_rank, - H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mrc) - - /* Non-captain clients allocate the buffer now */ - if (!H5FD_fphdf5_is_captain(lf)) { - /* Allocate room for the superblock buffer */ - H5_CHECK_OVERFLOW(super_info.size, hsize_t, size_t); - if((buf = H5MM_malloc((size_t)super_info.size))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for superblock buffer") - } /* end if */ - - /* Broadcast the actual superblock */ - H5_CHECK_OVERFLOW(super_info.size, hsize_t, int); - if ((mrc = MPI_Bcast(buf, (int)super_info.size, MPI_BYTE, (int)H5FP_capt_barrier_rank, - H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mrc) - - if (!H5FD_fphdf5_is_captain(lf)) { - if (H5F_read_superblock(file, dxpl_id, &root_loc, super_info.addr, - buf, (size_t)super_info.size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") - } + if (H5G_mkroot(file, dxpl_id, NULL)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") - /* The following barrier ensures that all set eoa operations - * associated with creating the superblock are complete before - * we attempt any allocations. - * JRM - 4/13/04 - */ - if ( (mrc = MPI_Barrier(H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS ) - HMPI_GOTO_ERROR(NULL, "MPI_Barrier failed", mrc) - - if (!H5FD_fphdf5_is_captain(lf)) { - if (H5G_mkroot(file, dxpl_id, &root_loc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") - } + /* Write the superblock to the file */ + /* (This must be after the root group is created, since the root + * group's symbol table entry is part of the superblock) + */ + if (H5F_write_superblock(file, dxpl_id, buf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to write file superblock") - /* All clients free the buffer used for broadcasting the superblock */ - buf = H5MM_xfree (buf); - } /* end if */ -#endif /* H5_HAVE_FPHDF5 */ } else if (1 == shared->nrefs) { -#ifdef H5_HAVE_FPHDF5 - int mrc; /*MPI return code */ -#endif /* H5_HAVE_FPHDF5 */ - /* Read the superblock if it hasn't been read before. */ if(H5F_read_superblock(file, dxpl_id, &root_loc, HADDR_UNDEF, NULL, (size_t)0) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") -#ifdef H5_HAVE_FPHDF5 - if (H5FD_is_fphdf5_driver(lf)) { - /* reading the superblock generates lots of set_eoa calls. To avoid - * race conditions with allocations, make sure that everyone is done - * reading the superblock before we proceed. - */ - if ( (mrc = MPI_Barrier(H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS ) - HMPI_GOTO_ERROR(NULL, "MPI_Barrier failed", mrc) - } /* end if */ -#endif /* H5_HAVE_FPHDF5 */ - /* Make sure we can open the root group */ if (H5G_mkroot(file, dxpl_id, &root_loc)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") @@ -2430,21 +2337,9 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") /* flush (and invalidate) the entire meta data cache */ - /* - * FIXME: This should be CLEAR_ONLY for non-captain processes. - * Need to fix the H5G_mkroot() call so that only the captain - * allocates object headers (calls the H5O_init function...via a - * lot of other functions first).... - */ - H5AC_flags = 0; - if ( (flags & H5F_FLUSH_INVALIDATE) != 0 ) H5AC_flags |= H5AC__FLUSH_INVALIDATE_FLAG; - - if ( (flags & H5F_FLUSH_CLEAR_ONLY) != 0 ) - H5AC_flags |= H5AC__FLUSH_CLEAR_ONLY_FLAG; - if (H5AC_flush(f, dxpl_id, H5AC_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush meta data cache") @@ -2454,53 +2349,29 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) * "small data" blocks back to the free lists in the file. */ if (flags & H5F_FLUSH_INVALIDATE) { -#ifdef H5_HAVE_FPHDF5 - /* - * If this is not the SAP, then we want to send a "free" - * command to the SAP to free up the EOMA and EOSDA - * information. This might also update the EOA information on - * the clients... - */ - if (H5FD_is_fphdf5_driver(f->shared->lf) && !H5FD_fphdf5_is_sap(f->shared->lf)) { - unsigned req_id = 0; - H5FP_status_t status = H5FP_STATUS_OK; - - /* Send the request to the SAP */ - if (H5FP_request_update_eoma_eosda(f->shared->lf, - &req_id, &status) != SUCCEED) - /* FIXME: Should we check the "status" variable here? */ - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTFREE, FAIL, - "server couldn't free from file") - } else { -#endif /* H5_HAVE_FPHDF5 */ - - if (f->shared->lf->feature_flags & H5FD_FEAT_AGGREGATE_METADATA) { - /* Return the unused portion of the metadata block to a free list */ - if (f->shared->lf->eoma != 0) - if (H5FD_free(f->shared->lf, H5FD_MEM_DEFAULT, dxpl_id, - f->shared->lf->eoma, f->shared->lf->cur_meta_block_size) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free metadata block") - - /* Reset metadata block information, just in case */ - f->shared->lf->eoma=0; - f->shared->lf->cur_meta_block_size=0; - } /* end if */ - - if (f->shared->lf->feature_flags & H5FD_FEAT_AGGREGATE_SMALLDATA) { - /* Return the unused portion of the "small data" block to a free list */ - if (f->shared->lf->eosda != 0) - if (H5FD_free(f->shared->lf, H5FD_MEM_DRAW, dxpl_id, - f->shared->lf->eosda, f->shared->lf->cur_sdata_block_size) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free 'small data' block") - - /* Reset "small data" block information, just in case */ - f->shared->lf->eosda=0; - f->shared->lf->cur_sdata_block_size=0; - } /* end if */ - -#ifdef H5_HAVE_FPHDF5 - } -#endif /* H5_HAVE_FPHDF5 */ + if (f->shared->lf->feature_flags & H5FD_FEAT_AGGREGATE_METADATA) { + /* Return the unused portion of the metadata block to a free list */ + if (f->shared->lf->eoma != 0) + if (H5FD_free(f->shared->lf, H5FD_MEM_DEFAULT, dxpl_id, + f->shared->lf->eoma, f->shared->lf->cur_meta_block_size) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free metadata block") + + /* Reset metadata block information, just in case */ + f->shared->lf->eoma=0; + f->shared->lf->cur_meta_block_size=0; + } /* end if */ + + if (f->shared->lf->feature_flags & H5FD_FEAT_AGGREGATE_SMALLDATA) { + /* Return the unused portion of the "small data" block to a free list */ + if (f->shared->lf->eosda != 0) + if (H5FD_free(f->shared->lf, H5FD_MEM_DRAW, dxpl_id, + f->shared->lf->eosda, f->shared->lf->cur_sdata_block_size) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free 'small data' block") + + /* Reset "small data" block information, just in case */ + f->shared->lf->eosda=0; + f->shared->lf->cur_sdata_block_size=0; + } /* end if */ } /* end if */ /* Write the superblock to disk */ @@ -2737,31 +2608,10 @@ H5F_try_close(H5F_t *f) /* Flush at this point since the file will be closed */ /* (Only try to flush the file if it was opened with write access) */ if(f->intent&H5F_ACC_RDWR) { -#ifdef H5_HAVE_FPHDF5 - /* - * We only want the captain to perform the flush of the metadata - * to the file. - */ - if (!H5FD_is_fphdf5_driver(f->shared->lf) || - H5FD_fphdf5_is_captain(f->shared->lf)) { -#endif /* H5_HAVE_FPHDF5 */ - - /* Flush and destroy all caches */ - if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL, - H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") - -#ifdef H5_HAVE_FPHDF5 - } else { - /* - * If this isn't the captain process, flush but only clear - * the flags. - */ - if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL, - H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING | H5F_FLUSH_CLEAR_ONLY) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") - } /* end if */ -#endif /* H5_HAVE_FPHDF5 */ + /* Flush and destroy all caches */ + if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL, + H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ /* @@ -44,9 +44,6 @@ #include "H5FDstdio.h" /* Standard C buffered I/O */ #include "H5FDstream.h" /* In-memory files streamed via sockets */ #include "H5FLprivate.h" /* Free lists */ -#ifdef H5_HAVE_FPHDF5 -#include "H5FPprivate.h" /* Flexible Parallel HDF5 */ -#endif /* H5_HAVE_FPHDF5 */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ @@ -169,9 +166,6 @@ H5FD_term_interface(void) #ifdef H5_HAVE_PARALLEL H5FD_mpio_term(); H5FD_mpiposix_term(); -#ifdef H5_HAVE_FPHDF5 - H5FD_fphdf5_term(); -#endif /* H5_HAVE_FPHDF5 */ #endif /* H5_HAVE_PARALLEL */ #ifdef H5_HAVE_STREAM H5FD_stream_term(); @@ -1484,14 +1478,6 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_alloc * Purpose: Private version of H5FDalloc(). - * - * For FPHDF5, the dxpl_id is meaningless. The only place it - * is likely to be used is in the H5FD_free() function where - * it can make a call to H5FD_write() (which needs this - * property list). FPHDF5 doesn't have metadata accumulation - * turned on, so it won't ever call the H5FD_write() - * function. - * * Return: Success: The format address of the new file memory. * Failure: The undefined address HADDR_UNDEF * Programmer: Robb Matzke @@ -1526,25 +1512,6 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); -#ifdef H5_HAVE_FPHDF5 - /* - * When we're using the FPHDF5 driver, allocate from the SAP. If this - * is the SAP executing this code, then skip the send to the SAP and - * try to do the actual allocations. - */ - if ( H5FD_is_fphdf5_driver(file) && !H5FD_fphdf5_is_sap(file) ) { - haddr_t addr; - - if ( (addr = H5FP_client_alloc(file, type, dxpl_id, size)) - == HADDR_UNDEF) { - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTALLOC, HADDR_UNDEF, - "allocation failed.") - } else { - HGOTO_DONE(addr) - } - } -#endif /* H5_HAVE_FPHDF5 */ - #ifdef H5F_DEBUG if (H5DEBUG(F)) HDfprintf(H5DEBUG(F), "%s: alignment=%Hd, threshold=%Hd, size=%Hd\n", @@ -2251,26 +2218,6 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t si assert(file->cls); assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); -#ifdef H5_HAVE_FPHDF5 - /* - * When we're using the FPHDF5 driver, free with the SAP. If this - * is the SAP executing this code, then skip the send to the SAP and - * try to do the actual free. - */ - if (H5FD_is_fphdf5_driver(file) && !H5FD_fphdf5_is_sap(file)) { - unsigned req_id; - H5FP_status_t status; - - /* Send the request to the SAP */ - if (H5FP_request_free(file, type, addr, size, &req_id, &status) != SUCCEED) - /* FIXME: Should we check the "status" variable here? */ - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTFREE, FAIL, "server couldn't free from file") - - /* We've succeeded -- return the value */ - HGOTO_DONE(ret_value) - } -#endif /* H5_HAVE_FPHDF5 */ - if (!H5F_addr_defined(addr) || addr>file->maxaddr || H5F_addr_overflow(addr, size) || addr+size>file->maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid region") diff --git a/src/H5FDfphdf5.c b/src/H5FDfphdf5.c deleted file mode 100644 index c600715..0000000 --- a/src/H5FDfphdf5.c +++ /dev/null @@ -1,1545 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_fphdf5_init_interface - - -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ - -#ifdef H5_HAVE_FPHDF5 - -#include "H5FPprivate.h" /* Flexible PHDF5 */ - -/* - * The driver identification number, initialized at runtime if - * H5_HAVE_FPHDF5 is defined. This allows applications to still have - * the H5FD_FPHDF5 "constants" in their source code (it also makes this - * file strictly ANSI compliant when H5_HAVE_FPHDF5 isn't defined) - */ -static hid_t H5FD_FPHDF5_g = 0; - -/* - * Private Prototypes - */ - -/* - * Callbacks - */ -static void *H5FD_fphdf5_fapl_get(H5FD_t *_file); -static H5FD_t *H5FD_fphdf5_open(const char *name, unsigned flags, - hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_fphdf5_close(H5FD_t *_file); -static herr_t H5FD_fphdf5_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_fphdf5_get_eoa(const H5FD_t *_file); -static herr_t H5FD_fphdf5_set_eoa(H5FD_t *_file, haddr_t addr); -static haddr_t H5FD_fphdf5_get_eof(const H5FD_t *_file); -static herr_t H5FD_fphdf5_get_handle(H5FD_t *_file, hid_t fapl, - void **file_handle); -static herr_t H5FD_fphdf5_read(H5FD_t *_file, H5FD_mem_t mem_type, hid_t dxpl_id, - haddr_t addr, size_t size, void *buf); -static herr_t H5FD_fphdf5_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, size_t size, const void *buf); -static herr_t H5FD_fphdf5_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); -static int H5FD_fphdf5_mpi_rank(const H5FD_t *_file); -static int H5FD_fphdf5_mpi_size(const H5FD_t *_file); -static MPI_Comm H5FD_fphdf5_barrier_communicator(const H5FD_t *_file); - -/* - * FPHDF5-specific file access properties - */ -typedef struct H5FD_fphdf5_fapl_t { - MPI_Comm comm; /*communicator */ - MPI_Comm barrier_comm; /*barrier communicator */ - MPI_Info info; /*file information */ - unsigned sap_rank; /*SAP's rank */ - unsigned capt_rank; /*captain rank */ -} H5FD_fphdf5_fapl_t; - -/* - * The FPHDF5 file driver information - */ -const H5FD_class_mpi_t H5FD_fphdf5_g = { - { /* Start of superclass information */ - "fphdf5", /*name */ - HADDR_MAX, /*maxaddr */ - H5F_CLOSE_SEMI, /*fc_degree */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_fphdf5_fapl_t), /*fapl_size */ - H5FD_fphdf5_fapl_get, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_fphdf5_open, /*open */ - H5FD_fphdf5_close, /*close */ - NULL, /*cmp */ - H5FD_fphdf5_query, /*query */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_fphdf5_get_eoa, /*get_eoa */ - H5FD_fphdf5_set_eoa, /*set_eoa */ - H5FD_fphdf5_get_eof, /*get_eof */ - H5FD_fphdf5_get_handle, /*get_handle */ - H5FD_fphdf5_read, /*read */ - H5FD_fphdf5_write, /*write */ - H5FD_fphdf5_flush, /*flush */ - NULL, /*lock */ - NULL, /*unlock */ - H5FD_FLMAP_SINGLE /*fl_map */ - }, /* End of superclass information */ - H5FD_fphdf5_mpi_rank, /*get_rank */ - H5FD_fphdf5_mpi_size, /*get_size */ - H5FD_fphdf5_barrier_communicator /*get_comm */ -}; - - -/*-------------------------------------------------------------------------- -NAME - H5FD_fphdf5_init_interface -- Initialize interface-specific information -USAGE - herr_t H5FD_fphdf5_init_interface() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_fphdf5_init currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD_fphdf5_init_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_fphdf5_init_interface) - - FUNC_LEAVE_NOAPI(H5FD_fphdf5_init()) -} /* H5FD_fphdf5_init_interface() */ - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_init - * Purpose: Initialize this driver by registering the driver with the - * library. - * Return: Success: The driver ID for the FPHDF5 driver. - * Failure: Doesn't fail. - * Programmer: Bill Wendling - * 30. January 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -hid_t -H5FD_fphdf5_init(void) -{ - hid_t ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_init, FAIL) - - if (H5Iget_type(H5FD_FPHDF5_g) != H5I_VFL) - H5FD_FPHDF5_g = H5FD_register((const H5FD_class_t *)&H5FD_fphdf5_g,sizeof(H5FD_class_mpi_t)); - - /* Set return value */ - ret_value = H5FD_FPHDF5_g; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*--------------------------------------------------------------------------- - * Function: H5FD_fphdf5_term - * - * Purpose: Shut down the VFD - * - * Return: <none> - * - * Programmer: Quincey Koziol - * Friday, Jan 30, 2004 - * - * Modification: - * - *--------------------------------------------------------------------------- - */ -void -H5FD_fphdf5_term(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_fphdf5_term) - - /* Reset VFL ID */ - H5FD_FPHDF5_g=0; - - FUNC_LEAVE_NOAPI_VOID -} /* end H5FD_fphdf5_term() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pset_fapl_fphdf5 - * Purpose: Store the user supplied MPIO communicator COMM and INFO - * in the file access property list FAPL_ID which can then - * be used to create and/or open the file. This function is - * available only in the parallel HDF5 library and is not - * collective. - * - * COMM is the MPI communicator to be used for file open as - * defined in MPI_FILE_OPEN of MPI-2. This function does not - * make a duplicated communicator. Any modification to COMM - * after this function call returns may have an indeterminate - * effect on the access property list. Users should not - * modify the communicator while it is defined in a property - * list. - * - * INFO is the MPI info object to be used for file open as - * defined in MPI_FILE_OPEN of MPI-2. This function does not - * make a duplicated info. Any modification to info after - * this function call returns may have an indeterminate effect - * on the access property list. Users should not modify the - * info while it is defined in a property list. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling - * 30. January 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -herr_t -H5Pset_fapl_fphdf5(hid_t fapl_id, MPI_Comm comm, MPI_Comm barrier_comm, - MPI_Info info, unsigned sap_rank) -{ - H5FD_fphdf5_fapl_t fa; - H5P_genplist_t *plist; - int mrc, comm_size; - herr_t ret_value; - - FUNC_ENTER_API(H5Pset_fapl_fphdf5, FAIL) - H5TRACE5("e","iMcMcMiIu",fapl_id,comm,barrier_comm,info,sap_rank); - - if (fapl_id == H5P_DEFAULT) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - - /* Check arguments */ - if ((plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") - - if ((mrc = MPI_Comm_size(comm, &comm_size)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_size failed", mrc) - - /* Initialize driver specific properties */ - fa.comm = comm; - fa.barrier_comm = barrier_comm; - fa.info = info; - fa.sap_rank = sap_rank; - fa.capt_rank = (sap_rank + 1) % comm_size; - - ret_value = H5P_set_driver(plist, H5FD_FPHDF5, &fa); - -done: - FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Pget_fapl_fphdf5 - * Purpose: If the file access property list is set to the - * H5FD_FPHDF5 driver then this function returns the MPI - * communicator and information through the COMM and INFO - * pointers. - * Return: Success: SUCCEED with the communicator and information - * returned through the COMM and INFO arguments - * if non-null. Neither piece of information is - * copied and they are therefore valid only - * until the file access property list is - * modified or closed. - * Failure: FAIL - * Programmer: Bill Wendling - * 30. January 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -herr_t -H5Pget_fapl_fphdf5(hid_t fapl_id, MPI_Comm *comm, MPI_Comm *barrier_comm, - MPI_Info *info, unsigned *sap_rank, unsigned *capt_rank) -{ - H5FD_fphdf5_fapl_t *fa; - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(H5Pget_fapl_fphdf5, FAIL) - H5TRACE6("e","i*Mc*Mc*Mi*Iu*Iu",fapl_id,comm,barrier_comm,info,sap_rank, - capt_rank); - - if ((plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") - - if (H5P_get_driver(plist) != H5FD_FPHDF5) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - - if ((fa = H5P_get_driver_info(plist)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - - if (comm) - *comm = fa->comm; - - if (barrier_comm) - *barrier_comm = fa->barrier_comm; - - if (info) - *info = fa->info; - - if (sap_rank) - *sap_rank = fa->sap_rank; - - if (capt_rank) - *capt_rank = fa->capt_rank; - -done: - FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_file_id - * Purpose: Returns the file ID for the file. - * Return: Success: File ID - * Failure: Doesn't fail - * Programmer: Bill Wendling - * 19. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -unsigned -H5FD_fphdf5_file_id(H5FD_t *_file) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; - unsigned ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_file_id, 0) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* Set return value */ - ret_value = file->file_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_is_sap - * Purpose: Asks the question "Is this process the SAP?". - * Return: Success: Non-zero if it is, 0 otherwise - * Failure: Doesn't fails - * Programmer: Bill Wendling - * 19. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -hbool_t -H5FD_fphdf5_is_sap(const H5FD_t *_file) -{ - const H5FD_fphdf5_t *file = (const H5FD_fphdf5_t*)_file; - hbool_t ret_value = FALSE; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_is_sap, FALSE) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* Set return value */ - ret_value = ((unsigned)file->mpi_rank == H5FP_sap_rank); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_is_captain - * Purpose: Asks the question "Is this process the captain?". - * Return: Success: Non-zero if it is, 0 otherwise - * Failure: Doesn't fails - * Programmer: Bill Wendling - * 19. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -hbool_t -H5FD_fphdf5_is_captain(H5FD_t *_file) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; - hbool_t ret_value = FALSE; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_is_captain, FALSE) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* Set return value */ - ret_value = ((unsigned)file->mpi_rank == H5FP_capt_rank); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_is_fphdf5_driver - * Purpose: Asks the question "Is this an FPHDF5 driver?". - * Return: Success: Non-zero if it is, 0 otherwise - * Failure: Doesn't fails - * Programmer: Bill Wendling - * 26. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -hbool_t -H5FD_is_fphdf5_driver(H5FD_t *_file) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; - hbool_t ret_value = FALSE; - - FUNC_ENTER_NOAPI(H5FD_is_fphdf5_driver, FALSE) - - /* check args */ - assert(file); - - /* Set return value */ - ret_value = file->pub.driver_id == H5FD_FPHDF5; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Pset_dxpl_fphdf5 - * Purpose: Set the data transfer property list DXPL_ID to use - * transfer mode XFER_MODE. The property list can then be - * used to control the I/O transfer mode during data I/O - * operations. The valid transfer modes are: - * - * H5FD_MPIO_INDEPENDENT: - * Use independent I/O access (the default). - * - * H5FD_MPIO_COLLECTIVE: - * Use collective I/O access. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling - * 10. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -herr_t -H5Pset_dxpl_fphdf5(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode) -{ - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(H5Pset_dxpl_fphdf5, FAIL) - H5TRACE2("e","iDt",dxpl_id,xfer_mode); - - if (dxpl_id == H5P_DEFAULT) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - - /* Check arguments */ - if ((plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") - - if (xfer_mode != H5FD_MPIO_INDEPENDENT && xfer_mode != H5FD_MPIO_COLLECTIVE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode") - - /* Set the transfer mode */ - if (H5P_set(plist, H5D_XFER_IO_XFER_MODE_NAME, &xfer_mode) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") - - /* Initialize driver-specific properties */ - ret_value = H5P_set_driver(plist, H5FD_FPHDF5, NULL); - -done: - FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Pget_dxpl_fphdf5 - * Purpose: Queries the transfer mode current set in the data - * transfer property list DXPL_ID. This is not collective. - * Return: Success: SUCCEED - with the transfer mode returned - * through the XFER_MODE argument if - * it is non-null. - * Failure: FAIL - * Programmer: Bill Wendling - * 10. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -herr_t -H5Pget_dxpl_fphdf5(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode) -{ - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(H5Pget_dxpl_fphdf5, FAIL) - H5TRACE2("e","i*Dt",dxpl_id,xfer_mode); - - if ((plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") - - if (H5P_get_driver(plist) != H5FD_FPHDF5) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - - /* Get the transfer mode */ - if (xfer_mode) - if (H5P_get(plist, H5D_XFER_IO_XFER_MODE_NAME, xfer_mode) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to get value") - -done: - FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_fapl_get - * Purpose: Returns a file access property list which could be used - * to create another file the same as this one. - * Return: Success: Ptr to new file access property list with all - * fields copied from the file pointer. - * Failure: NULL - * Programmer: Bill Wendling - * 07. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static void * -H5FD_fphdf5_fapl_get(H5FD_t *_file) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; - H5FD_fphdf5_fapl_t *fa = NULL; - void *ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_fapl_get, NULL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - if ((fa = H5MM_calloc(sizeof(H5FD_fphdf5_fapl_t))) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - /* These should both be copied. --rpm, 1999-08-13 */ - fa->comm = file->comm; - fa->barrier_comm = file->barrier_comm; - fa->info = file->info; - - /* Set return value */ - ret_value = fa; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_open - * Purpose: Opens a file with name NAME. The FLAGS are a bit field with - * purpose similar to the second argument of open(2) and - * which are defined in H5Fpublic.h. The file access - * property list FAPL_ID contains the properties driver - * properties and MAXADDR is the largest address which this - * file will be expected to access. This is collective. - * Return: Success: A new file pointer. - * Failure: NULL - * Programmer: Bill Wendling - * 05. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static H5FD_t * -H5FD_fphdf5_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) -{ - H5FD_fphdf5_t *file = NULL; - MPI_File fh; - int mpi_amode; - int mpi_rank; - int mpi_size; - int mrc; - MPI_Offset size; - H5FD_fphdf5_fapl_t _fa; - const H5FD_fphdf5_fapl_t *fa = NULL; - H5P_genplist_t *plist; - unsigned long feature_flags; - hsize_t meta_block_size = 0; - hsize_t sdata_block_size = 0; - hsize_t threshold; - hsize_t alignment; - unsigned file_id; - unsigned req_id = 0; - H5FD_t *ret_value = NULL; - - /* Flag to indicate that the file was successfully opened */ - unsigned file_opened = FALSE; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_open, NULL) - - /* check args */ - assert(name); - - /* Obtain a pointer to fphdf5-specific file access properties */ - if ((plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)) == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - - if (fapl_id == H5P_FILE_ACCESS_DEFAULT || H5P_get_driver(plist) != H5FD_FPHDF5) { - _fa.comm = MPI_COMM_SELF; /*default*/ - _fa.barrier_comm = MPI_COMM_SELF; /*default*/ - _fa.info = MPI_INFO_NULL; /*default*/ - fa = &_fa; - } else { - fa = H5P_get_driver_info(plist); - assert(fa); - } - - /* - * Convert HDF5 flags to MPI-IO flags. Some combinations are illegal; - * let MPI-IO figure it out - */ - mpi_amode = (flags & H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; - - if (flags & H5F_ACC_CREAT) mpi_amode |= MPI_MODE_CREATE; - if (flags & H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL; - - /* OKAY: CAST DISCARDS CONST */ - if ((mrc = MPI_File_open(H5FP_SAP_BARRIER_COMM, (char *)name, mpi_amode, - fa->info, &fh)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_File_open failed", mrc) - - file_opened = TRUE; - - if (H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &meta_block_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get meta data block size") - - if (H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &sdata_block_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'small data' block size") - - if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &threshold) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold") - - if (H5P_get(plist, H5F_ACS_ALIGN_NAME, &alignment) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment") - - /* Retrieve the VFL driver feature flags */ - H5FD_fphdf5_query(NULL, &feature_flags); /* doesn't fail */ - - /* Inform the SAP that the file was opened */ - if (H5FP_request_open(H5FP_OBJ_FILE, maxaddr, feature_flags, - meta_block_size, sdata_block_size, threshold, - alignment, &file_id, &req_id) == FAIL) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTOPENFILE, NULL, "can't inform SAP of file open") - - /* Broadcast the file ID */ - if ((mrc = MPI_Bcast(&file_id, 1, MPI_UNSIGNED, - (int)H5FP_capt_barrier_rank, - H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mrc) - - /* Grab the rank of this process */ - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, &mpi_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mrc) - - /* The captain rank will get the filesize and broadcast it. */ - if ((unsigned)mpi_rank == H5FP_capt_rank) - /* Get current file size */ - if ((mrc = MPI_File_get_size(fh, &size)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_File_get_size failed", mrc) - - /* Broadcast file size */ - if ((mrc = MPI_Bcast(&size, sizeof(MPI_Offset), MPI_BYTE, - (int)H5FP_capt_barrier_rank, - H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mrc) - - /* Only if size > 0, truncate the file - if requested */ - if (size && (flags & H5F_ACC_TRUNC)) { - if ((mrc = MPI_File_set_size(fh, (MPI_Offset)0)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_File_set_size (file truncation) failed", mrc) - - /* Don't let any proc return until all have truncated the file. */ - if ((mrc = MPI_Barrier(H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_Barrier failed", mrc) - - size = 0; - } - - /* Grab the size of the communicator */ - if ((mrc = MPI_Comm_size(H5FP_SAP_COMM, &mpi_size)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mrc) - - /* Build the return value and initialize it */ - if ((file = H5MM_calloc(sizeof(H5FD_fphdf5_t))) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - file->file_id = file_id; - file->f = fh; - file->comm = fa->comm; - file->info = fa->info; - file->mpi_rank = mpi_rank; - file->mpi_size = mpi_size; - file->eof = H5FD_mpi_MPIOff_to_haddr(size); - - /* Set return value */ - ret_value = (H5FD_t *)file; - -done: - if (!ret_value && file_opened) - MPI_File_close(&fh); - - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_close - * Purpose: Closes a file. This is collective. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling - * 07. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_fphdf5_close(H5FD_t *_file) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t *)_file; - unsigned req_id = 0; - H5FP_status_t status = H5FP_STATUS_OK; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_close, FAIL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* Tell the SAP that we're closing the file... */ - if (H5FP_request_close(_file, file->file_id, &req_id, &status) == FAIL) - HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "can't inform SAP of file close") - - /* MPI_File_close sets argument to MPI_FILE_NULL */ - if ((mrc = MPI_File_close(&file->f)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_close failed", mrc) - - /* Clean up other stuff */ - H5MM_xfree(file); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_query - * Purpose: Set the flags that this VFL driver is capable of - * supporting. (listed in H5FDpublic.h) - * Return: Success: SUCCEED - * Failure: Doesn't fail. - * Programmer: Bill Wendling - * 07. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_fphdf5_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_query, FAIL) - - /* Set the VFL feature flags that this driver supports */ - if (flags) { - *flags = 0; - - /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_AGGREGATE_METADATA; - - /* - * Distinguish between updating the metadata accumulator on - * writes and reads. This is particularly (perhaps only, even) - * important for MPI-I/O where we guarantee that writes are - * collective, but reads may not be. If we were to allow the - * metadata accumulator to be written during a read operation, - * the application would hang. - */ - -#if 0 - /* - * FIXME: For now, having metadata accumulate causes problems for - * the SAP when it goes to allocate data (oddly enough, an - * allocation can result in a call to H5FD_free...which can - * result in a call to H5FD_write...which needs a data xfer - * property list...but only when metadata accumulation is turned - * on...go figure). Turn it off for now. -- BW 02/19/2003 - */ - - /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA_WRITE; -#endif /* 0 */ - - /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_get_eoa - * Purpose: Gets the end-of-address marker for the file. The EOA - * marker is the first address past the last byte allocated - * in the format address space. - * Return: Success: The end-of-address marker. - * Failure: HADDR_UNDEF - * Programmer: Bill Wendling - * 07. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static haddr_t -H5FD_fphdf5_get_eoa(const H5FD_t *_file) -{ - const H5FD_fphdf5_t *file = (const H5FD_fphdf5_t *)_file; - unsigned req_id = 0; - H5FP_status_t status = H5FP_STATUS_OK; - haddr_t ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_get_eoa, HADDR_UNDEF) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* The SAP's eoa field is correct */ - if (!H5FD_fphdf5_is_sap(_file)) - /* Retrieve the EOA information */ - if (H5FP_request_get_eoa(_file, &file->eoa, &req_id, &status)) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTRECV, HADDR_UNDEF, "can't retrieve eoa information") - - /* Set return value */ - ret_value = file->eoa; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_set_eoa - * Purpose: Set the end-of-address marker for the file. This function - * is called shortly after an existing HDF5 file is opened - * in order to tell the driver where the end of the HDF5 - * data is located. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling - * 06. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_fphdf5_set_eoa(H5FD_t *_file, haddr_t addr) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t *)_file; - unsigned req_id = 0; - H5FP_status_t status = H5FP_STATUS_OK; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_set_eoa, FAIL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* The SAP's eoa field is correct */ - if (!H5FD_fphdf5_is_sap(_file)) - /* Retrieve the EOA information */ - if (H5FP_request_set_eoa(_file, addr, &req_id, &status)) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTRECV, FAIL, "can't retrieve eoa information") - - file->eoa = addr; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_get_eof - * Purpose: Gets the end-of-file marker for the file. The EOF marker - * is the real size of the file. - * - * The FPHDF5 driver doesn't bother keeping this field updated - * since that's a relatively expensive operation. - * Fortunately the library only needs the EOF just after the - * file is opened in order to determine whether the file is - * empty, truncated, or okay. Therefore, any MPIO I/O - * function will set its value to HADDR_UNDEF which is the - * error return value of this function. - * Return: Success: The end-of-address marker - * Failure: HADDR_UNDEF - * Programmer: Bill Wendling - * 06. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static haddr_t -H5FD_fphdf5_get_eof(const H5FD_t *_file) -{ - const H5FD_fphdf5_t *file = (const H5FD_fphdf5_t*)_file; - haddr_t ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_get_eof, HADDR_UNDEF) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* Set return value */ - ret_value = file->eof; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_get_handle - * Purpose: Returns the file handle of MPIO file driver. - * Returns: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling - * 06. February 2003 - * Modifications: - *------------------------------------------------------------------------- -*/ -static herr_t -H5FD_fphdf5_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t *)_file; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_get_handle, FAIL) - - /* check args */ - assert(file); - - if (!file_handle) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") - - *file_handle = &file->f; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_read - * Purpose: Reads SIZE bytes of data from FILE beginning at address - * ADDR into buffer BUF according to data transfer - * properties in DXPL_ID using potentially complex file and - * buffer types to effect the transfer. - * - * Reading past the end of the MPI file returns zeros - * instead of failing. MPI is able to coalesce requests - * from different processes (collective or independent). - * Return: Success: SUCCEED - Result is stored in caller-supplied - * buffer BUF - * Failure: FAIL - Contents of buffer BUF are undefined - * Programmer: Bill Wendling - * 10. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_fphdf5_read(H5FD_t *_file, H5FD_mem_t mem_type, hid_t dxpl_id, - haddr_t addr, size_t size, void *buf) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; - MPI_Status status; - MPI_Offset mpi_off; - int size_i; /* Integer copy of 'size' to read */ - int bytes_read; /* Number of bytes read in */ - int mrc; /* MPI return code */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_read, FAIL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - assert(buf); - - /* Make certain we have the correct type of property list */ - assert(H5I_get_type(dxpl_id) == H5I_GENPROP_LST); - assert(H5P_isa_class(dxpl_id, H5P_DATASET_XFER) == TRUE); - - /* Portably initialize MPI status variable */ - HDmemset(&status, 0, sizeof(MPI_Status)); - - /* Some numeric conversions */ - if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr_t to MPI offset") - - size_i = (int)size; - if ((hsize_t)size_i != size) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size_t to int") - - /* Only do real MPI stuff for raw data transfers */ - if(mem_type==H5FD_MEM_DRAW) { - H5P_genplist_t *plist; - H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */ - MPI_Datatype buf_type; /* MPI datatype for I/O operation */ - int n; - int type_size; /* MPI datatype used for I/O's size */ - int io_size; /* Actual number of bytes requested */ - unsigned use_view_this_time = 0; /* Flag to indicate we are using an MPI view */ - - /* Obtain the data transfer properties */ - if ((plist = H5I_object(dxpl_id)) == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - - xfer_mode = H5P_peek_unsigned(plist, H5D_XFER_IO_XFER_MODE_NAME); - - /* - * Set up for a fancy xfer using complex types, or single byte block. - * We wouldn't need to rely on the use_view field if MPI semantics - * allowed us to test that btype == ftype == MPI_BYTE (or even - * MPI_TYPE_NULL, which could mean "use MPI_BYTE" by convention). - */ - if (xfer_mode == H5FD_MPIO_COLLECTIVE) { - MPI_Datatype file_type; - - /* Remember that views are used */ - use_view_this_time = TRUE; - - /* Prepare for a full-blown xfer using btype, ftype, and disp */ - if (H5P_get(plist, H5FD_MPI_XFER_MEM_MPI_TYPE_NAME, &buf_type) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") - - if (H5P_get(plist, H5FD_MPI_XFER_FILE_MPI_TYPE_NAME, &file_type) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") - - /* Set the file view when we are using MPI derived types */ - if ((mrc = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, - file_type, H5FD_mpi_native_g, - file->info)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mrc) - - /* - * When using types, use the address as the displacement for - * MPI_File_set_view and reset the address for the read to zero - */ - mpi_off = 0; - - /* Read the data. */ - if ((mrc = MPI_File_read_at_all(file->f, mpi_off, buf, size_i, - buf_type, &status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mrc) - - /* - * Reset the file view when we used MPI derived types - */ - if ((mrc = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, - H5FD_mpi_native_g, file->info)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mrc) - } else { - /* - * Prepare for a simple xfer of a contiguous block of bytes. The - * btype, ftype, and disp fields are not used. - */ - buf_type = MPI_BYTE; - - /* Read the data. */ - if ((mrc = MPI_File_read_at(file->f, mpi_off, buf, size_i, - buf_type, &status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mrc) - } - - /* How many bytes were actually read? */ - /* [This works because the "basic elements" we use for all our MPI derived - * types are MPI_BYTE. We should be using the 'buf_type' for the MPI - * datatype in this call though... (We aren't because using it causes - * the LANL "qsc" machine to dump core - 12/19/03) - QAK] - */ - if (MPI_SUCCESS != (mrc=MPI_Get_elements(&status, MPI_BYTE, &bytes_read))) - HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mrc) - - /* Get the type's size */ - if (MPI_SUCCESS != (mrc=MPI_Type_size(buf_type,&type_size))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mrc) - - /* Compute the actual number of bytes requested */ - io_size=type_size*size_i; - - /* Check for read failure */ - if (bytes_read<0 || bytes_read>io_size) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - - /* - * This gives us zeroes beyond end of physical MPI file. - */ - if ((n=(io_size-bytes_read)) > 0) - HDmemset((char*)buf+bytes_read, 0, (size_t)n); - } /* end if */ - else { - /* - * This is metadata - we want to try to read it from the SAP - * first. - */ - unsigned req_id = 0; - H5FP_status_t sap_status = H5FP_STATUS_OK; - - if (H5FP_request_read_metadata(_file, file->file_id, dxpl_id, mem_type, - addr, size, (uint8_t**)&buf, - &req_id, &sap_status) != SUCCEED) { - /* FIXME: The read failed, for some reason */ -HDfprintf(stderr, "%s:%d: Metadata cache read failed!\n", FUNC, __LINE__); - } - - if (sap_status == H5FP_STATUS_OK) { - /* WAH-HOO! We've found it! We can leave now */ - } else if (sap_status == H5FP_STATUS_MDATA_NOT_CACHED) { - /* Metadata isn't cached, so grab it from the file */ - if ((mrc = MPI_File_read_at(file->f, mpi_off, buf, size_i, - MPI_BYTE, &status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mrc) - - if ((mrc = MPI_Get_count(&status, MPI_BYTE, &bytes_read)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Get_count failed", mrc) - } else { - /* FIXME: something bad happened */ -HDfprintf(stderr, "%s:%d: Metadata cache read failed!\n", FUNC, __LINE__); - } - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_write - * Purpose: Writes SIZE bytes of data to FILE beginning at address - * ADDR from buffer BUF according to data transfer - * properties in DXPL_ID using potentially complex file and - * buffer types to effect the transfer. - * - * MPI is able to coalesce requests from different processes - * (collective and independent). - * Return: Success: SUCCEED - USE_TYPES and OLD_USE_TYPES in the - * access params are altered. - * Failure: FAIL - USE_TYPES and OLD_USE_TYPES in the - * access params may be altered. - * Programmer: Bill Wendling - * 10. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_fphdf5_write(H5FD_t *_file, H5FD_mem_t mem_type, hid_t dxpl_id, - haddr_t addr, size_t size, const void *buf) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; - int size_i; - unsigned dumping = 0; - H5P_genplist_t *plist; - herr_t ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_write, FAIL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - assert(buf); - - /* Make certain we have the correct type of property list */ - assert(H5I_get_type(dxpl_id) == H5I_GENPROP_LST); - assert(H5P_isa_class(dxpl_id, H5P_DATASET_XFER) == TRUE); - - /* some numeric conversions */ - size_i = (int)size; - if ((hsize_t)size_i != size) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i") - - /* Obtain the data transfer properties */ - if ((plist = H5I_object(dxpl_id)) == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - - if (H5P_exist_plist(plist, H5FD_FPHDF5_XFER_DUMPING_METADATA) > 0) - if (H5P_get(plist, H5FD_FPHDF5_XFER_DUMPING_METADATA, &dumping) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") - - /* - * If metadata, write to the metadata cache but only if we're not - * dumping the data from the SAP... - */ - if (mem_type != H5FD_MEM_DRAW && !dumping) { - unsigned req_id = 0; - H5FP_status_t sap_status = H5FP_STATUS_OK; - - if (H5FP_request_write_metadata(_file, file->file_id, dxpl_id, mem_type, - addr, size_i, buf, &req_id, - &sap_status) != SUCCEED) { - /* FIXME: Couldn't write metadata. This is bad... */ -HDfprintf(stderr, "%s:%d: Couldn't write metadata to SAP (%d)\n", - FUNC, __LINE__, sap_status); - } - - switch (sap_status) { - case H5FP_STATUS_OK: - /* WAH-HOO! We've written it! We can leave now */ - /* Forget the EOF value (see H5FD_fphdf5_get_eof()) */ - file->eof = HADDR_UNDEF; - HGOTO_DONE(SUCCEED) - case H5FP_STATUS_FILE_CLOSING: - HGOTO_DONE(SUCCEED) - case H5FP_STATUS_DUMPING_FAILED: - case H5FP_STATUS_OOM: - case H5FP_STATUS_BAD_FILE_ID: - default: - /* FIXME: Something bad happened */ -HDfprintf(stderr, "%s: Couldn't write metadata to SAP (%d)\n", - FUNC, sap_status); - break; - } - } - - /* FIXME: Should I check this return value or just pass it on out? */ - ret_value = H5FD_fphdf5_write_real(_file, mem_type, plist, addr, size_i, buf); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_write_real - * Purpose: Do the actual writing to a file. Split apart from the - * H5FD_fphdf5_write call since I need to write things - * directly if the SAP is dumping data to me. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling - * 12. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -herr_t -H5FD_fphdf5_write_real(H5FD_t *_file, H5FD_mem_t mem_type, H5P_genplist_t *plist, - haddr_t addr, int size, const void *buf) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; - MPI_Status status; - MPI_Datatype buf_type = MPI_BYTE; - MPI_Offset mpi_off; - int mrc; - int bytes_written; - int type_size; /* MPI datatype used for I/O's size */ - int io_size; /* Actual number of bytes requested */ - unsigned use_view_this_time = 0; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_write_real, FAIL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - assert(plist); - assert(buf); - - /* Portably initialize MPI status variable */ - HDmemset(&status, 0, sizeof(MPI_Status)); - - /* some numeric conversions */ - if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off") - - /* Only check for fancy transfers with raw data I/O */ - if (mem_type == H5FD_MEM_DRAW) { - H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */ - - /* Obtain the data transfer properties */ - xfer_mode = (H5FD_mpio_xfer_t)H5P_peek_unsigned(plist, H5D_XFER_IO_XFER_MODE_NAME); - - /* - * Set up for a fancy xfer using complex types, or single byte block. - * We wouldn't need to rely on the use_view field if MPI semantics - * allowed us to test that btype == ftype == MPI_BYTE (or even - * MPI_TYPE_NULL, which could mean "use MPI_BYTE" by convention). - */ - if (xfer_mode == H5FD_MPIO_COLLECTIVE) { - MPI_Datatype file_type; - - /* Remember that views are used */ - use_view_this_time = TRUE; - - /* Prepare for a full-blown xfer using btype, ftype, and disp */ - if (H5P_get(plist, H5FD_MPI_XFER_MEM_MPI_TYPE_NAME, &buf_type) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") - - if (H5P_get(plist, H5FD_MPI_XFER_FILE_MPI_TYPE_NAME, &file_type) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") - - /* Set the file view when we are using MPI derived types */ - if ((mrc = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, - file_type, H5FD_mpi_native_g, - file->info)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mrc) - - /* - * When using types, use the address as the displacement for - * MPI_File_set_view and reset the address for the read to zero - */ - mpi_off = 0; - } - } /* end if */ - - /* Write the data. */ - if (use_view_this_time) { - /*OKAY: CAST DISCARDS CONST QUALIFIER*/ - if ((mrc = MPI_File_write_at_all(file->f, mpi_off, (void*)buf, - size, buf_type, &status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mrc) - - /* Reset the file view when we used MPI derived types */ - if ((mrc = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, - H5FD_mpi_native_g, file->info)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mrc) - } /* end if */ - else { - /*OKAY: CAST DISCARDS CONST QUALIFIER*/ - if ((mrc = MPI_File_write_at(file->f, mpi_off, (void*)buf, - size, buf_type, &status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mrc) - } - - /* How many bytes were actually written? */ - /* [This works because the "basic elements" we use for all our MPI derived - * types are MPI_BYTE. We should be using the 'buf_type' for the MPI - * datatype in this call though... (We aren't because using it causes - * the LANL "qsc" machine to dump core - 12/19/03) - QAK] - */ - if (MPI_SUCCESS != (mrc=MPI_Get_elements(&status, MPI_BYTE, &bytes_written))) - HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mrc) - - /* Get the type's size */ - if (MPI_SUCCESS != (mrc=MPI_Type_size(buf_type,&type_size))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mrc) - - /* Compute the actual number of bytes requested */ - io_size=type_size*size; - - /* Check for write failure */ - if (bytes_written!=io_size) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") - - /* Forget the EOF value (see H5FD_fphdf5_get_eof()) */ - file->eof = HADDR_UNDEF; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_flush - * Purpose: Makes sure that all data is on disk. This is collective. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling - * 12. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_fphdf5_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) -{ - H5FD_fphdf5_t *file = (H5FD_fphdf5_t*)_file; - MPI_Offset mpi_off; - int mrc; - unsigned req_id = 0; - H5FP_status_t status = H5FP_STATUS_OK; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_flush, FAIL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* - * Extend the file to make sure it's large enough, then sync. - * Unfortunately, keeping track of EOF is an expensive operation, so - * we can't just check whether EOF<EOA like with other drivers. - * Therefore we'll just read the byte at EOA-1 and then write it - * back. - */ - if (file->eoa > file->last_eoa) { - if (H5FD_mpi_haddr_to_MPIOff(file->eoa, &mpi_off) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset") - - /* Extend the file's size */ - if ((mrc = MPI_File_set_size(file->f, mpi_off)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mrc) - - /* - * Don't let any proc return until all have extended the file. - * (Prevents race condition where some processes go ahead and - * write more data to the file before all the processes have - * finished making it the shorter length, potentially truncating - * the file and dropping the new data written) - */ - if ((mrc = MPI_Barrier(H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mrc) - - /* Update the 'last' eoa value */ - file->last_eoa = file->eoa; - } - - /* Only the captain process needs to flush the metadata. */ - if (H5FD_fphdf5_is_captain(_file)) { - if (H5FP_request_flush_metadata(_file, file->file_id, dxpl_id, - &req_id, &status) != SUCCEED) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTFLUSH, FAIL, "can't flush metadata") - - /* Only sync the file if we are not going to immediately close it */ - if (!closing) - if ((mrc = MPI_File_sync(file->f)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_File_sync failed", mrc) - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_mpi_rank - * Purpose: Returns the MPI rank for a process - * Return: Success: MPI rank - * Failure: Doesn't fail - * Programmer: Bill Wendling - * 30. January 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static int -H5FD_fphdf5_mpi_rank(const H5FD_t *_file) -{ - const H5FD_fphdf5_t *file = (const H5FD_fphdf5_t*)_file; - int ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_mpi_rank, FAIL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* Set return value */ - ret_value = file->mpi_rank; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_mpi_size - * Purpose: Returns the number of MPI processes - * Return: Success: Number of MPI processes - * Failure: Doesn't fail - * Programmer: Bill Wendling - * 30. January 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static int -H5FD_fphdf5_mpi_size(const H5FD_t *_file) -{ - const H5FD_fphdf5_t *file = (const H5FD_fphdf5_t*)_file; - int ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_mpi_size, FAIL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* Set return value */ - ret_value = file->mpi_size; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/*------------------------------------------------------------------------- - * Function: H5FD_fphdf5_barrier_communicator - * Purpose: Returns the MPI communicator for the file that can be - * used in an MPI_Barrier() statement for the client - * processes. - * Return: Success: The barrier communicator - * Failure: NULL - * Programmer: Bill Wendling - * 10. February 2003 - * Modifications: - *------------------------------------------------------------------------- - */ -static MPI_Comm -H5FD_fphdf5_barrier_communicator(const H5FD_t *_file) -{ - const H5FD_fphdf5_t *file = (const H5FD_fphdf5_t*)_file; - MPI_Comm ret_value; - - FUNC_ENTER_NOAPI(H5FD_fphdf5_barrier_communicator, MPI_COMM_NULL) - - /* check args */ - assert(file); - assert(file->pub.driver_id == H5FD_FPHDF5); - - /* Set return value */ - ret_value = file->barrier_comm; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -#endif /* H5_HAVE_FPHDF5 */ diff --git a/src/H5FDfphdf5.h b/src/H5FDfphdf5.h deleted file mode 100644 index c2bbd0b..0000000 --- a/src/H5FDfphdf5.h +++ /dev/null @@ -1,122 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef H5FDFPHDF5_H__ -#define H5FDFPHDF5_H__ - -#ifdef H5_HAVE_FPHDF5 -# define H5FD_FPHDF5 (H5FD_fphdf5_init()) -#else -# define H5FD_FPHDF5 (-1) -#endif /* H5_HAVE_FPHDF5 */ - -/* Macros */ - -#ifndef H5_HAVE_FPHDF5 - -/* If FPHDF5 isn't specified, make this a "FALSE" value */ -#define IS_H5FD_FPHDF5(f) (0) - -#else - -#define IS_H5FD_FPHDF5(f) (H5F_get_driver_id(f) == H5FD_FPHDF5) - -/* Turn on H5FDfphdf5_debug if H5F_DEBUG is on */ -#if defined(H5F_DEBUG) && !defined(H5FDfphdf5_DEBUG) -# define H5FDfphdf5_DEBUG -#endif /* H5F_DEBUG && ! H5FDfphdf5_DEBUG */ - -#define H5FD_FPHDF5_XFER_DUMPING_METADATA "H5FD_fphdf5_dumping_metadata" -#define H5FD_FPHDF5_XFER_DUMPING_SIZE sizeof(unsigned) - -/* - * For specifying that only the captain is allowed to allocate things at - * this time. - */ -#define H5FD_FPHDF5_CAPTN_ALLOC_ONLY "Only_Captain_Alloc" -#define H5FD_FPHDF5_CAPTN_ALLOC_SIZE sizeof(unsigned) - -/* - * The description of a file belonging to this driver. - * - * The FILE_ID field is an SAP defined value. When reading/writing to the - * SAP, this value should be sent. - * - * The EOF field is only used just after the file is opened in order for - * the library to determine whether the file is empty, truncated, or - * okay. The FPHDF5 driver doesn't bother to keep it updated since it's - * an expensive operation. - */ -typedef struct H5FD_fphdf5_t { - H5FD_t pub; /*Public stuff, must be first (ick!) */ - unsigned file_id; /*ID used by the SAP */ - MPI_File f; /*MPIO file handle */ - MPI_Comm comm; /*Communicator */ - MPI_Comm barrier_comm; /*Barrier communicator */ - MPI_Info info; /*File information */ - int mpi_rank; /*This process's rank */ - int mpi_size; /*Total number of processes */ - haddr_t eof; /*End-of-file marker */ - haddr_t eoa; /*End-of-address marker */ - haddr_t last_eoa; /*Last known end-of-address marker */ -} H5FD_fphdf5_t; - -extern const H5FD_class_mpi_t H5FD_fphdf5_g; - -/* Function prototypes */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - *==--------------------------------------------------------------------------== - * API Functions - *==--------------------------------------------------------------------------== - */ -H5_DLL herr_t H5Pset_dxpl_fphdf5(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode); -H5_DLL herr_t H5Pget_dxpl_fphdf5(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode); -H5_DLL herr_t H5Pset_fapl_fphdf5(hid_t fapl_id, MPI_Comm comm, - MPI_Comm barrier_comm, MPI_Info info, - unsigned sap_rank); -H5_DLL herr_t H5Pget_fapl_fphdf5(hid_t fapl_id, MPI_Comm *comm, - MPI_Comm *barrier_comm, MPI_Info *info, - unsigned *sap_rank, unsigned *capt_rank); - -/* - *==--------------------------------------------------------------------------== - * Private Library Functions - *==--------------------------------------------------------------------------== - */ -/* Forward declarations for prototype arguments */ -struct H5P_genplist_t; - -H5_DLL hid_t H5FD_fphdf5_init(void); -H5_DLL void H5FD_fphdf5_term(void); -H5_DLL unsigned H5FD_fphdf5_file_id(H5FD_t *_file); -H5_DLL hbool_t H5FD_fphdf5_is_sap(const H5FD_t *_file); -H5_DLL hbool_t H5FD_fphdf5_is_captain(H5FD_t *_file); -H5_DLL hbool_t H5FD_is_fphdf5_driver(H5FD_t *_file); - -H5_DLL herr_t H5FD_fphdf5_write_real(H5FD_t *_file, H5FD_mem_t mem_type, - struct H5P_genplist_t *plist, - haddr_t addr, int size, - const void *buf); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* H5_HAVE_PARALLEL */ - -#endif /* H5FDFPHDF5_H__ */ diff --git a/src/H5FDmpi.h b/src/H5FDmpi.h index c9da439..480e7f7 100644 --- a/src/H5FDmpi.h +++ b/src/H5FDmpi.h @@ -61,7 +61,6 @@ typedef struct H5FD_class_mpi_t { #endif /* H5_HAVE_PARALLEL */ /* Include all the MPI VFL headers */ -#include "H5FDfphdf5.h" /* Flexible PHDF5 file driver */ #include "H5FDmpio.h" /* MPI I/O file driver */ #include "H5FDmpiposix.h" /* MPI/posix I/O file driver */ @@ -69,7 +68,7 @@ typedef struct H5FD_class_mpi_t { /* Single macro to check for all file drivers that use MPI */ #define IS_H5FD_MPI(file) \ - (IS_H5FD_MPIO(file) || IS_H5FD_MPIPOSIX(file) || IS_H5FD_FPHDF5(file)) + (IS_H5FD_MPIO(file) || IS_H5FD_MPIPOSIX(file)) #ifdef H5_HAVE_PARALLEL /* ======== Temporary data transfer properties ======== */ diff --git a/src/H5FP.c b/src/H5FP.c deleted file mode 100644 index 6d85b88..0000000 --- a/src/H5FP.c +++ /dev/null @@ -1,513 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - - -/* Private header files */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error Handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object Headers */ - -#ifdef H5_HAVE_FPHDF5 - -#include "H5FPprivate.h" /* Flexible Parallel Functions */ - -MPI_Datatype H5FP_request; /* MPI datatype for the H5FP_request_t type */ -MPI_Datatype H5FP_reply; /* MPI datatype for the H5FP_reply_t type */ -MPI_Datatype H5FP_read; /* MPI datatype for the H5FP_read_t type */ -MPI_Datatype H5FP_alloc; /* MPI datatype for the H5FP_alloc_t type */ -MPI_Datatype H5FP_eoa; /* MPI datatype for the H5FP_eoa_t type */ -MPI_Datatype H5FP_super; /* MPI datatype for the H5FP_super_t type */ - -/* SAP specific variables */ -MPI_Comm H5FP_SAP_COMM; /* Comm we use: Supplied by user */ -MPI_Comm H5FP_SAP_BARRIER_COMM; /* Comm if you want to do a barrier */ - -unsigned H5FP_sap_rank; /* The rank of the SAP: Supplied by user*/ -unsigned H5FP_capt_rank; /* The rank which tells SAP of opens */ -unsigned H5FP_capt_barrier_rank;/* Rank of captain in barrier comm */ - -/* local functions */ -static herr_t H5FP_commit_sap_datatypes(void); -static herr_t H5FP_request_sap_stop(void); - -/* - *===----------------------------------------------------------------------=== - * Public (API) Functions - *===----------------------------------------------------------------------=== - */ - -/* - * Function: H5FPinit - * Purpose: Initialize the SAP environment: duplicate the COMM the user - * supplies to us, set aside the SAP_RANK as the SAP. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 26. July, 2002 - * Modifications: - */ -herr_t -H5FPinit(MPI_Comm comm, int sap_rank, MPI_Comm *sap_comm, MPI_Comm *sap_barrier_comm) -{ - MPI_Group sap_group = MPI_GROUP_NULL, sap_barrier_group = MPI_GROUP_NULL; - int mrc, comm_size, my_rank; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(H5FPinit, FAIL); - H5TRACE4("e","McIs*Mc*Mc",comm,sap_rank,sap_comm,sap_barrier_comm); - - /* initialize to NULL so that we can release if an error occurs */ - H5FP_request = MPI_DATATYPE_NULL; - H5FP_reply = MPI_DATATYPE_NULL; - H5FP_read = MPI_DATATYPE_NULL; - H5FP_alloc = MPI_DATATYPE_NULL; - H5FP_eoa = MPI_DATATYPE_NULL; - H5FP_super = MPI_DATATYPE_NULL; - - *sap_comm = H5FP_SAP_COMM = MPI_COMM_NULL; - *sap_barrier_comm = H5FP_SAP_BARRIER_COMM = MPI_COMM_NULL; - - /* Set the global variable to track the SAP's rank */ - H5FP_sap_rank = sap_rank; - - /* Make a private copy of the communicator passed to us */ - if (MPI_Comm_dup(comm, &H5FP_SAP_COMM) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_dup failed"); - - *sap_comm = H5FP_SAP_COMM; - - if (MPI_Comm_group(H5FP_SAP_COMM, &sap_group) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_group failed"); - - /* Exclude the SAP from the barrier group group */ - if (MPI_Group_excl(sap_group, 1, (int *)&H5FP_sap_rank, - &sap_barrier_group) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Group_excl failed"); - - /* Create communicator for barrier group (all processes except the SAP) */ - if (MPI_Comm_create(H5FP_SAP_COMM, sap_barrier_group, - &H5FP_SAP_BARRIER_COMM) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_create failed"); - - *sap_barrier_comm = H5FP_SAP_BARRIER_COMM; - - /* Get the size of all the processes (including the SAP) */ - if (MPI_Comm_size(H5FP_SAP_COMM, &comm_size) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_size failed"); - - /* - * We assign the process right after the sap_rank as the one which - * will tell the SAP that files have been opened or closed. We mod - * it so that we don't go over the size of the communicator. - */ - H5FP_capt_rank = (H5FP_sap_rank + 1) % comm_size; - - /* Get this processes rank */ - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, (int *)&my_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - H5FP_capt_barrier_rank = 0; - - /* Get the rank of the captain in the barrier Comm */ - if (H5FP_capt_rank == (unsigned)my_rank) - if ((mrc = MPI_Comm_rank(H5FP_SAP_BARRIER_COMM, - (int *)&H5FP_capt_barrier_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - /* Broadcast the captain's barrier rank */ - if ((mrc = MPI_Bcast(&H5FP_capt_barrier_rank, 1, MPI_UNSIGNED, - (int)H5FP_capt_rank, - H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mrc); - - /* Create the MPI types used for communicating with the SAP */ - if (H5FP_commit_sap_datatypes() != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "H5FP_commit_sap_datatypes failed"); - - /* Go loop, if we are the SAP */ - if ((unsigned)my_rank == H5FP_sap_rank) - H5FP_sap_receive_loop(); - - /* Fall through and return to user, if not SAP */ - -done: - if (ret_value == FAIL) { - /* we've encountered an error...clean up */ - if (H5FP_request != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_request) != MPI_SUCCESS) - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_reply != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_reply) != MPI_SUCCESS) - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_read != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_read) != MPI_SUCCESS) - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_alloc != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_alloc) != MPI_SUCCESS) - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_eoa != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_eoa) != MPI_SUCCESS) - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_super != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_super) != MPI_SUCCESS) - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_SAP_BARRIER_COMM != MPI_COMM_NULL) - /* this comm will be NULL for the SAP */ - if (MPI_Comm_free(&H5FP_SAP_BARRIER_COMM) != MPI_SUCCESS) - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_free failed"); - - if (H5FP_SAP_COMM != MPI_COMM_NULL) - if (MPI_Comm_free(&H5FP_SAP_COMM) != MPI_SUCCESS) - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_free failed"); - } - - if (sap_group != MPI_GROUP_NULL) - MPI_Group_free(&sap_group); - - if (sap_barrier_group != MPI_GROUP_NULL) - MPI_Group_free(&sap_barrier_group); - - FUNC_LEAVE_API(ret_value); -} - -/* - * Function: H5FPfinalize - * Purpose: Get rid of the initilized environment we setup with H5FPinit. - * Mostly just freeing the duplicated COMM object and committed - * datatypes. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 26. July, 2002 - * Modifications: - */ -herr_t -H5FPfinalize(void) -{ - int mrc, my_rank; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(H5FPfinalize, FAIL); - H5TRACE0("e",""); - - /* Get this processes rank */ - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, (int *)&my_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - /* Stop the SAP */ - if ((unsigned)my_rank != H5FP_sap_rank) - if (H5FP_request_sap_stop() < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Error stopping the SAP"); - - /* Release the MPI types we created */ - if (H5FP_request != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_request) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_reply != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_reply) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_read != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_read) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_alloc != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_alloc) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_eoa != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_eoa) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - if (H5FP_super != MPI_DATATYPE_NULL) - if (MPI_Type_free(&H5FP_super) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed"); - - /* Release the barrier communicator */ - if (H5FP_SAP_BARRIER_COMM != MPI_COMM_NULL) - /* this comm will be NULL for the SAP */ - if (MPI_Comm_free(&H5FP_SAP_BARRIER_COMM) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_free failed"); - - /* Release the FPH5 communicator */ - if (MPI_Comm_free(&H5FP_SAP_COMM) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_free failed"); - -done: - FUNC_LEAVE_API(ret_value); -} - -/* - *===----------------------------------------------------------------------=== - * Public Library (non-API) Functions - *===----------------------------------------------------------------------=== - */ - -/* - * Function: H5FP_send_metadata - * Purpose: Send a string of metadata to a process. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 30. July, 2002 - * Modifications: - */ -herr_t -H5FP_send_metadata(const char *mdata, int len, int to) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_send_metadata, FAIL); - - assert(mdata); - assert(len); - - /* casts the CONST away: Okay */ - if (MPI_Send((void *)mdata, len, MPI_BYTE, to, H5FP_TAG_METADATA, H5FP_SAP_COMM) - != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Send failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_read_metadata - * Purpose: Read a string of metadata from process FROM. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 31. January, 2003 - * Modifications: - */ -herr_t -H5FP_read_metadata(char **mdata, int len, int from) -{ - MPI_Status status; - herr_t ret_value = SUCCEED; - int mrc; - - FUNC_ENTER_NOAPI(H5FP_read_metadata, FAIL); - - /* check args */ - assert(mdata); - - /* - * There is metadata associated with this request. Get it as a - * string (requires another read). - */ - if ((*mdata = (char *)H5MM_malloc((size_t)len + 1)) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory"); - - HDmemset(*mdata, 0, (size_t)len + 1); - - if ((mrc = MPI_Recv(*mdata, len + 1, MPI_BYTE, from, H5FP_TAG_METADATA, - H5FP_SAP_COMM, &status)) != MPI_SUCCESS) { - HDfree(*mdata); - *mdata = NULL; - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - } - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - *===----------------------------------------------------------------------=== - * Private Functions - *===----------------------------------------------------------------------=== - */ - -/* - * Function: H5FP_commit_sap_datatypes - * Purpose: Commit the H5FP_request, H5FP_reply, H5FP_read, - * H5FP_alloc, H5FP_eoa and H5FP_super structure datatypes - * to MPI. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 26. July, 2002 - * Modifications: - */ -static herr_t -H5FP_commit_sap_datatypes(void) -{ - int block_length[5]; - int i; - MPI_Aint displs[5]; - MPI_Datatype old_types[5]; - H5FP_request_t sap_req; - H5FP_reply_t sap_reply; - H5FP_read_t sap_read; - H5FP_alloc_t sap_alloc; - H5FP_eoa_t sap_eoa; - H5FP_super_t sap_super; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_commit_sap_datatypes, FAIL); - - /* Commit the H5FP_request datatype */ - block_length[0] = 8; - block_length[1] = 1; - block_length[2] = 4; - block_length[3] = 2; - old_types[0] = MPI_UNSIGNED; - old_types[1] = MPI_UNSIGNED_LONG; - old_types[2] = MPI_LONG_LONG_INT; - old_types[3] = HADDR_AS_MPI_TYPE; - MPI_Address(&sap_req.req_id, &displs[0]); - MPI_Address(&sap_req.feature_flags, &displs[1]); - MPI_Address(&sap_req.meta_block_size, &displs[2]); - MPI_Address(&sap_req.addr, &displs[3]); - - /* Calculate the displacements */ - for (i = 4; i >= 0; --i) - displs[i] -= displs[0]; - - if (MPI_Type_struct(4, block_length, displs, old_types, &H5FP_request) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_struct failed"); - - if (MPI_Type_commit(&H5FP_request) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_commit failed"); - - /* Commit the H5FP_reply datatype */ - block_length[0] = 4; - old_types[0] = MPI_UNSIGNED; - MPI_Address(&sap_reply.req_id, &displs[0]); - - /* Calculate the displacements */ - for (i = 0; i >= 0; --i) - displs[i] -= displs[0]; - - if (MPI_Type_struct(1, block_length, displs, old_types, &H5FP_reply) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_struct failed"); - - if (MPI_Type_commit(&H5FP_reply) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_commit failed"); - - /* Commit the H5FP_read datatype */ - block_length[0] = 5; - block_length[1] = 1; - old_types[0] = MPI_UNSIGNED; - old_types[1] = HADDR_AS_MPI_TYPE; - MPI_Address(&sap_read.req_id, &displs[0]); - MPI_Address(&sap_read.addr, &displs[1]); - - /* Calculate the displacements */ - for (i = 1; i >= 0; --i) - displs[i] -= displs[0]; - - if (MPI_Type_struct(2, block_length, displs, old_types, &H5FP_read) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_struct failed"); - - if (MPI_Type_commit(&H5FP_read) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_commit failed"); - - /* Commit the H5FP_alloc datatype */ - block_length[0] = 4; - block_length[1] = 2; - old_types[0] = MPI_UNSIGNED; - old_types[1] = HADDR_AS_MPI_TYPE; - MPI_Address(&sap_alloc.req_id, &displs[0]); - MPI_Address(&sap_alloc.addr, &displs[1]); - - /* Calculate the displacements */ - for (i = 1; i >= 0; --i) - displs[i] -= displs[0]; - - if (MPI_Type_struct(2, block_length, displs, old_types, &H5FP_alloc) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_struct failed"); - - if (MPI_Type_commit(&H5FP_alloc) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_commit failed"); - - /* Commit the H5FP_eoa datatype */ - block_length[0] = 3; - block_length[1] = 1; - old_types[0] = MPI_UNSIGNED; - old_types[1] = HADDR_AS_MPI_TYPE; - MPI_Address(&sap_eoa.req_id, &displs[0]); - MPI_Address(&sap_eoa.eoa, &displs[1]); - - /* Calculate the displacements */ - for (i = 1; i >= 0; --i) - displs[i] -= displs[0]; - - if (MPI_Type_struct(2, block_length, displs, old_types, &H5FP_eoa) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_struct failed"); - - if (MPI_Type_commit(&H5FP_eoa) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_commit failed"); - - /* Commit the H5FP_super datatype */ - block_length[0] = 1; - block_length[1] = 1; - old_types[0] = HADDR_AS_MPI_TYPE; - old_types[1] = MPI_LONG_LONG_INT; - MPI_Address(&sap_super.addr, &displs[0]); - MPI_Address(&sap_super.size, &displs[1]); - - /* Calculate the displacements */ - for (i = 1; i >= 0; --i) - displs[i] -= displs[0]; - - if (MPI_Type_struct(2, block_length, displs, old_types, &H5FP_super) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_struct failed"); - - if (MPI_Type_commit(&H5FP_super) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_commit failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_sap_stop - * Purpose: Request that the SAP stop it's loop processing. Each - * process should send this to the SAP. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - */ -static herr_t -H5FP_request_sap_stop(void) -{ - H5FP_request_t req; - int mrc, my_rank; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_sap_stop, FAIL); - - /* Get this processes rank */ - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, (int *)&my_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - HDmemset(&req, 0, sizeof(req)); - req.req_type = H5FP_REQ_STOP; - req.req_id = 0; - req.proc_rank = my_rank; - - if (MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Send failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - -#endif /* H5_HAVE_FPHDF5 */ diff --git a/src/H5FPclient.c b/src/H5FPclient.c deleted file mode 100644 index 274324a..0000000 --- a/src/H5FPclient.c +++ /dev/null @@ -1,1180 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#define H5S_PACKAGE /*suppress error about including H5Spkg */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata Cache */ -#include "H5Dprivate.h" /* Dataset Functions */ -#include "H5Eprivate.h" /* Error Handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File Drivers */ -#include "H5Gpkg.h" /* Group Functions */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory Allocation */ -#include "H5Oprivate.h" /* Object Headers */ -#include "H5Rprivate.h" /* References */ -#include "H5Spkg.h" /* Dataspace Functions */ - -#ifdef H5_HAVE_FPHDF5 - -#include "H5FDfphdf5.h" /* File Driver for FPHDF5 */ -#include "H5FPprivate.h" /* Flexible Parallel Functions */ - -/* local functions */ -static unsigned H5FP_gen_request_id(void); -static herr_t H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id); - - -/* - *===----------------------------------------------------------------------=== - * Public Library (non-API) Functions - *===----------------------------------------------------------------------=== - */ - -/* - * Function: H5FP_request_open - * Purpose: Request an open of a file from the SAP. You pass in the - * metadata string (MDATA) (the filename), it's length in - * (MD_LEN), and the type of the object you're trying to - * open (OBJ_TYPE). The request ID is returned in a pointer - * supplied by the user. - * - * The so-called "captain" process is in charge of telling - * the SAP that the processes opened a file. All processes - * opening the file, though, should call this function so - * that they can get the file ID that the SAP assigns to it. - * - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 28. August, 2002 - * Modifications: - */ -herr_t -H5FP_request_open(H5FP_obj_t obj_type, haddr_t maxaddr, - unsigned long feature_flags, hsize_t meta_block_size, - hsize_t sdata_block_size, hsize_t threshold, - hsize_t alignment, unsigned *file_id, unsigned *req_id) -{ - H5FP_request_t req; - MPI_Status mpi_status; - int mrc, my_rank; - int ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_open, FAIL); - - /* check args */ - assert(file_id); - assert(req_id); - - HDmemset(&mpi_status, 0, sizeof(MPI_Status)); - - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, &my_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - if ((unsigned)my_rank == H5FP_capt_rank) { - /* - * The captain process sends the information about the file to - * the SAP. - */ - HDmemset(&req, 0, sizeof(req)); - req.req_type = H5FP_REQ_OPEN; - req.req_id = H5FP_gen_request_id(); - req.proc_rank = my_rank; - req.md_size = 0; - req.obj_type = obj_type; - req.addr = maxaddr; - req.feature_flags = feature_flags; - req.meta_block_size = meta_block_size; - req.sdata_block_size = sdata_block_size; - req.threshold = threshold; - req.alignment = alignment; - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - if ((mrc = MPI_Recv(file_id, 1, MPI_UNSIGNED, (int)H5FP_sap_rank, - H5FP_TAG_FILE_ID, H5FP_SAP_COMM, - &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - } - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_lock - * Purpose: Request a lock on an object in a file from the SAP. The - * request ID is returned in a pointer supplied by the user. - * The status of the SAP is returned to the user in the - * supplied STATUS pointer. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 30. July, 2002 - * Modifications: - */ -herr_t -H5FP_request_lock(unsigned file_id, hobj_ref_t obj_oid, - H5FP_lock_t rw_lock, int last, unsigned *req_id, - H5FP_status_t *status) -{ - H5FP_request_t req; - int mrc, my_rank; - int ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_lock, FAIL); - - /* check args */ - assert(obj_oid); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, &my_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - *status = H5FP_STATUS_OK; - req.req_type = last ? H5FP_REQ_LOCK_END : H5FP_REQ_LOCK; - req.req_id = H5FP_gen_request_id(); - req.file_id = file_id; - req.rw_lock = rw_lock; - req.md_size = 0; - req.proc_rank = my_rank; - req.oid = obj_oid; - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) { - *status = H5FP_STATUS_LOCK_FAILED; - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - } - - if (last) { - /* - * On the last lock in the lock-group to be acquired, we expect a - * reply from the SAP - */ - H5FP_reply_t sap_reply; - MPI_Status mpi_status; - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_reply, 1, H5FP_reply, (int)H5FP_sap_rank, - H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - *status = sap_reply.status; - - if (sap_reply.status != H5FP_STATUS_LOCK_ACQUIRED) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTLOCK, FAIL, "can't lock object on server"); - } - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_release_lock - * Purpose: Release a lock on the file from the SAP. Request a lock - * on an object in a file from the SAP. The request ID is - * returned in a pointer supplied by the user. The status - * of the SAP is returned to the user in the supplied STATUS - * pointer. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 30. July, 2002 - * Modifications: - */ -herr_t -H5FP_request_release_lock(unsigned file_id, hobj_ref_t obj_oid, - int last, unsigned *req_id, H5FP_status_t *status) -{ - H5FP_request_t req; - int mrc, my_rank; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_release_lock, FAIL); - - /* check args */ - assert(obj_oid); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, &my_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - *status = H5FP_STATUS_OK; - req.oid = obj_oid; - req.req_type = last ? H5FP_REQ_RELEASE_END : H5FP_REQ_RELEASE; - req.req_id = H5FP_gen_request_id(); - req.file_id = file_id; - req.md_size = 0; - req.proc_rank = my_rank; - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) { - *status = H5FP_STATUS_LOCK_RELEASE_FAILED; - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - } - - if (last) { - /* - * On the last lock released in this lock-group, we expect a - * reply from the SAP - */ - H5FP_reply_t sap_reply; - MPI_Status mpi_status; - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_reply, 1, H5FP_reply, (int)H5FP_sap_rank, - H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - *status = sap_reply.status; - - if (sap_reply.status != H5FP_STATUS_LOCK_RELEASED) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTUNLOCK, FAIL, - "can't unlock object on server"); - } - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_read_metadata - * Purpose: Read a piece of metadata from the SAP. That is, if the - * SAP has access to that metadata. If not, then we'll need - * to read it from disk. - * - * This function has the potential of causing the process to - * act as a dumper for the SAP's metadata. Places which call - * this function and check the STATUS variable should take - * this into account. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - */ -herr_t -H5FP_request_read_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, - H5FD_mem_t UNUSED mem_type, haddr_t addr, - size_t size, uint8_t **buf, - unsigned *req_id, H5FP_status_t *status) -{ - H5FP_request_t req; - H5FP_read_t sap_read; - MPI_Status mpi_status; - int mrc, my_rank; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_read_metadata, FAIL); - - /* check args */ - assert(file); - assert(buf); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, &my_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - *status = H5FP_STATUS_OK; - req.req_type = H5FP_REQ_READ; - req.req_id = H5FP_gen_request_id(); - req.file_id = file_id; - req.proc_rank = my_rank; - req.addr = addr; - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_read, 1, H5FP_read, (int)H5FP_sap_rank, H5FP_TAG_READ, - H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - switch (sap_read.status) { - case H5FP_STATUS_OK: - /* use the info in the H5FP_read_t structure to update the metadata */ - *status = H5FP_STATUS_OK; - HDmemset(*buf, '\0', size); - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - /* the following code is a bit odd and doubtless needs a bit - * of explanation. I certainly stumbled over it the first - * time I read it. - * - * For reasons unknown, read requests sent to the SAP only - * include a base address, not a length. Thus the SAP sends - * along the largest contiguous chunk it has starting at the - * specified address. - * - * If the chunk is bigger than we want, we just copy over what - * we want, and discard the rest. - * - * If it is just the right size, we receive it in the provided - * buffer. - * - * if it is too small to fulfil our request, we scream and die. - * - * JRM - 4/13/04 - */ - if (size < sap_read.md_size) - { - char *mdata; - - if (H5FP_read_metadata(&mdata, (int)sap_read.md_size, (int)H5FP_sap_rank) == FAIL) { -HDfprintf(stderr, "Metadata Read Failed!!!!\n"); - } - - HDmemcpy(*buf, mdata, size); - HDfree(mdata); - } else if (size == sap_read.md_size) { - if ((mrc = MPI_Recv(*buf, (int)sap_read.md_size, MPI_BYTE, - (int)H5FP_sap_rank, H5FP_TAG_METADATA, - H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - } else { - HDfprintf(stdout, - "H5FP_request_read_metadata: size = %d > md_size = %d.\n", - (int)size, (int)(sap_read.md_size)); - HDfprintf(stdout, "Mssg received from SAP is too small!!!!\n"); - assert(0); - } - - break; - case H5FP_STATUS_DUMPING: - /* - * Collect the metadata updates from the SAP and write them to - * the file. We fall through because at this point the metadata - * won't be cached on the server anymore. - */ - if (H5FP_dump_to_file(file, dxpl_id) == FAIL) - HGOTO_ERROR(H5E_FPHDF5, H5E_WRITEERROR, FAIL, - "can't write metadata update to file"); - /* FALLTHROUGH */ - case H5FP_STATUS_MDATA_NOT_CACHED: - /* - * The metadata wasn't in the SAP's cache. Should read from disk - * now. - */ - *status = H5FP_STATUS_MDATA_NOT_CACHED; - break; - default: - *status = sap_read.status; - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't write metadata to server"); - } - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_write_metadata - * Purpose: Tell the SAP that we want to change a piece of metadata - * associated with the file. The request ID is returned in a - * pointer supplied by the user. - * - * This function has the potential of causing the process to - * act as a dumper for the SAP's metadata. Places which call - * this function and check the STATUS variable should take - * this into account. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - */ -herr_t -H5FP_request_write_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, - H5FD_mem_t mem_type, haddr_t addr, - int mdata_size, const char *mdata, - unsigned *req_id, H5FP_status_t *status) -{ - H5FP_reply_t sap_reply; - MPI_Status mpi_status; - H5FP_request_t req; - int mrc, my_rank; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_write_metadata, FAIL); - - /* check args */ - assert(file); - assert(mdata); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, &my_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - req.req_type = H5FP_REQ_WRITE; - req.req_id = H5FP_gen_request_id(); - req.proc_rank = my_rank; - req.file_id = file_id; - req.mem_type = mem_type; - req.addr = addr; - req.md_size = mdata_size; - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - /* The first MPI_Send will have been sent before this one will be read. */ - if (H5FP_send_metadata(mdata, mdata_size, (int)H5FP_sap_rank) != SUCCEED) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't send metadata to server"); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - HDmemset(&sap_reply, 0, sizeof(sap_reply)); - - if ((mrc = MPI_Recv(&sap_reply, 1, H5FP_reply, (int)H5FP_sap_rank, - H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - switch (sap_reply.status) { - case H5FP_STATUS_OK: - /* Nothing to do... */ - break; - case H5FP_STATUS_DUMPING: - /* - * Collect the metadata updates from the SAP and write them to - * the file. The function which sends us the dumping data sends - * it to us as an H5FP_read object instead of the H5FP_reply - * object we got above. So we need this "extra" read. - * - * FIXME: This is probably too much of a hack and could be fixed - * for read/write/closing instances... - */ - if (H5FP_dump_to_file(file, dxpl_id) == FAIL) { - *status = H5FP_STATUS_DUMPING_FAILED; - HGOTO_ERROR(H5E_FPHDF5, H5E_WRITEERROR, FAIL, - "can't write metadata update to file"); - } - - if ((mrc = MPI_Recv(&sap_reply, 1, H5FP_reply, (int)H5FP_sap_rank, - H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_reply.status != H5FP_STATUS_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't write metadata to server"); - - break; - default: - *status = sap_reply.status; - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't write metadata to server"); - } - - *status = H5FP_STATUS_OK; - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_flush_metadata - * Purpose: Tell the SAP that we want to change a piece of metadata - * associated with the file. The request ID is returned in a - * pointer supplied by the user. - * - * This function has the potential of causing the process to - * act as a dumper for the SAP's metadata. Places which call - * this function and check the STATUS variable should take - * this into account. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - */ -herr_t -H5FP_request_flush_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, - unsigned *req_id, H5FP_status_t *status) -{ - H5FP_reply_t sap_reply; - H5FP_request_t req; - MPI_Status mpi_status; - int mrc, ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_flush_metadata, FAIL); - - /* check args */ - assert(file); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, (int *)&req.proc_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - req.req_type = H5FP_REQ_FLUSH; - req.req_id = H5FP_gen_request_id(); - req.file_id = file_id; - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_reply, 1, H5FP_reply, (int)H5FP_sap_rank, - H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - switch (sap_reply.status) { - case H5FP_STATUS_OK: - /* Nothing to do... */ - break; - case H5FP_STATUS_DUMPING: - /* - * Collect the metadata updates from the SAP and write them to - * the file. The function which sends us the dumping data sends - * it to us as an H5FP_read object instead of the H5FP_reply - * object we got above. - */ - if (H5FP_dump_to_file(file, dxpl_id) == FAIL) { - *status = H5FP_STATUS_DUMPING_FAILED; - HGOTO_ERROR(H5E_FPHDF5, H5E_WRITEERROR, FAIL, - "can't write metadata update to file"); - } - - if ((mrc = MPI_Recv(&sap_reply, 1, H5FP_reply, (int)H5FP_sap_rank, - H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_reply.status != H5FP_STATUS_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't write metadata to server"); - - break; - default: - *status = sap_reply.status; - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't write metadata to server"); - } - - *status = H5FP_STATUS_OK; - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_close - * Purpose: Tell the SAP that we want all of the structural changes - * made on the file and then close the file. The request ID - * is returned in a pointer passed to the function by the - * user. - * - * This function has the potential of causing the process to - * act as a dumper for the SAP's metadata. Places which call - * this function and check the STATUS variable should take - * this into account. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - */ -herr_t -H5FP_request_close(H5FD_t *file, unsigned file_id, unsigned *req_id, - H5FP_status_t *status) -{ - H5FP_reply_t sap_reply; - H5FP_request_t req; - MPI_Status mpi_status; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_close, FAIL); - - /* check args */ - assert(file); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - req.req_type = H5FP_REQ_CLOSE; - req.req_id = H5FP_gen_request_id(); - req.file_id = file_id; - req.proc_rank = H5FD_mpi_get_rank(file); - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_reply, 1, H5FP_reply, (int)H5FP_sap_rank, - H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_reply.status != H5FP_STATUS_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't close file on server"); - - *status = H5FP_STATUS_OK; - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - - -/* - * Function: H5FP_client_alloc - * Purpose: Handle the client side of an allocation in the FP case. - * In essence, this is simply a matter of referring the - * request to the SAP, and then returning the reply. - * - * A modified version of this code used to live in H5FD_alloc(), - * but I move it here to encapsulate it and generally tidy up. - * - * One can argue that we should all be done in an alloc - * routine in H5FDfdhdf5.c, but this invlves a smaller - * change to the code, and thus a smaller loss if I missed - * a major gotcha. If things go well, and we don't heave - * the current implementation of FP, I'll probably go that - * route eventually. - * Return: Success: The format address of the new file memory. - * Failure: The undefined address HADDR_UNDEF - * Programmer: JRM - 4/7/04 - * Modifications: - */ -haddr_t -H5FP_client_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) -{ - haddr_t ret_value = HADDR_UNDEF; - unsigned req_id = 0; - unsigned capt_only = 0; - H5FP_status_t status = H5FP_STATUS_OK; - H5P_genplist_t *plist; - H5FP_alloc_t fp_alloc; - - FUNC_ENTER_NOAPI(H5FP_client_alloc, HADDR_UNDEF) - - /* check args */ - HDassert(file); - HDassert(file->cls); - HDassert(type >= 0 && type < H5FD_MEM_NTYPES); - HDassert(size > 0); - - /* verify that we are running FP and we are not the SAP. */ - HDassert(H5FD_is_fphdf5_driver(file) && !H5FD_fphdf5_is_sap(file)); - - /* Get the data xfer property list */ - if ( (plist = H5I_object(dxpl_id)) == NULL ) { - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, HADDR_UNDEF, "not a dataset transfer list") - } - - if ( H5P_exist_plist(plist, H5FD_FPHDF5_CAPTN_ALLOC_ONLY) > 0 ) { - if ( H5P_get(plist, H5FD_FPHDF5_CAPTN_ALLOC_ONLY, &capt_only) < 0 ) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, HADDR_UNDEF, "can't retrieve FPHDF5 property") - } - } - - HDmemset(&fp_alloc, 0, sizeof(fp_alloc)); - - /* - * If the captain is the only one who should allocate resources, - * then do just that... - */ - if ( !capt_only || H5FD_fphdf5_is_captain(file) ) { - /* Send the request to the SAP */ - if ( H5FP_request_allocate(file, type, size, &fp_alloc.addr, - &fp_alloc.eoa, &req_id, &status) - != SUCCEED ) { - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTALLOC, HADDR_UNDEF, - "server couldn't allocate from file") - } - } - - /* It should be impossible for this assertion to fail, but then - * that is what assertions are for. - */ - HDassert(status == H5FP_STATUS_OK); - - if ( capt_only ) { - int mrc; - - if ( (mrc = MPI_Bcast(&fp_alloc, 1, H5FP_alloc, - (int)H5FP_capt_barrier_rank, - H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS ) { - HMPI_GOTO_ERROR(HADDR_UNDEF, "MPI_Bcast failed", mrc); - } - } - - /* we used to send the eoa to the sap here, but that is silly, - * as the sap already knows, and it is possible that another - * interleaving allocation will result in a corrupted eoa. - * - * JRM - 4/7/04 - */ - - /* We've succeeded -- return the value */ - HGOTO_DONE(fp_alloc.addr) - -done: - FUNC_LEAVE_NOAPI(ret_value) - -} /* H5FP_client_alloc() */ - - -/* This function is now called only by H5FP_client_alloc() above. - * Should we make it a private function only accessible from this - * file? JRM - 4/8/04 - */ -/* - * Function: H5FP_request_allocate - * Purpose: Request an allocation of space from the SAP. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 19. February 2003 - * Modifications: - */ -herr_t -H5FP_request_allocate(H5FD_t *file, H5FD_mem_t mem_type, hsize_t size, - haddr_t *addr, haddr_t *eoa, unsigned *req_id, - H5FP_status_t *status) -{ - H5FP_alloc_t sap_alloc; - H5FP_request_t req; - MPI_Status mpi_status; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_allocate, FAIL); - - /* check args */ - assert(file); - assert(addr); - assert(eoa); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - req.req_type = H5FP_REQ_ALLOC; - req.req_id = H5FP_gen_request_id(); - req.file_id = H5FD_fphdf5_file_id(file); - req.proc_rank = H5FD_mpi_get_rank(file); - req.mem_type = mem_type; - req.meta_block_size = size; /* use this field as the size to allocate */ - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_alloc, 1, H5FP_alloc, (int)H5FP_sap_rank, - H5FP_TAG_ALLOC, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_alloc.status != H5FP_STATUS_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't allocate space on server"); - - *status = H5FP_STATUS_OK; - *addr = sap_alloc.addr; - *eoa = sap_alloc.eoa; - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_free - * Purpose: Request freeing of space from the SAP. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 20. February 2003 - * Modifications: - */ -herr_t -H5FP_request_free(H5FD_t *file, H5FD_mem_t mem_type, haddr_t addr, hsize_t size, - unsigned *req_id, H5FP_status_t *status) -{ - H5FP_alloc_t sap_alloc; - H5FP_request_t req; - MPI_Status mpi_status; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_free, FAIL); - - /* check args */ - assert(file); - assert(req_id); - assert(status); - - /* Allow zero-sized frees to occur without penalty */ - if (size == 0) - HGOTO_DONE(SUCCEED); - - HDmemset(&req, 0, sizeof(req)); - - req.req_type = H5FP_REQ_FREE; - req.req_id = H5FP_gen_request_id(); - req.file_id = H5FD_fphdf5_file_id(file); - req.proc_rank = H5FD_mpi_get_rank(file); - req.mem_type = mem_type; - req.addr = addr; - req.meta_block_size = size; - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_alloc, 1, H5FP_alloc, (int)H5FP_sap_rank, - H5FP_TAG_ALLOC, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_alloc.status != H5FP_STATUS_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't free space on server"); - -#if 0 /* JRM */ - /* the set_eoa call just sends the eoa we received from the SAP back - * -- with obvious race condition problems if there are interleaving - * calls. Thus I am commenting this call out for now, and will delete - * it in time if I can't find a reason for it. - * - * JRM -- 4/7/04 - */ - /* Set the EOA for all processes. This call doesn't fail. */ - file->cls->set_eoa(file, sap_alloc.eoa); -#endif /* JRM */ - *status = H5FP_STATUS_OK; - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_get_eoa - * Purpose: Request the SAP send the EOA of the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 30. October 2003 - * Modifications: - */ -herr_t -H5FP_request_get_eoa(const H5FD_t *file, haddr_t *eoa, unsigned *req_id, H5FP_status_t *status) -{ - H5FP_eoa_t sap_eoa; - H5FP_request_t req; - MPI_Status mpi_status; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_get_eoa, FAIL); - - /* check args */ - assert(file); - assert(eoa); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - req.req_type = H5FP_REQ_GET_EOA; - req.req_id = H5FP_gen_request_id(); - req.file_id = H5FD_fphdf5_file_id(file); - req.proc_rank = H5FD_mpi_get_rank(file); - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_eoa, 1, H5FP_eoa, (int)H5FP_sap_rank, - H5FP_TAG_EOA, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_eoa.status != H5FP_STATUS_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't free space on server"); - - /* Set the EOA for all processes. This doesn't fail. */ - *eoa = sap_eoa.eoa; - *status = H5FP_STATUS_OK; - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_set_eoa - * Purpose: Request the SAP set the EOA of the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 31. October 2003 - * Modifications: - */ -herr_t -H5FP_request_set_eoa(H5FD_t *file, haddr_t eoa, unsigned *req_id, H5FP_status_t *status) -{ - H5FP_reply_t sap_reply; - H5FP_request_t req; - MPI_Status mpi_status; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_set_eoa, FAIL); - - /* check args */ - assert(file); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - req.req_type = H5FP_REQ_SET_EOA; - req.req_id = H5FP_gen_request_id(); - req.file_id = H5FD_fphdf5_file_id(file); - req.proc_rank = H5FD_mpi_get_rank(file); - req.addr = eoa; - -#if 0 - /* This is useful debugging code -- lets keep for a while. - * JRM -- 4/13/04 - */ - /* dump stack each time we set the eoa */ - { - int mpi_rank; - - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - - HDfprintf(stdout, - "%d: %s: setting eoa: last eoa = %a, new eoa = %a.\n", - mpi_rank, "H5FP_request_set_eoa", last_eoa_received, eoa); - H5FS_print(stdout); - - } -#endif - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_reply, 1, H5FP_reply, (int)H5FP_sap_rank, - H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_reply.status != H5FP_STATUS_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't close file on server"); - - *status = H5FP_STATUS_OK; - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - * Function: H5FP_request_update_eoma_eosda - * Purpose: Request the SAP updates the EOMA and EOSDA information - * for the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. April 2003 - * Modifications: - */ -herr_t -H5FP_request_update_eoma_eosda(H5FD_t *file, unsigned *req_id, H5FP_status_t *status) -{ - H5FP_eoa_t sap_eoa; - H5FP_request_t req; - MPI_Status mpi_status; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5FP_request_update_eoma_eosda, FAIL); - - /* check args */ - assert(file); - assert(req_id); - assert(status); - - HDmemset(&req, 0, sizeof(req)); - - req.req_type = H5FP_REQ_UPDATE_EOMA_EOSDA; - req.req_id = H5FP_gen_request_id(); - req.file_id = H5FD_fphdf5_file_id(file); - req.proc_rank = H5FD_mpi_get_rank(file); - - if ((mrc = MPI_Send(&req, 1, H5FP_request, (int)H5FP_sap_rank, - H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(&sap_eoa, 1, H5FP_eoa, (int)H5FP_sap_rank, - H5FP_TAG_EOA, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_eoa.status != H5FP_STATUS_OK) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCHANGE, FAIL, "can't free space on server"); - - if ((mrc = MPI_Bcast(&sap_eoa, 1, H5FP_eoa, (int)H5FP_capt_barrier_rank, - H5FP_SAP_BARRIER_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed!", mrc); - -#if 0 - /* The following set_eoa just parrots back to the SAP the eoa - * we just received from it. While I don't think it is a problem - * in this case, there are obvious potentials for race conditions, - * and I don't see that it does anything useful. - * - * Thus I am commenting it out for now. I'll delete it completely - * as soon as I am sure that it serves no purpose whatsoever. - * - * JRM - 4/8/04 - */ - /* Set the EOA for all processes. This doesn't fail. */ - file->cls->set_eoa(file, sap_eoa.eoa); -#endif - *status = H5FP_STATUS_OK; - -done: - *req_id = req.req_id; - FUNC_LEAVE_NOAPI(ret_value); -} - -/* - *===----------------------------------------------------------------------=== - * Functions Private to Client Module - *===----------------------------------------------------------------------=== - */ - -/* - * Function: H5FP_gen_request_id - * Purpose: Generate a unique request ID to send along with a - * message. - * Return: Integer >= 0 - Doesn't fail. - * Programmer: Bill Wendling, 30. July, 2002 - * Modifications: - */ -static unsigned -H5FP_gen_request_id() -{ - static unsigned int i = 0; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_gen_request_id); - FUNC_LEAVE_NOAPI(i++); -} - -/* - * Function: H5FP_dump_to_file - * Purpose: Dump the updated metadata to the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 03. February 2003 - * Modifications: - */ -static herr_t -H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id) -{ - H5FP_read_t sap_read; - hid_t new_dxpl_id = FAIL; - H5P_genplist_t *plist = NULL, *old_plist; - unsigned dumping = 1; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_dump_to_file); - - /* check args */ - assert(file); - - if ((old_plist = H5I_object(dxpl_id)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); - - /* Compare property lists */ - if ((new_dxpl_id = H5P_copy_plist(old_plist)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property list"); - - if ((plist = H5P_object_verify(new_dxpl_id, H5P_DATASET_XFER)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list"); - - /* Set the fact that we're dumping metadata to the file */ - if (H5P_insert(plist, H5FD_FPHDF5_XFER_DUMPING_METADATA, - H5FD_FPHDF5_XFER_DUMPING_SIZE, &dumping, - NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property"); - - /* - * At this point, we've received a message saying that the SAP is - * dumping info to us. There's a metadata read waiting for us right - * now... - */ - for (;;) { - MPI_Status mpi_status; - int mrc; - char *mdata; - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - HDmemset(&sap_read, 0, sizeof(sap_read)); - - if ((mrc = MPI_Recv(&sap_read, 1, H5FP_read, (int)H5FP_sap_rank, - H5FP_TAG_DUMP, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (sap_read.status != H5FP_STATUS_DUMPING) { - if (sap_read.status == H5FP_STATUS_DUMPING_FINISHED) - break; - - /* FIXME: ERROR */ - } - - if (H5FP_read_metadata(&mdata, (int)sap_read.md_size, - (int)H5FP_sap_rank) != FAIL) { - if (H5FD_fphdf5_write_real(file, H5FD_MEM_DEFAULT, plist, - sap_read.addr, (int)sap_read.md_size, mdata) == FAIL) { - HDfree(mdata); - HGOTO_ERROR(H5E_FPHDF5, H5E_WRITEERROR, FAIL, "can't write metadata to file"); - } - - HDfree(mdata); - } else { - /* FIXME: Error */ - } - } - -done: - if (new_dxpl_id > 0) - H5I_dec_ref(new_dxpl_id); - - FUNC_LEAVE_NOAPI(ret_value); -} - -#endif /* H5_HAVE_FPHDF5 */ diff --git a/src/H5FPprivate.h b/src/H5FPprivate.h deleted file mode 100644 index da34a6c..0000000 --- a/src/H5FPprivate.h +++ /dev/null @@ -1,349 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef H5FPPRIVATE_H__ -#define H5FPPRIVATE_H__ 0 - -#ifdef H5_HAVE_FPHDF5 - -#include "H5ACpublic.h" /* Metadata Cache */ -#include "H5FPpublic.h" /* Flexible Parallel HDF5 */ -#include "H5Oprivate.h" /* Object Headers */ -#include "H5Rprivate.h" /* References */ - -/*===----------------------------------------------------------------------=== - * Request Types - *===----------------------------------------------------------------------=== - * - * The H5FP_REQ_LOCK_END and H5FP_REQ_RELEASE_END are used to lock and - * release a collection of objects at the same time. The last object you - * need to lock is sent with the H5FP_REQ_LOCK_END request type (this can - * also be a null message - where you're just sending a message that has - * H5FP_REQ_LOCK_END as the request type with no data associated with it. - * In that case, the md_size *MUST* be set to 0). The SAP will then try - * to lock all of the objects you've requested to lock at once. If it - * cannot do so, then it will fail and you have to try again at a later - * time. - * - * Releasing locks is done in the exact same way, except that the action - * will always release locks (i.e., not fail) if there is a vaild lock - * for that object. - */ -typedef enum { - /* Metadata Requests */ - H5FP_REQ_OPEN, /* Open a file (or eventually an object) */ - H5FP_REQ_LOCK, /* Lock an object (in a sequence) */ - H5FP_REQ_LOCK_END, /* Last lock request in lock sequence */ - H5FP_REQ_RELEASE, /* Unlock an object (in a sequence) */ - H5FP_REQ_RELEASE_END, /* Last unlock request in unlock sequence */ - H5FP_REQ_WRITE, /* Writing a piece of metadata */ - H5FP_REQ_READ, /* Reading a piece of metadata */ - H5FP_REQ_FLUSH, /* Flush the metadata out to disk */ - H5FP_REQ_CLOSE, /* Close a file (or eventually an object) */ - H5FP_REQ_GET_EOA, /* Get end of address space information */ - H5FP_REQ_SET_EOA, /* Set end of address space information */ - H5FP_REQ_STOP, /* Stop SAP */ - - /* Allocation Requests */ - H5FP_REQ_ALLOC, /* Allocate a region of metadata */ - H5FP_REQ_FREE, /* Free a region of metadata */ - H5FP_REQ_UPDATE_EOMA_EOSDA /* Update the EOMA and EOSDA information */ -} H5FP_req_t; - -/*===----------------------------------------------------------------------=== - * Lock Types - *===----------------------------------------------------------------------=== - * - * A ``read'' lock indicates that the process is busy reading the - * metadata of that object. It's non-exclusive, so any number of - * processes can have any number of locks on a given object. However, you - * cannot have a write and a read lock on an object. - * - * A ``write'' lock indicates that the process is busy writing to the - * metadata of that object. It's exclusive, so only one process can have - * a write lock on an object at any one time. However, that object can - * have any number of write locks on that object. - * - * It's up to the program to release all of the locks it has on a given - * object. - */ -typedef enum { - H5FP_LOCK_READ, - H5FP_LOCK_WRITE -} H5FP_lock_t; - -/*===----------------------------------------------------------------------=== - * Object Types - *===----------------------------------------------------------------------=== - * - * The various types of objects we're able to get a lock on or which we - * want to modify/read. - */ -typedef enum { - H5FP_OBJ_FILE, - H5FP_OBJ_GROUP, - H5FP_OBJ_DATASET, - H5FP_OBJ_DATATYPE, - H5FP_OBJ_ATTRIBUTE, - H5FP_OBJ_MEMORY -} H5FP_obj_t; - -/*===----------------------------------------------------------------------=== - * MPI Message Tags - *===----------------------------------------------------------------------=== - * - * Special tag numbers for requests, replies, and string passing - * messages. - * - * Certain actions (Open, Change, and Close) require a pathname to the - * object. This pathname is sent in a separate message and the SAP will - * search for it after getting the appropriate request. - */ -enum { - H5FP_TAG_REQUEST, - H5FP_TAG_REPLY, - H5FP_TAG_READ, - H5FP_TAG_METADATA, - H5FP_TAG_ALLOC, - H5FP_TAG_EOA, - H5FP_TAG_DUMP, - H5FP_TAG_FILE_ID -}; - -/*===----------------------------------------------------------------------=== - * Status - *===----------------------------------------------------------------------=== - * - * The status returned by the SAP. If the process receives an - * H5FP_STATUS_CATASTROPHIC status, then something *REALLY* bad happened - * on the set-aside process. The state of the program is then - * indeterminant and the only real course of action is for the program to - * abort operation. - */ -typedef enum sap_status { - H5FP_STATUS_OK, - - /* For locking */ - H5FP_STATUS_LOCK_ACQUIRED, - H5FP_STATUS_LOCK_FAILED, - - /* For releasing locks */ - H5FP_STATUS_LOCK_RELEASED, - H5FP_STATUS_LOCK_RELEASE_FAILED, - H5FP_STATUS_BAD_LOCK, /* Process doesn't own a lock on the OID */ - - /* For change requests */ - H5FP_STATUS_FILE_CLOSING, - H5FP_STATUS_NO_LOCK, - - /* For read requests */ - H5FP_STATUS_MDATA_NOT_CACHED, - - /* For dumping data to client */ - H5FP_STATUS_DUMPING, - H5FP_STATUS_DUMPING_FINISHED, - H5FP_STATUS_DUMPING_FAILED, - - /* Out of memory error */ - H5FP_STATUS_OOM, - - /* Bad file ID */ - H5FP_STATUS_BAD_FILE_ID, - - /* Can't do memory things */ - H5FP_STATUS_CANT_ALLOC, - H5FP_STATUS_CANT_FREE, - - /* Reserved for completely disasterous failures which require an abort */ - H5FP_STATUS_CATASTROPHIC -} H5FP_status_t; - -/*===----------------------------------------------------------------------=== - * H5FP_request - *===----------------------------------------------------------------------=== - * - * The structure sent to the SAP which holds all of the requested action - */ -typedef struct { - unsigned req_id; /* ID for request set by sending process */ - H5FP_req_t req_type; /* Request type */ - unsigned proc_rank; /* Rank of sending process */ - unsigned file_id; /* SAP's file ID for the specific file */ - H5FP_obj_t obj_type; /* Type of the object */ - H5FP_lock_t rw_lock; /* Indicates read or write lock */ - H5FD_mem_t mem_type; /* Type of memory updated, if req'd */ - unsigned md_size; /* Size of the metadata sent in next msg */ - unsigned long feature_flags; /* Feature flags for the file driver */ - hsize_t meta_block_size; /* Metadata block size */ - hsize_t sdata_block_size; /* Small data block size */ - hsize_t threshold; /* Alignment threshold */ - hsize_t alignment; /* Alignment (really!) */ - haddr_t addr; /* Address of the metadata */ - haddr_t oid; /* Buffer to store OID of object */ -} H5FP_request_t; - -extern MPI_Datatype H5FP_request; /* MPI datatype for the H5FP_request obj */ - -/*===----------------------------------------------------------------------=== - * H5FP_reply - *===----------------------------------------------------------------------=== - * - * Reply from the SAP on an H5FP_request send - */ -typedef struct { - unsigned req_id; /* Request ID copied from the SAP_request */ - unsigned file_id; /* File ID assigned to an open file */ - H5FP_status_t status; /* Status of the request */ - unsigned md_size; /* Size of the metadata sent in next msg */ -} H5FP_reply_t; - -extern MPI_Datatype H5FP_reply; /* MPI datatype for the H5FP_reply obj */ - -/*===----------------------------------------------------------------------=== - * H5FP_read - *===----------------------------------------------------------------------=== - * - * The reply message from the SAP on an H5FP_request H5FP_REQ_READ send - */ -typedef struct { - unsigned req_id; /* Request ID copied from the SAP_request */ - unsigned file_id; /* SAP's file ID for the specific file */ - H5FP_status_t status; /* Status of the request */ - H5FD_mem_t mem_type; /* Type of memory updated, if req'd */ - unsigned md_size; /* Size of the metadata sent in next msg */ - haddr_t addr; /* Address of the metadata */ -} H5FP_read_t; - -extern MPI_Datatype H5FP_read; /* MPI datatype for the H5FP_read obj */ - -/*===----------------------------------------------------------------------=== - * H5FP_alloc - *===----------------------------------------------------------------------=== - * - * The reply message from the SAP on an H5FP_alloc H5FP_REQ_ALLOC send. - */ -typedef struct { - unsigned req_id; /* Request ID copied from the SAP_request */ - unsigned file_id; /* SAP's file ID for the specific file */ - H5FP_status_t status; /* Status of the request */ - H5FD_mem_t mem_type; /* Type of memory updated, if req'd */ - haddr_t addr; /* Address of the metadata */ - haddr_t eoa; /* End of address space */ -} H5FP_alloc_t; - -extern MPI_Datatype H5FP_alloc; /* MPI datatype for the H5FP_alloc obj */ - -/*===----------------------------------------------------------------------=== - * H5FP_eoa - *===----------------------------------------------------------------------=== - * - * The reply message from the SAP on an H5FP_alloc H5FP_REQ_ALLOC send. - */ -typedef struct { - unsigned req_id; /* Request ID copied from the SAP_request */ - unsigned file_id; /* SAP's file ID for the specific file */ - H5FP_status_t status; /* Status of the request */ - haddr_t eoa; /* End of address space */ -} H5FP_eoa_t; - -extern MPI_Datatype H5FP_eoa; /* MPI datatype for the H5FP_eoa obj */ - -/*===----------------------------------------------------------------------=== - * H5FP_super - *===----------------------------------------------------------------------=== - * - * The message broadcast from the captain on creating a new file. - */ -typedef struct { - haddr_t addr; /* Address of the superblock */ - hsize_t size; /* Size of superblock */ -} H5FP_super_t; - -extern MPI_Datatype H5FP_super; /* MPI datatype for the H5FP_super obj */ - -/* SAP specific variables */ -extern MPI_Comm H5FP_SAP_COMM; /* Comm we use: Supplied by user */ -extern MPI_Comm H5FP_SAP_BARRIER_COMM; /* Comm if you want to do a barrier */ - -extern unsigned H5FP_sap_rank; /* The rank of the SAP: Supplied by user */ -extern unsigned H5FP_capt_rank; /* The rank which tells SAP of opens */ -extern unsigned H5FP_capt_barrier_rank;/* Rank of captain in barrier comm */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Start the SAP */ -extern herr_t H5FP_sap_receive_loop(void); - -/* Use these functions to communicate with the SAP */ -extern herr_t H5FP_request_open(H5FP_obj_t obj_type, - haddr_t maxaddr, - unsigned long feature_flags, - hsize_t meta_block_size, - hsize_t sdata_block_size, - hsize_t threshold, - hsize_t alignment, - unsigned *file_id, - unsigned *req_id); -extern herr_t H5FP_request_lock(unsigned sap_file_id, hobj_ref_t oid, - H5FP_lock_t rw_lock, int last, unsigned *req_id, - H5FP_status_t *status); -extern herr_t H5FP_request_release_lock(unsigned sap_file_id, hobj_ref_t oid, - int last, unsigned *req_id, - H5FP_status_t *status); -extern herr_t H5FP_request_read_metadata(H5FD_t *file, unsigned sap_file_id, hid_t dxpl_id, - H5FD_mem_t mem_type, haddr_t addr, - size_t size, uint8_t **buf, - unsigned *req_id, H5FP_status_t *status); -extern herr_t H5FP_request_write_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, - H5FD_mem_t mem_type, haddr_t addr, - int mdata_size, const char *mdata, - unsigned *req_id, H5FP_status_t *status); -extern herr_t H5FP_request_flush_metadata(H5FD_t *file, unsigned file_id, - hid_t dxpl_id, unsigned *req_id, - H5FP_status_t *status); -extern herr_t H5FP_request_close(H5FD_t *file, unsigned sap_file_id, - unsigned *req_id, H5FP_status_t *status); - -/* the following function should probably become a private function - * in H5FPclient.c if H5FP_client_alloc() does the job. -- JRM - */ -extern herr_t H5FP_request_allocate(H5FD_t *file, H5FD_mem_t mem_type, - hsize_t size, haddr_t *addr, - haddr_t *eoa, unsigned *req_id, - H5FP_status_t *status); -extern haddr_t H5FP_client_alloc(H5FD_t *file, H5FD_mem_t type, - hid_t dxpl_id, hsize_t size); -extern herr_t H5FP_request_free(H5FD_t *file, H5FD_mem_t mem_type, - haddr_t addr, hsize_t size, - unsigned *req_id, H5FP_status_t *status); -extern herr_t H5FP_request_get_eoa(const H5FD_t *file, haddr_t *eoa, unsigned *req_id, - H5FP_status_t *status); -extern herr_t H5FP_request_set_eoa(H5FD_t *file, haddr_t eoa, unsigned *req_id, - H5FP_status_t *status); -extern herr_t H5FP_request_update_eoma_eosda(H5FD_t *file, unsigned *req_id, - H5FP_status_t *status); - -/* NOTE: Don't use these functions outside of the H5FP* modules! */ -extern herr_t H5FP_send_metadata(const char *mdata, int len, int to); -extern herr_t H5FP_read_metadata(char **mdata, int len, int from); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* H5_HAVE_FPHDF5 */ - -#endif /* H5FPPRIVATE_H__ */ diff --git a/src/H5FPpublic.h b/src/H5FPpublic.h deleted file mode 100644 index b93bd5f..0000000 --- a/src/H5FPpublic.h +++ /dev/null @@ -1,35 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef H5FPPUBLIC_H__ -#define H5FPPUBLIC_H__ 0 - -#include "H5public.h" - -#ifdef H5_HAVE_FPHDF5 - -#ifdef __cplusplus -extern "C" { -#endif - -H5_DLL herr_t H5FPinit(MPI_Comm comm, int sap_rank, - MPI_Comm *FP_comm, MPI_Comm *FP_barrier_comm); -H5_DLL herr_t H5FPfinalize(void); - -#ifdef __cplusplus -} -#endif - -#endif /* H5_HAVE_FPHDF5 */ - -#endif /* H5FPPUBLIC_H__ */ diff --git a/src/H5FPserver.c b/src/H5FPserver.c deleted file mode 100644 index d7bd97a..0000000 --- a/src/H5FPserver.c +++ /dev/null @@ -1,2121 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * NOTE! This is NOT thread safe! - * - * NOTE: There will be caveats on call-back functions. - */ - -/* - * Purpose: - * - * This file has all of the code that a server (SAP) would run to - * handle requests from clients. - */ - - -/* Private header files */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata Cache */ -#include "H5Eprivate.h" /* Error Handling */ -#include "H5FDprivate.h" /* File Driver */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object Headers */ -#include "H5Pprivate.h" /* Property List */ -#include "H5Rprivate.h" /* References */ -#include "H5SLprivate.h" /* Skip lists */ - -#ifdef H5_HAVE_FPHDF5 - -#include "H5FDfphdf5.h" /* File Driver for FPHDF5 */ -#include "H5FPprivate.h" /* Flexible Parallel Functions */ - -/* Local macros */ -#define H5FP_DEFAULT_SKIPLIST_HEIGHT 8 - -/* Internal SAP structures */ - -/*===----------------------------------------------------------------------=== - * H5FP_object_lock - *===----------------------------------------------------------------------=== - * - * A lock on a given object. A list of current locks is kept in the - * appropriate H5FP_file_info structure. - */ -typedef struct { - hobj_ref_t oid; /* buffer to store OID of object */ - unsigned char *num_locks; /* number of times a rank has a lock */ - unsigned num_procs; /* number of processes that have the lock */ - H5FP_obj_t obj_type; /* type of object being locked */ - H5FP_lock_t rw_lock; /* indicates if it's a read or write lock */ -} H5FP_object_lock; - -/*===----------------------------------------------------------------------=== - * H5FP_mdata_mod - *===----------------------------------------------------------------------=== - * - * A given modification (write) of metadata in the file. A list of - * current modifications is kept in the appropriate H5FP_file_info - * structure. - */ -typedef struct { - H5FD_mem_t mem_type; /* type of memory updated */ - H5FP_obj_t obj_type; /* type of object modified */ - haddr_t addr; /* address of the metadata */ - unsigned md_size; /* size of the metadata */ - char *metadata; /* encoded metadata about the object */ -} H5FP_mdata_mod; - -/*===----------------------------------------------------------------------=== - * H5FP_file_info - *===----------------------------------------------------------------------=== - * - * This has all the information the SAP cares about for a given file: a - * copy of the H5FD_fphdf5_t structure for keeping track of metadata - * allocations in the file, the file ID assigned by the SAP, whether the - * file is in the process of being closed (and, therefore, can't accept - * anymore modifications), a count of the number of modifications not - * written to the file, a list of modifications (writes) made by clients - * to the metadata, and a list of current locks on objects in the file. - */ -typedef struct { - H5FD_fphdf5_t file; /* file driver structure */ - unsigned file_id; /* the file id the SAP keeps per file */ - int closing; /* we're closing the file - no more changes */ - unsigned num_mods; /* number of mdata writes outstanding */ - H5SL_t *mod_list; /* a list of metadata updates done */ - H5SL_t *locks; /* a list of locks on objects in the file */ -} H5FP_file_info; - -/* - * This marks the point at which we want to dump all of the metadata - * to a process so that that process can write them to the file. - */ -#define H5FP_MDATA_CACHE_HIGHWATER_MARK 1024 - -static H5SL_t *file_info_list; - -/* local functions */ -static herr_t H5FP_sap_receive(H5FP_request_t *req, int source, int tag, char **buf); - - /* local functions to generate unique ids for messages */ -static unsigned H5FP_gen_sap_file_id(void); - - /* local functions for handling object locks */ -static H5FP_object_lock *H5FP_new_object_lock(hobj_ref_t oid, - unsigned rank, - H5FP_obj_t obj_type, - H5FP_lock_t rw_lock); -static herr_t H5FP_free_object_lock(H5FP_object_lock *ol); -static herr_t H5FP_free_object_lock_cb(void *item, void *key, void *op_data); -static H5FP_object_lock *H5FP_find_object_lock(H5FP_file_info *info, - hobj_ref_t oid); -static herr_t H5FP_remove_object_lock_from_list(H5FP_file_info *info, - H5FP_object_lock *ol); - - /* local file information handling functions */ -static herr_t H5FP_add_new_file_info_to_list(unsigned file_id, - haddr_t maxaddr, - unsigned long feature_flags, - hsize_t meta_block_size, - hsize_t sdata_block_size, - hsize_t threshold, - hsize_t alignment); -static herr_t H5FP_remove_file_id_from_list(unsigned file_id); -static herr_t H5FP_free_file_info_node(H5FP_file_info *info); -static H5FP_file_info *H5FP_new_file_info_node(unsigned file_id); - - /* local file modification structure handling functions */ -static H5FP_mdata_mod *H5FP_new_file_mod_node(H5FD_mem_t mem_type, - haddr_t addr, - unsigned md_size, - char *metadata); -static herr_t H5FP_free_mod_node(H5FP_mdata_mod *info); -static herr_t H5FP_free_mod_node_cb(void *item, void *key, void *op_data); - - /* local request handling functions */ -static herr_t H5FP_sap_handle_open_request(H5FP_request_t *req, unsigned md_size); -static herr_t H5FP_sap_handle_lock_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_release_lock_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_read_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_write_request(H5FP_request_t *req, - char *mdata, - unsigned md_size); -static herr_t H5FP_sap_handle_flush_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_close_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_alloc_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_free_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_get_eoa_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_set_eoa_request(H5FP_request_t *req); -static herr_t H5FP_sap_handle_update_eoma_eosda_request(H5FP_request_t *req); - -/* - *===----------------------------------------------------------------------=== - * Public Library (non-API) Functions - *===----------------------------------------------------------------------=== - */ - -/* - * Function: H5FP_sap_receive_loop - * Purpose: Just receive message after message from the other - * processes and process that message. Return when we - * receive an "H5FP_REQ_STOP" message from all processes in - * H5FP_SAP_COMM. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 05. August, 2002 - * Modifications: - */ -herr_t -H5FP_sap_receive_loop(void) -{ - herr_t ret_value = SUCCEED; - int comm_size; - int stop = 0; - H5FP_request_t req; - - FUNC_ENTER_NOAPI(H5FP_sap_receive_loop, FAIL) - - /* Get the size of the SAP communicator */ - if (MPI_Comm_size(H5FP_SAP_COMM, &comm_size) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_size failed") - - /* Create the file structure tree. */ - if ((file_info_list = H5SL_create(H5SL_TYPE_UNSIGNED,0.5,H5FP_DEFAULT_SKIPLIST_HEIGHT)) == NULL) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTCREATE, FAIL, "cannot make skip list") - - for (;;) { - char *buf = NULL; - herr_t hrc; - - if (H5FP_sap_receive(&req, MPI_ANY_SOURCE, H5FP_TAG_REQUEST, &buf) != SUCCEED) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTRECV, FAIL, "cannot receive messages") - - switch (req.req_type) { - case H5FP_REQ_OPEN: - if ((hrc = H5FP_sap_handle_open_request(&req, req.md_size)) != SUCCEED) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTOPENOBJ, FAIL, "cannot open file") - break; - case H5FP_REQ_LOCK: - case H5FP_REQ_LOCK_END: - hrc = H5FP_sap_handle_lock_request(&req); - break; - case H5FP_REQ_RELEASE: - case H5FP_REQ_RELEASE_END: - hrc = H5FP_sap_handle_release_lock_request(&req); - break; - case H5FP_REQ_READ: - hrc = H5FP_sap_handle_read_request(&req); - break; - case H5FP_REQ_WRITE: - hrc = H5FP_sap_handle_write_request(&req, buf, req.md_size); - break; - case H5FP_REQ_FLUSH: - hrc = H5FP_sap_handle_flush_request(&req); - break; - case H5FP_REQ_CLOSE: - hrc = H5FP_sap_handle_close_request(&req); - break; - case H5FP_REQ_ALLOC: - hrc = H5FP_sap_handle_alloc_request(&req); - break; - case H5FP_REQ_FREE: - hrc = H5FP_sap_handle_free_request(&req); - break; - case H5FP_REQ_GET_EOA: - hrc = H5FP_sap_handle_get_eoa_request(&req); - break; - case H5FP_REQ_SET_EOA: - hrc = H5FP_sap_handle_set_eoa_request(&req); - break; - case H5FP_REQ_UPDATE_EOMA_EOSDA: - hrc = H5FP_sap_handle_update_eoma_eosda_request(&req); - break; - case H5FP_REQ_STOP: - hrc = SUCCEED; - if (++stop == comm_size - 1) - goto done; - break; - default: - HGOTO_ERROR(H5E_FPHDF5, H5E_ARGS, FAIL, "invalid request type") - } - - /* - * If the above calls didn't succeed, free the buffer - */ - if (hrc != SUCCEED) { - HDfree(buf); - } - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_receive - * Purpose: Receive a message from SOURCE with the given TAG. The REQ - * object passed in as a pointer is filled by the MPI_Recv - * function. - * Return: Success: Pointer to string passed in, if one was sent. - * As well as the SAP_request object. - * Failure: FAIL - * Programmer: Bill Wendling, 17. September, 2002 - * Modifications: - */ -static herr_t -H5FP_sap_receive(H5FP_request_t *req, int source, int tag, char **buf) -{ - MPI_Status status; - herr_t ret_value = SUCCEED; - int mrc; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_receive) - - HDmemset(&status, 0, sizeof(status)); - - if ((mrc = MPI_Recv(req, 1, H5FP_request, source, tag, - H5FP_SAP_COMM, &status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - - if (buf && req->md_size) - if (H5FP_read_metadata(buf, (int)req->md_size, (int)req->proc_rank) == FAIL) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTRECV, FAIL, "can't read metadata from process") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_new_object_lock - * Purpose: Create a new object lock. The locks are keyed off of the - * OID when they're inserted into the skip list. There's a - * reference count so the same process can request the lock - * multiple times, if need be. The rank of the requesting - * process is kept around so that we can determine who - * wanted it in the first place. RW_LOCK tells us what kind - * of lock it is -- READ or WRITE. - * Return: Success: Pointer to SAP_OBJ_LOCK structure. - * Failure: NULL - * Programmer: Bill Wendling, 09. September 2002 - * Modifications: - */ -static H5FP_object_lock * -H5FP_new_object_lock(hobj_ref_t oid, unsigned rank, H5FP_obj_t obj_type, - H5FP_lock_t rw_lock) -{ - int comm_size; - H5FP_object_lock *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_new_object_lock) - - if (MPI_Comm_size(H5FP_SAP_COMM, &comm_size) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_Comm_size failed") - - if ((ret_value = (H5FP_object_lock *)H5MM_malloc(sizeof(H5FP_object_lock))) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "out of memory") - - if ((ret_value->num_locks = (unsigned char *)HDcalloc((size_t)comm_size, 1)) == NULL) { - HDfree(ret_value); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "out of memory") - } - - ret_value->oid = oid; - ret_value->num_locks[rank] = TRUE; - ret_value->obj_type = obj_type; - ret_value->num_procs = 1; - ret_value->rw_lock = rw_lock; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_free_object_lock - * Purpose: Free up the space allocated for the object lock. - * Return: SUCCEED (never fails) - * Programmer: Bill Wendling, 09. September 2002 - * Modifications: - */ -static herr_t -H5FP_free_object_lock(H5FP_object_lock *ol) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_free_object_lock) - - if (ol) { - HDfree(ol->num_locks); - HDfree(ol); - } - - FUNC_LEAVE_NOAPI(SUCCEED) -} - -/* - * Function: H5FP_free_object_lock_cb - * Purpose: Free up the space allocated for the object lock. - * Purpose: Helper function to call H5FP_free_object_lock when closing - * skip lists - * Return: SUCCEED (never fails) - * Programmer: Quincey Koziol, 30. December, 2004 - * Modifications: - */ -static herr_t -H5FP_free_object_lock_cb(void *item, void UNUSED *key, void UNUSED *op_data) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_free_object_lock_cb) - - H5FP_free_object_lock(item); - - FUNC_LEAVE_NOAPI(SUCCEED) -} - -/* - * Function: H5FP_find_object_lock - * Purpose: Find the object lock for the given OID if there is one. - * Return: Success: Pointer to the object - * Failure: NULL - * Programmer: Bill Wendling, 09. September 2002 - * Modifications: - */ -static H5FP_object_lock * -H5FP_find_object_lock(H5FP_file_info *info, hobj_ref_t oid) -{ - H5FP_object_lock *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_find_object_lock) - - assert(info); - assert(oid); - - if (info->locks) - if ((ret_value = H5SL_search(info->locks, &oid)) == NULL) - HGOTO_ERROR(H5E_FPHDF5, H5E_NOTFOUND, NULL, "lock not found") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_remove_object_lock_from_list - * Purpose: Remove the object lock from the file structure's lock - * list. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 09. September 2002 - * Modifications: - */ -static herr_t -H5FP_remove_object_lock_from_list(H5FP_file_info *info, - H5FP_object_lock *ol) -{ - H5FP_object_lock *lock; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_remove_object_lock_from_list) - - if ((lock = H5SL_remove(info->locks, &ol->oid)) == NULL) - HGOTO_ERROR(H5E_FPHDF5, H5E_NOTFOUND, FAIL, "lock not found") - - if(H5FP_free_object_lock(lock)<0) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTFREE, FAIL, "can't release lock") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_free_mod_node - * Purpose: Helper function to free up an SAP_FILE_MOD node and all - * of the malloced space it has. - * Return: SUCCEED (doesn't fail) - * Programmer: Bill Wendling, 31. July, 2002 - * Modifications: - */ -static herr_t -H5FP_free_mod_node(H5FP_mdata_mod *info) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_free_mod_node) - - if (info) { - HDfree(info->metadata); - HDfree(info); - } - - FUNC_LEAVE_NOAPI(SUCCEED) -} - -/* - * Function: H5FP_free_mod_node_cb - * Purpose: Helper function to call H5FP_free_mod_node when closing - * skip lists - * Return: SUCCEED (doesn't fail) - * Programmer: Quincey Koziol, 30. December, 2004 - * Modifications: - */ -static herr_t -H5FP_free_mod_node_cb(void *item, void UNUSED *key, void UNUSED *op_data) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_free_mod_node_cb) - - H5FP_free_mod_node(item); - - FUNC_LEAVE_NOAPI(SUCCEED) -} - -/* - * Function: H5FP_new_file_mod_node - * Purpose: Create a new sap_file_mod node and initialize it. This - * object now has responsibility for freeing the metadata - * information. - * Return: Success: Pointer to new sap_file_mod structure. - * Failure: NULL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - */ -static H5FP_mdata_mod * -H5FP_new_file_mod_node(H5FD_mem_t mem_type, haddr_t addr, unsigned md_size, char *metadata) -{ - H5FP_mdata_mod *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_new_file_mod_node) - - if ((ret_value = (H5FP_mdata_mod *)H5MM_malloc(sizeof(H5FP_mdata_mod))) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "out of memory") - - ret_value->mem_type = mem_type; - ret_value->addr = addr; - ret_value->md_size = md_size; - ret_value->metadata = metadata; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_merge_mod_node_with_next - * - * Purpose: Given a node in a mod tree which overlaps with the next - * node in the tree, merge the two. Where the two nodes - * overlap, use the data from the supplied node. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: JRM - 3/18/04 - * - * Modifications: - * - * None. - */ -static herr_t -H5FP_merge_mod_node_with_next(H5SL_t *slist, H5SL_node_t *node_ptr) -{ - H5SL_node_t *next_node_ptr; - H5FP_mdata_mod *mod_ptr; - H5FP_mdata_mod *next_mod_ptr; - herr_t ret_value=SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_merge_mod_node_with_next) - - /* check parameters & do some initializations in passing */ - HDassert(slist); - HDassert(node_ptr); - if ( ( (mod_ptr = H5SL_item(node_ptr)) == NULL ) || - ( (next_node_ptr = H5SL_next(node_ptr)) == NULL ) || - ( (next_mod_ptr = H5SL_item(next_node_ptr)) == NULL ) || - ( mod_ptr->addr >= next_mod_ptr->addr ) || - ( (mod_ptr->addr + mod_ptr->md_size) <= next_mod_ptr->addr ) ) - HGOTO_ERROR(H5E_FPHDF5, H5E_BADVALUE, FAIL, "One or more bad params detected on entry.") - - /* Check for partial overlap */ - if ( (mod_ptr->addr + mod_ptr->md_size) < - (next_mod_ptr->addr + next_mod_ptr->md_size) ) { - unsigned combined_md_size; - char *combined_metadata_ptr; - unsigned offset; - unsigned i,j; - - /* The next node address range is not completely subsumed in - * that of the current node. Must allocate a new buffer, and - * copy over the contents of the two buffers. Where the buffers - * overlap, give precidence to the data from *node_ptr - */ - combined_md_size = (next_mod_ptr->addr + next_mod_ptr->md_size) - - mod_ptr->addr; - - combined_metadata_ptr = (char *)H5MM_malloc((size_t)(combined_md_size)); - if ( combined_metadata_ptr == NULL ) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate buffer for combined node.") - - i = 0; /* this is the index into the combined buffer */ - - for ( j = 0; j < mod_ptr->md_size; j++ ) - combined_metadata_ptr[i++] = (mod_ptr->metadata)[j]; - - offset = (mod_ptr->addr + mod_ptr->md_size) - next_mod_ptr->addr; - - for ( j = offset; j < next_mod_ptr->md_size; j++ ) - combined_metadata_ptr[i++] = (next_mod_ptr->metadata)[j]; - - HDassert(i == combined_md_size); - - HDfree(mod_ptr->metadata); - mod_ptr->metadata = combined_metadata_ptr; - mod_ptr->md_size = combined_md_size; - } /* end if */ - - /* We have copied metadata from the next node into the current node - * if this was necessary. All that remains is to delete the next - * node from the tree and free it. - */ - H5SL_remove(slist, &next_mod_ptr->addr); - - H5FP_free_mod_node(next_mod_ptr); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FP_merge_mod_node_with_next() */ - -/* - * Function: H5FP_merge_mod_node_with_prev - * - * Purpose: Given a node in a mod tree which overlaps with the previous - * node in the tree, merge the two. Where the two nodes - * overlap, use the data from the supplied node. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: JRM - 3/19/04 - * - * Modifications: - * - * None. - */ -static herr_t -H5FP_merge_mod_node_with_prev(H5SL_t *slist, H5SL_node_t *node_ptr) -{ - H5SL_node_t *prev_node_ptr; - H5FP_mdata_mod *mod_ptr; - H5FP_mdata_mod *prev_mod_ptr; - unsigned i,j; - herr_t ret_value=SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_merge_mod_node_with_prev) - - /* check parameters & do some initializations in passing */ - HDassert(slist); - HDassert(node_ptr); - if ( ( (mod_ptr = H5SL_item(node_ptr)) == NULL ) || - ( (prev_node_ptr = H5SL_prev(node_ptr)) == NULL ) || - ( (prev_mod_ptr = H5SL_item(prev_node_ptr)) == NULL ) || - ( mod_ptr->addr <= prev_mod_ptr->addr ) || - ( (prev_mod_ptr->addr + prev_mod_ptr->md_size) <= mod_ptr->addr ) ) - HGOTO_ERROR(H5E_FPHDF5, H5E_BADVALUE, FAIL, "One or more bad params detected on entry.") - - if ( (prev_mod_ptr->addr + prev_mod_ptr->md_size) < - (mod_ptr->addr + mod_ptr->md_size) ) { - unsigned combined_md_size; - char *combined_metadata_ptr; - unsigned limit; - - /* The node address range is not completely subsumed in - * that of the previous node. Must allocate a new buffer, and - * copy over the contents of the two buffers. Where the buffers - * overlap, give precidence to the data from *node_ptr - */ - combined_md_size = (mod_ptr->addr + mod_ptr->md_size) - - (prev_mod_ptr->addr); - - combined_metadata_ptr = (char *)H5MM_malloc((size_t)(combined_md_size)); - if ( combined_metadata_ptr == NULL ) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate buffer for combined node.") - - i = 0; /* this is the index into the combined buffer */ - - limit = mod_ptr->addr - prev_mod_ptr->addr; - HDassert(limit > 0 ); - - for ( j = 0; j < limit; j++ ) - combined_metadata_ptr[i++] = (prev_mod_ptr->metadata)[j]; - - for ( j = 0; j < mod_ptr->md_size; j++ ) - combined_metadata_ptr[i++] = (mod_ptr->metadata)[j]; - - HDassert(i == combined_md_size); - - HDfree(prev_mod_ptr->metadata); - prev_mod_ptr->metadata = combined_metadata_ptr; - prev_mod_ptr->md_size = combined_md_size; - } else { /* supplied node is completely inside previous node */ - /* no need to allocate a new buffer. Just copy data from - * mod_ptr->metadata to the appropriate locations in - * prev_mod_ptr->metadata. - */ - - i = mod_ptr->addr - prev_mod_ptr->addr; - - for ( j = 0; j < mod_ptr->md_size; j++ ) - (prev_mod_ptr->metadata)[i++] = (mod_ptr->metadata)[j]; - - HDassert(i <= prev_mod_ptr->md_size); - } /* end else */ - - /* We have copied metadata from the current node into the previous - * node. All that remains is to delete the current node from the - * tree and free it. - */ - - H5SL_remove(slist, &mod_ptr->addr); - - H5FP_free_mod_node(mod_ptr); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FP_merge_mod_node_with_prev() */ - -/* - * Function: H5FP_mod_node_overlaps_with_next - * - * Purpose: Given a node in a mod tree, see if there is an overlap - * between the address range of the supplied node, and that - * of the next node in the tree (if any). - * - * Return: TRUE if there is an overlap, and FALSE if there - * isn't. - * - * Programmer: JRM - 3/18/04 - * - * Modifications: - * - * None. - */ -static hbool_t -H5FP_mod_node_overlaps_with_next(H5SL_node_t *node_ptr) -{ - hbool_t ret_value=FALSE; - H5SL_node_t *next_node_ptr; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_mod_node_overlaps_with_next) - - HDassert(node_ptr != NULL); - - next_node_ptr = H5SL_next(node_ptr); - - if ( next_node_ptr != NULL ) { -#if 0 - if ( ( ((H5FP_mdata_mod *)H5SL_item(node_ptr))->addr > 100000 ) || - ( (((H5FP_mdata_mod *)H5SL_item(node_ptr))->md_size) > 1024 ) ) { - HDfprintf(stdout, "%s: addr = %a, size = %u, mem_type = %d.\n", - "H5FP_mod_node_overlaps_with_next(2)", - ((H5FP_mdata_mod *)H5SL_item(node_ptr))->addr, - ((H5FP_mdata_mod *)H5SL_item(node_ptr))->md_size, - (int)(((H5FP_mdata_mod *)H5SL_item(node_ptr))->mem_type)); - } - - if ( (((H5FP_mdata_mod *)H5SL_item(node_ptr))->addr) - >= - (((H5FP_mdata_mod *)H5SL_item(next_node_ptr))->addr) - ) { - HDfprintf(stdout, "%s: addr,len = %a,%u, next_addr,len = %a,%u.\n", - "H5FP_mod_node_overlaps_with_next", - (((H5FP_mdata_mod *)H5SL_item(node_ptr))->addr), - ((H5FP_mdata_mod *)H5SL_item(node_ptr))->md_size, - (((H5FP_mdata_mod *)H5SL_item(next_node_ptr))->addr), - ((H5FP_mdata_mod *)H5SL_item(next_node_ptr))->md_size); - - HDassert((((H5FP_mdata_mod *)H5SL_item(node_ptr))->addr) - < - (((H5FP_mdata_mod *)H5SL_item(next_node_ptr))->addr) - ); - } -#endif - if ( ( (((H5FP_mdata_mod *)H5SL_item(node_ptr))->addr) - + - (((H5FP_mdata_mod *)H5SL_item(node_ptr))->md_size) - ) - > - (((H5FP_mdata_mod *)H5SL_item(next_node_ptr))->addr) - ) { -#if 0 - /* This is useful debugging code -- keep it around for - * a while. JRM -- 4/13/03 - */ - HDfprintf(stdout, - "H5FP_mod_node_overlaps_with_next: addr = %a, next_addr = %a.\n", - (((H5FP_mdata_mod *)(node_ptr->data))->addr), - (((H5FP_mdata_mod *)(next_node_ptr->data))->addr)); -#endif - ret_value = TRUE; - } - } - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FP_mod_node_overlaps_with_next() */ - -/* - * Function: H5FP_mod_node_overlaps_with_prev - * - * Purpose: Givena node in a mod tree, see if there is an overlap - * between the address range of the supplied node, and that - * of the previous node in the tree (if any). - * - * Return: TRUE if there is an overlap, and FALSE if there - * isn't. - * - * Programmer: JRM - 3/18/04 - * - * Modifications: - * - * None. - */ -static hbool_t -H5FP_mod_node_overlaps_with_prev(H5SL_node_t *node_ptr) -{ - hbool_t ret_value=FALSE; - H5SL_node_t *prev_node_ptr; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_mod_node_overlaps_with_prev) - - HDassert(node_ptr != NULL); - - prev_node_ptr = H5SL_prev(node_ptr); - - if ( prev_node_ptr != NULL ) - { - HDassert((((H5FP_mdata_mod *)H5SL_item(node_ptr))->addr) - > - (((H5FP_mdata_mod *)H5SL_item(prev_node_ptr))->addr) - ); - - if ( ( (((H5FP_mdata_mod *)H5SL_item(prev_node_ptr))->addr) - + - (((H5FP_mdata_mod *)H5SL_item(prev_node_ptr))->md_size) - ) - > - (((H5FP_mdata_mod *)H5SL_item(node_ptr))->addr) - ) { -#if 0 - /* This is useful debugging code -- keep it around for - * a while. JRM - 4/13/04 - */ - HDfprintf(stdout, - "H5FP_mod_node_overlaps_with_prev: addr = %a, prev_addr = %a.\n", - (((H5FP_mdata_mod *)(node_ptr->data))->addr), - (((H5FP_mdata_mod *)(prev_node_ptr->data))->addr)); -#endif - ret_value = TRUE; - } - } - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FP_mod_node_overlaps_with_prev() */ - -/* - * Function: H5FP_add_file_mod_to_list - * Purpose: Add a metadata write to a file ID. If the metadata is - * already in the cache, then we just replace it with the - * updated bits. (Only the metadata info and size should - * change in this case.) - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - * Re-worked code to merge overlapping metadata changes, - * and to avoid discarding metadata if the supplied metadata - * is smaller than that already in the mod list. - * JRM -- 3/29/04 - */ -static herr_t -H5FP_add_file_mod_to_list(H5FP_file_info *info, H5FD_mem_t mem_type, - haddr_t addr, unsigned md_size, - char *metadata) -{ - H5FP_mdata_mod *fm; - H5SL_node_t *node; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_add_file_mod_to_list) - - /* check args */ - assert(info); - -#if 0 - /* This is useful debugging code -- keep it around for a - * while. JRM -- 4/13/04 - */ - HDfprintf(stdout, - "H5FP_add_file_mod_to_list: Adding chunk at %a of length %u.\n", - addr, md_size); -#endif - if ((node = H5SL_find(info->mod_list, &addr)) != NULL) { - /* - * The metadata is in the cache already. All we have to do is - * replace what's there. The addr and type should be the same. - * The only things to change is the metadata and its size. - */ - fm = H5SL_item(node); - - if ( fm->md_size > md_size ) { - HDmemcpy(fm->metadata,metadata,md_size); - HDfree(metadata); - } else if ( fm->md_size < md_size ) { - HDfree(fm->metadata); - fm->metadata = metadata; - fm->md_size = md_size; - - while ( H5FP_mod_node_overlaps_with_next(node) ) { - if ( H5FP_merge_mod_node_with_next(info->mod_list, node)<0) - /* Need to define better errors here. -- JRM */ - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTCHANGE, FAIL, "Can't merge with next.") - - (info->num_mods)--; /* since we just merged */ - } - } else { /* fm->md_size == md_size */ - HDfree(fm->metadata); - fm->metadata = metadata; - } - } /* end if */ - else { - if ( (fm = H5FP_new_file_mod_node(mem_type, addr, md_size, metadata)) == NULL) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTALLOC, FAIL, "can't create modification node") - - if ( (node = H5SL_add(info->mod_list, fm, &fm->addr)) == NULL ) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, "can't insert modification into list") - - (info->num_mods)++; - - /* merge with next as required */ - while ( H5FP_mod_node_overlaps_with_next(node) ) { - if ( H5FP_merge_mod_node_with_next(info->mod_list, node) < 0) - /* Need to define better errors here. -- JRM */ - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTCHANGE, FAIL, "Can't merge new node with next.") - - (info->num_mods)--; /* since we just merged */ - } - - /* if the tree was valid to begin with, we must merge with at - * most one previous node. - */ - if ( H5FP_mod_node_overlaps_with_prev(node) ) { - if ( H5FP_merge_mod_node_with_prev(info->mod_list, node) < 0 ) - /* Need to define better errors here. -- JRM */ - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTCHANGE, FAIL, "Can't merge new node with prev.") - - (info->num_mods)--; /* since we just merged */ - } - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_free_file_info_node - * Purpose: Helper function to free up an SAP_FILE_STRUCT node and all - * of the malloced space it has. - * Return: SUCCEED (never fails) - * Programmer: Bill Wendling, 31. July, 2002 - * Modifications: - */ -static herr_t -H5FP_free_file_info_node(H5FP_file_info *info) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_free_file_info_node) - - if (info) { - H5SL_destroy(info->mod_list,H5FP_free_mod_node_cb,NULL); - H5SL_destroy(info->locks,H5FP_free_object_lock_cb,NULL); - H5FD_free_freelist(&info->file.pub); - H5MM_xfree(info); - } - - FUNC_LEAVE_NOAPI(SUCCEED) -} - -/* - * Function: H5FP_new_file_info_node - * Purpose: Create and initialize an sap_file_info node. - * Return: Success: Pointer to new node - * Failure: NULL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - */ -static H5FP_file_info * -H5FP_new_file_info_node(unsigned file_id) -{ - H5FP_file_info *ret_value; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_new_file_info_node) - - if ((ret_value = (H5FP_file_info *)H5MM_malloc(sizeof(H5FP_file_info))) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "out of memory") - - ret_value->file_id = file_id; - ret_value->closing = FALSE; - ret_value->num_mods = 0; - - if ((ret_value->mod_list = H5SL_create(H5SL_TYPE_HADDR,0.5,H5FP_DEFAULT_SKIPLIST_HEIGHT)) == NULL) { - HDfree(ret_value); - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTCREATE, NULL, "cannot make skip list") - } - - if ((ret_value->locks = H5SL_create(H5SL_TYPE_HADDR,0.5,H5FP_DEFAULT_SKIPLIST_HEIGHT)) == NULL) { - H5SL_close(ret_value->mod_list); - HDfree(ret_value); - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTCREATE, NULL, "cannot make skip list") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_add_new_file_info_to_list - * Purpose: Add a FILE_ID to the list of file IDS. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. August, 2002 - * Modifications: - */ -static herr_t -H5FP_add_new_file_info_to_list(unsigned file_id, haddr_t maxaddr, - unsigned long feature_flags, - hsize_t meta_block_size, - hsize_t sdata_block_size, - hsize_t threshold, - hsize_t alignment) -{ - H5FP_file_info *info; - herr_t ret_value = FAIL; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_add_new_file_info_to_list) - - if ((info = H5FP_new_file_info_node(file_id)) != NULL) { - int mrc; - - if (H5SL_insert(file_info_list, info, &info->file_id)<0) { - H5FP_free_file_info_node(info); - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, "can't insert file structure into tree") - } - - /* - * Initialize some of the information needed for metadata - * allocation requests - */ - HDmemset(&info->file, 0, sizeof(info->file)); - info->file.pub.driver_id = H5FD_FPHDF5; - info->file.pub.cls = (const H5FD_class_t *)&H5FD_fphdf5_g; - info->file.pub.maxaddr = maxaddr; - info->file.pub.accum_loc = HADDR_UNDEF; - info->file.pub.feature_flags = feature_flags; - info->file.pub.def_meta_block_size = meta_block_size; - info->file.pub.def_sdata_block_size = sdata_block_size; - info->file.pub.threshold = threshold; - info->file.pub.alignment = alignment; - - if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, &info->file.mpi_rank)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - if ((mrc = MPI_Comm_size(H5FP_SAP_COMM, &info->file.mpi_size)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); - - ret_value = SUCCEED; - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_remove_file_id_from_list - * Purpose: Remove an FILE_ID from the list of file IDS. - * - * NOTE: This should only be called after all modifications to - * the file descriptor have been synced to all processes and the - * file has been closed by all processes. - * - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 31. July, 2002 - * Modifications: - */ -static herr_t -H5FP_remove_file_id_from_list(unsigned file_id) -{ - H5FP_file_info *info; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_remove_file_id_from_list) - - /* Remove the file info from the skip list */ - if ((info = H5SL_remove(file_info_list, &file_id)) == NULL) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTFREE, FAIL, "can't release file info") - - /* Free file info */ - H5FP_free_file_info_node(info); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - *===----------------------------------------------------------------------=== - * Functions to reply to requests - *===----------------------------------------------------------------------=== - */ - -/* - * Function: H5FP_send_reply - * Purpose: Send an H5FP_reply message to process TO. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 31. July, 2002 - * Modifications: - */ -static herr_t -H5FP_send_reply(unsigned to, unsigned req_id, unsigned file_id, H5FP_status_t status) -{ - H5FP_reply_t reply; - herr_t ret_value = SUCCEED; - int mrc; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_send_reply) - - reply.req_id = req_id; - reply.file_id = file_id; - reply.status = status; - - if ((mrc = MPI_Send(&reply, 1, H5FP_reply, (int)to, H5FP_TAG_REPLY, - H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_dump - * Purpose: Dump all metadata writes to a process so that that - * process will write them to the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 31. July, 2002 - * Modifications: - */ -static herr_t -H5FP_dump(H5FP_file_info *info, unsigned to, unsigned req_id, unsigned file_id) -{ - H5FP_read_t r; - H5SL_node_t *node; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_dump) - - /* check args */ - assert(info); - - if (info->mod_list==NULL || H5SL_count(info->mod_list)==0) - /* Nothing to write to the file */ - HGOTO_DONE(SUCCEED) - - r.req_id = req_id; - r.file_id = file_id; - r.status = H5FP_STATUS_DUMPING; - - node = H5SL_first(info->mod_list); - while (node) { - H5FP_mdata_mod *m = H5SL_item(node); - - r.mem_type = m->mem_type; - r.addr = m->addr; - r.md_size = m->md_size; - - if ((mrc = MPI_Send(&r, 1, H5FP_read, (int)to, H5FP_TAG_DUMP, - H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - if (H5FP_send_metadata(m->metadata, (int)m->md_size, (int)to) != SUCCEED) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't dump metadata to client") - - node = H5SL_next(node); - } - - /* Tell the receiving process that we're finished... */ - r.mem_type = 0; - r.addr = 0; - r.md_size = 0; - r.status = H5FP_STATUS_DUMPING_FINISHED; - - if ((mrc = MPI_Send(&r, 1, H5FP_read, (int)to, H5FP_TAG_DUMP, - H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - /* Free up the nodes in the modification list */ - if(H5SL_free(info->mod_list, H5FP_free_mod_node_cb, NULL)<0) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTFREE, FAIL, "cannot free skip list") - - info->num_mods = 0; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - *===----------------------------------------------------------------------=== - * Functions to handle SAP requests - *===----------------------------------------------------------------------=== - */ - -/* - * Function: H5FP_gen_request_id - * Purpose: Generate a unique request ID to send along with a - * message. - * Return: Integer >= 0 - Doesn't fail. - * Programmer: Bill Wendling, 30. July, 2002 - * Modifications: - */ -static unsigned -H5FP_gen_sap_file_id() -{ - static unsigned i = 0; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_gen_sap_file_id) - FUNC_LEAVE_NOAPI(i++) -} - -/* - * Function: H5FP_sap_handle_open_request - * Purpose: Handle a request to open a file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 06. August, 2002 - * Modifications: - */ -static herr_t -H5FP_sap_handle_open_request(H5FP_request_t *req, unsigned UNUSED md_size) -{ - herr_t ret_value = SUCCEED; - int mrc; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_open_request) - - if (req->obj_type == H5FP_OBJ_FILE) { - unsigned new_file_id = H5FP_gen_sap_file_id(); - - /* N.B. At this point, req->addr is equiv. to maxaddr in H5FD_open() */ - if (H5FP_add_new_file_info_to_list(new_file_id, req->addr, req->feature_flags, - req->meta_block_size, req->sdata_block_size, - req->threshold, req->alignment) != SUCCEED) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, - "can't insert new file structure to list") - - /* file ID gets broadcast via the captain process */ - if ((mrc = MPI_Send(&new_file_id, 1, MPI_UNSIGNED, (int)req->proc_rank, - H5FP_TAG_FILE_ID, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_lock_request - * Purpose: Handle a request to lock an object. There are two - * different kinds of locks. There are READ and WRITE locks. - * The READ locks are sharable, that is if all processes want - * to READ the object, they can. They just tell the SAP that - * they're doing so and the SAP gives them a "token" to do - * that. WRITE locks, on the other hand, are exclusive. You - * can't have any outstanding READ or WRITE locks on an - * object before you get a WRITE lock on it. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 06. August, 2002 - * Modifications: - */ -static herr_t -H5FP_sap_handle_lock_request(H5FP_request_t *req) -{ - struct lock_group { - hobj_ref_t oid; - unsigned file_id; - unsigned locked; - H5FP_lock_t rw_lock; - H5FP_file_info *info; - H5FP_object_lock *lock; - } *oids; - unsigned list_size = 2; /* the size of the "oids" list */ - H5FP_status_t exit_state = H5FP_STATUS_LOCK_ACQUIRED; - unsigned i, j; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_lock_request) - - if ((oids = (struct lock_group *)H5MM_malloc(list_size * - sizeof(struct lock_group))) == NULL) { - exit_state = H5FP_STATUS_OOM; - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory") - } - - /* - * Gather together all of the OIDs the process is requesting to lock - * at one time. - */ - for (i = 0;; ++i) { - if (req->oid) { - if (i == list_size) { - list_size <<= 1; /* equiv to list_size *= 2; */ - oids = HDrealloc(oids, list_size * sizeof(struct lock_group)); - - if (!oids) { - exit_state = H5FP_STATUS_OOM; - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory") - } - } - - oids[i].oid = req->oid; - oids[i].file_id = req->file_id; - oids[i].rw_lock = req->rw_lock; - oids[i].locked = FALSE; - } - - if (req->req_type == H5FP_REQ_LOCK_END) - /* this was the last lock request */ - break; - - if (H5FP_sap_receive(req, (int)req->proc_rank, - H5FP_TAG_REQUEST, NULL) != SUCCEED) { - exit_state = H5FP_STATUS_LOCK_FAILED; - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTRECV, FAIL, "cannot receive messages") - } - } - - /* - * Check to see if we can acquire all of the locks requested. If - * not, the it's an error and we need to return. - */ - for (j = 0; j <= i; ++j) { - if ((oids[j].info = H5SL_search(file_info_list,&oids[j].file_id)) == NULL) { - exit_state = H5FP_STATUS_BAD_FILE_ID; - HGOTO_DONE(FAIL) - } - - if (oids[j].info->closing) { - /* we're closing the file - don't accept anymore locks */ - exit_state = H5FP_STATUS_FILE_CLOSING; - HGOTO_DONE(FAIL) - } - - oids[j].lock = H5FP_find_object_lock(oids[j].info, oids[j].oid); - - /* - * Don't panic! - * - * This horrid little if-then statement is just the logical - * inverse of the if-then statement in the next for-loop. - */ - if (oids[j].lock && - !((oids[j].rw_lock == H5FP_LOCK_READ && - oids[j].lock->rw_lock == H5FP_LOCK_READ) || - (oids[j].rw_lock == H5FP_LOCK_WRITE && - oids[j].lock->rw_lock == H5FP_LOCK_WRITE && - oids[j].lock->num_locks[req->proc_rank]))) { - /* FAILURE */ - exit_state = H5FP_STATUS_LOCK_FAILED; - HGOTO_DONE(FAIL) - } - } - - /* - * Actually acquire the locks. This shouldn't fail because of the - * previous checks. The only thing which can likely occur is an - * out-of-memory error. - */ - for (j = 0; j <= i; ++j) { - if (oids[j].lock) { - /* - * Don't panic! - * - * This horrid little if-then statement is just checking so - * that if you want a READ lock and the current lock is a - * READ lock, then we bump up the reference count on it. If - * you want a WRITE lock and the current lock is a WRITE lock - * and furthermore the current process has that lock, we will - * also bump up the reference count. - * - * Otherwise, it's a failure. - */ - if ((oids[j].rw_lock == H5FP_LOCK_READ && - oids[j].lock->rw_lock == H5FP_LOCK_READ) || - (oids[j].rw_lock == H5FP_LOCK_WRITE && - oids[j].lock->rw_lock == H5FP_LOCK_WRITE && - oids[j].lock->num_locks[req->proc_rank])) { - /* - * The requesting process may already have this lock. Might - * be a request from some call-back function of some sort. - * Increase the reference count if this process hasn't - * gotten a lock on this before and then increment that - * process's num_locks reference count. - */ - if (!oids[j].lock->num_locks[req->proc_rank]) - ++oids[j].lock->num_procs; - - ++oids[j].lock->num_locks[req->proc_rank]; - oids[j].locked = TRUE; - } else { - /* FIXME: reply saying object locked? */ - exit_state = H5FP_STATUS_LOCK_FAILED; - ret_value = FAIL; - goto rollback; - } - } else { - H5FP_object_lock *lock = H5FP_new_object_lock(oids[j].oid, req->proc_rank, - req->obj_type, req->rw_lock); - - if (lock) { - if (H5SL_insert(oids[j].info->locks, lock, &lock->oid)<0) { - H5FP_free_object_lock(lock); - exit_state = H5FP_STATUS_LOCK_FAILED; - HDONE_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, "can't insert lock into tree"); - goto rollback; - } - - oids[j].locked = TRUE; - } else { - /* out of memory...ulp! */ - exit_state = H5FP_STATUS_OOM; - HDONE_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory"); - goto rollback; - } - } - } - - goto done; - - /* Error handling code */ -rollback: - /* - * More than likely, out of memory during the actual locking phase. - * Try to release any locks which may have been obtained. If it's not - * possible to release those locks, we're in big trouble. The file is - * now in an inconsistent state, as far as the SAP is concerned. The - * only options left to the program are either to abort or completely - * close the file and reopen which could cause corruption. - */ - for (j = 0; j <= i; ++j) { - if (oids[j].locked) { - if (oids[j].lock) { - if (oids[j].lock->num_locks[req->proc_rank]) { - if (--oids[j].lock->num_locks[req->proc_rank] == 0) - if (--oids[j].lock->num_procs == 0) - H5FP_remove_object_lock_from_list(oids[j].info, oids[j].lock); - } else { - /* CATASTROPHIC FAILURE!!! */ - /* LOCK WAS NOT CLEARED */ - exit_state = H5FP_STATUS_CATASTROPHIC; - } - } else { - /* CATASTROPHIC FAILURE!!! */ - /* LOCK WAS NOT CLEARED */ - exit_state = H5FP_STATUS_CATASTROPHIC; - } - } - } - -done: - if (ret_value != SUCCEED) { - /* Can't lock the whole group at one time for some reason */ -HDfprintf(stderr, "%s: locking failure (%d)!!\n", FUNC, ret_value); -assert(0); - } - - HDfree(oids); - H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_release_lock_request - * Purpose: Handle a request to release the lock on an object. - * Return: Nothing - * Programmer: Bill Wendling, 06. August, 2002 - * Modifications: - */ -static herr_t -H5FP_sap_handle_release_lock_request(H5FP_request_t *req) -{ - struct release_group { - hobj_ref_t oid; - unsigned file_id; - H5FP_file_info *info; - H5FP_object_lock *lock; - } *oids; - unsigned list_size = 2; /* the size of the "oids" list */ - H5FP_status_t exit_state = H5FP_STATUS_LOCK_RELEASED; - herr_t ret_value = SUCCEED; - unsigned i, j; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_release_lock_request) - - if ((oids = (struct release_group *)H5MM_malloc(list_size * - sizeof(struct release_group))) == NULL) { - exit_state = H5FP_STATUS_OOM; - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory") - } - - /* - * Gather together all of the OIDs the process is requesting to - * release locks at one time. - */ - for (i = 0;; ++i) { - if (req->oid) { - if (i == list_size) { - list_size <<= 1; /* equiv to list_size *= 2; */ - oids = HDrealloc(oids, list_size * sizeof(struct release_group)); - - if (!oids) { - exit_state = H5FP_STATUS_OOM; - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory") - } - } - - oids[i].oid = req->oid; - oids[i].file_id = req->file_id; - } - - if (req->req_type == H5FP_REQ_RELEASE_END) - /* this was the last lock request */ - break; - - if (H5FP_sap_receive(req, (int)req->proc_rank, H5FP_TAG_REQUEST, NULL) != SUCCEED) { - exit_state = H5FP_STATUS_LOCK_RELEASE_FAILED; - HGOTO_DONE(FAIL) - } - } - - /* - * Check here to see if the locks exist and we have the locks. This - * will help keep us from being in a catastrophic state. - */ - for (j = 0; j <= i; ++j) { - if ((oids[j].info = H5SL_search(file_info_list,&oids[j].file_id)) == NULL) { - exit_state = H5FP_STATUS_BAD_FILE_ID; - HGOTO_DONE(FAIL) - } - - oids[j].lock = H5FP_find_object_lock(oids[j].info, oids[j].oid); - - if (!oids[j].lock || !oids[j].lock->num_locks[req->proc_rank]) { - exit_state = H5FP_STATUS_BAD_LOCK; - HGOTO_DONE(FAIL) - } - } - - /* - * Release a lock. There may be multiple locks to release if they - * were locked in a group, so loop finding all of the locks and - * release them. - */ - for (j = 0; j <= i; ++j) { - if (oids[j].lock) { - if (oids[j].lock->num_locks[req->proc_rank]) { - if (--oids[j].lock->num_locks[req->proc_rank] == 0) - if (--oids[j].lock->num_procs == 0) - H5FP_remove_object_lock_from_list(oids[j].info, oids[j].lock); - } else { - /* AAAIIIIEEE!!! */ - exit_state = H5FP_STATUS_CATASTROPHIC; - HGOTO_DONE(FAIL) - } - } else { - /* AAAIIIIEEE!!! */ - exit_state = H5FP_STATUS_CATASTROPHIC; - HGOTO_DONE(FAIL) - } - } - -done: - HDfree(oids); - H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_read_request - * Purpose: Handle a read request from a client. The bit of metadata - * that the client wants may or may not be in here. It's not - * an error if it isn't here. When that's the case, the - * client just goes and reads it from the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 06. August, 2002 - * Modifications: - */ -static herr_t -H5FP_sap_handle_read_request(H5FP_request_t *req) -{ - H5FP_file_info *info; - H5FP_read_t r; - herr_t ret_value = SUCCEED; - char *metadata = NULL; - int mrc; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_read_request) -#if 0 - /* More useful debugging code to keep for a time. JRM - 4/13/04 */ - HDfprintf(stdout, - "H5FP_sap_handle_read_request: req->addr = %a.\n", - req->addr); -#endif - - r.req_id = req->req_id; - r.file_id = req->file_id; - r.md_size = 0; - r.addr = 0; - r.status = H5FP_STATUS_MDATA_NOT_CACHED; - - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL && info->num_mods) { - H5FP_mdata_mod *fm; - - if (info->num_mods >= H5FP_MDATA_CACHE_HIGHWATER_MARK) { - if (H5FP_dump(info, req->proc_rank, req->req_id, req->file_id) == FAIL) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't dump metadata to client") - - /* - * We aren't going to find the information we need since it - * was just dumped. - */ - HGOTO_DONE(SUCCEED) - } - - if ((fm = H5SL_less(info->mod_list, &req->addr)) != NULL) { - if (H5F_addr_eq(req->addr, fm->addr)) { - r.md_size = fm->md_size; - r.addr = fm->addr; - r.status = H5FP_STATUS_OK; - metadata = fm->metadata; /* Sent out in a separate message */ - } else if (H5F_addr_gt(req->addr, fm->addr) - && H5F_addr_lt(req->addr, fm->addr + fm->md_size)) { - r.md_size = fm->md_size - (req->addr - fm->addr); - r.addr = req->addr; - r.status = H5FP_STATUS_OK; - metadata = fm->metadata + (req->addr - fm->addr); /* Sent out separately */ - } else { -HDfprintf(stderr, "Panic!!!!\n"); -assert(0); - } - } else { -HDfprintf(stderr, "%s: Couldn't find metadata at req->addr == %a\n", FUNC, req->addr); -assert(0); - } - } - - if ((mrc = MPI_Send(&r, 1, H5FP_read, (int)req->proc_rank, - H5FP_TAG_READ, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - - if (r.md_size) - if (H5FP_send_metadata(metadata, (int)r.md_size, (int)req->proc_rank) != SUCCEED) - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, - "can't send metadata to client") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_write_request - * Purpose: Handle a request to write a piece of metadata in the - * file. - * - * N.B: We assume that the client has the lock on the - * requesting object before getting here. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 06. August, 2002 - * Modifications: - */ -static herr_t -H5FP_sap_handle_write_request(H5FP_request_t *req, char *mdata, unsigned md_size) -{ - H5FP_file_info *info; - H5FP_status_t exit_state = H5FP_STATUS_OK; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_write_request) -#if 0 - /* Debugging code -- lets keep it for a time. JRM -- 4/13/04 */ - HDfprintf(stdout, - "H5FP_sap_handle_write_request: addr = %a, md_size = %d.\n", - (haddr_t)(req->addr), (int)md_size); -#endif - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL) { - if (info->num_mods >= H5FP_MDATA_CACHE_HIGHWATER_MARK) { - /* - * If there are any modifications not written out yet, dump - * them to this process - */ - if (H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, - H5FP_STATUS_DUMPING) == FAIL) { - exit_state = H5FP_STATUS_DUMPING_FAILED; - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, - "can't send message to client") - } - - if (H5FP_dump(info, req->proc_rank, req->req_id, req->file_id) == FAIL) { - exit_state = H5FP_STATUS_DUMPING_FAILED; - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, - "metadata dump failed") - } - } - - if (info->closing) { - /* we're closing the file - don't accept anymore changes */ - exit_state = H5FP_STATUS_FILE_CLOSING; - HGOTO_DONE(FAIL) - } - - if (H5FP_add_file_mod_to_list(info, req->mem_type, (haddr_t)req->addr, - md_size, mdata) != SUCCEED) { - exit_state = H5FP_STATUS_OOM; - HGOTO_DONE(FAIL) - } - } else { - /* error: there isn't a file opened to change */ - exit_state = H5FP_STATUS_BAD_FILE_ID; - HGOTO_DONE(FAIL) - } - -done: - H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_flush_request - * Purpose: Handle a request to flush the metadata to a file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling - * 12. February 2003 - * Modifications: - */ -static herr_t -H5FP_sap_handle_flush_request(H5FP_request_t *req) -{ - H5FP_file_info *info; - H5FP_status_t exit_state = H5FP_STATUS_OK; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_flush_request) - - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL) { - if (info->num_mods) { - /* - * If there are any modifications not written out yet, dump - * them to this process - */ - if (H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, - H5FP_STATUS_DUMPING) == FAIL) { - exit_state = H5FP_STATUS_DUMPING_FAILED; - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, - "can't send message to client") - } - - if (H5FP_dump(info, req->proc_rank, req->req_id, req->file_id) == FAIL) { - exit_state = H5FP_STATUS_DUMPING_FAILED; - HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, - "can't dump metadata to client") - } - } - } else { - HGOTO_ERROR(H5E_FPHDF5, H5E_NOTFOUND, FAIL, - "can't find information for file") - } - -done: - H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_close_request - * Purpose: Handle a request to close a file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 06. August, 2002 - * Modifications: - */ -static herr_t -H5FP_sap_handle_close_request(H5FP_request_t *req) -{ - H5FP_file_info *info; - H5FP_status_t exit_state = H5FP_STATUS_OK; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_close_request) - - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL) { - int comm_size; - - /* Get the size of the SAP communicator */ - if (MPI_Comm_size(H5FP_SAP_COMM, &comm_size) != MPI_SUCCESS) - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_size failed") - - if (++info->closing == comm_size - 1) { - /* Free the freelist -- this call never fails */ - H5FD_free_freelist((H5FD_t*)&info->file); - - /* All processes have closed the file - remove it from list */ - if (H5FP_remove_file_id_from_list(req->file_id) != SUCCEED) { - exit_state = H5FP_STATUS_BAD_FILE_ID; - HGOTO_ERROR(H5E_FPHDF5, H5E_NOTFOUND, FAIL, - "cannot remove file ID from list") - } - } - } else { - HGOTO_ERROR(H5E_FPHDF5, H5E_NOTFOUND, FAIL, - "can't find information for file") - } - -done: - H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_alloc_request - * Purpose: Handle a request to allocate data from the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 19. February 2003 - * Modifications: - */ -static herr_t -H5FP_sap_handle_alloc_request(H5FP_request_t *req) -{ - H5FP_alloc_t sap_alloc; - H5FP_file_info *info; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_alloc_request) - - sap_alloc.req_id = req->req_id; - sap_alloc.file_id = req->file_id; - sap_alloc.status = H5FP_STATUS_OK; - sap_alloc.mem_type = req->mem_type; - - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL) { - /* - * Try allocating from the free-list that is kept on the server - * first. If that fails, then call the specified allocation - * functions depending upon what type of data is being allocated. - * - * Note: H5P_DEFAULT is passed in as the data xfer property list. - * This is okay since the only situation where that will be used - * is if you have a "hole" in the middle of your metadata (in - * aggregate mode) that needs to be freed. We've turned off - * metadata aggregation for FPHDF5 because we don't have the - * proper information. - * - * Whatta pain. - */ - if ((sap_alloc.addr = H5FD_alloc((H5FD_t*)&info->file, req->mem_type, H5P_DEFAULT, - req->meta_block_size)) == HADDR_UNDEF) { - sap_alloc.status = H5FP_STATUS_CANT_ALLOC; - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, - "SAP unable to allocate file memory") - } - - /* Get the EOA. */ - sap_alloc.eoa = ((H5FD_fphdf5_t*)&info->file)->eoa; - sap_alloc.status = H5FP_STATUS_OK; - } else { - sap_alloc.addr = HADDR_UNDEF; - sap_alloc.eoa = HADDR_UNDEF; - sap_alloc.status = H5FP_STATUS_CANT_ALLOC; - } -#if 0 - /* Debugging code -- lets keep it for a time. JRM -- 4/13/04 */ - HDfprintf(stdout, - "%s: req_size = %d, req_type = %d, addr = %a, eoa = %a, status = %d, rp_rank = %d.\n", - "H5FP_sap_handle_alloc_request", - (int)(req->meta_block_size), - (int)(req->mem_type), - sap_alloc.addr, - sap_alloc.eoa, - (int)(sap_alloc.status), - (int)(req->proc_rank)); -#endif -done: - if ((mrc = MPI_Send(&sap_alloc, 1, H5FP_alloc, (int)req->proc_rank, - H5FP_TAG_ALLOC, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_DONE_ERROR(FAIL, "MPI_Send failed", mrc); - - FUNC_LEAVE_NOAPI(ret_value) - -} /* H5FP_sap_handle_alloc_request() */ - -/* - * Function: H5FP_sap_handle_free_request - * Purpose: Handle a request to free data from the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 31. March 2003 - * Modifications: - */ -static herr_t -H5FP_sap_handle_free_request(H5FP_request_t *req) -{ - H5FP_alloc_t sap_alloc; - H5FP_file_info *info; - H5FP_status_t exit_state = H5FP_STATUS_OK; - herr_t ret_value = SUCCEED; - int mrc; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_free_request) - - sap_alloc.req_id = req->req_id; - sap_alloc.file_id = req->file_id; - sap_alloc.status = H5FP_STATUS_OK; - sap_alloc.mem_type = req->mem_type; - -#if 0 - /* Debugging code -- lets keep it for a time. JRM -- 4/13/04 */ - HDfprintf(stdout, - "%s: addr = %a, block_size = %a, mem_type = %d, rp_rank = %d.\n", - "H5FP_sap_handle_free_request", - req->addr, - req->meta_block_size, - (int)(req->mem_type), - (int)(req->proc_rank)); -#endif - - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL) { - if (H5FD_free((H5FD_t*)&info->file, req->mem_type, H5P_DEFAULT, - req->addr, req->meta_block_size) != SUCCEED) { - exit_state = H5FP_STATUS_CANT_FREE; - sap_alloc.status = H5FP_STATUS_CANT_FREE; - HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, - "SAP unable to free metadata block") - } - - /* Get the EOA. */ - sap_alloc.eoa = ((H5FD_fphdf5_t*)&info->file)->eoa; - sap_alloc.status = H5FP_STATUS_OK; - } else { - sap_alloc.status = H5FP_STATUS_CANT_FREE; - } - -done: - if ((mrc = MPI_Send(&sap_alloc, 1, H5FP_alloc, (int)req->proc_rank, - H5FP_TAG_ALLOC, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_DONE_ERROR(FAIL, "MPI_Send failed", mrc); - - FUNC_LEAVE_NOAPI(ret_value) - -} /* H5FP_sap_handle_free_request() */ - -/* - * Function: H5FP_sap_handle_get_eoa_request - * Purpose: Handle a request for the EOA of the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 31. October 2003 - * Modifications: - */ -static herr_t -H5FP_sap_handle_get_eoa_request(H5FP_request_t *req) -{ - H5FP_eoa_t sap_eoa; - H5FP_file_info *info; - int mrc; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_get_eoa_request) - - sap_eoa.req_id = req->req_id; - sap_eoa.file_id = req->file_id; - - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL) { - -#if 0 - /* Debugging code -- lets keep it for a time. JRM -- 4/13/04 */ - HDfprintf(stdout, "%s: eoa = %a, rp_rank = %d.\n", - "H5FP_sap_handle_get_eoa_request", - ((H5FD_fphdf5_t*)&info->file)->eoa, - (int)(req->proc_rank)); -#endif - - /* Get the EOA. */ - sap_eoa.eoa = ((H5FD_fphdf5_t*)&info->file)->eoa; - sap_eoa.status = H5FP_STATUS_OK; - } else { -#if 1 - /* Debugging code -- lets keep it for a time. JRM -- 4/13/04 */ - HDfprintf(stdout, "%s: function failed. rp_rank = %d.\n", - "H5FP_sap_handle_get_eoa_request", - (int)(req->proc_rank)); -#endif - sap_eoa.eoa = HADDR_UNDEF; - sap_eoa.status = H5FP_STATUS_CANT_ALLOC; - ret_value = FAIL; - } - -#ifdef LATER -done: -#endif /* LATER */ - if ((mrc = MPI_Send(&sap_eoa, 1, H5FP_eoa, (int)req->proc_rank, - H5FP_TAG_EOA, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_DONE_ERROR(FAIL, "MPI_Send failed", mrc); - - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_set_eoa_request - * Purpose: Handle a request setting the EOA of the file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 31. October 2003 - * Modifications: - */ -static herr_t -H5FP_sap_handle_set_eoa_request(H5FP_request_t *req) -{ - H5FP_status_t exit_state = H5FP_STATUS_OK; - H5FP_file_info *info; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FP_sap_handle_set_eoa_request) - - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL) { - -#if 0 - /* Debugging code -- lets keep it for a time. JRM -- 4/13/04 */ - if ( req->addr < ((H5FD_fphdf5_t*)&info->file)->eoa ) { - HDfprintf(stdout, - "%s: old eoa = %a, new eoa = %a, rp_rank = %d. %s\n", - "H5FP_sap_handle_set_eoa_request", - ((H5FD_fphdf5_t*)&info->file)->eoa, - req->addr, - (int)(req->proc_rank), - "<---- eoa reduced!!! -------"); - } -#if 0 - else { - HDfprintf(stdout, - "%s: old eoa = %a, new eoa = %a, rp_rank = %d.\n", - "H5FP_sap_handle_set_eoa_request", - ((H5FD_fphdf5_t*)&info->file)->eoa, - req->addr, - (int)(req->proc_rank)); - } -#endif -#endif - - /* Get the EOA. */ - ((H5FD_fphdf5_t*)&info->file)->eoa = req->addr; - exit_state = H5FP_STATUS_OK; - } else { -#if 1 - /* Debugging code -- lets keep it for a time. JRM -- 4/13/04 */ - HDfprintf(stdout, - "%s: Function failed -- Couldn't get info. new eoa = %a.\n", - "H5FP_sap_handle_set_eoa_request", - req->addr); -#endif - exit_state = H5FP_STATUS_CANT_ALLOC; - ret_value = FAIL; - } - -#ifdef LATER -done: -#endif /* LATER */ - H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); - FUNC_LEAVE_NOAPI(ret_value) -} - -/* - * Function: H5FP_sap_handle_update_eoma_eosda_request - * Purpose: Handle a request to update the EOMA and EOSDA for a file. - * Return: Success: SUCCEED - * Failure: FAIL - * Programmer: Bill Wendling, 02. April 2003 - * Modifications: - */ -static herr_t -H5FP_sap_handle_update_eoma_eosda_request(H5FP_request_t *req) -{ - H5FP_eoa_t sap_eoa; - H5FP_file_info *info; - H5FP_status_t exit_state = H5FP_STATUS_OK; - herr_t ret_value = SUCCEED; - int mrc; - - FUNC_ENTER_NOAPI_NOINIT(H5FP_sap_handle_update_eoma_eosda_request) - - sap_eoa.req_id = req->req_id; - sap_eoa.file_id = req->file_id; - sap_eoa.status = H5FP_STATUS_OK; - - if ((info = H5SL_search(file_info_list,&req->file_id)) != NULL) { - H5FD_t *f = (H5FD_t*)&info->file; - - if (f->eoma) - if (H5FD_free(f, H5FD_MEM_DEFAULT, H5P_DEFAULT, - f->eoma, f->cur_meta_block_size) != SUCCEED) { - exit_state = H5FP_STATUS_CANT_FREE; - sap_eoa.status = H5FP_STATUS_CANT_FREE; - HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, - "SAP unable to free metadata block") - } - - /* Reset metadata block information, just in case */ - f->eoma = 0; - f->cur_meta_block_size = 0; - - if (f->eosda) - if (H5FD_free(f, H5FD_MEM_DRAW, H5P_DEFAULT, - f->eosda, f->cur_sdata_block_size) != SUCCEED) { - exit_state = H5FP_STATUS_CANT_FREE; - sap_eoa.status = H5FP_STATUS_CANT_FREE; - HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, - "SAP unable to free 'small data' block") - } - - /* Reset "small data" block information, just in case */ - f->eosda = 0; - f->cur_sdata_block_size = 0; - - /* Get the EOA. */ - sap_eoa.eoa = ((H5FD_fphdf5_t*)&info->file)->eoa; - } else { - sap_eoa.eoa = HADDR_UNDEF; - sap_eoa.status = H5FP_STATUS_CANT_FREE; - } - -done: - if ((mrc = MPI_Send(&sap_eoa, 1, H5FP_eoa, (int)req->proc_rank, - H5FP_TAG_EOA, H5FP_SAP_COMM)) != MPI_SUCCESS) - HMPI_DONE_ERROR(FAIL, "MPI_Send failed", mrc); - - FUNC_LEAVE_NOAPI(ret_value) -} - -#endif /* H5_HAVE_FPHDF5 */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 4bb6380..bc50cfd 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -44,7 +44,6 @@ typedef struct H5F_t H5F_t; #define H5F_FLUSH_NONE (0U) /* No flags specified */ #define H5F_FLUSH_INVALIDATE (1U << 0) /* Invalidate cached data */ #define H5F_FLUSH_CLOSING (1U << 1) /* Closing the file */ -#define H5F_FLUSH_CLEAR_ONLY (1U << 2) /* Don't write, just clear dirty flags */ /* * Encode and decode macros for file meta-data. diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index d7d0e6e..a4f7042 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -351,11 +351,8 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc, haddr_t addr, if (HADDR_UNDEF == (eof = H5FD_get_eof(lf))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size") -#ifdef H5_HAVE_FPHDF5 - if (!H5FD_is_fphdf5_driver(lf) || H5FD_fphdf5_is_captain(lf)) -#endif /* !H5_HAVE_FPHDF5 */ - if (eof < stored_eoa) - HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, "truncated file") + if (eof < stored_eoa) + HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, "truncated file") /* * Tell the file driver how much address space has already been diff --git a/src/H5config.h.in b/src/H5config.h.in index 3dd4515..d8bc362 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -81,9 +81,6 @@ /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK -/* Define if we want flexible parallel HDF5 support */ -#undef HAVE_FPHDF5 - /* Define to 1 if you have the `frexpf' function. */ #undef HAVE_FREXPF diff --git a/src/H5err.txt b/src/H5err.txt index 02a21d8..0624578 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -66,7 +66,6 @@ MAJOR, H5E_PLINE, Data filters MAJOR, H5E_EFL, External file list MAJOR, H5E_REFERENCE, References MAJOR, H5E_VFL, Virtual File Layer -MAJOR, H5E_FPHDF5, Flexible Parallel HDF5 MAJOR, H5E_TST, Ternary Search Trees MAJOR, H5E_RS, Reference Counted Strings MAJOR, H5E_ERROR, Error API @@ -89,7 +88,6 @@ SECTION, DSPACE, Dataspace errors SECTION, PLIST, Property list errors SECTION, MPI, Parallel MPI errors SECTION, HEAP, Heap errors -SECTION, FPH5, FPHDF5 errors SECTION, PIPELINE, I/O pipeline errors SECTION, SYSTEM, System level errors SECTION, NONE, No error @@ -105,6 +103,7 @@ MINOR, ARGS, H5E_BADVALUE, Bad value # Resource errors MINOR, RESOURCE, H5E_NOSPACE, No space available for allocation +MINOR, RESOURCE, H5E_CANTALLOC, Can't allocate space MINOR, RESOURCE, H5E_CANTCOPY, Unable to copy object MINOR, RESOURCE, H5E_CANTFREE, Unable to free object MINOR, RESOURCE, H5E_ALREADYEXISTS, Object already exists @@ -213,12 +212,6 @@ MINOR, HEAP, H5E_CANTRESTORE, Can't restore condition MINOR, HEAP, H5E_CANTCOMPUTE, Can't compute value MINOR, HEAP, H5E_CANTEXTEND, Can't extend heap's space -# FPHDF5 errors -MINOR, FPH5, H5E_CANTRECV, Can't receive messages from processes -MINOR, FPH5, H5E_CANTSENDMDATA, Can't send metadata message -MINOR, FPH5, H5E_CANTCHANGE, Can't register change with server -MINOR, FPH5, H5E_CANTALLOC, Can't allocate from file - # I/O pipeline errors MINOR, PIPELINE, H5E_NOFILTER, Requested filter is not available MINOR, PIPELINE, H5E_CALLBACK, Callback failed diff --git a/src/Makefile.am b/src/Makefile.am index e1dc539..662a97c 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,9 +47,9 @@ libhdf5_la_SOURCES= H5.c H5dbg.c H5A.c H5AC.c H5B.c H5Bcache.c \ H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \ H5E.c H5F.c \ H5Fdbg.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5FD.c H5FDcore.c \ - H5FDfamily.c H5FDfphdf5.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ + H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDstdio.c \ - H5FDstream.c H5FL.c H5FO.c H5FP.c H5FPclient.c H5FPserver.c H5FS.c \ + H5FDstream.c H5FL.c H5FO.c H5FS.c \ H5G.c H5Gent.c H5Glink.c H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c \ H5Goh.c \ H5Gstab.c \ @@ -83,8 +83,8 @@ libhdf5_la_SOURCES= H5.c H5dbg.c H5A.c H5AC.c H5B.c H5Bcache.c \ include_HEADERS =H5public.h H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDfamily.h \ - H5FDfphdf5.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ - H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h H5FPpublic.h \ + H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ + H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h \ H5Gpublic.h H5Ipublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h H5pubconf.h hdf5.h H5api_adpt.h diff --git a/src/Makefile.in b/src/Makefile.in index 1c3c4ee..dc5430e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -88,28 +88,27 @@ am_libhdf5_la_OBJECTS = H5.lo H5dbg.lo H5A.lo H5AC.lo H5B.lo \ H5Dcontig.lo H5Defl.lo H5Dio.lo H5Distore.lo H5Dmpio.lo \ H5Doh.lo H5Dselect.lo H5Dtest.lo H5E.lo H5F.lo H5Fdbg.lo \ H5Fmount.lo H5Fsfile.lo H5Fsuper.lo H5FD.lo H5FDcore.lo \ - H5FDfamily.lo H5FDfphdf5.lo H5FDlog.lo H5FDmpi.lo H5FDmpio.lo \ + H5FDfamily.lo H5FDlog.lo H5FDmpi.lo H5FDmpio.lo \ H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo H5FDstdio.lo \ - H5FDstream.lo H5FL.lo H5FO.lo H5FP.lo H5FPclient.lo \ - H5FPserver.lo H5FS.lo H5G.lo H5Gent.lo H5Glink.lo H5Gloc.lo \ - H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Gstab.lo H5Gtest.lo \ - H5Gtraverse.lo H5HF.lo H5HFcache.lo H5HFdbg.lo H5HFdblock.lo \ - H5HFdtable.lo H5HFflist.lo H5HFhdr.lo H5HFiblock.lo H5HFint.lo \ - H5HFstat.lo H5HFtest.lo H5HG.lo H5HGdbg.lo H5HL.lo H5HLdbg.lo \ - H5HP.lo H5I.lo H5MF.lo H5MM.lo H5MP.lo H5MPtest.lo H5O.lo \ - H5Oattr.lo H5Obogus.lo H5Ocache.lo H5Ocont.lo H5Odtype.lo \ - H5Oefl.lo H5Ofill.lo H5Oginfo.lo H5Olayout.lo H5Olinfo.lo \ - H5Olink.lo H5Omtime.lo H5Oname.lo H5Onull.lo H5Opline.lo \ - H5Osdspace.lo H5Oshared.lo H5Ostab.lo H5P.lo H5Pacpl.lo \ - H5Pdcpl.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo H5Pgcpl.lo \ - H5Pocpl.lo H5Ptest.lo H5R.lo H5RC.lo H5RS.lo H5S.lo H5Sall.lo \ - H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo \ - H5Stest.lo H5SL.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo \ - H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tenum.lo \ - H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo \ - H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo \ - H5Tprecis.lo H5Tstrpad.lo H5Tvlen.lo H5TS.lo H5V.lo H5Z.lo \ - H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ + H5FDstream.lo H5FL.lo H5FO.lo H5FS.lo H5G.lo H5Gent.lo \ + H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo \ + H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFcache.lo \ + H5HFdbg.lo H5HFdblock.lo H5HFdtable.lo H5HFflist.lo H5HFhdr.lo \ + H5HFiblock.lo H5HFint.lo H5HFstat.lo H5HFtest.lo H5HG.lo \ + H5HGdbg.lo H5HL.lo H5HLdbg.lo H5HP.lo H5I.lo H5MF.lo H5MM.lo \ + H5MP.lo H5MPtest.lo H5O.lo H5Oattr.lo H5Obogus.lo H5Ocache.lo \ + H5Ocont.lo H5Odtype.lo H5Oefl.lo H5Ofill.lo H5Oginfo.lo \ + H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omtime.lo H5Oname.lo \ + H5Onull.lo H5Opline.lo H5Osdspace.lo H5Oshared.lo H5Ostab.lo \ + H5P.lo H5Pacpl.lo H5Pdcpl.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo \ + H5Pgcpl.lo H5Pocpl.lo H5Ptest.lo H5R.lo H5RC.lo H5RS.lo H5S.lo \ + H5Sall.lo H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo \ + H5Sselect.lo H5Stest.lo H5SL.lo H5ST.lo H5T.lo H5Tarray.lo \ + H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo \ + H5Tenum.lo H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo \ + H5Tnative.lo H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo \ + H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo H5Tvlen.lo H5TS.lo H5V.lo \ + H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS) PROGRAMS = $(noinst_PROGRAMS) @@ -403,9 +402,9 @@ libhdf5_la_SOURCES = H5.c H5dbg.c H5A.c H5AC.c H5B.c H5Bcache.c \ H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \ H5E.c H5F.c \ H5Fdbg.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5FD.c H5FDcore.c \ - H5FDfamily.c H5FDfphdf5.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ + H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDstdio.c \ - H5FDstream.c H5FL.c H5FO.c H5FP.c H5FPclient.c H5FPserver.c H5FS.c \ + H5FDstream.c H5FL.c H5FO.c H5FS.c \ H5G.c H5Gent.c H5Glink.c H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c \ H5Goh.c \ H5Gstab.c \ @@ -439,8 +438,8 @@ libhdf5_la_SOURCES = H5.c H5dbg.c H5A.c H5AC.c H5B.c H5Bcache.c \ include_HEADERS = H5public.h H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDfamily.h \ - H5FDfphdf5.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ - H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h H5FPpublic.h \ + H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ + H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h \ H5Gpublic.h H5Ipublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h H5pubconf.h hdf5.h H5api_adpt.h @@ -592,7 +591,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FD.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDcore.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDfamily.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDfphdf5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDlog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDmpi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDmpio.Plo@am__quote@ @@ -603,9 +601,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDstream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FL.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FO.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FP.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FPclient.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FPserver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FS.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fdbg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fmount.Plo@am__quote@ @@ -27,7 +27,6 @@ #include "H5Epublic.h" /* Errors */ #include "H5Fpublic.h" /* Files */ #include "H5FDpublic.h" /* File drivers */ -#include "H5FPpublic.h" /* Flexible Parallel HDF5 */ #include "H5Gpublic.h" /* Groups */ #include "H5Ipublic.h" /* ID management */ #include "H5MMpublic.h" /* Memory management */ diff --git a/src/hdf5.lnt b/src/hdf5.lnt index ed623b4..95b7d72 100755 --- a/src/hdf5.lnt +++ b/src/hdf5.lnt @@ -91,7 +91,6 @@ The following files have had their FUNC_ENTER, FUNC_LEAVE & HGOTO* macros cleaned up, but have not been linted due to their dependencies on features that we don't support on Windows: - H5FDfphdf5.c H5FDmpio.c H5FDmpiposix.c H5FDstream.c |