[svn-r23152] I took out the obsolete function H5PSIwrite_chunk and its related test and performance test.

Tested on koala.
This commit is contained in:
Raymond Lu 2013-01-11 16:34:31 -05:00
parent 7b895e1dd8
commit 3a7b11863a
9 changed files with 37 additions and 1131 deletions

View File

@ -505,7 +505,6 @@
./perform/build_h5perf_alone.sh
./perform/build_h5perf_serial_alone.sh
./perform/chunk.c
./perform/dectris_perf.c
./perform/gen_report.pl
./perform/iopipe.c
./perform/overhead.c
@ -951,7 +950,6 @@
./test/corrupt_stab_msg.h5
./test/cross_read.c
./test/dangle.c
./test/dectris_tst.c
./test/deflate.h5
./test/dsets.c
./test/dt_arith.c

View File

@ -52,12 +52,12 @@ if BUILD_PARALLEL_CONDITIONAL
TEST_PROG_PARA=h5perf perf
endif
# Serial test programs.
TEST_PROG = dectris_perf iopipe chunk overhead zip_perf perf_meta h5perf_serial $(BUILD_ALL_PROGS)
TEST_PROG = iopipe chunk overhead zip_perf perf_meta h5perf_serial $(BUILD_ALL_PROGS)
# check_PROGRAMS will be built but not installed. Do not any executable
# that is in bin_PROGRAMS already. Otherwise, it will be removed twice in
# "make clean" and some systems, e.g., AIX, do not like it.
check_PROGRAMS= dectris_perf iopipe chunk overhead zip_perf perf_meta $(BUILD_ALL_PROGS) perf
check_PROGRAMS= iopipe chunk overhead zip_perf perf_meta $(BUILD_ALL_PROGS) perf
h5perf_SOURCES=pio_perf.c pio_engine.c pio_timer.c
h5perf_serial_SOURCES=sio_perf.c sio_engine.c sio_timer.c
@ -72,7 +72,6 @@ LDADD=$(LIBHDF5)
h5perf_LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5)
h5perf_serial_LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5)
perf_LDADD=$(LIBH5TEST) $(LIBHDF5)
dectris_perf_LDADD=$(LIBH5TEST) $(LIBHDF5)
iopipe_LDADD=$(LIBH5TEST) $(LIBHDF5)
zip_perf_LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5)
perf_meta_LDADD=$(LIBH5TEST) $(LIBHDF5)

View File

