static void write_file(Bytef *source, uLongf sourceLen) { Bytef *d_ptr, *dest; uLongf d_len, destLen; struct timeval timer_start, timer_stop; /* destination buffer needs to be at least 0.1% larger than sourceLen * plus 12 bytes */ destLen = (uLongf)((double)sourceLen + ((double)sourceLen * 0.1)) + 12; dest = (Bytef *)HDmalloc(destLen); if (!dest) error("out of memory"); HDgettimeofday(&timer_start, NULL); compress_buffer(dest, &destLen, source, sourceLen); HDgettimeofday(&timer_stop, NULL); compression_time += ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / MICROSECOND) - ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); if (report_once_flag) { HDfprintf(stdout, "\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); report_once_flag = 0; } d_ptr = dest; d_len = destLen; /* loop to make sure we write everything out that we want to write */ for (;;) { int rc = (int)HDwrite(output, d_ptr, (size_t)d_len); if (rc == -1) error(HDstrerror(errno)); if (rc == (int)d_len) break; d_len -= rc; d_ptr += rc; } HDfree(dest); }
/*------------------------------------------------------------------------- * Function: H5_timer_begin * * Purpose: Initialize a timer to time something. * * Return: void * * Programmer: Robb Matzke * Thursday, April 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ void H5_timer_begin (H5_timer_t *timer) { #ifdef H5_HAVE_GETRUSAGE struct rusage rusage; #endif #ifdef H5_HAVE_GETTIMEOFDAY struct timeval etime; #endif assert (timer); #ifdef H5_HAVE_GETRUSAGE HDgetrusage (RUSAGE_SELF, &rusage); timer->utime = (double)rusage.ru_utime.tv_sec + ((double)rusage.ru_utime.tv_usec/1e6); timer->stime = (double)rusage.ru_stime.tv_sec + ((double)rusage.ru_stime.tv_usec/1e6); #else timer->utime = 0.0; timer->stime = 0.0; #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday (&etime, NULL); timer->etime = (double)etime.tv_sec + ((double)etime.tv_usec/1e6); #else timer->etime = 0.0; #endif } /* end H5_timer_begin() */
/*------------------------------------------------------------------------- * Function: retrieve_time * * Purpose: Returns time in seconds, in a double number. * * Programmer: Raymond Lu * Friday, Oct 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ double retrieve_time(void) { #ifdef H5_HAVE_PARALLEL if(facc_type == FACC_DEFAULT) { #endif /*H5_HAVE_PARALLEL*/ struct timeval t; HDgettimeofday(&t, NULL); return ((double)t.tv_sec + (double)t.tv_usec / 1000000); #ifdef H5_HAVE_PARALLEL } else { return MPI_Wtime(); } #endif /*H5_HAVE_PARALLEL*/ }
/*------------------------------------------------------------------------- * Function: H5_now * * Purpose: Retrieves the current time, as seconds after the UNIX epoch. * * Return: # of seconds from the epoch (can't fail) * * Programmer: Quincey Koziol * Tuesday, November 28, 2006 * *------------------------------------------------------------------------- */ time_t H5_now(void) { time_t now; /* Current time */ #ifdef H5_HAVE_GETTIMEOFDAY { struct timeval now_tv; HDgettimeofday(&now_tv, NULL); now = now_tv.tv_sec; } #else /* H5_HAVE_GETTIMEOFDAY */ now = HDtime(NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ return(now); } /* end H5_now() */
/* * Function: set_time * Purpose: Set the time in a ``pio_time'' object. * Return: Pointer to the passed in ``pio_time'' object. * Programmer: Bill Wendling, 01. October 2001 * Modifications: */ pio_time * set_time(pio_time *pt, timer_type t, int start_stop) { if (pt) { if (pt->type == MPI_TIMER) { if (start_stop == TSTART) { pt->mpi_timer[t] = MPI_Wtime(); /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS * we compute the time it took to only open the file */ if(t == HDF5_FINE_WRITE_FIXED_DIMS) pt->total_time[HDF5_FILE_WRITE_OPEN] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_WRITE_FIXED_DIMS]; else if(t == HDF5_FINE_READ_FIXED_DIMS) pt->total_time[HDF5_FILE_READ_OPEN] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_READ_FIXED_DIMS]; } else { pt->total_time[t] += MPI_Wtime() - pt->mpi_timer[t]; pt->mpi_timer[t] = MPI_Wtime(); /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS * we compute the time it took to close the file after the last read/write finished */ if(t == HDF5_GROSS_WRITE_FIXED_DIMS) pt->total_time[HDF5_FILE_WRITE_CLOSE] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_WRITE_FIXED_DIMS]; else if(t == HDF5_GROSS_READ_FIXED_DIMS) pt->total_time[HDF5_FILE_READ_CLOSE] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_READ_FIXED_DIMS]; } } else { if (start_stop == TSTART) { HDgettimeofday(&pt->sys_timer[t], NULL); /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS * we compute the time it took to only open the file */ if(t == HDF5_FINE_WRITE_FIXED_DIMS) pt->total_time[HDF5_FILE_WRITE_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS])); else if(t == HDF5_FINE_READ_FIXED_DIMS) pt->total_time[HDF5_FILE_READ_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS])); } else { struct timeval sys_t; HDgettimeofday(&sys_t, NULL); pt->total_time[t] += sub_time(&sys_t, &(pt->sys_timer[t])); /* ((double)sys_t.tv_sec + ((double)sys_t.tv_usec) / MICROSECOND) - ((double)pt->sys_timer[t].tv_sec + ((double)pt->sys_timer[t].tv_usec) / MICROSECOND);*/ /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS * we compute the time it took to close the file after the last read/write finished */ if(t == HDF5_GROSS_WRITE_FIXED_DIMS) pt->total_time[HDF5_FILE_WRITE_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS])); else if(t == HDF5_GROSS_READ_FIXED_DIMS) pt->total_time[HDF5_FILE_READ_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS])); } } if (pio_debug_level >= 4) { const char *msg; int myrank; MPI_Comm_rank(pio_comm_g, &myrank); switch (t) { case HDF5_FILE_OPENCLOSE: msg = "File Open/Close"; break; case HDF5_DATASET_CREATE: msg = "Dataset Create"; break; case HDF5_MPI_WRITE: msg = "MPI Write"; break; case HDF5_MPI_READ: msg = "MPI Read"; break; case HDF5_FINE_WRITE_FIXED_DIMS: msg = "Fine Write"; break; case HDF5_FINE_READ_FIXED_DIMS: msg = "Fine Read"; break; case HDF5_GROSS_WRITE_FIXED_DIMS: msg = "Gross Write"; break; case HDF5_GROSS_READ_FIXED_DIMS: msg = "Gross Read"; break; case HDF5_RAW_WRITE_FIXED_DIMS: msg = "Raw Write"; break; case HDF5_RAW_READ_FIXED_DIMS: msg = "Raw Read"; break; default: msg = "Unknown Timer"; break; } fprintf(output, " Proc %d: %s %s: %.2f\n", myrank, msg, (start_stop == TSTART ? "Start" : "Stop"), pt->total_time[t]); } } return pt; }
static void do_write_test(unsigned long file_size, unsigned long min_buf_size, unsigned long max_buf_size) { uLongf src_len, total_len; struct timeval timer_start, timer_stop; double total_time; Bytef *src; for (src_len = min_buf_size; src_len <= max_buf_size; src_len <<= 1) { register unsigned long i, iters; iters = file_size / src_len; src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); if (!src) { cleanup(); error("out of memory"); } compression_time = 0.0; if (random_test) fill_with_random_data(src, src_len); HDfprintf(stdout, "Buffer size == "); if (src_len >= ONE_KB && (src_len % ONE_KB) == 0) { if (src_len >= ONE_MB && (src_len % ONE_MB) == 0) { HDfprintf(stdout, "%ldMB", src_len / ONE_MB); } else { HDfprintf(stdout, "%ldKB", src_len / ONE_KB); } } else { HDfprintf(stdout, "%ld", src_len); } HDfprintf(stdout, "\n"); /* do uncompressed data write */ HDgettimeofday(&timer_start, NULL); output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU); if (output == -1) error(HDstrerror(errno)); for (i = 0; i <= iters; ++i) { Bytef *s_ptr = src; uLong s_len = src_len; /* loop to make sure we write everything out that we want to write */ for (;;) { ssize_t rc = HDwrite(output, s_ptr, s_len); if (rc == -1) error(HDstrerror(errno)); if (rc == (ssize_t)s_len) break; s_len -= rc; s_ptr += rc; } } HDclose(output); HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / MICROSECOND) - ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); HDfprintf(stdout, "\tUncompressed Write Time: %.2fs\n", total_time); HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); HDunlink(filename); /* do compressed data write */ output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU); if (output == -1) error(HDstrerror(errno)); report_once_flag = 1; HDgettimeofday(&timer_start, NULL); for (total_len = 0; total_len < file_size; total_len += src_len) write_file(src, src_len); HDclose(output); HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / MICROSECOND) - ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); HDfprintf(stdout, "\tCompressed Write Time: %.2fs\n", total_time); HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); HDfprintf(stdout, "\tCompression Time: %gs\n", compression_time); HDunlink(filename); HDfree(src); } }
/*------------------------------------------------------------------------- * Function: H5O_mtime_decode * * Purpose: Decode a modification time message and return a pointer to a * new time_t value. * * Return: Success: Ptr to new message in native struct. * * Failure: NULL * * Programmer: Robb Matzke * [email protected] * Jul 24 1998 * *------------------------------------------------------------------------- */ static void * H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, unsigned UNUSED mesg_flags, unsigned UNUSED *ioflags, const uint8_t *p) { time_t *mesg, the_time; int i; struct tm tm; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(f); HDassert(p); /* Initialize time zone information */ if(!ntzset) { HDtzset(); ntzset = TRUE; } /* end if */ /* decode */ for(i = 0; i < 14; i++) if(!HDisdigit(p[i])) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message") /* * Convert YYYYMMDDhhmmss UTC to a time_t. This is a little problematic * because mktime() operates on local times. We convert to local time * and then figure out the adjustment based on the local time zone and * daylight savings setting. */ HDmemset(&tm, 0, sizeof tm); tm.tm_year = (p[0]-'0')*1000 + (p[1]-'0')*100 + (p[2]-'0')*10 + (p[3]-'0') - 1900; tm.tm_mon = (p[4]-'0')*10 + (p[5]-'0') - 1; tm.tm_mday = (p[6]-'0')*10 + (p[7]-'0'); tm.tm_hour = (p[8]-'0')*10 + (p[9]-'0'); tm.tm_min = (p[10]-'0')*10 + (p[11]-'0'); tm.tm_sec = (p[12]-'0')*10 + (p[13]-'0'); tm.tm_isdst = -1; /*figure it out*/ if((time_t)-1 == (the_time = HDmktime(&tm))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message") #if defined(H5_HAVE_TM_GMTOFF) /* FreeBSD, OSF 4.0 */ the_time += tm.tm_gmtoff; #elif defined(H5_HAVE___TM_GMTOFF) /* Linux libc-4 */ the_time += tm.__tm_gmtoff; #elif defined(H5_HAVE_TIMEZONE) #if _MSC_VER >= 1900 long timezone = 0; _get_timezone(&timezone); #endif /* Linux libc-5 */ the_time -= timezone - (tm.tm_isdst?3600:0); #elif defined(H5_HAVE_BSDGETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE) /* Irix5.3 */ { struct timezone tz; if(HDBSDgettimeofday(NULL, &tz) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information") the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0); } #elif defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE) && defined(H5_GETTIMEOFDAY_GIVES_TZ) { struct timezone tz; struct timeval tv; /* Used as a placebo; some systems don't like NULL */ if(HDgettimeofday(&tv, &tz) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information") the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0); } #else /* * The catch-all. If we can't convert a character string universal * coordinated time to a time_t value reliably then we can't decode the * modification time message. This really isn't as bad as it sounds -- the * only way a user can get the modification time is from our internal * query routines, which can gracefully recover. */ /* Irix64 */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information") #endif /* The return value */ if(NULL == (mesg = H5FL_MALLOC(time_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") *mesg = the_time; /* Set return value */ ret_value = mesg; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_mtime_decode() */
/*------------------------------------------------------------------------- * Function: main * * Purpose: * * Return: Success: * * Failure: * * Programmer: Robb Matzke * Thursday, March 12, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int main (void) { static hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; static unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; unsigned char *the_data = NULL; hid_t file, dset, file_space = -1; herr_t status; #ifdef H5_HAVE_GETRUSAGE struct rusage r_start, r_stop; #else struct timeval r_start, r_stop; #endif struct timeval t_start, t_stop; int fd; unsigned u; hssize_t n; off_t offset; hsize_t start[2]; hsize_t count[2]; #ifdef H5_HAVE_SYS_TIMEB struct _timeb *tbstart = malloc(sizeof(struct _timeb)); struct _timeb *tbstop = malloc(sizeof(struct _timeb)); #endif /* * The extra cast in the following statement is a bug workaround for the * Win32 version 5.0 compiler. * 1998-11-06 ptl */ printf ("I/O request size is %1.1fMB\n", (double)(hssize_t)(size[0]*size[1])/1024.0F*1024); /* Open the files */ file = H5Fcreate (HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); fd = HDopen (RAW_FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666); assert (fd>=0); /* Create the dataset */ file_space = H5Screate_simple (2, size, size); assert(file_space >= 0); dset = H5Dcreate2(file, "dset", H5T_NATIVE_UCHAR, file_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); assert(dset >= 0); the_data = (unsigned char *)malloc((size_t)(size[0] * size[1])); /* initial fill for lazy malloc */ HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); /* Fill raw */ synchronize (); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "fill raw"); for(u = 0; u < nwrite; u++) { putc (PROGRESS, stderr); HDfflush(stderr); HDmemset(the_data, 0xAA, (size_t)(size[0]*size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstop); t_start.tv_sec = tbstart->time; t_start.tv_usec = tbstart->millitm; t_stop.tv_sec = tbstop->time; t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("fill raw", &r_start, &r_stop, &t_start, &t_stop, (size_t)(nread*size[0]*size[1])); /* Fill hdf5 */ synchronize (); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "fill hdf5"); for(u = 0; u < nread; u++) { putc (PROGRESS, stderr); HDfflush(stderr); status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); assert (status>=0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstop); t_start.tv_sec = tbstart->time; t_start.tv_usec = tbstart->millitm; t_stop.tv_sec = tbstop->time; t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("fill hdf5", &r_start, &r_stop, &t_start, &t_stop, (size_t)(nread*size[0]*size[1])); /* Write the raw dataset */ synchronize (); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "out raw"); for(u = 0; u < nwrite; u++) { putc (PROGRESS, stderr); HDfflush(stderr); offset = HDlseek (fd, (off_t)0, SEEK_SET); assert (0==offset); n = HDwrite (fd, the_data, (size_t)(size[0]*size[1])); assert (n>=0 && (size_t)n==size[0]*size[1]); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstop); t_start.tv_sec = tbstart->time; t_start.tv_usec = tbstart->millitm; t_stop.tv_sec = tbstop->time; t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("out raw", &r_start, &r_stop, &t_start, &t_stop, (size_t)(nread*size[0]*size[1])); /* Write the hdf5 dataset */ synchronize (); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "out hdf5"); for(u = 0; u < nwrite; u++) { putc (PROGRESS, stderr); HDfflush(stderr); status = H5Dwrite (dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, the_data); assert (status>=0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstop); t_start.tv_sec = tbstart->time; t_start.tv_usec = tbstart->millitm; t_stop.tv_sec = tbstop->time; t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("out hdf5", &r_start, &r_stop, &t_start, &t_stop, (size_t)(nread*size[0]*size[1])); /* Read the raw dataset */ synchronize (); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "in raw"); for(u = 0; u < nread; u++) { putc (PROGRESS, stderr); HDfflush(stderr); offset = HDlseek (fd, (off_t)0, SEEK_SET); assert (0==offset); n = HDread (fd, the_data, (size_t)(size[0]*size[1])); assert (n>=0 && (size_t)n==size[0]*size[1]); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstop); t_start.tv_sec = tbstart->time; t_start.tv_usec = tbstart->millitm; t_stop.tv_sec = tbstop->time; t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("in raw", &r_start, &r_stop, &t_start, &t_stop, (size_t)(nread*size[0]*size[1])); /* Read the hdf5 dataset */ synchronize (); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "in hdf5"); for(u = 0; u < nread; u++) { putc (PROGRESS, stderr); HDfflush(stderr); status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); assert (status>=0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstop); t_start.tv_sec = tbstart->time; t_start.tv_usec = tbstart->millitm; t_stop.tv_sec = tbstop->time; t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("in hdf5", &r_start, &r_stop, &t_start, &t_stop, (size_t)(nread*size[0]*size[1])); /* Read hyperslab */ assert (size[0]>20 && size[1]>20); start[0] = start[1] = 10; count[0] = count[1] = size[0]-20; status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, start, NULL, count, NULL); assert (status>=0); synchronize (); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "in hdf5 partial"); for(u = 0; u < nread; u++) { putc (PROGRESS, stderr); HDfflush(stderr); status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); assert (status>=0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif #ifdef H5_HAVE_GETTIMEOFDAY HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB _ftime(tbstop); t_start.tv_sec = tbstart->time; t_start.tv_usec = tbstart->millitm; t_stop.tv_sec = tbstop->time; t_stop.tv_usec = tbstop->millitm; #endif #endif putc('\n', stderr); print_stats("in hdf5 partial", &r_start, &r_stop, &t_start, &t_stop, (size_t)(nread*count[0]*count[1])); /* Close everything */ HDclose(fd); H5Dclose(dset); H5Sclose(file_space); H5Fclose(file); free(the_data); return 0; }