Write speed / hyperslabing ordering? HDF5 1.8

Hi Everybody,

I have looked through the documentation and ran several tests, but I am still having the following problem:

If I write a large file to disk as a single piece, I see fast write speeds. If however, I write the identical file to disk in successive (contiguous) hyperslabs, the write speed depends on the order I traverse the hyperslab write loop. The forward traverse is fast. The reverse traverse is a factor of three slower.

The hyperslabs are large and few. Hard disk seek times are not a factor. The two loops are shown below. The only difference between the two is the order I traverse the loop.

Best regards,
Tim

The following code is in C#, but I saw the same effect in C:

Forward ordering:

for (int index = 0; index < rows; index += slabSize)
            {
                startFile[0] = (ulong)index;
                H5S.selectHyperslab(mSpaceID, H5S.SelectOperator.SET, startMem, countMem);
                H5S.selectHyperslab(fSpaceID, H5S.SelectOperator.SET, startFile, countFile);
                H5D.write(dataSetID, new H5DataTypeId(H5T.H5Type.NATIVE_UINT), mSpaceID, fSpaceID, new H5PropertyListId(H5P.Template.DEFAULT), new H5Array<int>(myDataBuffer));
            }

Reverse Ordering

for (int index = rows-slabSize; index >=0 ; index -= slabSize)
            {
                startFile[0] = (ulong) index;
                H5S.selectHyperslab(mSpaceID, H5S.SelectOperator.SET, startMem, countMem);
                H5S.selectHyperslab(fSpaceID, H5S.SelectOperator.SET, startFile, countFile);
                H5D.write(dataSetID, new H5DataTypeId(H5T.H5Type.NATIVE_UINT), mSpaceID, fSpaceID, new H5PropertyListId(H5P.Template.DEFAULT), new H5Array<int>(myDataBuffer));
            }

···

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

I don't know much about your storage system but it sounds like maybe
you are seeing the (negative) impacts of read-ahead caching? A lot
of systems assume applications read in the forward direction and
prefetch blocks. In your case, 100% of the prefetched blocks are
wasted effort.

What dimension are your hyperslabs and datasets? Mostly, I'm just
curious. You're decomposing an N-dimensional dataset the same way in
either direction, so that's probably not a factor, but I'd still like
to know.

==rob

···

On Mon, Feb 16, 2009 at 02:15:15PM -0800, Tim R wrote:

If I write a large file to disk as a single piece, I see fast write
speeds. If however, I write the identical file to disk in
successive (contiguous) hyperslabs, the write speed depends on the
order I traverse the hyperslab write loop. The forward traverse is
fast. The reverse traverse is a factor of three slower.

--
Rob Latham
Mathematics and Computer Science Division A215 0178 EA2D B059 8CDF
Argonne National Lab, IL USA B29D F333 664A 4280 315B

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Hi Robert and All,

For now, I'm simply writing (not reading) to hard drives, both internal SATA and external USB drives.

I was seeing a performance hit with the actual 3D data sets, so I am being methodical and running simple tests with 1D data sets. Windows platform, VS2005, HDF5 1.8. I saw the problem with HDF 1.66, C code, as well.

The full C# code for the test functions are below. They only differ in the loop traverse direction. The saved datasets on disk are identical as confirmed by a HEX editor.

Best regards,
Tim

CODE:

static void SaveLinearWithSlabbingReverse(int dataLength, int slabSize)
        {
            string fullFilename = "F:\\H5Test\\WithSlabbingReverse.h5";
            int[] myDataBuffer = new int[slabSize];
            for (int index = 0; index < slabSize; index++) myDataBuffer[index] = index; //fill buffer with values
            
            H5FileId fileID = H5F.create(fullFilename, H5F.CreateMode.ACC_TRUNC);
            H5DataTypeId typeID = H5T.copy(H5T.H5Type.NATIVE_INT);
            H5GroupId dataGroupID = H5G.create(fileID, "/Data",0);
            const int RANK = 1;
            ulong[] fileDims = new ulong[RANK];
            fileDims[0] = (ulong) dataLength;
            H5DataSpaceId fSpaceID = H5S.create_simple(RANK, fileDims);
            H5DataSetId dataSetID = H5D.create(dataGroupID, "Img", typeID, fSpaceID);

            ulong[] dimsMem = new ulong[RANK];
            dimsMem[0] = (ulong) slabSize;
            H5DataSpaceId mSpaceID = H5S.create_simple(RANK, dimsMem);

            ulong[] startFile = new ulong[RANK]; //used for hyperslab selection
            ulong[] countFile = new ulong[RANK];
            ulong[] startMem = new ulong[RANK];
            ulong[] countMem = new ulong[RANK];

            countFile[0] = (ulong) slabSize;
            countMem[0] = (ulong) slabSize;
            startMem[0] = 0;

            for (int index = dataLength-slabSize; index >=0 ; index -= slabSize)
            {
                startFile[0] = (ulong) index;
                H5S.selectHyperslab(mSpaceID, H5S.SelectOperator.SET, startMem, countMem);
                H5S.selectHyperslab(fSpaceID, H5S.SelectOperator.SET, startFile, countFile);
                H5D.write(dataSetID, new H5DataTypeId(H5T.H5Type.NATIVE_UINT), mSpaceID, fSpaceID, new H5PropertyListId(H5P.Template.DEFAULT), new H5Array<int>(myDataBuffer));
            }

        }