@ -76,9 +76,9 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
@BUILD_PARALLEL_CONDITIONAL_TRUE@bin_PROGRAMS = \
@BUILD_PARALLEL_CONDITIONAL_TRUE@ h5perf_serial$(EXEEXT) \
@BUILD_PARALLEL_CONDITIONAL_TRUE@ h5perf$(EXEEXT)
check_PROGRAMS = dectris_perf$(EXEEXT) iopipe$(EXEEXT) chunk$(EXEEXT) \
overhead$(EXEEXT) zip_perf$(EXEEXT) perf_meta$(EXEEXT) \
$(am__EXEEXT_2) perf$(EXEEXT)
check_PROGRAMS = iopipe$(EXEEXT) chunk$(EXEEXT) overhead$(EXEEXT) \
zip_perf$(EXEEXT) perf_meta$(EXEEXT) $(am__EXEEXT_2) \
perf$(EXEEXT)
TESTS = $(am__EXEEXT_3)
subdir = perform
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -101,9 +101,6 @@ AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
dectris_perf_SOURCES = dectris_perf.c
dectris_perf_OBJECTS = dectris_perf.$(OBJEXT)
dectris_perf_DEPENDENCIES = $(LIBH5TEST) $(LIBHDF5)
am_h5perf_OBJECTS = pio_perf.$(OBJEXT) pio_engine.$(OBJEXT) \
pio_timer.$(OBJEXT)
h5perf_OBJECTS = $(am_h5perf_OBJECTS)
@ -168,12 +165,10 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = chunk.c dectris_perf.c $(h5perf_SOURCES) \
$(h5perf_serial_SOURCES) iopipe.c overhead.c perf.c \
perf_meta.c zip_perf.c
DIST_SOURCES = chunk.c dectris_perf.c $(h5perf_SOURCES) \
$(h5perf_serial_SOURCES) iopipe.c overhead.c perf.c \
perf_meta.c zip_perf.c
SOURCES = chunk.c $(h5perf_SOURCES) $(h5perf_serial_SOURCES) iopipe.c \
overhead.c perf.c perf_meta.c zip_perf.c
DIST_SOURCES = chunk.c $(h5perf_SOURCES) $(h5perf_serial_SOURCES) \
iopipe.c overhead.c perf.c perf_meta.c zip_perf.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -185,9 +180,9 @@ am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
am__tty_colors = $(am__tty_colors_dummy)
am__EXEEXT_3 = dectris_perf$(EXEEXT) iopipe$(EXEEXT) chunk$(EXEEXT) \
overhead$(EXEEXT) zip_perf$(EXEEXT) perf_meta$(EXEEXT) \
h5perf_serial$(EXEEXT) $(am__EXEEXT_2)
am__EXEEXT_3 = iopipe$(EXEEXT) chunk$(EXEEXT) overhead$(EXEEXT) \
zip_perf$(EXEEXT) perf_meta$(EXEEXT) h5perf_serial$(EXEEXT) \
$(am__EXEEXT_2)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ADD_PARALLEL_FILES = @ADD_PARALLEL_FILES@
@ -485,7 +480,7 @@ h5perf_serial_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
# Parallel test programs.
@BUILD_PARALLEL_CONDITIONAL_TRUE@TEST_PROG_PARA = h5perf perf
# Serial test programs.
TEST_PROG = dectris_perf iopipe chunk overhead zip_perf perf_meta h5perf_serial $(BUILD_ALL_PROGS)
TEST_PROG = iopipe chunk overhead zip_perf perf_meta h5perf_serial $(BUILD_ALL_PROGS)
h5perf_SOURCES = pio_perf.c pio_engine.c pio_timer.c
h5perf_serial_SOURCES = sio_perf.c sio_engine.c sio_timer.c
@ -499,7 +494,6 @@ LDADD = $(LIBHDF5)
h5perf_LDADD = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5)
h5perf_serial_LDADD = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5)
perf_LDADD = $(LIBH5TEST) $(LIBHDF5)
dectris_perf_LDADD = $(LIBH5TEST) $(LIBHDF5)
iopipe_LDADD = $(LIBH5TEST) $(LIBHDF5)
zip_perf_LDADD = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5)
perf_meta_LDADD = $(LIBH5TEST) $(LIBHDF5)
@ -616,9 +610,6 @@ clean-checkPROGRAMS:
chunk$(EXEEXT): $(chunk_OBJECTS) $(chunk_DEPENDENCIES) $(EXTRA_chunk_DEPENDENCIES)
@rm -f chunk$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(chunk_OBJECTS) $(chunk_LDADD) $(LIBS)
dectris_perf$(EXEEXT): $(dectris_perf_OBJECTS) $(dectris_perf_DEPENDENCIES) $(EXTRA_dectris_perf_DEPENDENCIES)
@rm -f dectris_perf$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dectris_perf_OBJECTS) $(dectris_perf_LDADD) $(LIBS)
h5perf$(EXEEXT): $(h5perf_OBJECTS) $(h5perf_DEPENDENCIES) $(EXTRA_h5perf_DEPENDENCIES)
@rm -f h5perf$(EXEEXT)
$(AM_V_CCLD)$(h5perf_LINK) $(h5perf_OBJECTS) $(h5perf_LDADD) $(LIBS)
@ -648,7 +639,6 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunk.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dectris_perf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iopipe.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/overhead.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf.Po@am__quote@

View File

