summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-10-28 18:45:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-10-28 18:45:26 (GMT)
commit0d1aba339eb7f0fd53282412289226896df1e988 (patch)
tree46ffeb916926d629eae9d9d37e0c825a1d19fe17
parent4bd557ec1ee1f85bfda57a304093ca1768ba2d0a (diff)
downloadhdf5-0d1aba339eb7f0fd53282412289226896df1e988.zip
hdf5-0d1aba339eb7f0fd53282412289226896df1e988.tar.gz
hdf5-0d1aba339eb7f0fd53282412289226896df1e988.tar.bz2
[svn-r6040] Purpose:
Code cleanup Description: Add more comments and clean up small bits of the FPH5 code. Platforms tested: FreeBSD 4.7 (sleipnir), changes too minor to affect other platforms.
-rw-r--r--src/H5FP.c26
-rw-r--r--src/H5FPclient.c12
-rw-r--r--src/H5FPprivate.h28
-rw-r--r--src/H5FPpublic.h11
-rw-r--r--src/H5FPserver.c8
-rw-r--r--src/H5Ofphdf5.c28
-rw-r--r--src/H5Oplist.c5
7 files changed, 53 insertions, 65 deletions
diff --git a/src/H5FP.c b/src/H5FP.c
index cdf0a7d..140600d 100644
--- a/src/H5FP.c
+++ b/src/H5FP.c
@@ -11,10 +11,8 @@
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+/* Private header files */
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error Handling */
#include "H5Oprivate.h" /* Object Headers */
@@ -24,12 +22,11 @@
#include "H5FPprivate.h" /* Flexible Parallel Functions */
-#include "mpi.h"
+/* Pablo mask */
+#define PABLO_MASK H5FP_mask
/* Interface initialization */
-#define PABLO_MASK H5FP_mask
#define INTERFACE_INIT NULL
-
static int interface_initialize_g = 0;
MPI_Datatype SAP_request_t; /* MPI datatype for the SAP_request obj */
@@ -68,22 +65,28 @@ H5FPinit(MPI_Comm comm, int sap_rank)
FUNC_ENTER_API(H5FPinit, FAIL);
H5TRACE2("e","McIs",comm,sap_rank);
+
+ /* Set the global variable to track the SAP's rank */
H5FP_sap_rank = sap_rank;
+ /* Make a private copy of the communicator we were passed */
if (MPI_Comm_dup(comm, &H5FP_SAP_COMM) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_dup failed");
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_Comm_group failed");
+ 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");
+ /* Get the size of all the processes (including the SAP) */
if (MPI_Comm_size(H5FP_SAP_COMM, &H5FP_comm_size) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_size failed");
@@ -92,15 +95,20 @@ H5FPinit(MPI_Comm comm, int sap_rank)
* we mod it so that we don't go over the size of the communicator. */
H5FP_capt_rank = (H5FP_sap_rank + 1) % H5FP_comm_size;
+ /* Get this processes rank */
if (MPI_Comm_rank(H5FP_SAP_COMM, (int *)&H5FP_my_rank) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_rank failed");
+ /* 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 (H5FP_my_rank == H5FP_sap_rank)
H5FP_sap_receive_loop();
+ /* Fall through and return to user, if not SAP */
+
done:
if (sap_group != MPI_GROUP_NULL)
MPI_Group_free(&sap_group);
@@ -129,10 +137,12 @@ H5FPfinalize(void)
FUNC_ENTER_API(H5FPfinalize, FAIL);
H5TRACE0("e","");
+ /* Stop the SAP */
if (H5FP_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 (MPI_Type_free(&SAP_request_t) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed");
@@ -142,11 +152,13 @@ H5FPfinalize(void)
if (MPI_Type_free(&SAP_sync_t) != 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");
diff --git a/src/H5FPclient.c b/src/H5FPclient.c
index 7926813..9ec0fe1 100644
--- a/src/H5FPclient.c
+++ b/src/H5FPclient.c
@@ -11,31 +11,24 @@
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#define H5S_PACKAGE /*suppress error about including H5Spkg */
-#include "H5Spkg.h"
-
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error Handling */
#include "H5Oprivate.h" /* Object Headers */
+#include "H5Spkg.h" /* Dataspace functions */
#include "H5TBprivate.h" /* Threaded, Balanced, Binary Trees */
#ifdef H5_HAVE_FPHDF5
#include "H5FPprivate.h" /* Flexible Parallel Functions */
-#include "mpi.h"
-
/* Pablo mask */
#define PABLO_MASK H5FPclient_mask
/* Is the interface initialized? */
static int interface_initialize_g = 0;
-
#define INTERFACE_INIT NULL
MPI_Datatype SAP_request_t; /* MPI datatype for the SAP_request obj */
@@ -70,6 +63,7 @@ static herr_t H5FP_update_metadata_cache(hid_t file_id, struct SAP_sync *sap_syn
* Programmer: Bill Wendling, 28. August, 2002
* Modifications:
*/
+/* FIXME: This seems to be only related to opening a file, not an object, contrary to the comments above... -QAK */
herr_t
H5FP_request_open(const char *mdata, int md_len, enum sap_obj_type obj_type,
unsigned *file_id, unsigned *req_id)
@@ -171,6 +165,7 @@ H5FP_request_lock(unsigned int sap_file_id, unsigned char *obj_oid,
*status = sap_reply.status;
if (sap_reply.status != H5FP_STATUS_LOCK_ACQUIRED)
+ /* FIXME: Shouldn't this issue an error also? - QAK */
HGOTO_DONE(FAIL);
}
@@ -429,6 +424,7 @@ H5FP_update_metadata_cache(hid_t file_id, struct SAP_sync *sap_sync, H5O_fphdf5_
case H5FP_ACT_CREATE:
case H5FP_ACT_EXTEND:
if (sap_sync->obj_type == H5FP_OBJ_DATASET) {
+ /* FIXME: These shouldn't be calling API functions. -QAK */
gid = H5Gopen(file_id, fmeta->group->s);
dset_id = H5Dopen(gid, fmeta->dset->s);
diff --git a/src/H5FPprivate.h b/src/H5FPprivate.h
index c5e5f00..2e1210a 100644
--- a/src/H5FPprivate.h
+++ b/src/H5FPprivate.h
@@ -17,14 +17,6 @@
#include "H5FPpublic.h" /* Flexible Parallel HDF5 */
#include "H5Rprivate.h" /* References */
-#ifndef TRUE
-#define TRUE 1
-#endif /* !TRUE */
-
-#ifndef FALSE
-#define FALSE 0
-#endif /* !FALSE */
-
#define H5FP_BYTE_BITS 8
/* Different types of requests */
@@ -44,15 +36,15 @@
* for that object.
*/
enum sap_request {
- H5FP_REQ_OPEN,
- H5FP_REQ_LOCK,
- H5FP_REQ_LOCK_END,
- H5FP_REQ_RELEASE,
- H5FP_REQ_RELEASE_END,
- H5FP_REQ_CHANGE,
- H5FP_REQ_SYNC,
- H5FP_REQ_CLOSE,
- H5FP_REQ_STOP
+ 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_CHANGE, /* Change an object */
+ H5FP_REQ_SYNC, /* Syncronize changes in file */
+ H5FP_REQ_CLOSE, /* Close a file (or eventually an object) */
+ H5FP_REQ_STOP /* Stop SAP */
};
/* Actions to take when performing a change */
@@ -150,7 +142,7 @@ extern MPI_Datatype SAP_sync_t; /* MPI datatype for the SAP_sync obj */
* search for it after getting the appropriate request.
*/
enum {
- H5FP_TAG_REQUEST = 37,
+ H5FP_TAG_REQUEST = 37, /* FIXME: Why is this 37? -QAK */
H5FP_TAG_REPLY,
H5FP_TAG_SYNC,
H5FP_TAG_METADATA,
diff --git a/src/H5FPpublic.h b/src/H5FPpublic.h
index 047c0ce..f282e23 100644
--- a/src/H5FPpublic.h
+++ b/src/H5FPpublic.h
@@ -16,7 +16,14 @@
#include "H5public.h"
-extern herr_t H5FPinit(MPI_Comm comm, int sap_rank);
-extern herr_t H5FPfinalize(void);
+#ifdef __cplusplus
+extern "C" {
+#endif
+H5_DLL herr_t H5FPinit(MPI_Comm comm, int sap_rank);
+H5_DLL herr_t H5FPfinalize(void);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* H5FPPUBLIC_H__ */
diff --git a/src/H5FPserver.c b/src/H5FPserver.c
index b4eb3bc..5fe3df3 100644
--- a/src/H5FPserver.c
+++ b/src/H5FPserver.c
@@ -25,10 +25,6 @@
* handle requests from clients.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error Handling */
#include "H5Oprivate.h" /* Object Headers */
@@ -38,14 +34,11 @@
#include "H5FPprivate.h" /* Flexible Parallel Functions */
-#include "mpi.h"
-
/* Pablo mask */
#define PABLO_MASK H5FPserver_mask
/* Is the interface initialized? */
static int interface_initialize_g = 0;
-
#define INTERFACE_INIT NULL
MPI_Datatype SAP_request_t; /* MPI datatype for the SAP_request obj */
@@ -819,6 +812,7 @@ H5FP_sap_handle_open_request(struct SAP_request req, char *mdata, int md_len)
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, "can't insert file structure into tree");
/* broadcast the file id to all processes */
+ /* FIXME: Isn't there some way to broadcast this result to the barrier group? -QAK */
for (i = 0; i < H5FP_comm_size; ++i)
if ((unsigned)i != H5FP_sap_rank)
if ((mrc = MPI_Send(&new_file_id, 1, MPI_UNSIGNED, i,
diff --git a/src/H5Ofphdf5.c b/src/H5Ofphdf5.c
index a93611b..a51d42a 100644
--- a/src/H5Ofphdf5.c
+++ b/src/H5Ofphdf5.c
@@ -22,9 +22,9 @@
#include "H5FLprivate.h" /* Free lists */
#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
-#include "H5Rprivate.h"
-#include "H5Ppkg.h"
-#include "H5Spkg.h"
+#include "H5Ppkg.h" /* Property lists */
+#include "H5Rprivate.h" /* References */
+#include "H5Spkg.h" /* Dataspace functions */
#if defined (WIN32) && !defined (__MWERKS__)
#include <sys/types.h>
@@ -33,6 +33,7 @@
#ifdef H5_HAVE_FPHDF5
+/* Pablo mask */
#define PABLO_MASK H5O_fphdf5_mask
/* local prototypes */
@@ -64,7 +65,6 @@ const H5O_class_t H5O_FPHDF5[1] = {{
/* Is the interface initialized? */
static int interface_initialize_g = 0;
-
#define INTERFACE_INIT NULL
/* Define the free list for H5O_fphdf5_t's */
@@ -110,11 +110,7 @@ H5O_fphdf5_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
fmeta = H5FL_ALLOC(H5O_fphdf5_t, 1);
/* decode the OID first */
- for (i = 0; i < sizeof(fmeta->oid); ++i)
- fmeta->oid[i] = p[i];
-
- /* jump past the OID part */
- p += sizeof(fmeta->oid);
+ NBYTEDECODE(fmeta->oid,p,sizeof(fmeta->oid));
/* decode the dataspace dimensions next */
fmeta->sdim = H5O_SDSPACE[0].decode(f, p, NULL);
@@ -223,11 +219,7 @@ H5O_fphdf5_encode(H5F_t *f, uint8_t *p, const void *mesg)
assert(fmeta);
/* encode the OID first */
- for (i = 0; i < sizeof(fmeta->oid); ++i)
- p[i] = fmeta->oid[i];
-
- /* jump past the OID part */
- p += sizeof(fmeta->oid);
+ NBYTEENCODE(p,fmeta->oid,sizeof(fmeta->oid));
/* encode the dataspace dimensions next */
ret_value = H5O_SDSPACE[0].encode(f, p, fmeta->sdim);
@@ -303,7 +295,6 @@ H5O_fphdf5_copy(const void *mesg, void *dest)
const H5O_fphdf5_t *src = (const H5O_fphdf5_t *)mesg;
H5O_fphdf5_t *dst = (H5O_fphdf5_t *)dest;
void *ret_value;
- unsigned int i;
FUNC_ENTER_NOAPI(H5O_fphdf5_copy, NULL);
@@ -314,8 +305,7 @@ H5O_fphdf5_copy(const void *mesg, void *dest)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* copy the individual metadata*/
- for (i = 0; i < sizeof(src->oid); ++i)
- dst->oid[i] = src->oid[i];
+ HDmemcpy(dst->oid,src->oid,sizeof(src->oid));
H5O_SDSPACE[0].copy(src->sdim, dst->sdim);
H5O_DTYPE[0].copy(src->dtype, dst->dtype);
@@ -394,8 +384,7 @@ H5O_fphdf5_reset(void *mesg)
FUNC_ENTER_NOAPI(H5O_fphdf5_reset, FAIL);
/* reset the metadata */
- for (i = 0; i < sizeof(fmeta->oid); ++i)
- fmeta->oid[i] = '\0';
+ HDmemset(fmeta->oid,0,sizeof(fmeta->oid));
if (H5O_SDSPACE[0].reset)
ret_value = H5O_SDSPACE[0].reset(fmeta->sdim);
@@ -439,7 +428,6 @@ H5O_fphdf5_free(void *mesg)
FUNC_ENTER_NOAPI(H5O_fphdf5_free, FAIL);
assert(fmeta);
- /* reset the metadata */
if (H5O_SDSPACE[0].free)
ret_value = H5O_SDSPACE[0].free(fmeta->sdim);
diff --git a/src/H5Oplist.c b/src/H5Oplist.c
index a326fba..093e0b0 100644
--- a/src/H5Oplist.c
+++ b/src/H5Oplist.c
@@ -22,14 +22,14 @@
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5Ppkg.h"
+#include "H5Ppkg.h" /* Property lists */
#if defined (WIN32) && !defined (__MWERKS__)
#include <sys/types.h>
#include <sys/timeb.h>
#endif
+/* Pablo mask */
#define PABLO_MASK H5O_plist_mask
/* local prototypes */
@@ -60,7 +60,6 @@ const H5O_class_t H5O_PLIST[1] = {{
/* Is the interface initialized? */
static int interface_initialize_g = 0;
-
#define INTERFACE_INIT NULL
/* Declare external the free list for hsize_t arrays */