static void SaveLinearWithSlabbingForward(int dataLength, int slabSize)
        {
            string fullFilename = "F:\\H5Test\\WithSlabbingForward.h5";
            int[] myDataBuffer = new int[slabSize];
            for (int index = 0; index < slabSize; index++) myDataBuffer[index] = index; //fill buffer with values

            H5FileId fileID = H5F.create(fullFilename, H5F.CreateMode.ACC_TRUNC);
            H5DataTypeId typeID = H5T.copy(H5T.H5Type.NATIVE_INT);
            H5GroupId dataGroupID = H5G.create(fileID, "/Data",0);
            const int RANK = 1;
            ulong[] fileDims = new ulong[RANK];
            fileDims[0] = (ulong) dataLength;
            H5DataSpaceId fSpaceID = H5S.create_simple(RANK, fileDims);
            H5DataSetId dataSetID = H5D.create(dataGroupID, "Img", typeID, fSpaceID);

            ulong[] dimsMem = new ulong[RANK];
            dimsMem[0] = (ulong) slabSize;
            H5DataSpaceId mSpaceID = H5S.create_simple(RANK, dimsMem);

            ulong[] startFile = new ulong[RANK]; //used for hyperslab selection
            ulong[] countFile = new ulong[RANK];
            ulong[] startMem = new ulong[RANK];
            ulong[] countMem = new ulong[RANK];

            countFile[0] = (ulong) slabSize;
            countMem[0] = (ulong) slabSize;
            startMem[0] = 0;

            for (int index = 0; index < dataLength; index += slabSize)
            {
                startFile[0] = (ulong)index;
                H5S.selectHyperslab(mSpaceID, H5S.SelectOperator.SET, startMem, countMem);
                H5S.selectHyperslab(fSpaceID, H5S.SelectOperator.SET, startFile, countFile);
                H5D.write(dataSetID, new H5DataTypeId(H5T.H5Type.NATIVE_UINT), mSpaceID, fSpaceID, new H5PropertyListId(H5P.Template.DEFAULT), new H5Array<int>(myDataBuffer));
            }

        }

···

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Hi all,

I recently noticed few such issues, related to different speeds when
writing once with references and once with separate datasets. It turns
out it is a windows specific problem. I attach the test code (replace
the time measurement macros with your own) and an excel file with my
results and the THG results. This is the response of THG:

"I spent some more time debugging and benchmarking, and I have been
unable to find any problems with the windows file driver. I suspect
the anomalous performance is probably due to some sort of buffering
the operating system does, as the total wall time is typically about
the same. Even though the windows driver (by default) uses
"unbuffered" I/O functions, the use of these functions does not
prevent buffering by the underlying filesystem driver. For what it's
worth, defining WINDOWS_USE_STDIO in h5pubconf.h seems to make the
performance more consistent, albeit with much higher CPU usage.

Here are my results (on an old P4 laptop, XP 32 bit, VS2008 Express).
I measured the wall time, as well as the kernel and user time. I also
metered the windows file driver to keep track of the total number of
reads, writes, and truncates, as well as the total number of bytes
read and written. All of these meaurements are totals for the 30 runs
(not averaged). The first 4 benchmarks do not use STDIO, while the
last 4 do."

HTH

-- dimitris

#include <string.h>
#include "hdf5.h"

#define INSTRUMENTWITHTIMEPROFILER

const char* filename="test_layer_performance.h5";
int *data=0;
int *rdata=0;