@ -1,657 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This test is for the DECTRIS project to the H5PSIdirect_write function
*
*/
#include "hdf5.h"
#include "H5private.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef H5_HAVE_FILTER_DEFLATE
#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER)
# define H5_ZLIB_HEADER "zlib.h"
#endif
#if defined(H5_ZLIB_HEADER)
# include H5_ZLIB_HEADER /* "zlib.h" */
#endif
const char *FILENAME[] = {
"dectris_perf",
"unix.raw",
NULL
};
/*
* Print the current location on the standard output stream.
*/
#define FUNC __func__
#define AT() printf (" at %s:%d in %s()...\n", \
__FILE__, __LINE__, FUNC);
#define H5_FAILED() {puts("*FAILED*");fflush(stdout);}
#define TEST_ERROR {H5_FAILED(); AT(); goto error;}
#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);}
#define PASSED() {puts(" PASSED");fflush(stdout);}
#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset"
#define DIRECT_COMPRESSED_DSET "direct_compressed_dset"
#define REG_COMPRESSED_DSET "reg_compressed_dset"
#define REG_NO_COMPRESS_DSET "reg_no_compress_dset"
#define RANK 3
#define NX 100
#define NY 1000
#define NZ 250
#define CHUNK_NX 1
#define CHUNK_NY 1000
#define CHUNK_NZ 250
#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s))*1.001)+12)
char filename[1024];
unsigned int *outbuf[NX];
size_t data_size[NX];
double total_size = 0.0;
unsigned int *direct_buf[NX];
double MB = 1048576.0;
/*--------------------------------------------------
* Function to report IO rate
*--------------------------------------------------
*/
void reportTime(struct timeval start, double mbytes)
{
struct timeval timeval_stop,timeval_diff;
/*end timing*/
gettimeofday(&timeval_stop,NULL);
/* Calculate the elapsed gettimeofday time */
timeval_diff.tv_usec=timeval_stop.tv_usec-start.tv_usec;
timeval_diff.tv_sec=timeval_stop.tv_sec-start.tv_sec;
if(timeval_diff.tv_usec<0) {
timeval_diff.tv_usec+=1000000;
timeval_diff.tv_sec--;
} /* end if */
printf("MBytes/second: %lf\n", (double)mbytes/((double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0)));
}
/*--------------------------------------------------
* Create file, datasets, and initialize data
*--------------------------------------------------
*/
int create_file(hid_t fapl_id)
{
hid_t file; /* handles */
hid_t fapl;
hid_t cparms;
hid_t dataspace, dataset;
hsize_t dims[RANK] = {NX, NY, NZ};
hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ};
unsigned int aggression = 9; /* Compression aggression setting */
int ret;
int i, j, n;
int flag;
int unix_file;
unsigned int *p;
size_t buf_size = CHUNK_NY*CHUNK_NZ*sizeof(unsigned int);
const Bytef *z_src;
Bytef *z_dst; /*destination buffer */
uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
uLong z_src_nbytes = (uLong)buf_size;
TESTING("Create a file and dataset");
/*
* Create the data space with unlimited dimensions.
*/
if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0)
TEST_ERROR;
/*
* Create a new file. If file exists its contents will be overwritten.
*/
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
TEST_ERROR;
/*
* Modify dataset creation properties, i.e. enable chunking and compression
*/
if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR;
if(H5Pset_chunk( cparms, RANK, chunk_dims) < 0)
TEST_ERROR;
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
if((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
cparms, H5P_DEFAULT)) < 0)
TEST_ERROR;
if(H5Dclose(dataset) < 0)
TEST_ERROR;
if((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
cparms, H5P_DEFAULT)) < 0)
TEST_ERROR;
if(H5Dclose(dataset) < 0)
TEST_ERROR;
/* Set compression */
if(H5Pset_deflate( cparms, aggression) < 0)
TEST_ERROR;
if((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
cparms, H5P_DEFAULT)) < 0)
TEST_ERROR;
if(H5Dclose(dataset) < 0)
TEST_ERROR;
if((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
cparms, H5P_DEFAULT)) < 0)
TEST_ERROR;
if(H5Dclose(dataset) < 0)
TEST_ERROR;
if(H5Fclose(file) < 0)
TEST_ERROR;
if(H5Sclose(dataspace) < 0)
TEST_ERROR;
if(H5Pclose(cparms) < 0)
TEST_ERROR;
/* create a unix file*/
flag = O_CREAT|O_TRUNC|O_WRONLY;
if ((unix_file=open(FILENAME[1],flag,S_IRWXU))== -1)
TEST_ERROR;
if (close(unix_file) < 0)
{
printf(" unable to close the file\n");
TEST_ERROR;
}
/* Initialize data for chunks */
for(i = 0; i < NX; i++) {
p = direct_buf[i] = (unsigned int*)malloc(CHUNK_NY*CHUNK_NZ*sizeof(unsigned int));
for(j=0; j < CHUNK_NY*CHUNK_NZ; j++, p++)
*p = rand() % 65000;
z_src = (const Bytef*)direct_buf[i];
z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
/* Allocate output (compressed) buffer */
outbuf[i] = (unsigned int*)malloc((size_t)z_dst_nbytes);
z_dst = (Bytef *)outbuf[i];
/* Perform compression from the source to the destination buffer */
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
data_size[i] = (size_t)z_dst_nbytes;
total_size += data_size[i];
/* Check for various zlib errors */
if(Z_BUF_ERROR == ret) {
fprintf(stderr, "overflow");
TEST_ERROR;
} else if(Z_MEM_ERROR == ret) {
fprintf(stderr, "deflate memory error");
TEST_ERROR;
} else if(Z_OK != ret) {
fprintf(stderr, "other deflate error");
TEST_ERROR;
}
}
PASSED();
error:
H5E_BEGIN_TRY {
H5Dclose(dataset);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Fclose(file);
} H5E_END_TRY;
return 1;
}
/*--------------------------------------------------
* Benchmark the performance of the new function
* with precompressed data.
*--------------------------------------------------
*/
int
test_direct_write_uncompressed_data(hid_t fapl_id)
{
hid_t file; /* handles */
hid_t dataspace, dataset;
hid_t dxpl;
herr_t status;
int i;
unsigned filter_mask = 0;
hsize_t offset[RANK] = {0, 0, 0};
struct timeval timeval_start;
TESTING("H5PSIdirect_write for uncompressed data");
if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
/* Start the timer */
gettimeofday(&timeval_start,NULL);
/* Reopen the file and dataset */
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
TEST_ERROR;
if((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Write the compressed chunk data repeatedly to cover all the chunks in the
* dataset, using the direct writing function. */
for(i=0; i<NX; i++) {
status = H5PSIdirect_write(dataset, dxpl, filter_mask, offset, CHUNK_NY*CHUNK_NZ*sizeof(unsigned int), direct_buf[i]);
(offset[0])++;
}
/*
* Close/release resources.
*/
H5Dclose(dataset);
H5Pclose(dxpl);
H5Fclose(file);
/* Report the performance */
reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB));
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Dclose(dataset);
H5Pclose(dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
}
/*--------------------------------------------------
* Benchmark the performance of the new function
* with precompressed data.
*--------------------------------------------------
*/
int
test_direct_write_compressed_data(hid_t fapl_id)
{
hid_t file; /* handles */
hid_t dataspace, dataset;
hid_t dxpl;
herr_t status;
int i;
unsigned filter_mask = 0;
hsize_t offset[RANK] = {0, 0, 0};
struct timeval timeval_start;
TESTING("H5PSIdirect_write for pre-compressed data");
if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
/* Start the timer */
gettimeofday(&timeval_start,NULL);
/* Reopen the file and dataset */
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
TEST_ERROR;
if((dataset = H5Dopen2(file, DIRECT_COMPRESSED_DSET, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Write the compressed chunk data repeatedly to cover all the chunks in the
* dataset, using the direct writing function. */
for(i=0; i<NX; i++) {
status = H5PSIdirect_write(dataset, dxpl, filter_mask, offset, data_size[i], outbuf[i]);
(offset[0])++;
}
/*
* Close/release resources.
*/
H5Dclose(dataset);
H5Pclose(dxpl);
H5Fclose(file);
/* Report the performance */
reportTime(timeval_start, (double)(total_size/MB));
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Dclose(dataset);
H5Pclose(dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
}
/*--------------------------------------------------
* Benchmark the performance of the regular H5Dwrite
* with compression filter enabled.
*--------------------------------------------------
*/
int
test_compressed_write(hid_t fapl_id)
{
hid_t file; /* handles */
hid_t dataspace, dataset;
hid_t mem_space;
hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ};
hid_t dxpl;
herr_t status;
int i;
hsize_t start[RANK]; /* Start of hyperslab */
hsize_t stride[RANK]; /* Stride of hyperslab */
hsize_t count[RANK]; /* Block count */
hsize_t block[RANK]; /* Block sizes */
struct timeval timeval_start;
TESTING("H5Dwrite with compression enabled");
if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
TEST_ERROR;
/* Start the timer */
gettimeofday(&timeval_start,NULL);
/* Reopen the file and dataset */
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
TEST_ERROR;
if((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0)
TEST_ERROR;
if((dataspace = H5Dget_space(dataset)) < 0)
TEST_ERROR;
start[0] = start[1] = start[2] = 0;
stride[0] = stride[1] = stride[2] = 1;
count[0] = count[1] = count[2] = 1;
block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ;
for(i=0; i<NX; i++) {
/*
* Select hyperslab for one chunk in the file
*/
if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
TEST_ERROR;
(start[0])++;
if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace,
H5P_DEFAULT, direct_buf[i])) < 0)
TEST_ERROR;
}
/*
* Close/release resources.
*/
H5Dclose(dataset);
H5Sclose(dataspace);
H5Sclose(mem_space);
H5Pclose(dxpl);
H5Fclose(file);
/* Report the performance */
reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB));
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Dclose(dataset);
H5Sclose(dataspace);
H5Sclose(mem_space);
H5Pclose(dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
}
/*--------------------------------------------------
* Benchmark the performance of the regular H5Dwrite
* with compression
*--------------------------------------------------
*/
int
test_no_compress_write(hid_t fapl_id)
{
hid_t file; /* handles */
hid_t dataspace, dataset;
hid_t mem_space;
hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ};
hid_t dxpl;
herr_t status;
int i;
hsize_t start[RANK]; /* Start of hyperslab */
hsize_t stride[RANK]; /* Stride of hyperslab */
hsize_t count[RANK]; /* Block count */
hsize_t block[RANK]; /* Block sizes */
struct timeval timeval_start;
TESTING("H5Dwrite without compression");
if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
TEST_ERROR;
/* Start the timer */
gettimeofday(&timeval_start,NULL);
/* Reopen the file and dataset */
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
TEST_ERROR;
if((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0)
TEST_ERROR;
if((dataspace = H5Dget_space(dataset)) < 0)
TEST_ERROR;
start[0] = start[1] = start[2] = 0;
stride[0] = stride[1] = stride[2] = 1;
count[0] = count[1] = count[2] = 1;
block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ;
for(i=0; i<NX; i++) {
/*
* Select hyperslab for one chunk in the file
*/
if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
TEST_ERROR;
(start[0])++;
if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace,
H5P_DEFAULT, direct_buf[i])) < 0)
TEST_ERROR;
}
/*
* Close/release resources.
*/
H5Dclose(dataset);
H5Sclose(dataspace);
H5Sclose(mem_space);
H5Pclose(dxpl);
H5Fclose(file);
/* Report the performance */
reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB));
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Dclose(dataset);
H5Sclose(dataspace);
H5Sclose(mem_space);
H5Pclose(dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
}
/*--------------------------------------------------
* Benchmark the performance for writing compressed
* data to a Unix file
*--------------------------------------------------
*/
int
test_unix_write(void)
{
int file, flag;
ssize_t op_size;
int i;
struct timeval timeval_start;
TESTING("Write compressed data to a Unix file");
/* create file*/
flag = O_WRONLY;
/* Start the timer */
gettimeofday(&timeval_start,NULL);
if ((file=open(FILENAME[1],flag))== -1)
TEST_ERROR;
/* Write the compressed chunk data repeatedly to cover all the chunks in the
* dataset, using the direct writing function. */
for(i=0; i<NX; i++) {
op_size = write(file, outbuf[i],data_size[i]);
if (op_size < 0)
{
printf(" Error in writing data to file because %s \n", strerror(errno));
TEST_ERROR;
}
else if (op_size == 0)
{
printf(" unable to write sufficent data to file because %s \n", strerror(errno));
TEST_ERROR;
}
}
if (close(file) < 0)
{
printf(" unable to close the file\n");
TEST_ERROR;
}
/* Report the performance */
reportTime(timeval_start, (double)(total_size/MB));
PASSED();
return 0;
error:
return 1;
}
/*--------------------------------------------------
* Main function
*--------------------------------------------------
*/
int
main (void)
{
hid_t fapl;
int i;
/* Testing setup */
h5_reset();
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
create_file(fapl);
test_direct_write_uncompressed_data(fapl);
test_direct_write_compressed_data(fapl);
test_no_compress_write(fapl);
test_compressed_write(fapl);
test_unix_write();
for(i=0; i<NX; i++) {
free(outbuf[i]);
free(direct_buf[i]);
}
h5_cleanup(FILENAME, fapl);
return 0;
}
#else
int
main (void)
{
printf("Skipped because DEFLATE filter is disabled");
return 0;
}
#endif /* H5_HAVE_FILTER_DEFLATE */

