Commit 0e853656 authored by Marc Howison's avatar Marc Howison

* fixed bug in h5bl_defin3dchunkdims call that was using variables addresses ins

* added new MultiBlock module that is used for efficiently loading regular
rectilinear grid blocks (using chunking) and handling ghost zones in a
distributed-memory environment
** still need to add the "halo exchange" routine for reshuffling ghost regions
** performed some basic testing of read/write functionality

~Mark
parent 3d1ed0e9
......@@ -33,6 +33,13 @@ src/H5BlockReadWrite.h -text
src/H5BlockReadWriteF.c -text
src/H5BlockReadWriteF90.inc -text
src/H5BlockTypes.h -text
src/H5MultiBlock.c -text
src/H5MultiBlock.h -text
src/H5MultiBlockErrors.h -text
src/H5MultiBlockPrivate.h -text
src/H5MultiBlockReadWrite.c -text
src/H5MultiBlockReadWrite.h -text
src/H5MultiBlockTypes.h -text
src/H5Part.c -text
src/H5Part.h -text
src/H5PartErrors.h -text
......@@ -44,6 +51,7 @@ src/Makefile.am -text
src/TestUnderscore.f -text
src/TestUnderscoreC.c -text
src/generate-h5bl-readwrite.py -text
src/generate-h5multi-readwrite.py -text
test/Bench.c -text
test/BlockTestSpecs.txt -text
test/H5BlockDissolveGhosts.c -text
......
......@@ -182,6 +182,11 @@ _H5Block_close (
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
b->memshape = -1;
}
if ( b->create_prop != H5P_DEFAULT ) {
herr = H5Pclose ( b->create_prop );
if ( herr < 0 ) return HANDLE_H5P_CLOSE_ERR ("create_prop");
b->create_prop = H5P_DEFAULT;
}
free ( f->block );
f->block = NULL;
f->close_block = NULL;
......@@ -674,7 +679,7 @@ _dissolve_ghostzones (
\internal
*/
h5part_int64_t
static h5part_int64_t
_release_hyperslab (
H5PartFile *f /*!< IN: file handle */
) {
......@@ -720,7 +725,7 @@ H5BlockDefine3DFieldLayout(
) {
SET_FNAME ( "H5BlockDefine3DFieldLayout" );
INIT( f );
BLOCK_INIT( f );
struct H5BlockStruct *b = f->block;
struct H5BlockPartition *p = &b->user_layout[f->myproc];
......@@ -731,7 +736,7 @@ H5BlockDefine3DFieldLayout(
p->k_start = k_start;
p->k_end = k_end;
_normalize_partition( p );
_normalize_partition ( p );
h5part_int64_t herr = _allgather ( f );
if ( herr < 0 ) return HANDLE_MPI_ALLGATHER_ERR;
......@@ -760,13 +765,13 @@ H5BlockDefine3DFieldLayout(
h5part_int64_t
H5BlockDefine3DChunkDims(
H5PartFile *f, /*!< IN: File handle */
const h5part_int64_t i, /*!< IN: size of \c i */
const h5part_int64_t j, /*!< IN: size of \c j */
const h5part_int64_t k /*!< IN: size of \c k */
const h5part_int64_t i, /*!< IN: size of \c i */
const h5part_int64_t j, /*!< IN: size of \c j */
const h5part_int64_t k /*!< IN: size of \c k */
) {
SET_FNAME ( "H5BlockDefine3DChunkDims" );
INIT( f );
BLOCK_INIT( f );
struct H5BlockStruct *b = f->block;
......@@ -782,6 +787,8 @@ H5BlockDefine3DChunkDims(
(long long)b->chunk[0] );
b->create_prop = H5Pcreate (H5P_DATASET_CREATE);
if (b->create_prop < 0) return HANDLE_H5P_CREATE_ERR;
herr_t herr = H5Pset_chunk ( b->create_prop, 3, b->chunk );
if ( herr < 0 ) return HANDLE_H5P_SET_CHUNK_ERR;
......@@ -804,7 +811,7 @@ H5BlockGet3DChunkDims(
) {
SET_FNAME ( "H5BlockGet3DChunkDims" );
INIT( f );
BLOCK_INIT( f );
struct H5BlockStruct *b = f->block;
......@@ -869,7 +876,7 @@ H5Block3dGetPartitionOfProc (
) {
SET_FNAME ( "H5Block3dGetProcOf" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_LAYOUT ( f );
if ( ( proc < 0 ) || ( proc >= f->nprocs ) )
......@@ -909,7 +916,7 @@ H5Block3dGetReducedPartitionOfProc (
) {
SET_FNAME ( "H5Block3dGetProcOf" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_LAYOUT ( f );
if ( ( proc < 0 ) || ( proc >= f->nprocs ) )
......@@ -945,7 +952,7 @@ H5Block3dGetProcOf (
) {
SET_FNAME ( "H5Block3dGetProcOf" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_LAYOUT ( f );
struct H5BlockPartition *layout = f->block->write_layout;
......@@ -1060,8 +1067,8 @@ _H5Block_close_field_group (
\return \c H5PART_SUCCESS or error code
*/
static h5part_int64_t
_select_hyperslab_for_reading (
h5part_int64_t
_H5Block_select_hyperslab_for_reading (
H5PartFile *f, /*!< IN: file handle */
hid_t dataset
) {
......@@ -1155,6 +1162,7 @@ _H5Block_read_data (
hid_t type /*!< IN: data type */
) {
h5part_int64_t herr;
struct H5BlockStruct *b = f->block;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
......@@ -1164,7 +1172,7 @@ _H5Block_read_data (
#endif
if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( name );
h5part_int64_t herr = _select_hyperslab_for_reading ( f, dataset_id );
herr = _H5Block_select_hyperslab_for_reading ( f, dataset_id );
if ( herr < 0 ) return herr;
herr = H5Dread (
......@@ -1172,7 +1180,7 @@ _H5Block_read_data (
type,
f->block->memshape,
f->block->diskshape,
H5P_DEFAULT,
f->xfer_prop,
data );
if ( herr < 0 ) return HANDLE_H5D_READ_ERR ( name, f->timestep );
......@@ -1400,7 +1408,6 @@ _H5Block_write_data (
herr_t herr;
hid_t dataset;
hid_t create_prop = H5P_DEFAULT;
struct H5BlockStruct *b = f->block;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
......@@ -1420,7 +1427,6 @@ _H5Block_write_data (
b->shape,
b->create_prop );
#endif
if ( dataset < 0 ) return HANDLE_H5D_CREATE_ERR ( name, f->timestep );
herr = H5Dwrite (
......@@ -1435,11 +1441,6 @@ _H5Block_write_data (
herr = H5Dclose ( dataset );
if ( herr < 0 ) return HANDLE_H5D_CLOSE_ERR;
if ( create_prop != H5P_DEFAULT ) {
herr = H5Pclose ( create_prop );
if ( herr < 0 ) return HANDLE_H5P_CLOSE_ERR ( "create_prop" );
}
return H5PART_SUCCESS;
}
......@@ -1458,7 +1459,7 @@ H5BlockGetNumFields (
) {
SET_FNAME ( "H5BlockGetNumFields" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
if ( ! _H5Part_have_group ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK ) )
......@@ -1558,7 +1559,7 @@ H5BlockGetFieldInfo (
) {
SET_FNAME ( "H5BlockGetFieldInfo" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
h5part_int64_t herr = _H5Part_get_object_name (
......@@ -1591,7 +1592,7 @@ H5BlockGetFieldInfoByName (
) {
SET_FNAME ( "H5BlockGetFieldInfo" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
return _get_field_info (
......@@ -1620,7 +1621,7 @@ _write_field_attrib (
h5part_int64_t herr = _H5Block_open_field_group ( f, field_name );
if ( herr < 0 ) return herr;
_H5Part_write_attrib (
herr = _H5Part_write_attrib (
f->block->field_group_id,
attrib_name,
attrib_type,
......@@ -1653,7 +1654,7 @@ H5BlockWriteFieldAttrib (
) {
SET_FNAME ( "H5BlockWriteFieldAttrib" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE( f );
CHECK_TIMEGROUP( f );
......@@ -1681,7 +1682,7 @@ H5BlockWriteFieldAttribString (
) {
SET_FNAME ( "H5BlockWriteFieldAttribString" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE( f );
CHECK_TIMEGROUP( f );
......@@ -1706,7 +1707,7 @@ H5BlockGetNumFieldAttribs (
) {
SET_FNAME ( "H5BlockGetNumFieldAttribs" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, field_name );
......@@ -1744,7 +1745,7 @@ H5BlockGetFieldAttribInfo (
) {
SET_FNAME ( "H5BlockGetFieldAttribInfo" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, field_name );
......@@ -1815,7 +1816,7 @@ H5BlockReadFieldAttrib (
) {
SET_FNAME ( "H5PartReadFieldAttrib" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
return _read_field_attrib (
......@@ -1840,7 +1841,7 @@ H5Block3dGetFieldOrigin (
) {
SET_FNAME ( "H5BlockSetFieldOrigin" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
h5part_float64_t origin[3];
......@@ -1874,7 +1875,7 @@ H5Block3dSetFieldOrigin (
) {
SET_FNAME ( "H5BlockSetFieldOrigin" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE( f );
CHECK_TIMEGROUP( f );
......@@ -1906,7 +1907,7 @@ H5Block3dGetFieldSpacing (
) {
SET_FNAME ( "H5BlockGetFieldSpacing" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
h5part_float64_t spacing[3];
......@@ -1940,7 +1941,7 @@ H5Block3dSetFieldSpacing (
) {
SET_FNAME ( "H5BlockSetFieldSpacing" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE( f );
CHECK_TIMEGROUP( f );
......@@ -1970,7 +1971,7 @@ H5BlockHasFieldData (
) {
SET_FNAME ( "H5BlockHasFieldData" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP( f );
if ( ! _H5Part_have_group ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK ) ) {
......
......@@ -34,6 +34,7 @@
_H5Part_get_funcname(), \
H5PART_ERR_INVAL, \
"Group \"%s\" already exists", name )
#define HANDLE_H5S_CREATE_SIMPLE_3D_ERR( dims ) \
(*_err_handler) ( \
_H5Part_get_funcname(), \
......
......@@ -99,14 +99,14 @@ h5bl_define3dlayout (
h5part_int64_t
h5bl_define3dchunkdims (
h5part_int64_t *f,
const h5part_int64_t i,
const h5part_int64_t j,
const h5part_int64_t k
const h5part_int64_t *i,
const h5part_int64_t *j,
const h5part_int64_t *k
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
return H5BlockDefine3DChunkDims ( filehandle, i, j, k );
return H5BlockDefine3DChunkDims ( filehandle, *i, *j, *k );
}
h5part_int64_t
......
......@@ -3,7 +3,7 @@
#define H5BLOCK_GROUPNAME_BLOCK "Block"
#define INIT( f ) { \
#define BLOCK_INIT( f ) { \
h5part_int64_t herr = _H5Block_init ( f ); \
if ( herr < 0 ) return herr; \
}
......@@ -34,6 +34,12 @@ _H5Block_create_field_group (
H5PartFile *f,
const char *name
);
h5part_int64_t
_H5Block_select_hyperslab_for_reading (
H5PartFile *f,
hid_t dataset
);
h5part_int64_t
_H5Block_write_data (
......
......@@ -31,7 +31,7 @@ H5Block3dWriteScalarFieldFloat64 (
) {
SET_FNAME ( "H5Block3dWriteScalarFieldFloat64" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -67,7 +67,7 @@ H5Block3dReadScalarFieldFloat64 (
) {
SET_FNAME ( "H5Block3dReadScalarFieldFloat64" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -106,7 +106,7 @@ H5Block3dWrite3dVectorFieldFloat64 (
) {
SET_FNAME ( "H5Block3dWrite3dVectorFieldFloat64" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -150,7 +150,7 @@ H5Block3dRead3dVectorFieldFloat64 (
) {
SET_FNAME ( "H5Block3dRead3dVectorFieldFloat64" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -189,7 +189,7 @@ H5Block3dWriteScalarFieldFloat32 (
) {
SET_FNAME ( "H5Block3dWriteScalarFieldFloat32" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -225,7 +225,7 @@ H5Block3dReadScalarFieldFloat32 (
) {
SET_FNAME ( "H5Block3dReadScalarFieldFloat32" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -264,7 +264,7 @@ H5Block3dWrite3dVectorFieldFloat32 (
) {
SET_FNAME ( "H5Block3dWrite3dVectorFieldFloat32" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -308,7 +308,7 @@ H5Block3dRead3dVectorFieldFloat32 (
) {
SET_FNAME ( "H5Block3dRead3dVectorFieldFloat32" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -347,7 +347,7 @@ H5Block3dWriteScalarFieldInt64 (
) {
SET_FNAME ( "H5Block3dWriteScalarFieldInt64" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -383,7 +383,7 @@ H5Block3dReadScalarFieldInt64 (
) {
SET_FNAME ( "H5Block3dReadScalarFieldInt64" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -422,7 +422,7 @@ H5Block3dWrite3dVectorFieldInt64 (
) {
SET_FNAME ( "H5Block3dWrite3dVectorFieldInt64" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -466,7 +466,7 @@ H5Block3dRead3dVectorFieldInt64 (
) {
SET_FNAME ( "H5Block3dRead3dVectorFieldInt64" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -505,7 +505,7 @@ H5Block3dWriteScalarFieldInt32 (
) {
SET_FNAME ( "H5Block3dWriteScalarFieldInt32" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -541,7 +541,7 @@ H5Block3dReadScalarFieldInt32 (
) {
SET_FNAME ( "H5Block3dReadScalarFieldInt32" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -580,7 +580,7 @@ H5Block3dWrite3dVectorFieldInt32 (
) {
SET_FNAME ( "H5Block3dWrite3dVectorFieldInt32" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......@@ -624,7 +624,7 @@ H5Block3dRead3dVectorFieldInt32 (
) {
SET_FNAME ( "H5Block3dRead3dVectorFieldInt32" );
INIT ( f );
BLOCK_INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
......
This diff is collapsed.
#ifndef __H5MULTIBLOCK_H
#define __H5MULTIBLOCK_H
#ifdef __cplusplus
extern "C" {
#endif
/*!
Include read/write call variants for different data types and
field dimensions.
*/
#include "H5MultiBlockReadWrite.h"
#define H5MULTIBLOCK_ATTR_NAME "__BlockDims__"
h5part_int64_t
H5MultiBlock3dDefineRadius (
H5PartFile *f,
const h5part_int64_t r
);
h5part_int64_t
H5MultiBlock3dDefineRadii (
H5PartFile *f,
const h5part_int64_t ri,
const h5part_int64_t rj,
const h5part_int64_t rk
);
h5part_int64_t
H5MultiBlock3dDefineDims (
H5PartFile *f,
const h5part_int64_t *field_dims,
const h5part_int64_t *block_dims
);
h5part_int64_t
H5MultiBlock3dGetFieldDims(
H5PartFile *f,
h5part_int64_t *dims
);
h5part_int64_t
H5MultiBlock3dGetBlockDims(
H5PartFile *f,
const char *field_name,
h5part_int64_t *dims
);
h5part_int64_t
H5MultiBlock3dGetOffsetsOfProc (
H5PartFile *f,
const h5part_int64_t proc,
h5part_int64_t *offsets
);
h5part_int64_t
H5MultiBlock3dCalculateDecomp (
const int nprocs,
h5part_int64_t *decomp
);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __H5MULTIBLOCKERRORS_H
#define __H5MULTIBLOCKERRORS_H
#define _err_handler H5PartGetErrorHandler()
#define CHECK_DECOMP( f ) \
if ( ! f->multiblock->have_decomp ) \
return (*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_DECOMP, \
"No dimensions defined." )
#define HANDLE_H5PART_BLOCK_DECOMP_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_DECOMP, \
"Number of blocks does not equal number of procs" );
#endif
#ifndef __H5MULTIBLOCKPRIVATE_H
#define __H5MULTIBLOCKPRIVATE_H
#define MULTIBLOCK_INIT( f ) { \
h5part_int64_t herr = _H5MultiBlock_init ( f ); \
if ( herr < 0 ) return herr; \
}
h5part_int64_t
_H5MultiBlock_init (
H5PartFile *f
);
h5part_int64_t
_H5MultiBlock_close (
H5PartFile *f
);
h5part_int64_t
_H5MultiBlock_write_data (
H5PartFile *f,
const char *field_name,
const void *data,
const hid_t type
);
h5part_int64_t
_H5MultiBlock_read_data (
H5PartFile *f,
const char *field_name,
char **data,
hid_t type
);
#endif
#include <stdlib.h>
#include <string.h>
#include <hdf5.h>
#include "H5Part.h"
#include "H5PartErrors.h"
#include "H5PartPrivate.h"
#include "H5MultiBlockErrors.h"
#include "H5MultiBlockPrivate.h"
/*!
\ingroup h5multiblock_c_api
Write a multiblock field \c name from the buffer starting at \c data
to the current time-step using the defined block decomposition and dimensions.
Values are floating points (64-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5MultiBlock3dWriteFieldFloat64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float64_t *data /*!< IN: data to write */
) {
SET_FNAME( "H5MultiBlock3dWriteFieldFloat64" );
h5part_int64_t herr;
herr = _H5MultiBlock_write_data ( f, name, data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5multiblock_c_api
Allocate a buffer to hold a block from a multiblock field and place the
pointer in \c data, then read the block into the buffer. Uses the block
decomposition specified in the file and the defined halo radius.
Values are floating points (64-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5MultiBlock3dReadFieldFloat64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_float64_t **data /*!< OUT: ptr to read buffer */
) {
SET_FNAME( "H5MultiBlock3dReadFieldFloat64" );
h5part_int64_t herr;
herr = _H5MultiBlock_read_data ( f, name, (char**) data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5multiblock_c_api
Write a multiblock field \c name from the buffer starting at \c data
to the current time-step using the defined block decomposition and dimensions.
Values are floating points (32-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5MultiBlock3dWriteFieldFloat32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float32_t *data /*!< IN: data to write */
) {
SET_FNAME( "H5MultiBlock3dWriteFieldFloat32" );
h5part_int64_t herr;
herr = _H5MultiBlock_write_data ( f, name, data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5multiblock_c_api
Allocate a buffer to hold a block from a multiblock field and place the
pointer in \c data, then read the block into the buffer. Uses the block
decomposition specified in the file and the defined halo radius.
Values are floating points (32-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code