summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcvs2svn <no_author@cvs2svn>2004-08-02 14:10:07 (GMT)
committercvs2svn <no_author@cvs2svn>2004-08-02 14:10:07 (GMT)
commit529c7b27c78a42fddc90df243d8d3f43e8fec7d6 (patch)
tree61100929e0c289603c8016a9fa147c818056ff30
parentf8b2efd52d6239251d65975ca7146dd3d20c4843 (diff)
downloadhdf5-529c7b27c78a42fddc90df243d8d3f43e8fec7d6.zip
hdf5-529c7b27c78a42fddc90df243d8d3f43e8fec7d6.tar.gz
hdf5-529c7b27c78a42fddc90df243d8d3f43e8fec7d6.tar.bz2
[svn-r8984] This commit was manufactured by cvs2svn to create branch 'hdf5_1_6'.
-rw-r--r--src/H5FDmpi.h94
-rw-r--r--src/H5HGdbg.c135
-rw-r--r--src/H5HGpkg.h96
-rw-r--r--src/H5HLpkg.h81
-rw-r--r--testpar/t_coll_chunk.c489
5 files changed, 895 insertions, 0 deletions
diff --git a/src/H5FDmpi.h b/src/H5FDmpi.h
new file mode 100644
index 0000000..aac7bf6
--- /dev/null
+++ b/src/H5FDmpi.h
@@ -0,0 +1,94 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Friday, January 30, 2004
+ *
+ * Purpose: The public header file for common items for all MPI VFL drivers
+ */
+#ifndef H5FDmpi_H
+#define H5FDmpi_H
+
+/* Type of I/O for data transfer properties */
+typedef enum H5FD_mpio_xfer_t {
+ H5FD_MPIO_INDEPENDENT = 0, /*zero is the default*/
+ H5FD_MPIO_COLLECTIVE
+} H5FD_mpio_xfer_t;
+
+#ifdef H5_HAVE_PARALLEL
+
+/* Sub-class the H5FD_class_t to add more specific functions for MPI-based VFDs */
+typedef struct H5FD_class_mpi_t {
+ H5FD_class_t super; /* Superclass information & methods */
+ int (*get_rank)(const H5FD_t *file); /* Get the MPI rank of a process */
+ int (*get_size)(const H5FD_t *file); /* Get the MPI size of a communicator */
+ MPI_Comm (*get_comm)(const H5FD_t *file); /* Get the communicator for a file */
+} 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 */
+
+/* Macros */
+
+/* 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))
+
+#ifdef H5_HAVE_PARALLEL
+/* ======== Temporary data transfer properties ======== */
+/* Definitions for memory MPI type property */
+#define H5FD_MPI_XFER_MEM_MPI_TYPE_NAME "H5FD_mpi_mem_mpi_type"
+#define H5FD_MPI_XFER_MEM_MPI_TYPE_SIZE sizeof(MPI_Datatype)
+/* Definitions for file MPI type property */
+#define H5FD_MPI_XFER_FILE_MPI_TYPE_NAME "H5FD_mpi_file_mpi_type"
+#define H5FD_MPI_XFER_FILE_MPI_TYPE_SIZE sizeof(MPI_Datatype)
+
+/*
+ * The view is set to this value
+ */
+H5_DLLVAR char H5FD_mpi_native_g[];
+
+/* Function prototypes */
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* General routines */
+H5_DLL haddr_t H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off);
+H5_DLL herr_t H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/);
+H5_DLL herr_t H5FD_mpi_comm_info_dup(MPI_Comm comm, MPI_Info info,
+ MPI_Comm *comm_new, MPI_Info *info_new);
+H5_DLL herr_t H5FD_mpi_comm_info_free(MPI_Comm *comm, MPI_Info *info);
+#ifdef NOT_YET
+H5_DLL herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *file);
+H5_DLL herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *file);
+#endif /* NOT_YET */
+H5_DLL herr_t H5FD_mpi_setup_collective(hid_t dxpl_id, MPI_Datatype btype,
+ MPI_Datatype ftype);
+H5_DLL herr_t H5FD_mpi_teardown_collective(hid_t dxpl_id);
+
+/* Driver specific methods */
+H5_DLL int H5FD_mpi_get_rank(const H5FD_t *file);
+H5_DLL int H5FD_mpi_get_size(const H5FD_t *file);
+H5_DLL MPI_Comm H5FD_mpi_get_comm(const H5FD_t *_file);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H5_HAVE_PARALLEL */
+
+#endif /* H5FDmpi_H */
diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c
new file mode 100644
index 0000000..68a3e85
--- /dev/null
+++ b/src/H5HGdbg.c
@@ -0,0 +1,135 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Wednesday, July 9, 2003
+ *
+ * Purpose: Global Heap object debugging functions.
+ */
+#define H5HG_PACKAGE /*suppress error about including H5HGpkg */
+
+/* Pablo information */
+/* (Put before include files to avoid problems with inline functions) */
+#define PABLO_MASK H5HGdbg_mask
+
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HGpkg.h" /* Global heaps */
+#include "H5Iprivate.h" /* ID Functions */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HG_debug
+ *
+ * Purpose: Prints debugging information about a global heap collection.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Mar 27, 1998
+ *
+ * Modifications:
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
+ *
+ * Robb Matzke, LLNL, 2003-06-05
+ * The size does not include the object header, just the data.
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
+ int fwidth)
+{
+ unsigned u, nused, maxobj;
+ unsigned j, k;
+ H5HG_heap_t *h = NULL;
+ char buf[64];
+ uint8_t *p = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5HG_debug, FAIL);
+
+ /* check arguments */
+ assert(f);
+ assert(H5F_addr_defined (addr));
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ if (NULL == (h = H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL, H5AC_READ)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection");
+
+ fprintf(stream, "%*sGlobal Heap Collection...\n", indent, "");
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Dirty:",
+ (int)(h->cache_info.is_dirty));
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Total collection size in file:",
+ (unsigned long)(h->size));
+
+ for (u=1, nused=0, maxobj=0; u<h->nused; u++) {
+ if (h->obj[u].begin) {
+ nused++;
+ if (u>maxobj) maxobj = u;
+ }
+ }
+ fprintf (stream, "%*s%-*s %u/%lu/", indent, "", fwidth,
+ "Objects defined/allocated/max:",
+ nused, (unsigned long)h->nalloc);
+ fprintf (stream, nused ? "%u\n": "NA\n", maxobj);
+
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Free space:",
+ (unsigned long)(h->obj[0].size));
+
+ for (u=1; u<h->nused; u++) {
+ if (h->obj[u].begin) {
+ sprintf (buf, "Object %u", u);
+ fprintf (stream, "%*s%s\n", indent, "", buf);
+ fprintf (stream, "%*s%-*s %d\n", indent+3, "", MIN(fwidth-3, 0),
+ "Reference count:",
+ h->obj[u].nrefs);
+ fprintf (stream, "%*s%-*s %lu/%lu\n", indent+3, "",
+ MIN(fwidth-3, 0),
+ "Size of object body:",
+ (unsigned long)(h->obj[u].size),
+ (unsigned long)H5HG_ALIGN(h->obj[u].size));
+ p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR (f);
+ for (j=0; j<h->obj[u].size; j+=16) {
+ fprintf (stream, "%*s%04d: ", indent+6, "", j);
+ for (k=0; k<16; k++) {
+ if (8==k) fprintf (stream, " ");
+ if (j+k<h->obj[u].size) {
+ fprintf (stream, "%02x ", p[j+k]);
+ } else {
+ HDfputs(" ", stream);
+ }
+ }
+ for (k=0; k<16 && j+k<h->obj[u].size; k++) {
+ if (8==k) fprintf (stream, " ");
+ HDfputc(p[j+k]>' ' && p[j+k]<='~' ? p[j+k] : '.', stream);
+ }
+ fprintf (stream, "\n");
+ }
+ }
+ }
+
+done:
+ if (h && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, addr, h, FALSE) != SUCCEED)
+ HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header");
+
+ FUNC_LEAVE_NOAPI(ret_value);
+}
diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h
new file mode 100644
index 0000000..de5bb77
--- /dev/null
+++ b/src/H5HGpkg.h
@@ -0,0 +1,96 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Wednesday, July 9, 2003
+ *
+ * Purpose: This file contains declarations which are visible
+ * only within the H5HG package. Source files outside the
+ * H5HG package should include H5HGprivate.h instead.
+ */
+#ifndef H5HG_PACKAGE
+#error "Do not include this file outside the H5HG package!"
+#endif
+
+#ifndef _H5HGpkg_H
+#define _H5HGpkg_H
+
+/* Get package's private header */
+#include "H5HGprivate.h"
+
+/* Other private headers needed by this file */
+
+/*****************************/
+/* Package Private Variables */
+/*****************************/
+
+/* The cache subclass */
+H5_DLLVAR const H5AC_class_t H5AC_GHEAP[1];
+
+/**************************/
+/* Package Private Macros */
+/**************************/
+
+/*
+ * Pad all global heap messages to a multiple of eight bytes so we can load
+ * the entire collection into memory and operate on it there. Eight should
+ * be sufficient for machines that have alignment constraints because our
+ * largest data type is eight bytes.
+ */
+#define H5HG_ALIGNMENT 8
+#define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/ \
+ H5HG_ALIGNMENT))
+#define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X))
+
+/*
+ * The overhead associated with each object in the heap, always a multiple of
+ * the alignment so that the stuff that follows the header is aligned.
+ */
+#define H5HG_SIZEOF_OBJHDR(f) \
+ H5HG_ALIGN(2 + /*object id number */ \
+ 2 + /*reference count */ \
+ 4 + /*reserved */ \
+ H5F_SIZEOF_SIZE(f)) /*object data size */
+
+/****************************/
+/* Package Private Typedefs */
+/****************************/
+
+typedef struct H5HG_obj_t {
+ int nrefs; /*reference count */
+ size_t size; /*total size of object */
+ uint8_t *begin; /*ptr to object into heap->chunk*/
+} H5HG_obj_t;
+
+struct H5HG_heap_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
+ haddr_t addr; /*collection address */
+ size_t size; /*total size of collection */
+ uint8_t *chunk; /*the collection, incl. header */
+ size_t nalloc; /*numb object slots allocated */
+ size_t nused; /*number of slots used */
+ /* If this value is >65535 then all indices */
+ /* have been used at some time and the */
+ /* correct new index should be searched for */
+ H5HG_obj_t *obj; /*array of object descriptions */
+};
+
+/******************************/
+/* Package Private Prototypes */
+/******************************/
+
+#endif
+
diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h
new file mode 100644
index 0000000..1a61866
--- /dev/null
+++ b/src/H5HLpkg.h
@@ -0,0 +1,81 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Wednesday, July 9, 2003
+ *
+ * Purpose: This file contains declarations which are visible
+ * only within the H5HL package. Source files outside the
+ * H5HL package should include H5HLprivate.h instead.
+ */
+#ifndef H5HL_PACKAGE
+#error "Do not include this file outside the H5HL package!"
+#endif
+
+#ifndef _H5HLpkg_H
+#define _H5HLpkg_H
+
+/* Get package's private header */
+#include "H5HLprivate.h"
+
+/* Other private headers needed by this file */
+
+/*****************************/
+/* Package Private Variables */
+/*****************************/
+
+/* The cache subclass */
+H5_DLLVAR const H5AC_class_t H5AC_LHEAP[1];
+
+/**************************/
+/* Package Private Macros */
+/**************************/
+
+#define H5HL_SIZEOF_HDR(F) \
+ H5HL_ALIGN(H5HL_SIZEOF_MAGIC + /*heap signature */ \
+ 4 + /*reserved */ \
+ H5F_SIZEOF_SIZE (F) + /*data size */ \
+ H5F_SIZEOF_SIZE (F) + /*free list head */ \
+ H5F_SIZEOF_ADDR (F)) /*data address */
+
+/****************************/
+/* Package Private Typedefs */
+/****************************/
+
+typedef struct H5HL_free_t {
+ size_t offset; /*offset of free block */
+ size_t size; /*size of free block */
+ struct H5HL_free_t *prev; /*previous entry in free list */
+ struct H5HL_free_t *next; /*next entry in free list */
+} H5HL_free_t;
+
+struct H5HL_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
+ haddr_t addr; /*address of data */
+ size_t disk_alloc; /*data bytes allocated on disk */
+ size_t mem_alloc; /*data bytes allocated in mem */
+ size_t disk_resrv; /*data bytes "reserved" on disk */
+ uint8_t *chunk; /*the chunk, including header */
+ H5HL_free_t *freelist; /*the free list */
+};
+
+/******************************/
+/* Package Private Prototypes */
+/******************************/
+
+#endif
+
+
diff --git a/testpar/t_coll_chunk.c b/testpar/t_coll_chunk.c
new file mode 100644
index 0000000..8c2373b
--- /dev/null
+++ b/testpar/t_coll_chunk.c
@@ -0,0 +1,489 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include "testphdf5.h"
+#include "H5Dprivate.h"
+
+/*#define SPACE_DIM1 256
+#define SPACE_DIM2 256
+#define BYROW_CONT 1
+#define BYROW_DISCONT 2
+#define DSET_COLLECTIVE_CHUNK_NAME "coll_chunk_name"
+*/
+
+/* some commonly used routines for collective chunk IO tests*/
+static void ccslab_set(int mpi_rank,int mpi_size,hssize_t start[],hsize_t count[],
+ hsize_t stride[],hsize_t block[],int mode);
+
+static void ccdataset_fill(hssize_t start[],hsize_t count[],
+ hsize_t stride[],hsize_t block[],DATATYPE*dataset);
+
+static void ccdataset_print(hssize_t start[],hsize_t block[],DATATYPE*dataset);
+
+static int ccdataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[],
+ hsize_t block[], DATATYPE *dataset, DATATYPE *original);
+
+static void coll_chunktest(char* filename,int chunk_factor,int select_factor);
+
+/*-------------------------------------------------------------------------
+ * Function: coll_chunk1
+ *
+ * Purpose: Test the special case of the collective chunk io
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Unknown
+ * July 12th, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+coll_chunk1(void)
+{
+
+ char *filename;
+ filename = (char *) GetTestParameters();
+ coll_chunktest(filename,1,BYROW_CONT);
+
+}
+
+void
+coll_chunk2(void)
+{
+
+ char *filename;
+ filename = (char *) GetTestParameters();
+ coll_chunktest(filename,1,BYROW_DISCONT);
+
+}
+
+
+void
+coll_chunk3(void)
+{
+
+ char *filename;
+ filename = (char *) GetTestParameters();
+ coll_chunktest(filename,4,BYROW_CONT);
+
+}
+
+void
+coll_chunk4(void)
+{
+
+ char *filename;
+ filename = (char *) GetTestParameters();
+ coll_chunktest(filename,4,BYROW_DISCONT);
+
+}
+
+static void
+coll_chunktest(char* filename,int chunk_factor,int select_factor) {
+
+ hid_t file,dataset, file_dataspace;
+ hid_t acc_plist,xfer_plist,crp_plist;
+ hsize_t dims[RANK], chunk_dims[RANK];
+ int* data_array1 = NULL;
+ int* data_origin1 = NULL;
+ herr_t status;
+ hssize_t start[RANK];
+ hsize_t count[RANK],stride[RANK],block[RANK];
+#ifdef H5_HAVE_INSTRUMENTED_LIBRARY
+ unsigned prop_value;
+#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */
+ int mpi_size,mpi_rank;
+ MPI_Comm comm = MPI_COMM_WORLD;
+ MPI_Info info = MPI_INFO_NULL;
+
+ /* set up MPI parameters */
+ MPI_Comm_size(comm,&mpi_size);
+ MPI_Comm_rank(comm,&mpi_rank);
+
+ /* Create the data space */
+ acc_plist = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((acc_plist >= 0),"");
+
+
+ status = H5Pset_fapl_mpio(acc_plist,comm,info);
+ VRFY((acc_plist >= 0),"MPIO creation property list succeeded");
+
+ file = H5Fcreate(filename,H5F_ACC_TRUNC,H5P_DEFAULT,acc_plist);
+ VRFY((file >= 0),"H5Fcreate succeeded");
+
+ status = H5Pclose(acc_plist);
+ VRFY((status >= 0),"");
+
+ /* setup dimensionality object */
+
+ dims[0] = SPACE_DIM1;
+ dims[1] = SPACE_DIM2;
+
+ /* each process takes a slab of rows
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = SPACE_DIM1/mpi_size;
+ count[1] = SPACE_DIM2;
+ start[0] = mpi_rank*count[0];
+ start[1] = 0;
+ block[0] = 1;
+ block[1] = 1;
+ */
+
+ /* allocate memory for data buffer */
+ data_array1 = (int *)malloc(SPACE_DIM1*SPACE_DIM2*sizeof(int));
+ VRFY((data_array1 != NULL), "data_array1 malloc succeeded");
+
+ /* set up dimensions of the slab this process accesses */
+ ccslab_set(mpi_rank, mpi_size, start, count, stride, block, select_factor);
+
+ file_dataspace = H5Screate_simple(2, dims, NULL);
+ VRFY((file_dataspace >= 0),"file dataspace created succeeded");
+
+ crp_plist = H5Pcreate(H5P_DATASET_CREATE);
+ VRFY((crp_plist >= 0),"");
+
+ /* test1: chunk size is equal to dataset size */
+ chunk_dims[0] = SPACE_DIM1/chunk_factor;
+ chunk_dims[1] = SPACE_DIM2/chunk_factor;
+ status = H5Pset_chunk(crp_plist, 2, chunk_dims);
+ VRFY((status >= 0),"chunk creation property list succeeded");
+
+ dataset = H5Dcreate(file,DSET_COLLECTIVE_CHUNK_NAME,H5T_NATIVE_INT,
+ file_dataspace,crp_plist);
+ VRFY((dataset >= 0),"dataset created succeeded");
+/* H5Sclose(file_dataspace); */
+
+ status = H5Pclose(crp_plist);
+ VRFY((status >= 0),"");
+
+ /*put some trivial data in the data array */
+ ccdataset_fill(start, stride,count,block, data_array1);
+ MESG("data_array initialized");
+
+/* file_dataspace = H5Dget_space(dataset); */
+ status=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride,
+ count, block);
+ VRFY((status >= 0),"hyperslab selection succeeded");
+
+ /* set up the collective transfer property list */
+ xfer_plist = H5Pcreate (H5P_DATASET_XFER);
+ VRFY((xfer_plist >= 0),"");
+
+ status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ VRFY((status>= 0),"MPIO collective transfer property succeeded");
+#ifdef H5_HAVE_INSTRUMENTED_LIBRARY
+ prop_value = H5D_XFER_COLL_CHUNK_DEF;
+#ifdef H5_WANT_H5_V1_6_COMPAT
+ status = H5Pinsert(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,H5D_XFER_COLL_CHUNK_SIZE,&prop_value,
+ NULL,NULL,NULL,NULL,NULL);
+#else /* H5_WANT_H5_V1_6_COMPAT */
+ status = H5Pinsert(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,H5D_XFER_COLL_CHUNK_SIZE,&prop_value,
+ NULL,NULL,NULL,NULL,NULL,NULL);
+#endif /* H5_WANT_H5_V1_6_COMPAT */
+ VRFY((status >= 0),"testing property list inserted succeeded");
+#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */
+
+ /* write data collectively */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, file_dataspace,
+ xfer_plist, data_array1);
+ VRFY((status >= 0),"dataset write succeeded");
+
+#ifdef H5_HAVE_INSTRUMENTED_LIBRARY
+ status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,&prop_value);
+ VRFY((status >= 0),"testing property list get succeeded");
+ if(chunk_factor == 4 && select_factor == BYROW_DISCONT) { /* suppose to use independent */
+ VRFY((prop_value == 0), "H5Dwrite shouldn't use MPI Collective IO call");
+ }
+ else {
+ VRFY((prop_value == 1), "H5Dwrite didn't use MPI Collective IO call");
+ }
+#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */
+ status = H5Dclose(dataset);
+ VRFY((status >= 0),"");
+
+ /* check whether using collective IO */
+ /* Should use H5Pget and H5Pinsert to handle this test. */
+
+ status = H5Pclose(xfer_plist);
+ VRFY((status >= 0),"property list closed");
+
+ status = H5Sclose(file_dataspace);
+ VRFY((status >= 0),"");
+
+ status = H5Fclose(file);
+ VRFY((status >= 0),"");
+
+ if (data_array1) free(data_array1);
+
+ /* Using read to verify the data inside the dataset is correct */
+
+ /* allocate memory for data buffer */
+ data_array1 = (int *)malloc(SPACE_DIM1*SPACE_DIM2*sizeof(int));
+ VRFY((data_array1 != NULL), "data_array1 malloc succeeded");
+
+ /* allocate memory for data buffer */
+ data_origin1 = (int *)malloc(SPACE_DIM1*SPACE_DIM2*sizeof(int));
+ VRFY((data_origin1 != NULL), "data_origin1 malloc succeeded");
+
+ /* Create the data space */
+ acc_plist = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((acc_plist >= 0),"");
+
+ status = H5Pset_fapl_mpio(acc_plist,comm,info);
+ VRFY((acc_plist >= 0),"MPIO creation property list succeeded");
+
+ file = H5Fopen(filename,H5F_ACC_RDONLY,acc_plist);
+ VRFY((file >= 0),"H5Fcreate succeeded");
+
+ status = H5Pclose(acc_plist);
+ VRFY((status >= 0),"");
+
+ /* open the dataset collectively */
+ dataset = H5Dopen(file, DSET_COLLECTIVE_CHUNK_NAME);
+ VRFY((dataset >= 0), "");
+
+ /* set up dimensions of the slab this process accesses */
+ ccslab_set(mpi_rank, mpi_size, start, count, stride, block, select_factor);
+
+ /* create a file dataspace independently */
+ file_dataspace = H5Dget_space (dataset);
+ VRFY((file_dataspace >= 0), "");
+ status=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((status >= 0), "");
+
+ /* fill dataset with test data */
+ ccdataset_fill(start, stride,count,block, data_origin1);
+ xfer_plist = H5Pcreate (H5P_DATASET_XFER);
+ VRFY((xfer_plist >= 0),"");
+ status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ VRFY((status>= 0),"MPIO collective transfer property succeeded");
+#ifdef H5_HAVE_INSTRUMENTED_LIBRARY
+ prop_value = H5D_XFER_COLL_CHUNK_DEF;
+#ifdef H5_WANT_H5_V1_6_COMPAT
+ status = H5Pinsert(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,H5D_XFER_COLL_CHUNK_SIZE,&prop_value,
+ NULL,NULL,NULL,NULL,NULL);
+#else /* H5_WANT_H5_V1_6_COMPAT */
+ status = H5Pinsert(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,H5D_XFER_COLL_CHUNK_SIZE,&prop_value,
+ NULL,NULL,NULL,NULL,NULL,NULL);
+#endif /* H5_WANT_H5_V1_6_COMPAT */
+ VRFY((status >= 0),"testing property list inserted succeeded");
+#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */
+ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, file_dataspace,
+ xfer_plist, data_array1);
+ VRFY((status >=0),"dataset read succeeded");
+#ifdef H5_HAVE_INSTRUMENTED_LIBRARY
+ status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_NAME,&prop_value);
+ VRFY((status >= 0),"testing property list get succeeded");
+ if(chunk_factor == 4 && select_factor == BYROW_DISCONT) { /* suppose to use independent */
+ VRFY((prop_value == 0), "H5Dread shouldn't use MPI Collective IO call");
+ }
+ else {
+ VRFY((prop_value == 1), "H5Dread didn't use MPI Collective IO call");
+ }
+#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */
+
+ /* verify the read data with original expected data */
+
+ status = ccdataset_vrfy(start, count, stride, block, data_array1, data_origin1);
+ if (status) nerrors++;
+
+ status = H5Pclose(xfer_plist);
+ VRFY((status >= 0),"property list closed");
+
+ /* close dataset collectively */
+ status=H5Dclose(dataset);
+ VRFY((status >= 0), "");
+
+ /* release all IDs created */
+ H5Sclose(file_dataspace);
+
+ /* close the file collectively */
+ H5Fclose(file);
+
+ /* release data buffers */
+ if (data_array1) free(data_array1);
+ if (data_origin1) free(data_origin1);
+
+}
+
+
+static void
+ccslab_set(int mpi_rank, int mpi_size, hssize_t start[], hsize_t count[],
+ hsize_t stride[], hsize_t block[], int mode)
+{
+ switch (mode){
+ case BYROW_CONT:
+ /* Each process takes a slabs of rows. */
+ block[0] = 1;
+ block[1] = 1;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = SPACE_DIM1/mpi_size;
+ count[1] = SPACE_DIM2;
+ start[0] = mpi_rank*count[0];
+ start[1] = 0;
+
+ if (VERBOSE_MED) printf("slab_set BYROW_CONT\n");
+ break;
+ case BYROW_DISCONT:
+ /* Each process takes several disjoint blocks. */
+ block[0] = 2;
+ block[1] = 2;
+ stride[0] = 3;
+ stride[1] = 6;
+ count[0] = 2;
+ count[1] = 3;
+ start[0] = SPACE_DIM1/mpi_size*mpi_rank;
+ start[1] = 0;
+if (VERBOSE_MED) printf("slab_set BYROW_DISCONT\n");
+ break;
+ default:
+ /* Unknown mode. Set it to cover the whole dataset. */
+ printf("unknown slab_set mode (%d)\n", mode);
+ block[0] = SPACE_DIM1;
+ block[1] = SPACE_DIM2;
+ stride[0] = block[0];
+ stride[1] = block[1];
+ count[0] = 1;
+ count[1] = 1;
+ start[0] = 0;
+ start[1] = 0;
+if (VERBOSE_MED) printf("slab_set wholeset\n");
+ break;
+ }
+if (VERBOSE_MED){
+ printf("start[]=(%ld,%ld), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total datapoints=%lu\n",
+ (long)start[0], (long)start[1], (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1],
+ (unsigned long)(block[0]*block[1]*count[0]*count[1]));
+ }
+}
+
+
+/*
+ * Fill the dataset with trivial data for testing.
+ * Assume dimension rank is 2 and data is stored contiguous.
+ */
+static void
+ccdataset_fill(hssize_t start[], hsize_t stride[], hsize_t count[], hsize_t block[], DATATYPE * dataset)
+{
+ DATATYPE *dataptr = dataset;
+ DATATYPE *tmptr;
+ hsize_t i, j,k1,k2;
+
+ /* put some trivial data in the data_array */
+ tmptr = dataptr;
+
+ /* assign the disjoint block (two-dimensional)data array value
+ through the pointer */
+ for (k1 = 0; k1 < count[0]; k1++) {
+ for(i = 0;i < block[0]; i++) {
+ for(k2 = 0; k2<count[1]; k2++) {
+ for(j=0;j<block[1]; j++) {
+
+ dataptr = tmptr + ((start[0]+k1*stride[0]+i)*SPACE_DIM2+
+ start[1]+k2*stride[1]+j);
+
+ *dataptr = (DATATYPE)(k1+k2+i+j);
+ }
+ }
+ }
+ }
+
+}
+
+/*
+ * Print the first block of the content of the dataset.
+ */
+static void
+ccdataset_print(hssize_t start[], hsize_t block[], DATATYPE * dataset)
+{
+ DATATYPE *dataptr = dataset;
+ hsize_t i, j;
+
+ /* print the column heading */
+ printf("Print only the first block of the dataset\n");
+ printf("%-8s", "Cols:");
+ for (j=0; j < block[1]; j++){
+ printf("%3ld ", (long)(start[1]+j));
+ }
+ printf("\n");
+
+ /* print the slab data */
+ for (i=0; i < block[0]; i++){
+ printf("Row %2ld: ", (long)(i+start[0]));
+ for (j=0; j < block[1]; j++){
+ printf("%03d ", *dataptr++);
+ }
+ printf("\n");
+ }
+}
+
+
+/*
+ * Print the content of the dataset.
+ */
+static int
+ccdataset_vrfy(hssize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, DATATYPE *original)
+{
+ hsize_t i, j,k1,k2;
+ int vrfyerrs;
+ DATATYPE *dataptr,*oriptr;
+
+ /* print it if VERBOSE_MED */
+ if (VERBOSE_MED) {
+ printf("dataset_vrfy dumping:::\n");
+ printf("start(%ld, %ld), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n",
+ (long)start[0], (long)start[1], (unsigned long)count[0], (unsigned long)count[1],
+ (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1]);
+ printf("original values:\n");
+ ccdataset_print(start, block, original);
+ printf("compared values:\n");
+ ccdataset_print(start, block, dataset);
+ }
+
+ vrfyerrs = 0;
+
+ for (k1 = 0; k1 < count[0];k1++) {
+ for(i = 0;i < block[0];i++) {
+ for(k2 = 0; k2<count[1];k2++) {
+ for(j=0;j<block[1];j++) {
+
+ dataptr = dataset + ((start[0]+k1*stride[0]+i)*SPACE_DIM2+
+ start[1]+k2*stride[1]+j);
+ oriptr = original + ((start[0]+k1*stride[0]+i)*SPACE_DIM2+
+ start[1]+k2*stride[1]+j);
+
+ if (*dataptr != *oriptr){
+ if (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED){
+ printf("Dataset Verify failed at [%ld][%ld]: expect %d, got %d\n",
+ (long)i, (long)j,
+ *(original), *(dataset));
+ }
+ }
+ }
+ }
+ }
+ }
+ if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED)
+ printf("[more errors ...]\n");
+ if (vrfyerrs)
+ printf("%d errors found in dataset_vrfy\n", vrfyerrs);
+ return(vrfyerrs);
+}