View File

@ -285,7 +285,7 @@ H5FL_BLK_DEFINE_STATIC(chunk);
/*-------------------------------------------------------------------------
* Function: H5D__chunk_direct_write
*
* Purpose: Internal routine for H5PSIdirect_write to write a chunk
* Purpose: Internal routine to write a chunk
* directly into the file.
*
* Return: Non-negative on success/Negative on failure

View File

@ -370,94 +370,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__pre_write() */
/*-------------------------------------------------------------------------
* Function: H5PSIdirect_write
*
* Purpose: Temporary name for the DECTRIS project. It writes an entire
* chunk to the file directly.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* 30 July 2012
*
*-------------------------------------------------------------------------
*/
herr_t
H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, uint32_t filters, hsize_t *offset,
size_t data_size, const void *buf)
{
H5D_t *dset = NULL;
int ndims;
hsize_t *dims = NULL;
hsize_t *internal_offset = NULL;
int i;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
/* check arguments */
if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if(NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
if(H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Get the default dataset transfer property list if the user didn't provide one */
if(H5P_DEFAULT == dxpl_id)
dxpl_id= H5P_DATASET_XFER_DEFAULT;
else
if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
if(!offset)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset")
if(!data_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no data size")
if(!buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no data buffer")
ndims = (int)H5S_GET_EXTENT_NDIMS(dset->shared->space);
if(NULL == (dims = (hsize_t *)H5MM_malloc(ndims*sizeof(hsize_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for dimensions")
if(NULL == (internal_offset = (hsize_t *)H5MM_malloc((ndims+1)*sizeof(hsize_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for offset")
if(H5S_get_simple_extent_dims(dset->shared->space, dims, NULL) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims")
for(i=0; i<ndims; i++) {
/* Make sure the offset doesn't exceed the dataset's dimensions */
if(offset[i] > dims[i])
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset")
/* Make sure the offset fall right on a chunk's boundary */
if(offset[i] % dset->shared->layout.u.chunk.dim[i])
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary")
internal_offset[i] = offset[i];
}
/* The library's chunking code requires the offset terminates with a zero */
internal_offset[ndims] = 0;
/* write raw data */
if(H5D__chunk_direct_write(dset, dxpl_id, filters, internal_offset, data_size, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write chunk directly")
done:
if(dims)
H5MM_free(dims);
FUNC_LEAVE_API(ret_value)
} /* end H5PSIdirect_write() */
/*-------------------------------------------------------------------------
* Function: H5D__read

View File

@ -39,7 +39,7 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT)
TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
pool accum hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \
big mtime fillval mount flush1 flush2 app_ref enum dectris_tst \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe enc_dec_plist enc_dec_plist_with_endianess\
getname vfd ntypes dangle dtransform reserved cross_read \
freespace mf farray earray btree2 fheap file_image
@ -128,7 +128,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
earray.h5 efc[0-5].h5 log_vfd_out.log \
new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \
split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \
file_image_core_test.h5.copy dectris.h5
file_image_core_test.h5.copy
# Sources for testhdf5 executable
testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \

View File

@ -107,8 +107,8 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
external$(EXEEXT) efc$(EXEEXT) objcopy$(EXEEXT) links$(EXEEXT) \
unlink$(EXEEXT) big$(EXEEXT) mtime$(EXEEXT) fillval$(EXEEXT) \
mount$(EXEEXT) flush1$(EXEEXT) flush2$(EXEEXT) \
app_ref$(EXEEXT) enum$(EXEEXT) dectris_tst$(EXEEXT) \
set_extent$(EXEEXT) ttsafe$(EXEEXT) enc_dec_plist$(EXEEXT) \
app_ref$(EXEEXT) enum$(EXEEXT) set_extent$(EXEEXT) \
ttsafe$(EXEEXT) enc_dec_plist$(EXEEXT) \
enc_dec_plist_with_endianess$(EXEEXT) getname$(EXEEXT) \
vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \
@ -168,10 +168,6 @@ dangle_SOURCES = dangle.c
dangle_OBJECTS = dangle.$(OBJEXT)
dangle_LDADD = $(LDADD)
dangle_DEPENDENCIES = libh5test.la $(LIBHDF5)
dectris_tst_SOURCES = dectris_tst.c
dectris_tst_OBJECTS = dectris_tst.$(OBJEXT)
dectris_tst_LDADD = $(LDADD)
dectris_tst_DEPENDENCIES = libh5test.la $(LIBHDF5)
dsets_SOURCES = dsets.c
dsets_OBJECTS = dsets.$(OBJEXT)
dsets_LDADD = $(LDADD)
@ -471,7 +467,23 @@ am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \
btree2.c cache.c cache_api.c cache_tagging.c cmpd_dset.c \
cross_read.c dangle.c dectris_tst.c dsets.c dt_arith.c \
cross_read.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c \
earray.c efc.c enc_dec_plist.c enc_dec_plist_with_endianess.c \
enum.c err_compat.c error_test.c extend.c external.c farray.c \
fheap.c file_image.c fillval.c filter_fail.c flush1.c flush2.c \
freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \
gen_deflate.c gen_file_image.c gen_filespace.c gen_filters.c \
gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \
gen_new_super.c gen_noencoder.c gen_nullspace.c gen_plist.c \
gen_sizes_lheap.c gen_specmetaread.c gen_udlinks.c getname.c \
gheap.c hyperslab.c istore.c lheap.c links.c links_env.c mf.c \
mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \
set_extent.c space_overflow.c stab.c tcheck_version.c \
$(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
vfd.c
DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \
bittests.c btree2.c cache.c cache_api.c cache_tagging.c \
cmpd_dset.c cross_read.c dangle.c dsets.c dt_arith.c \
dtransform.c dtypes.c earray.c efc.c enc_dec_plist.c \
enc_dec_plist_with_endianess.c enum.c err_compat.c \
error_test.c extend.c external.c farray.c fheap.c file_image.c \
@ -485,23 +497,6 @@ SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \
ntypes.c objcopy.c ohdr.c pool.c reserved.c set_extent.c \
space_overflow.c stab.c tcheck_version.c $(testhdf5_SOURCES) \
testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \
bittests.c btree2.c cache.c cache_api.c cache_tagging.c \
cmpd_dset.c cross_read.c dangle.c dectris_tst.c dsets.c \
dt_arith.c dtransform.c dtypes.c earray.c efc.c \
enc_dec_plist.c enc_dec_plist_with_endianess.c enum.c \
err_compat.c error_test.c extend.c external.c farray.c fheap.c \
file_image.c fillval.c filter_fail.c flush1.c flush2.c \
freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \
gen_deflate.c gen_file_image.c gen_filespace.c gen_filters.c \
gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \
gen_new_super.c gen_noencoder.c gen_nullspace.c gen_plist.c \
gen_sizes_lheap.c gen_specmetaread.c gen_udlinks.c getname.c \
gheap.c hyperslab.c istore.c lheap.c links.c links_env.c mf.c \
mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \
set_extent.c space_overflow.c stab.c tcheck_version.c \
$(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
vfd.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -822,8 +817,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \
objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \
earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \
new_multi_file_v16-s.h5 split_get_file_image_test-m.h5 \
split_get_file_image_test-r.h5 file_image_core_test.h5.copy \
dectris.h5
split_get_file_image_test-r.h5 file_image_core_test.h5.copy
INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
@ -841,7 +835,7 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT)
TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
pool accum hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \
big mtime fillval mount flush1 flush2 app_ref enum dectris_tst \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe enc_dec_plist enc_dec_plist_with_endianess\
getname vfd ntypes dangle dtransform reserved cross_read \
freespace mf farray earray btree2 fheap file_image
@ -1012,9 +1006,6 @@ cross_read$(EXEEXT): $(cross_read_OBJECTS) $(cross_read_DEPENDENCIES) $(EXTRA_cr
dangle$(EXEEXT): $(dangle_OBJECTS) $(dangle_DEPENDENCIES) $(EXTRA_dangle_DEPENDENCIES)
@rm -f dangle$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dangle_OBJECTS) $(dangle_LDADD) $(LIBS)
dectris_tst$(EXEEXT): $(dectris_tst_OBJECTS) $(dectris_tst_DEPENDENCIES) $(EXTRA_dectris_tst_DEPENDENCIES)
@rm -f dectris_tst$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dectris_tst_OBJECTS) $(dectris_tst_LDADD) $(LIBS)
dsets$(EXEEXT): $(dsets_OBJECTS) $(dsets_DEPENDENCIES) $(EXTRA_dsets_DEPENDENCIES)
@rm -f dsets$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dsets_OBJECTS) $(dsets_LDADD) $(LIBS)
@ -1223,7 +1214,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmpd_dset.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cross_read.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dangle.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dectris_tst.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dsets.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dt_arith.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtransform.Po@am__quote@

View File

@ -1,326 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This test is for the DECTRIS project to the H5PSIdirect_write function
*
*/
#include "h5test.h"
#include <math.h>
#include <stdlib.h>
#ifdef H5_HAVE_FILTER_DEFLATE
#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER)
# define H5_ZLIB_HEADER "zlib.h"
#endif
#if defined(H5_ZLIB_HEADER)
# include H5_ZLIB_HEADER /* "zlib.h" */
#endif
const char *FILENAME[] = {
"dectris",
NULL
};
#define DATASETNAME "Array"
#define RANK 2
#define NX 16
#define NY 16
#define CHUNK_NX 4
#define CHUNK_NY 4
#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s))*1.001)+12)
int
main (void)
{
char filename[1024];
hid_t file; /* handles */
hid_t fapl;
hid_t dataspace, dataset;
hid_t mem_space;
hid_t cparms, dxpl;
hsize_t dims[2] = {NX, NY};
hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY};
herr_t status;
int ret;
int data[NX][NY];
int check[NX][NY];
int i, j, n;
unsigned filter_mask = 0;
int direct_buf[CHUNK_NX][CHUNK_NY];
int check_chunk[CHUNK_NX][CHUNK_NY];
hsize_t offset[2] = {0, 0};
size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int);
const Bytef *z_src = (const Bytef*)(direct_buf);
Bytef *z_dst; /*destination buffer */
uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
uLong z_src_nbytes = (uLong)buf_size;
int aggression = 9; /* Compression aggression setting */
void *outbuf = NULL; /* Pointer to new buffer */
hsize_t start[2]; /* Start of hyperslab */
hsize_t stride[2]; /* Stride of hyperslab */
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
TESTING("H5PSIdirect_write for DECTRIS project");
/* Testing setup */
h5_reset();
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
/*
* Create the data space with unlimited dimensions.
*/
if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
TEST_ERROR;
if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
TEST_ERROR;
/*
* Create a new file. If file exists its contents will be overwritten.
*/
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
/*
* Modify dataset creation properties, i.e. enable chunking and compression
*/
if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR;
if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
TEST_ERROR;
if((status = H5Pset_deflate( cparms, aggression)) < 0)
TEST_ERROR;
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
cparms, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Initialize the dataset */
for(i = n = 0; i < NX; i++)
for(j = 0; j < NY; j++)
data[i][j] = n++;
if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
/*
* Write the data for the dataset. It should stay in the chunk cache.
* It will be evicted from the cache by the H5PSIdirect_write calls.
*/
if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
H5P_DEFAULT, data)) < 0)
TEST_ERROR;
/* Initialize data for one chunk */
for(i = n = 0; i < CHUNK_NX; i++)
for(j = 0; j < CHUNK_NY; j++)
direct_buf[i][j] = n++;
/* Allocate output (compressed) buffer */
outbuf = malloc(z_dst_nbytes);
z_dst = (Bytef *)outbuf;
/* Perform compression from the source to the destination buffer */
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
/* Check for various zlib errors */
if(Z_BUF_ERROR == ret) {
fprintf(stderr, "overflow");
TEST_ERROR;
} else if(Z_MEM_ERROR == ret) {
fprintf(stderr, "deflate memory error");
TEST_ERROR;
} else if(Z_OK != ret) {
fprintf(stderr, "other deflate error");
TEST_ERROR;
}
/* Write the compressed chunk data repeatedly to cover all the chunks in the
* dataset, using the direct writing function. */
for(i=0; i<NX/CHUNK_NX; i++) {
for(j=0; j<NY/CHUNK_NY; j++) {
status = H5PSIdirect_write(dataset, dxpl, filter_mask, offset, z_dst_nbytes, outbuf);
offset[1] += CHUNK_NY;
}
offset[0] += CHUNK_NX;
offset[1] = 0;
}
if(outbuf)
free(outbuf);
if(H5Dclose(dataset) < 0)
TEST_ERROR;
if(H5Fclose(file) < 0)
TEST_ERROR;
/* Reopen the file and dataset */
if((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
TEST_ERROR;
if((dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT)) < 0)
TEST_ERROR;
/*
* Select hyperslab for one chunk in the file
*/
start[0] = CHUNK_NX; start[1] = CHUNK_NY;
stride[0] = 1; stride[1] = 1;
count[0] = 1; count[1] = 1;
block[0] = CHUNK_NX; block[1] = CHUNK_NY;
if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
TEST_ERROR;
/* Read the chunk back */
if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
for(i = 0; i < CHUNK_NX; i++) {
for(j = 0; j < CHUNK_NY; j++) {
if(direct_buf[i][j] != check_chunk[i][j]) {
printf(" 1. Read different values than written.");
printf(" At index %d,%d\n", i, j);
printf(" direct_buf=%d, check_chunk=%d\n", direct_buf[i][j], check_chunk[i][j]);
goto error;
}
}
}
/* Reinitialize different data for one chunk */
for(i = 0; i < CHUNK_NX; i++)
for(j = 0; j < CHUNK_NY; j++)
direct_buf[i][j] = i + j;
/* Allocate output (compressed) buffer */
outbuf = malloc(z_dst_nbytes);
z_dst = (Bytef *)outbuf;
/* Perform compression from the source to the destination buffer */
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
/* Check for various zlib errors */
if(Z_BUF_ERROR == ret) {
fprintf(stderr, "overflow");
TEST_ERROR;
} else if(Z_MEM_ERROR == ret) {
fprintf(stderr, "deflate memory error");
TEST_ERROR;
} else if(Z_OK != ret) {
fprintf(stderr, "other deflate error");
TEST_ERROR;
}
/* Rewrite the compressed chunk data repeatedly to cover all the chunks in the
* dataset, using the direct writing function. */
offset[0] = offset[1] = 0;
for(i=0; i<NX/CHUNK_NX; i++) {
for(j=0; j<NY/CHUNK_NY; j++) {
status = H5PSIdirect_write(dataset, dxpl, filter_mask, offset, z_dst_nbytes, outbuf);
offset[1] += CHUNK_NY;
}
offset[0] += CHUNK_NX;
offset[1] = 0;
}
if(outbuf)
free(outbuf);
if(H5Dclose(dataset) < 0)
TEST_ERROR;
if(H5Fclose(file) < 0)
TEST_ERROR;
/* Reopen the file and dataset */
if((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
TEST_ERROR;
if((dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Read the chunk back */
if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
for(i = 0; i < CHUNK_NX; i++) {
for(j = 0; j < CHUNK_NY; j++) {
if(direct_buf[i][j] != check_chunk[i][j]) {
printf(" 2. Read different values than written.");
printf(" At index %d,%d\n", i, j);
printf(" direct_buf=%d, check_chunk=%d\n", direct_buf[i][j], check_chunk[i][j]);
goto error;
}
}
}
/*
* Close/release resources.
*/
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
H5Fclose(file);
h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
H5Fclose(file);
} H5E_END_TRY;
if(outbuf)
free(outbuf);
return 1;
}
#else
int
main(void)
{
TESTING("Skipped because DEFLATE filter is disabled");
return 0;
}
#endif /* H5_HAVE_FILTER_DEFLATE */