int datasize = 0;
//Create
void createHyperslab1()
{
    hid_t fid, gid, sid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gcreate(fid,"hyperslab1",H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    hsize_t dims[]={6,datasize};
    sid = H5Screate_simple(2,dims,dims);
    did =
H5Dcreate(gid,"hyperslab1",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
}

void createHyperslab2()
{
    hid_t fid, gid, sid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gcreate(fid,"hyperslab2",H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    hsize_t dims[]={datasize,6};
    sid = H5Screate_simple(2,dims,dims);
    did =
H5Dcreate(gid,"hyperslab2",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
}

void createSeparate()
{
    hid_t fid, gid, sid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gcreate(fid,"Separate",H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    hsize_t dims[]={datasize};
    sid = H5Screate_simple(1,dims,dims);
    did =
H5Dcreate(gid,"Separate1",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate2",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate3",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate4",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate5",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate6",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
}

void createReferences()
{
    hid_t fid, gid, sid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gcreate(fid,"References",H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    hsize_t dims[]={6};
    sid = H5Screate_simple(1,dims,dims);
    did =
H5Dcreate(gid,"References",H5T_STD_REF_OBJ,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Sclose(sid);
    H5Dclose(did);

    hobj_ref_t ref[6];
    dims[0]=datasize;
    sid = H5Screate_simple(1,dims,dims);
    did =
H5Dcreate(gid,"Separate1",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate2",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate3",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate4",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate5",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Dclose(did);
    did =
H5Dcreate(gid,"Separate6",H5T_NATIVE_INT,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Sclose(sid);
    H5Dclose(did);

    H5Rcreate(&ref[0], gid,"Separate1", H5R_OBJECT,-1);
    H5Rcreate(&ref[1], gid,"Separate2", H5R_OBJECT,-1);
    H5Rcreate(&ref[2], gid,"Separate3", H5R_OBJECT,-1);
    H5Rcreate(&ref[3], gid,"Separate4", H5R_OBJECT,-1);
    H5Rcreate(&ref[4], gid,"Separate5", H5R_OBJECT,-1);
    H5Rcreate(&ref[5], gid,"Separate6", H5R_OBJECT,-1);

    did = H5Dopen(gid,"References",H5P_DEFAULT);
    H5Dwrite(did,H5T_STD_REF_OBJ,H5S_ALL,H5S_ALL,H5P_DEFAULT,ref);

    H5Dclose(did);

    H5Gclose(gid);
    H5Fclose(fid);
}

void createComposite()
{
    hid_t fid, gid, sid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gcreate(fid,"Composite",H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    hsize_t dims[]={6};
    sid = H5Screate_simple(1,dims,dims);
    dims[0]=datasize;
    hid_t tid = H5Tarray_create2( H5T_NATIVE_INT, 1, dims );
    did =
H5Dcreate(gid,"Composite",tid,sid,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Tclose(tid);
    H5Fclose(fid);
}

//Write
void writeHyperslab1()
{
    hid_t fid, gid, sid, did; /* file ID */
    hsize_t dims[3];
    hsize_t start[3];
    hsize_t count[3];

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"hyperslab1",H5P_DEFAULT);
    did = H5Dopen(gid,"hyperslab1",H5P_DEFAULT);
    sid=H5Dget_space(did);

    H5Sget_simple_extent_dims(sid,dims,NULL);

    memcpy(count,dims,sizeof(count));
    memset(start,0,sizeof(start));

    start[0]=3;
    count[0]=1;

    H5Sselect_hyperslab(sid,H5S_SELECT_SET,start,NULL,count,NULL);

    hsize_t nels = datasize;
    hid_t mid = H5Screate_simple(1, &nels, &nels);
    H5Dwrite(did,H5T_NATIVE_INT,mid,sid,H5P_DEFAULT,data);

    H5Sclose(mid);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
}

void writeHyperslab2()
{
    hid_t fid, gid, sid, did; /* file ID */
    hsize_t dims[3];
    hsize_t start[3];
    hsize_t count[3];

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"hyperslab2",H5P_DEFAULT);
    did = H5Dopen(gid,"hyperslab2",H5P_DEFAULT);
    sid=H5Dget_space(did);

    H5Sget_simple_extent_dims(sid,dims,NULL);// returns [6][datasize]?!?!?

    memcpy(count,dims,sizeof(count));
    memset(start,0,sizeof(start));

    start[1]=3;
    count[1]=1;

    H5Sselect_hyperslab(sid,H5S_SELECT_SET,start,NULL,count,NULL);

    hsize_t nels = datasize;
    hid_t mid = H5Screate_simple(1, &nels, &nels);
    H5Dwrite(did,H5T_NATIVE_INT,mid,sid,H5P_DEFAULT,data);

    H5Sclose(mid);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
}

void writeSeparate()
{
    hid_t fid, gid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"Separate",H5P_DEFAULT);

    did = H5Dopen(gid,"Separate3",H5P_DEFAULT);
    H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data);

    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
}

void writeReferences()
{
    hid_t fid, gid, sid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"References",H5P_DEFAULT);

    did = H5Dopen(gid,"References",H5P_DEFAULT);
    hobj_ref_t ref[6];

    H5Dread(did,H5T_STD_REF_OBJ,H5S_ALL,H5S_ALL,H5P_DEFAULT,ref);

    hid_t rid = H5Rdereference(gid,H5R_OBJECT,&(ref[2]));
    H5Dwrite(rid,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data);

    H5Dclose(rid);
    H5Dclose(did);

    H5Gclose(gid);
    H5Fclose(fid);
}

void writeComposite()
{
    hid_t fid, gid, sid, did; /* file ID */

    hsize_t start[1];
    hsize_t count[1];

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"Composite",H5P_DEFAULT);
    did = H5Dopen(gid,"Composite",H5P_DEFAULT);
    sid=H5Dget_space(did);

    start[0]=3;
    count[0]=1;

    H5Sselect_hyperslab(sid,H5S_SELECT_SET,start,NULL,count,NULL);
    hid_t tid = H5Dget_type(did);

    hsize_t nels = 1;
    hid_t mid = H5Screate_simple(1, &nels, &nels);
    H5Dwrite(did,tid,mid,sid,H5P_DEFAULT,data);

    H5Sclose(mid);

    H5Tclose(tid);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);

}

//read
void readHyperslab1()
{
    hid_t fid, gid, sid, did; /* file ID */
    hsize_t dims[3];
    hsize_t start[3];
    hsize_t count[3];

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"hyperslab1",H5P_DEFAULT);
    did = H5Dopen(gid,"hyperslab1",H5P_DEFAULT);
    sid=H5Dget_space(did);

    H5Sget_simple_extent_dims(sid,dims,NULL);

    memcpy(count,dims,sizeof(count));
    memset(start,0,sizeof(start));

    start[0]=3;
    count[0]=1;

    H5Sselect_hyperslab(sid,H5S_SELECT_SET,start,NULL,count,NULL);

    hsize_t nels = datasize;
    hid_t mid = H5Screate_simple(1, &nels, &nels);
    H5Dread(did,H5T_NATIVE_INT,mid,sid,H5P_DEFAULT,rdata);

    H5Sclose(mid);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);

    if (rdata[datasize-1]!=datasize-1)
    {
        throw "Wrong Size";
    }
}

void readHyperslab2()
{
    hid_t fid, gid, sid, did; /* file ID */
    hsize_t dims[3];
    hsize_t start[3];
    hsize_t count[3];

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"hyperslab2",H5P_DEFAULT);
    did = H5Dopen(gid,"hyperslab2",H5P_DEFAULT);
    sid=H5Dget_space(did);

    H5Sget_simple_extent_dims(sid,dims,NULL);// returns [6][datasize]?!?!?

    memcpy(count,dims,sizeof(count));
    memset(start,0,sizeof(start));

    start[1]=3;
    count[1]=1;

    H5Sselect_hyperslab(sid,H5S_SELECT_SET,start,NULL,count,NULL);

    hsize_t nels = datasize;
    hid_t mid = H5Screate_simple(1, &nels, &nels);
    H5Dread(did,H5T_NATIVE_INT,mid,sid,H5P_DEFAULT,rdata);

    H5Sclose(mid);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
    if (rdata[datasize-1]!=datasize-1)
    {
        throw "Wrong Size";
    }
}

void readSeparate()
{
    hid_t fid, gid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"Separate",H5P_DEFAULT);

    did = H5Dopen(gid,"Separate3",H5P_DEFAULT);
    H5Dread(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata);

    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
    if (rdata[datasize-1]!=datasize-1)
    {
        throw "Wrong Size";
    }
}

void readReferences()
{
    hid_t fid, gid, sid, did; /* file ID */

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"References",H5P_DEFAULT);

    did = H5Dopen(gid,"References",H5P_DEFAULT);
    hobj_ref_t ref[6];

    H5Dread(did,H5T_STD_REF_OBJ,H5S_ALL,H5S_ALL,H5P_DEFAULT,ref);

    hid_t rid = H5Rdereference(gid,H5R_OBJECT,&(ref[2]));
    H5Dread(rid,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata);

    H5Dclose(rid);
    H5Dclose(did);

    H5Gclose(gid);
    H5Fclose(fid);
    if (rdata[datasize-1]!=datasize-1)
    {
        throw "Wrong Size";
    }
}

void readComposite()
{
    hid_t fid, gid, sid, did; /* file ID */

    hsize_t start[1];
    hsize_t count[1];

    fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
    gid = H5Gopen(fid,"Composite",H5P_DEFAULT);
    did = H5Dopen(gid,"Composite",H5P_DEFAULT);
    sid=H5Dget_space(did);

    start[0]=3;
    count[0]=1;

    H5Sselect_hyperslab(sid,H5S_SELECT_SET,start,NULL,count,NULL);
    hid_t tid = H5Dget_type(did);

    hsize_t nels = 1;
    hid_t mid = H5Screate_simple(1, &nels, &nels);
    H5Dread(did,tid,mid,sid,H5P_DEFAULT,rdata);

    H5Sclose(mid);

    H5Tclose(tid);
    H5Sclose(sid);
    H5Dclose(did);
    H5Gclose(gid);
    H5Fclose(fid);
    if (rdata[datasize-1]!=datasize-1)
    {
        throw "Wrong Size";
    }

}

int main (void)
{
    hid_t fid; /* file ID */

    datasize=1000000;
    data=new int[datasize];
    rdata=new int[datasize];
    int i;

    for(i=0;i<datasize;i++)
    {
        data[i]=i;
    }
    std::string name;

    BEGINPROFILER

    for(i=0;i<30;i++)
    {
    fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    H5Fclose(fid);
name = "createHyperslab1";
    BEGINPROFILERBLOCK(name)
    createHyperslab1();
    ENDPROFILERBLOCK(name);

/* name = "createHyperslab2";
    BEGINPROFILERBLOCK(name)
    createHyperslab2();
    ENDPROFILERBLOCK(name);*/

    name = "createSeparate";
    BEGINPROFILERBLOCK(name)
    createSeparate();
    ENDPROFILERBLOCK(name);

    name = "createReferences";
    BEGINPROFILERBLOCK(name)
    createReferences();
    ENDPROFILERBLOCK(name);

    name = "createComposite";
    BEGINPROFILERBLOCK(name)
    createComposite();
    ENDPROFILERBLOCK(name);

// write
   name = "writeHyperslab1";
    BEGINPROFILERBLOCK(name)
    writeHyperslab1();
    ENDPROFILERBLOCK(name);

     /*name = "writeHyperslab2";
    BEGINPROFILERBLOCK(name)
    writeHyperslab2();
    ENDPROFILERBLOCK(name);*/

    name = "writeSeparate";
    BEGINPROFILERBLOCK(name)
    writeSeparate();
    ENDPROFILERBLOCK(name);

    name = "writeReferences";
    BEGINPROFILERBLOCK(name)
    writeReferences();
    ENDPROFILERBLOCK(name);

    name = "writeComposite";
    BEGINPROFILERBLOCK(name)
    writeComposite();
    ENDPROFILERBLOCK(name);

//read
    name = "readHyperslab1";
    BEGINPROFILERBLOCK(name)
    readHyperslab1();
    ENDPROFILERBLOCK(name);

    /*name = "readHyperslab2";
    BEGINPROFILERBLOCK(name)
    readHyperslab2();
    ENDPROFILERBLOCK(name);*/

    name = "readSeparate";
    BEGINPROFILERBLOCK(name)
    readSeparate();
    ENDPROFILERBLOCK(name);

    name = "readReferences";
    BEGINPROFILERBLOCK(name)
    readReferences();
    ENDPROFILERBLOCK(name);

    name = "readComposite";
    BEGINPROFILERBLOCK(name)
    readComposite();
    ENDPROFILERBLOCK(name);

    ENDPROFILERCYCLE
    }
    ENDPROFILER

    delete [] data;
    delete [] rdata;

}

HDF5_performance_layers.xls (77 KB)