SlideShare ist ein Scribd-Unternehmen logo
1 von 59
The HDF Group

HDF5 Advanced Topics
Elena Pourmal
The HDF Group
The 13th HDF and HDF-EOS Workshop
November 3-5, 2009

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

1

www.hdfgroup.org
Outline
• HDF5 Datatypes
• Partial I/O

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

2

www.hdfgroup.org
The HDF Group

HDF5 Datatypes

Overview

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

3

www.hdfgroup.org
HDF5 Datatypes
• An HDF5 datatype
• Required description of a data element
• the set of possible values it can have
• Example: enumeration datatype

• the operations that can be performed
• Example: type conversion cannot be performed on
opaque datatype

• how the values of that type are stored
• Example: values of variable-length type are stored in a
heap in a file

• Stored in the file along with the data it
describes
• Not to be confused with the C, C++, Java
and Fortran types
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

4

www.hdfgroup.org
HDF5 Datatypes Examples
• We provide examples how to create, write
and read data of different types
http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/api18-c.html

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

5

www.hdfgroup.org
HDF5 Datatypes Examples

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

6

www.hdfgroup.org
HDF5 Datatypes
• When HDF5 Datatypes are used?
• To describe application data in a file
• H5Dcreate, H5Acreate calls
• Example:
• A C application stores integer data as 32-bit littleendian signed two’s complement integer; it uses
H5T_SDT_I32LE with the H5Dcreate call
• A C applications stores double precision data “as is”
in the application memory; it uses
H5T_NATIVE_DOUBLE with the H5Acreate call
• A Fortran application stores array of real numbers as
64-bit big-endian IEEE format; it uses
H5T_IEEE_F64BE with h5dcreate_f call; HDF5
library will perform all necessary conversions

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

7

www.hdfgroup.org
HDF5 Datatypes
• When HDF5 Datatypes are used?
• To describe application data in memory
• Data buffer to be written or read into with
H5Dwrite/ H5Dread and H5Awrite/H5Aread
calls
• Example:
• C application reads data from the file and stores it in
an integer buffer; it uses H5T_NATIVE_INT to describe
the buffer.
• A Fortran application reads floating point data from the
file and stores it an integer buffer; it uses
H5T_NATIVE_INTEGER to describe the buffer;

• HDF5 library performs datatype conversion;
overflow/underflow may occur.
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

8

www.hdfgroup.org
Example
C Array of integers on Linux platform
Native integer (H5T_NATIVE_INT)
is little-endian, 4 bytes

H5T_NATIVE_INT

Fortran Array of integers on AIX platform
Native integer (H5T_NATIVE_INTEGER)
is big-endian, 8 bytes

e
rit ion
D w e rs
H5 n v
co

No

H5
Co Dr e
nv
ers ad
ion

H5T_NATIVE_INTEGER

HDF5 File

H5T_SDT_I32LE
Data is stored as little-endian, converted to big-endian on read
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

9

www.hdfgroup.org
HDF5 Datatypes

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

10

www.hdfgroup.org
Example: Writing/reading an Array to HDF5 file

• Calls you’ve already seen in Intro Tutorial
• H5LTmake_dataset
• H5Dwrite, H5Dread

• APIs to handle specific C data type
• H5LTmake_dataset_<*>
• <*> is one of “char”, “short”, “int”, “long”,
“float”, “double”, “string”

• All data array is written (no sub-setting)
• Data stored in a file as it is in memory
• H5LTread_dataset,
H5LTread_dataset_<*>
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

11

www.hdfgroup.org
Example: Read data into array of longs
#include "hdf5.h”
#include "hdf5_hl.h”
int main( void ){
long *data;
…
/* Open file from ex_lite1.c */
file_id = H5Fopen ("ex_lite1.h5", H5F_ACC_RDONLY,
H5P_DEFAULT);
/* Get information about dimensions to allocate memory buffer */
status = H5LTget_dataset_ndims(file_id,"/dset",rank);
status = H5LTget_dataset_info(file_id,"/dset",dims,dt_class,dt_size);
/* Allocate buffer to read data in */
data = (long*)malloc(…
/* Read dataset */
status = H5LTread_dataset_long(file_id,"/dset",data);
/
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

12

www.hdfgroup.org
Example: Read data into array of longs
#include hdf5.h
…
long *rdata;
….
/* Open file and dataset. */
file_id = H5Fopen (“ex_lite1.h5”, H5F_ACC_RDONLY, H5P_DEFAULT);
dset_id = H5Dopen (file, “/dset”, H5P_DEFAULT);
/* Get information about dimensions to allocate memory buffer */
space = H5Dget_space (dset);
rank = H5Sget_simple_extent_dims (space, dims, NULL);
status = H5Dread (dset, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL,
H5P_DEFAULT, rdata);
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

13

www.hdfgroup.org
Basic Atomic HDF5 Datatypes

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

14

www.hdfgroup.org
Basic Atomic Datatypes
• Integers & floats
• Strings (fixed and variable size)
• Pointers - references to objects and dataset
regions
• Bitfield
• Opaque

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

15

www.hdfgroup.org
HDF5 Predefined Datatypes
• HDF5 Library provides predefined datatypes
(symbols) for all basic atomic datatypes except
opaque datatype
• H5T_<arch>_<base>
• Examples:
•
•
•
•
•
•

H5T_IEEE_F64LE
H5T_STD_I32BE
H5T_C_S1, H5T_FORTRAN_S1
H5T_STD_B32LE
H5T_STD_REF_OBJ, H5T_STD_REF_DSETREG
H5T_NATIVE_INT

• Predefined datatypes do not have constant
values; initialized when library is initialized
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

16

www.hdfgroup.org
HDF5 Pre-defined Datatypes

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

17

www.hdfgroup.org
HDF5 Predefined Datatypes

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

18

www.hdfgroup.org
HDF5 integer datatype
• HDF5 supports 1,2,4,and 8 byte signed
and unsigned integers in memory and in
the file
• Support differs by language
• C language
• All C integer types including C99 extended
integer types (when available)
• Examples:
• H5T_NATIVE_INT16 for int16_t
• H5T_NATIVE_INT_LEAST64 for int_least64_t
• H5T_NATIVE_UINT_FAST16 for uint_fast16_t

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

19

www.hdfgroup.org
HDF5 integer datatype
• Fortran language
• In memory supports only Fortran “integer”
• Examples:
• H5T_NATIVE_INTEGER for integer

• In the file supports all HDF5 integer types
• Example: one-byte integer has to be
represented by integer in memory; can be
stored as one-byte integer by creating an
appropriate dataset (H5T_SDT_I8LE)

• Next major release of HDF5 will support
ANY kinds of Fortran integers

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

20

www.hdfgroup.org
HDF5 floating-point datatype
• HDF5 supports 32 and 64-bit floating point
IEEE big-endian, little-endian types in
memory and in the file
• Support differs by language
• C languge
•
•
•
•

H5T_IEEE_F64BE and H5T_IEEE_F32LE
H5T_NATIVE_FLOAT
H5T_NATIVE_DOUBLE
H5T_NATIVE_LDOUBLE

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

21

www.hdfgroup.org
HDF5 floating-point datatype
• Fortran language
• In memory supports only Fortran “real” and
“double precision” (obsolete)
• Examples:
• H5T_NATIVE_REAL for real
• H5T_NATIVE_DOUBLE for double precision

• In the file supports all HDF5 floating-point
types
• Next major release of HDF5 will support
ANY kinds of Fortran reals

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

22

www.hdfgroup.org
HDF5 string datatype
• HDF5 strings are characterized by
• The way each element of a string type is
stored in a file
• NULL terminated (C type string)
char *mystring[]=“Once upon a time”;
HDF5 stores <Once upon a time/0>

• Space padded (Fortran string)
character(len=16) :: mystring=‘Once upon a time’
HDF5 stores <Once upon a time> and adds spaces if
required

• The sizes of elements in the same dataset
or attribute
• Fixed-length string
• Variable-length string
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

23

www.hdfgroup.org
Example: Creating fixed-length string
• C Example: “Once upon a time” has 16characters
string_id = H5Tcopy(H5T_C_S1);
H5Tset_size(string_id, size);
• Size value have to include accommodate
“/0”, i.e., size=17 for “Once upon a time”
string
• Overhead for short strings, e.g., “Once” will
have extra 13 bytes allocated for storage
• Compressed well

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

24

www.hdfgroup.org
Example: Creating variable-length string
• C example:
string_id = H5Tcopy(H5T_C_S1);
H5Tset_size(string_id, H5T_VARIABLE);
• Overhead to store and access data
• Cannot be compressed (may be in the future)

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

25

www.hdfgroup.org
Reference Datatype
• Reference to an HDF5 object
• Pointer to a group or a dataset in a file
• Predefined datatype H5T_STD_REG_OBJ
describe object references

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

26

www.hdfgroup.org
Reference to Object
ref_obj.h5
/

Group1

Integers

MyType

Group2
Object References

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

27

www.hdfgroup.org
Reference to Object
h5dump –d /”object_reference” ref_obj.h5
DATASET "OBJECT_REFERENCES" {
DATATYPE H5T_REFERENCE
DATASPACE SIMPLE { ( 4 ) / ( 4 ) }
DATA {
(0): GROUP 808 /GROUP1 , GROUP 1848 /GROUP1/GROUP2 ,
(2): DATASET 2808 /INTEGERS , DATATYPE 3352 /MYTYPE
}

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

28

www.hdfgroup.org
Reference to Object
• Create a reference to group object
H5Rcreate(&ref[1], fileid, "/GROUP1/GROUP2",
H5R_OBJECT, -1);

• Write references to a dataset
H5Dwrite(dsetr_id, H5T_STD_REF_OBJ, H5S_ALL,
H5S_ALL, H5P_DEFAULT, ref);

• Read reference back with H5Dread and find an object it
points to
type_id = H5Rdereference(dsetr_id, H5R_OBJECT,
&ref[3]);
name_size = H5Rget_name(dsetr_id, H5R_OBJECT,
&ref_out[3], (char*)buf, 10);

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

29

www.hdfgroup.org
Saving Selected Region in a File

Need to select and access the same
elements of a dataset

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

30

www.hdfgroup.org
Reference Datatype
• Reference to a dataset region (or to
selection)
• Pointer to the dataspace selection
• Predefined datatype
H5T_STD_REF_DSETREG to describe
regions

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

31

www.hdfgroup.org
Reference to Dataset Region
REF_REG.h5
Root

Matrix

Region References

1 1 2 3 3 4 5 5 6
1 2 2 3 4 4 5 6 6

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

32

www.hdfgroup.org
Reference to Dataset Region
Example
dsetr_id = H5Dcreate(file_id,
“REGION REFERENCES”, H5T_STD_REF_DSETREG,
…);
H5Sselect_hyperslab(space_id,
H5S_SELECT_SET, start, NULL, …);
H5Rcreate(&ref[0], file_id, “MATRIX”,
H5R_DATASET_REGION, space_id);
H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG,
H5S_ALL, H5S_ALL, H5P_DEFAULT,ref);
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

33

www.hdfgroup.org
Reference to Dataset Region
HDF5 "REF_REG.h5" {
GROUP "/" {
DATASET "MATRIX" {
……
}
DATASET "REGION_REFERENCES" {
DATATYPE H5T_REFERENCE
DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
DATA {
(0): DATASET /MATRIX {(0,3)-(1,5)},
(1): DATASET /MATRIX {(0,0), (1,6), (0,8)}
}
}
}
}

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

34

www.hdfgroup.org
The HDF Group

Part II
Working with subsets

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

54

www.hdfgroup.org
Collect data one way ….
Array of images (3D)

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

55

www.hdfgroup.org
Display data another way …

Stitched image (2D array)

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

56

www.hdfgroup.org
Data is too big to read….

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

57

www.hdfgroup.org
Refer to a region…

Need to select and access the same
elements of a dataset

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

58

www.hdfgroup.org
HDF5 Library Features
• HDF5 Library provides capabilities to
• Describe subsets of data and perform
write/read operations on subsets
• Hyperslab selections and partial I/O

• Store descriptions of the data subsets in a file
• Object references
• Region references

• Use efficient storage mechanism to achieve
good performance while writing/reading
subsets of data
• Chunking, compression
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

59

www.hdfgroup.org
The HDF Group

Partial I/O in HDF5

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

60

www.hdfgroup.org
How to Describe a Subset in HDF5?
• Before writing and reading a subset of data
one has to describe it to the HDF5 Library.
• HDF5 APIs and documentation refer to a
subset as a “selection” or “hyperslab
selection”.
• If specified, HDF5 Library will perform I/O
on a selection only and not on all elements
of a dataset.

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

61

www.hdfgroup.org
Types of Selections in HDF5
• Two types of selections
• Hyperslab selection
• Regular hyperslab
• Simple hyperslab
• Result of set operations on hyperslabs
(union, difference, …)

• Point selection

• Hyperslab selection is especially important
for doing parallel I/O in HDF5 (See Parallel
HDF5 Tutorial)
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

62

www.hdfgroup.org
Regular Hyperslab

Collection of regularly spaced blocks of equal size
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

63

www.hdfgroup.org
Simple Hyperslab

Contiguous subset or sub-array
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

64

www.hdfgroup.org
Hyperslab Selection

Result of union operation on three simple hyperslabs
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

65

www.hdfgroup.org
Hyperslab Description
• Start - starting location of a hyperslab (1,1)
• Stride - number of elements that separate each
block (3,2)
• Count - number of blocks (2,6)
• Block - block size (2,1)
• Everything is “measured” in number of elements

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

66

www.hdfgroup.org
Simple Hyperslab Description
• Two ways to describe a simple hyperslab
• As several blocks
• Stride – (1,1)
• Count – (2,6)
• Block – (2,1)

• As one block
• Stride – (1,1)
• Count – (1,1)
• Block – (4,6)

No performance penalty for
one way or another
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

67

www.hdfgroup.org
H5Sselect_hyperslab Function

space_id Identifier of dataspace
op
Selection operator
H5S_SELECT_SET or H5S_SELECT_OR
start
Array with starting coordinates of hyperslab
stride
Array specifying which positions along a dimension
to select
count
Array specifying how many blocks to select from the
dataspace, in each dimension
block
Array specifying size of element block
(NULL indicates a block size of a single element in
a dimension)

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

68

www.hdfgroup.org
Reading/Writing Selections
Programming model for reading from a dataset in

a file
1. Open a dataset.
2. Get file dataspace handle of the dataset and specify
subset to read from.
a. H5Dget_space returns file dataspace handle
a.

File dataspace describes array stored in a file (number of
dimensions and their sizes).

b. H5Sselect_hyperslab selects elements of the array
that participate in I/O operation.

3. Allocate data buffer of an appropriate shape and size

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

69

www.hdfgroup.org
Reading/Writing Selections
Programming model (continued)
4. Create a memory dataspace and specify subset to write
to.
1.
2.
3.

Memory dataspace describes data buffer (its rank and
dimension sizes).
Use H5Screate_simple function to create memory
dataspace.
Use H5Sselect_hyperslab to select elements of the data
buffer that participate in I/O operation.

4. Issue H5Dread or H5Dwrite to move the data between
file and memory buffer.
5. Close file dataspace and memory dataspace when
done.
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

70

www.hdfgroup.org
Example : Reading Two Rows
1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

-1

-1

-1

Data in a file
4x6 matrix

Buffer in memory
1-dim array of length 14
-1

-1

November 3-5, 2009

-1

-1

-1

-1

-1

HDF/HDF-EOS Workshop XIII

-1
71

-1

-1

-1

www.hdfgroup.org
Example: Reading Two Rows
1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

20

21

22

23

=
=
=
=

{1,0}
{2,6}
{1,1}
{1,1}

18

19

start
count
block
stride

24

filespace = H5Dget_space (dataset);
H5Sselect_hyperslab (filespace, H5S_SELECT_SET,
start, NULL, count, NULL)

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

72

www.hdfgroup.org
Example: Reading Two Rows
start[1] = {1}
count[1] = {12}
dim[1]
= {14}

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

memspace = H5Screate_simple(1, dim, NULL);
H5Sselect_hyperslab (memspace, H5S_SELECT_SET,
start, NULL, count, NULL)

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

73

www.hdfgroup.org
Example: Reading Two Rows
1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

H5Dread (…, …, memspace, filespace, …, …);

-1

7

November 3-5, 2009

8

9

10 11 12 13 14 15 16 17 18 -1
HDF/HDF-EOS Workshop XIII

74

www.hdfgroup.org
Things to Remember
• Number of elements selected in a file and in a
memory buffer must be the same
• H5Sget_select_npoints returns number of
selected elements in a hyperslab selection

• HDF5 partial I/O is tuned to move data between
selections that have the same dimensionality;
avoid choosing subsets that have different ranks
(as in example above)
• Allocate a buffer of an appropriate size when
reading data; use H5Tget_native_type and
H5Tget_size to get the correct size of the data
element in memory.
November 3-5, 2009

HDF/HDF-EOS Workshop XIII

75

www.hdfgroup.org
The HDF Group

Thank You!

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

76

www.hdfgroup.org
Acknowledgements
This work was supported by cooperative agreement
number NNX08AO77A from the National
Aeronautics and Space Administration (NASA).
Any opinions, findings, conclusions, or
recommendations expressed in this material are
those of the author[s] and do not necessarily reflect
the views of the National Aeronautics and Space
Administration.

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

77

www.hdfgroup.org
The HDF Group

Questions/comments?

November 3-5, 2009

HDF/HDF-EOS Workshop XIII

78

www.hdfgroup.org

Weitere ähnliche Inhalte

Was ist angesagt?

Abo Oml125
Abo Oml125Abo Oml125
Abo Oml125
ennioeni
 
Mitsubishi fd80 n forklift trucks service repair manual snf32c 10011-up
Mitsubishi fd80 n forklift trucks service repair manual snf32c 10011-upMitsubishi fd80 n forklift trucks service repair manual snf32c 10011-up
Mitsubishi fd80 n forklift trucks service repair manual snf32c 10011-up
jskemmdn eukdms
 
Offshore pipelines design, analysis & method
Offshore pipelines   design, analysis & methodOffshore pipelines   design, analysis & method
Offshore pipelines design, analysis & method
Thanh Tran
 
Gornik.eksploatacji.podziemnej 711[02] z4.04_u
Gornik.eksploatacji.podziemnej 711[02] z4.04_uGornik.eksploatacji.podziemnej 711[02] z4.04_u
Gornik.eksploatacji.podziemnej 711[02] z4.04_u
Muszex
 
Sacs otc 2012
Sacs otc 2012Sacs otc 2012
Sacs otc 2012
HSD Luu
 

Was ist angesagt? (20)

Abo Oml125
Abo Oml125Abo Oml125
Abo Oml125
 
Fpso – general overview of conversion & topside process description -abstract
Fpso – general overview of conversion & topside process description -abstractFpso – general overview of conversion & topside process description -abstract
Fpso – general overview of conversion & topside process description -abstract
 
Dynamic positioning
Dynamic positioningDynamic positioning
Dynamic positioning
 
PD184 - TopSide Processing System
PD184 - TopSide Processing SystemPD184 - TopSide Processing System
PD184 - TopSide Processing System
 
Mitsubishi fd80 n forklift trucks service repair manual snf32c 10011-up
Mitsubishi fd80 n forklift trucks service repair manual snf32c 10011-upMitsubishi fd80 n forklift trucks service repair manual snf32c 10011-up
Mitsubishi fd80 n forklift trucks service repair manual snf32c 10011-up
 
SUC Brasil 2012 : Importing Models to Sesam GeniE
SUC Brasil 2012 : Importing Models to Sesam GeniESUC Brasil 2012 : Importing Models to Sesam GeniE
SUC Brasil 2012 : Importing Models to Sesam GeniE
 
Psr 2 coding style guide - Tidepool Labs
Psr 2   coding style guide - Tidepool LabsPsr 2   coding style guide - Tidepool Labs
Psr 2 coding style guide - Tidepool Labs
 
How to fix kaspersky error 27300 - Easy Steps
How to fix kaspersky error 27300 - Easy StepsHow to fix kaspersky error 27300 - Easy Steps
How to fix kaspersky error 27300 - Easy Steps
 
General Arrangement - Crane Barge (Accomodation Crane Barge) 180 Feet
General Arrangement - Crane Barge (Accomodation Crane Barge) 180 FeetGeneral Arrangement - Crane Barge (Accomodation Crane Barge) 180 Feet
General Arrangement - Crane Barge (Accomodation Crane Barge) 180 Feet
 
Offshore packages
Offshore packagesOffshore packages
Offshore packages
 
Offshore pipelines design, analysis & method
Offshore pipelines   design, analysis & methodOffshore pipelines   design, analysis & method
Offshore pipelines design, analysis & method
 
apl-brochure
apl-brochureapl-brochure
apl-brochure
 
Os f101 2013-10-2
Os f101 2013-10-2Os f101 2013-10-2
Os f101 2013-10-2
 
Gornik.eksploatacji.podziemnej 711[02] z4.04_u
Gornik.eksploatacji.podziemnej 711[02] z4.04_uGornik.eksploatacji.podziemnej 711[02] z4.04_u
Gornik.eksploatacji.podziemnej 711[02] z4.04_u
 
Design and Analysis of Floating Production Systems
Design and Analysis of Floating Production Systems Design and Analysis of Floating Production Systems
Design and Analysis of Floating Production Systems
 
Sacs otc 2012
Sacs otc 2012Sacs otc 2012
Sacs otc 2012
 
Underwater welding
Underwater weldingUnderwater welding
Underwater welding
 
DNV GL Asset Life Extension (ALE) Projects Showcase
DNV GL Asset Life Extension (ALE) Projects ShowcaseDNV GL Asset Life Extension (ALE) Projects Showcase
DNV GL Asset Life Extension (ALE) Projects Showcase
 
z/OS V2R2 Communications Server Overview
z/OS V2R2 Communications Server Overviewz/OS V2R2 Communications Server Overview
z/OS V2R2 Communications Server Overview
 
Davos
DavosDavos
Davos
 

Ähnlich wie HDF5 Advanced Topics - Datatypes and Partial I/O

Ähnlich wie HDF5 Advanced Topics - Datatypes and Partial I/O (20)

Advanced HDF5 Features
Advanced HDF5 FeaturesAdvanced HDF5 Features
Advanced HDF5 Features
 
Introduction to HDF5 Data Model, Programming Model and Library APIs
Introduction to HDF5 Data Model, Programming Model and Library APIsIntroduction to HDF5 Data Model, Programming Model and Library APIs
Introduction to HDF5 Data Model, Programming Model and Library APIs
 
Advanced HDF5 Features
Advanced HDF5 FeaturesAdvanced HDF5 Features
Advanced HDF5 Features
 
Introduction to HDF5
Introduction to HDF5Introduction to HDF5
Introduction to HDF5
 
Introduction to HDF5
Introduction to HDF5Introduction to HDF5
Introduction to HDF5
 
Introduction to HDF5
Introduction to HDF5Introduction to HDF5
Introduction to HDF5
 
Hdf5 intro
Hdf5 introHdf5 intro
Hdf5 intro
 
Introduction to HDF5 Data and Programming Models
Introduction to HDF5 Data and Programming ModelsIntroduction to HDF5 Data and Programming Models
Introduction to HDF5 Data and Programming Models
 
Parallel HDF5 Introductory Tutorial
Parallel HDF5 Introductory TutorialParallel HDF5 Introductory Tutorial
Parallel HDF5 Introductory Tutorial
 
HDF5 Advanced Topics
HDF5 Advanced TopicsHDF5 Advanced Topics
HDF5 Advanced Topics
 
Introduction to HDF5 Data Model, Programming Model and Library APIs
Introduction to HDF5 Data Model, Programming Model and Library APIsIntroduction to HDF5 Data Model, Programming Model and Library APIs
Introduction to HDF5 Data Model, Programming Model and Library APIs
 
Introduction to HDF5
Introduction to HDF5Introduction to HDF5
Introduction to HDF5
 
HDF5 Life cycle of data
HDF5 Life cycle of dataHDF5 Life cycle of data
HDF5 Life cycle of data
 
Performance Tuning in HDF5
Performance Tuning in HDF5 Performance Tuning in HDF5
Performance Tuning in HDF5
 
HDF5 Advanced Topics
HDF5 Advanced TopicsHDF5 Advanced Topics
HDF5 Advanced Topics
 
Using HDF5 tools for performance tuning and troubleshooting
Using HDF5 tools for performance tuning and troubleshootingUsing HDF5 tools for performance tuning and troubleshooting
Using HDF5 tools for performance tuning and troubleshooting
 
Introduction to HDF5 Data Model, Programming Model and Library APIs
Introduction to HDF5 Data Model, Programming Model and Library APIsIntroduction to HDF5 Data Model, Programming Model and Library APIs
Introduction to HDF5 Data Model, Programming Model and Library APIs
 
HDF5 Advanced Topics - Object's Properties, Storage Methods, Filters, Datatypes
HDF5 Advanced Topics - Object's Properties, Storage Methods, Filters, DatatypesHDF5 Advanced Topics - Object's Properties, Storage Methods, Filters, Datatypes
HDF5 Advanced Topics - Object's Properties, Storage Methods, Filters, Datatypes
 
Hdf5 parallel
Hdf5 parallelHdf5 parallel
Hdf5 parallel
 
Substituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scriptsSubstituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scripts
 

Mehr von The HDF-EOS Tools and Information Center

Mehr von The HDF-EOS Tools and Information Center (20)

Cloud-Optimized HDF5 Files
Cloud-Optimized HDF5 FilesCloud-Optimized HDF5 Files
Cloud-Optimized HDF5 Files
 
Accessing HDF5 data in the cloud with HSDS
Accessing HDF5 data in the cloud with HSDSAccessing HDF5 data in the cloud with HSDS
Accessing HDF5 data in the cloud with HSDS
 
The State of HDF
The State of HDFThe State of HDF
The State of HDF
 
Highly Scalable Data Service (HSDS) Performance Features
Highly Scalable Data Service (HSDS) Performance FeaturesHighly Scalable Data Service (HSDS) Performance Features
Highly Scalable Data Service (HSDS) Performance Features
 
Creating Cloud-Optimized HDF5 Files
Creating Cloud-Optimized HDF5 FilesCreating Cloud-Optimized HDF5 Files
Creating Cloud-Optimized HDF5 Files
 
HDF5 OPeNDAP Handler Updates, and Performance Discussion
HDF5 OPeNDAP Handler Updates, and Performance DiscussionHDF5 OPeNDAP Handler Updates, and Performance Discussion
HDF5 OPeNDAP Handler Updates, and Performance Discussion
 
Hyrax: Serving Data from S3
Hyrax: Serving Data from S3Hyrax: Serving Data from S3
Hyrax: Serving Data from S3
 
Accessing Cloud Data and Services Using EDL, Pydap, MATLAB
Accessing Cloud Data and Services Using EDL, Pydap, MATLABAccessing Cloud Data and Services Using EDL, Pydap, MATLAB
Accessing Cloud Data and Services Using EDL, Pydap, MATLAB
 
HDF - Current status and Future Directions
HDF - Current status and Future DirectionsHDF - Current status and Future Directions
HDF - Current status and Future Directions
 
HDFEOS.org User Analsys, Updates, and Future
HDFEOS.org User Analsys, Updates, and FutureHDFEOS.org User Analsys, Updates, and Future
HDFEOS.org User Analsys, Updates, and Future
 
HDF - Current status and Future Directions
HDF - Current status and Future Directions HDF - Current status and Future Directions
HDF - Current status and Future Directions
 
H5Coro: The Cloud-Optimized Read-Only Library
H5Coro: The Cloud-Optimized Read-Only LibraryH5Coro: The Cloud-Optimized Read-Only Library
H5Coro: The Cloud-Optimized Read-Only Library
 
MATLAB Modernization on HDF5 1.10
MATLAB Modernization on HDF5 1.10MATLAB Modernization on HDF5 1.10
MATLAB Modernization on HDF5 1.10
 
HDF for the Cloud - Serverless HDF
HDF for the Cloud - Serverless HDFHDF for the Cloud - Serverless HDF
HDF for the Cloud - Serverless HDF
 
HDF5 <-> Zarr
HDF5 <-> ZarrHDF5 <-> Zarr
HDF5 <-> Zarr
 
HDF for the Cloud - New HDF Server Features
HDF for the Cloud - New HDF Server FeaturesHDF for the Cloud - New HDF Server Features
HDF for the Cloud - New HDF Server Features
 
Apache Drill and Unidata THREDDS Data Server for NASA HDF-EOS on S3
Apache Drill and Unidata THREDDS Data Server for NASA HDF-EOS on S3Apache Drill and Unidata THREDDS Data Server for NASA HDF-EOS on S3
Apache Drill and Unidata THREDDS Data Server for NASA HDF-EOS on S3
 
STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...
STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...
STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...
 
HDF5 and Ecosystem: What Is New?
HDF5 and Ecosystem: What Is New?HDF5 and Ecosystem: What Is New?
HDF5 and Ecosystem: What Is New?
 
HDF5 Roadmap 2019-2020
HDF5 Roadmap 2019-2020HDF5 Roadmap 2019-2020
HDF5 Roadmap 2019-2020
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

HDF5 Advanced Topics - Datatypes and Partial I/O

  • 1. The HDF Group HDF5 Advanced Topics Elena Pourmal The HDF Group The 13th HDF and HDF-EOS Workshop November 3-5, 2009 November 3-5, 2009 HDF/HDF-EOS Workshop XIII 1 www.hdfgroup.org
  • 2. Outline • HDF5 Datatypes • Partial I/O November 3-5, 2009 HDF/HDF-EOS Workshop XIII 2 www.hdfgroup.org
  • 3. The HDF Group HDF5 Datatypes Overview November 3-5, 2009 HDF/HDF-EOS Workshop XIII 3 www.hdfgroup.org
  • 4. HDF5 Datatypes • An HDF5 datatype • Required description of a data element • the set of possible values it can have • Example: enumeration datatype • the operations that can be performed • Example: type conversion cannot be performed on opaque datatype • how the values of that type are stored • Example: values of variable-length type are stored in a heap in a file • Stored in the file along with the data it describes • Not to be confused with the C, C++, Java and Fortran types November 3-5, 2009 HDF/HDF-EOS Workshop XIII 4 www.hdfgroup.org
  • 5. HDF5 Datatypes Examples • We provide examples how to create, write and read data of different types http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/api18-c.html November 3-5, 2009 HDF/HDF-EOS Workshop XIII 5 www.hdfgroup.org
  • 6. HDF5 Datatypes Examples November 3-5, 2009 HDF/HDF-EOS Workshop XIII 6 www.hdfgroup.org
  • 7. HDF5 Datatypes • When HDF5 Datatypes are used? • To describe application data in a file • H5Dcreate, H5Acreate calls • Example: • A C application stores integer data as 32-bit littleendian signed two’s complement integer; it uses H5T_SDT_I32LE with the H5Dcreate call • A C applications stores double precision data “as is” in the application memory; it uses H5T_NATIVE_DOUBLE with the H5Acreate call • A Fortran application stores array of real numbers as 64-bit big-endian IEEE format; it uses H5T_IEEE_F64BE with h5dcreate_f call; HDF5 library will perform all necessary conversions November 3-5, 2009 HDF/HDF-EOS Workshop XIII 7 www.hdfgroup.org
  • 8. HDF5 Datatypes • When HDF5 Datatypes are used? • To describe application data in memory • Data buffer to be written or read into with H5Dwrite/ H5Dread and H5Awrite/H5Aread calls • Example: • C application reads data from the file and stores it in an integer buffer; it uses H5T_NATIVE_INT to describe the buffer. • A Fortran application reads floating point data from the file and stores it an integer buffer; it uses H5T_NATIVE_INTEGER to describe the buffer; • HDF5 library performs datatype conversion; overflow/underflow may occur. November 3-5, 2009 HDF/HDF-EOS Workshop XIII 8 www.hdfgroup.org
  • 9. Example C Array of integers on Linux platform Native integer (H5T_NATIVE_INT) is little-endian, 4 bytes H5T_NATIVE_INT Fortran Array of integers on AIX platform Native integer (H5T_NATIVE_INTEGER) is big-endian, 8 bytes e rit ion D w e rs H5 n v co No H5 Co Dr e nv ers ad ion H5T_NATIVE_INTEGER HDF5 File H5T_SDT_I32LE Data is stored as little-endian, converted to big-endian on read November 3-5, 2009 HDF/HDF-EOS Workshop XIII 9 www.hdfgroup.org
  • 10. HDF5 Datatypes November 3-5, 2009 HDF/HDF-EOS Workshop XIII 10 www.hdfgroup.org
  • 11. Example: Writing/reading an Array to HDF5 file • Calls you’ve already seen in Intro Tutorial • H5LTmake_dataset • H5Dwrite, H5Dread • APIs to handle specific C data type • H5LTmake_dataset_<*> • <*> is one of “char”, “short”, “int”, “long”, “float”, “double”, “string” • All data array is written (no sub-setting) • Data stored in a file as it is in memory • H5LTread_dataset, H5LTread_dataset_<*> November 3-5, 2009 HDF/HDF-EOS Workshop XIII 11 www.hdfgroup.org
  • 12. Example: Read data into array of longs #include "hdf5.h” #include "hdf5_hl.h” int main( void ){ long *data; … /* Open file from ex_lite1.c */ file_id = H5Fopen ("ex_lite1.h5", H5F_ACC_RDONLY, H5P_DEFAULT); /* Get information about dimensions to allocate memory buffer */ status = H5LTget_dataset_ndims(file_id,"/dset",rank); status = H5LTget_dataset_info(file_id,"/dset",dims,dt_class,dt_size); /* Allocate buffer to read data in */ data = (long*)malloc(… /* Read dataset */ status = H5LTread_dataset_long(file_id,"/dset",data); / November 3-5, 2009 HDF/HDF-EOS Workshop XIII 12 www.hdfgroup.org
  • 13. Example: Read data into array of longs #include hdf5.h … long *rdata; …. /* Open file and dataset. */ file_id = H5Fopen (“ex_lite1.h5”, H5F_ACC_RDONLY, H5P_DEFAULT); dset_id = H5Dopen (file, “/dset”, H5P_DEFAULT); /* Get information about dimensions to allocate memory buffer */ space = H5Dget_space (dset); rank = H5Sget_simple_extent_dims (space, dims, NULL); status = H5Dread (dset, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); November 3-5, 2009 HDF/HDF-EOS Workshop XIII 13 www.hdfgroup.org
  • 14. Basic Atomic HDF5 Datatypes November 3-5, 2009 HDF/HDF-EOS Workshop XIII 14 www.hdfgroup.org
  • 15. Basic Atomic Datatypes • Integers & floats • Strings (fixed and variable size) • Pointers - references to objects and dataset regions • Bitfield • Opaque November 3-5, 2009 HDF/HDF-EOS Workshop XIII 15 www.hdfgroup.org
  • 16. HDF5 Predefined Datatypes • HDF5 Library provides predefined datatypes (symbols) for all basic atomic datatypes except opaque datatype • H5T_<arch>_<base> • Examples: • • • • • • H5T_IEEE_F64LE H5T_STD_I32BE H5T_C_S1, H5T_FORTRAN_S1 H5T_STD_B32LE H5T_STD_REF_OBJ, H5T_STD_REF_DSETREG H5T_NATIVE_INT • Predefined datatypes do not have constant values; initialized when library is initialized November 3-5, 2009 HDF/HDF-EOS Workshop XIII 16 www.hdfgroup.org
  • 17. HDF5 Pre-defined Datatypes November 3-5, 2009 HDF/HDF-EOS Workshop XIII 17 www.hdfgroup.org
  • 18. HDF5 Predefined Datatypes November 3-5, 2009 HDF/HDF-EOS Workshop XIII 18 www.hdfgroup.org
  • 19. HDF5 integer datatype • HDF5 supports 1,2,4,and 8 byte signed and unsigned integers in memory and in the file • Support differs by language • C language • All C integer types including C99 extended integer types (when available) • Examples: • H5T_NATIVE_INT16 for int16_t • H5T_NATIVE_INT_LEAST64 for int_least64_t • H5T_NATIVE_UINT_FAST16 for uint_fast16_t November 3-5, 2009 HDF/HDF-EOS Workshop XIII 19 www.hdfgroup.org
  • 20. HDF5 integer datatype • Fortran language • In memory supports only Fortran “integer” • Examples: • H5T_NATIVE_INTEGER for integer • In the file supports all HDF5 integer types • Example: one-byte integer has to be represented by integer in memory; can be stored as one-byte integer by creating an appropriate dataset (H5T_SDT_I8LE) • Next major release of HDF5 will support ANY kinds of Fortran integers November 3-5, 2009 HDF/HDF-EOS Workshop XIII 20 www.hdfgroup.org
  • 21. HDF5 floating-point datatype • HDF5 supports 32 and 64-bit floating point IEEE big-endian, little-endian types in memory and in the file • Support differs by language • C languge • • • • H5T_IEEE_F64BE and H5T_IEEE_F32LE H5T_NATIVE_FLOAT H5T_NATIVE_DOUBLE H5T_NATIVE_LDOUBLE November 3-5, 2009 HDF/HDF-EOS Workshop XIII 21 www.hdfgroup.org
  • 22. HDF5 floating-point datatype • Fortran language • In memory supports only Fortran “real” and “double precision” (obsolete) • Examples: • H5T_NATIVE_REAL for real • H5T_NATIVE_DOUBLE for double precision • In the file supports all HDF5 floating-point types • Next major release of HDF5 will support ANY kinds of Fortran reals November 3-5, 2009 HDF/HDF-EOS Workshop XIII 22 www.hdfgroup.org
  • 23. HDF5 string datatype • HDF5 strings are characterized by • The way each element of a string type is stored in a file • NULL terminated (C type string) char *mystring[]=“Once upon a time”; HDF5 stores <Once upon a time/0> • Space padded (Fortran string) character(len=16) :: mystring=‘Once upon a time’ HDF5 stores <Once upon a time> and adds spaces if required • The sizes of elements in the same dataset or attribute • Fixed-length string • Variable-length string November 3-5, 2009 HDF/HDF-EOS Workshop XIII 23 www.hdfgroup.org
  • 24. Example: Creating fixed-length string • C Example: “Once upon a time” has 16characters string_id = H5Tcopy(H5T_C_S1); H5Tset_size(string_id, size); • Size value have to include accommodate “/0”, i.e., size=17 for “Once upon a time” string • Overhead for short strings, e.g., “Once” will have extra 13 bytes allocated for storage • Compressed well November 3-5, 2009 HDF/HDF-EOS Workshop XIII 24 www.hdfgroup.org
  • 25. Example: Creating variable-length string • C example: string_id = H5Tcopy(H5T_C_S1); H5Tset_size(string_id, H5T_VARIABLE); • Overhead to store and access data • Cannot be compressed (may be in the future) November 3-5, 2009 HDF/HDF-EOS Workshop XIII 25 www.hdfgroup.org
  • 26. Reference Datatype • Reference to an HDF5 object • Pointer to a group or a dataset in a file • Predefined datatype H5T_STD_REG_OBJ describe object references November 3-5, 2009 HDF/HDF-EOS Workshop XIII 26 www.hdfgroup.org
  • 27. Reference to Object ref_obj.h5 / Group1 Integers MyType Group2 Object References November 3-5, 2009 HDF/HDF-EOS Workshop XIII 27 www.hdfgroup.org
  • 28. Reference to Object h5dump –d /”object_reference” ref_obj.h5 DATASET "OBJECT_REFERENCES" { DATATYPE H5T_REFERENCE DATASPACE SIMPLE { ( 4 ) / ( 4 ) } DATA { (0): GROUP 808 /GROUP1 , GROUP 1848 /GROUP1/GROUP2 , (2): DATASET 2808 /INTEGERS , DATATYPE 3352 /MYTYPE } November 3-5, 2009 HDF/HDF-EOS Workshop XIII 28 www.hdfgroup.org
  • 29. Reference to Object • Create a reference to group object H5Rcreate(&ref[1], fileid, "/GROUP1/GROUP2", H5R_OBJECT, -1); • Write references to a dataset H5Dwrite(dsetr_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref); • Read reference back with H5Dread and find an object it points to type_id = H5Rdereference(dsetr_id, H5R_OBJECT, &ref[3]); name_size = H5Rget_name(dsetr_id, H5R_OBJECT, &ref_out[3], (char*)buf, 10); November 3-5, 2009 HDF/HDF-EOS Workshop XIII 29 www.hdfgroup.org
  • 30. Saving Selected Region in a File Need to select and access the same elements of a dataset November 3-5, 2009 HDF/HDF-EOS Workshop XIII 30 www.hdfgroup.org
  • 31. Reference Datatype • Reference to a dataset region (or to selection) • Pointer to the dataspace selection • Predefined datatype H5T_STD_REF_DSETREG to describe regions November 3-5, 2009 HDF/HDF-EOS Workshop XIII 31 www.hdfgroup.org
  • 32. Reference to Dataset Region REF_REG.h5 Root Matrix Region References 1 1 2 3 3 4 5 5 6 1 2 2 3 4 4 5 6 6 November 3-5, 2009 HDF/HDF-EOS Workshop XIII 32 www.hdfgroup.org
  • 33. Reference to Dataset Region Example dsetr_id = H5Dcreate(file_id, “REGION REFERENCES”, H5T_STD_REF_DSETREG, …); H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, …); H5Rcreate(&ref[0], file_id, “MATRIX”, H5R_DATASET_REGION, space_id); H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref); November 3-5, 2009 HDF/HDF-EOS Workshop XIII 33 www.hdfgroup.org
  • 34. Reference to Dataset Region HDF5 "REF_REG.h5" { GROUP "/" { DATASET "MATRIX" { …… } DATASET "REGION_REFERENCES" { DATATYPE H5T_REFERENCE DATASPACE SIMPLE { ( 2 ) / ( 2 ) } DATA { (0): DATASET /MATRIX {(0,3)-(1,5)}, (1): DATASET /MATRIX {(0,0), (1,6), (0,8)} } } } } November 3-5, 2009 HDF/HDF-EOS Workshop XIII 34 www.hdfgroup.org
  • 35. The HDF Group Part II Working with subsets November 3-5, 2009 HDF/HDF-EOS Workshop XIII 54 www.hdfgroup.org
  • 36. Collect data one way …. Array of images (3D) November 3-5, 2009 HDF/HDF-EOS Workshop XIII 55 www.hdfgroup.org
  • 37. Display data another way … Stitched image (2D array) November 3-5, 2009 HDF/HDF-EOS Workshop XIII 56 www.hdfgroup.org
  • 38. Data is too big to read…. November 3-5, 2009 HDF/HDF-EOS Workshop XIII 57 www.hdfgroup.org
  • 39. Refer to a region… Need to select and access the same elements of a dataset November 3-5, 2009 HDF/HDF-EOS Workshop XIII 58 www.hdfgroup.org
  • 40. HDF5 Library Features • HDF5 Library provides capabilities to • Describe subsets of data and perform write/read operations on subsets • Hyperslab selections and partial I/O • Store descriptions of the data subsets in a file • Object references • Region references • Use efficient storage mechanism to achieve good performance while writing/reading subsets of data • Chunking, compression November 3-5, 2009 HDF/HDF-EOS Workshop XIII 59 www.hdfgroup.org
  • 41. The HDF Group Partial I/O in HDF5 November 3-5, 2009 HDF/HDF-EOS Workshop XIII 60 www.hdfgroup.org
  • 42. How to Describe a Subset in HDF5? • Before writing and reading a subset of data one has to describe it to the HDF5 Library. • HDF5 APIs and documentation refer to a subset as a “selection” or “hyperslab selection”. • If specified, HDF5 Library will perform I/O on a selection only and not on all elements of a dataset. November 3-5, 2009 HDF/HDF-EOS Workshop XIII 61 www.hdfgroup.org
  • 43. Types of Selections in HDF5 • Two types of selections • Hyperslab selection • Regular hyperslab • Simple hyperslab • Result of set operations on hyperslabs (union, difference, …) • Point selection • Hyperslab selection is especially important for doing parallel I/O in HDF5 (See Parallel HDF5 Tutorial) November 3-5, 2009 HDF/HDF-EOS Workshop XIII 62 www.hdfgroup.org
  • 44. Regular Hyperslab Collection of regularly spaced blocks of equal size November 3-5, 2009 HDF/HDF-EOS Workshop XIII 63 www.hdfgroup.org
  • 45. Simple Hyperslab Contiguous subset or sub-array November 3-5, 2009 HDF/HDF-EOS Workshop XIII 64 www.hdfgroup.org
  • 46. Hyperslab Selection Result of union operation on three simple hyperslabs November 3-5, 2009 HDF/HDF-EOS Workshop XIII 65 www.hdfgroup.org
  • 47. Hyperslab Description • Start - starting location of a hyperslab (1,1) • Stride - number of elements that separate each block (3,2) • Count - number of blocks (2,6) • Block - block size (2,1) • Everything is “measured” in number of elements November 3-5, 2009 HDF/HDF-EOS Workshop XIII 66 www.hdfgroup.org
  • 48. Simple Hyperslab Description • Two ways to describe a simple hyperslab • As several blocks • Stride – (1,1) • Count – (2,6) • Block – (2,1) • As one block • Stride – (1,1) • Count – (1,1) • Block – (4,6) No performance penalty for one way or another November 3-5, 2009 HDF/HDF-EOS Workshop XIII 67 www.hdfgroup.org
  • 49. H5Sselect_hyperslab Function space_id Identifier of dataspace op Selection operator H5S_SELECT_SET or H5S_SELECT_OR start Array with starting coordinates of hyperslab stride Array specifying which positions along a dimension to select count Array specifying how many blocks to select from the dataspace, in each dimension block Array specifying size of element block (NULL indicates a block size of a single element in a dimension) November 3-5, 2009 HDF/HDF-EOS Workshop XIII 68 www.hdfgroup.org
  • 50. Reading/Writing Selections Programming model for reading from a dataset in a file 1. Open a dataset. 2. Get file dataspace handle of the dataset and specify subset to read from. a. H5Dget_space returns file dataspace handle a. File dataspace describes array stored in a file (number of dimensions and their sizes). b. H5Sselect_hyperslab selects elements of the array that participate in I/O operation. 3. Allocate data buffer of an appropriate shape and size November 3-5, 2009 HDF/HDF-EOS Workshop XIII 69 www.hdfgroup.org
  • 51. Reading/Writing Selections Programming model (continued) 4. Create a memory dataspace and specify subset to write to. 1. 2. 3. Memory dataspace describes data buffer (its rank and dimension sizes). Use H5Screate_simple function to create memory dataspace. Use H5Sselect_hyperslab to select elements of the data buffer that participate in I/O operation. 4. Issue H5Dread or H5Dwrite to move the data between file and memory buffer. 5. Close file dataspace and memory dataspace when done. November 3-5, 2009 HDF/HDF-EOS Workshop XIII 70 www.hdfgroup.org
  • 52. Example : Reading Two Rows 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 -1 -1 -1 Data in a file 4x6 matrix Buffer in memory 1-dim array of length 14 -1 -1 November 3-5, 2009 -1 -1 -1 -1 -1 HDF/HDF-EOS Workshop XIII -1 71 -1 -1 -1 www.hdfgroup.org
  • 53. Example: Reading Two Rows 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 20 21 22 23 = = = = {1,0} {2,6} {1,1} {1,1} 18 19 start count block stride 24 filespace = H5Dget_space (dataset); H5Sselect_hyperslab (filespace, H5S_SELECT_SET, start, NULL, count, NULL) November 3-5, 2009 HDF/HDF-EOS Workshop XIII 72 www.hdfgroup.org
  • 54. Example: Reading Two Rows start[1] = {1} count[1] = {12} dim[1] = {14} -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 memspace = H5Screate_simple(1, dim, NULL); H5Sselect_hyperslab (memspace, H5S_SELECT_SET, start, NULL, count, NULL) November 3-5, 2009 HDF/HDF-EOS Workshop XIII 73 www.hdfgroup.org
  • 55. Example: Reading Two Rows 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 H5Dread (…, …, memspace, filespace, …, …); -1 7 November 3-5, 2009 8 9 10 11 12 13 14 15 16 17 18 -1 HDF/HDF-EOS Workshop XIII 74 www.hdfgroup.org
  • 56. Things to Remember • Number of elements selected in a file and in a memory buffer must be the same • H5Sget_select_npoints returns number of selected elements in a hyperslab selection • HDF5 partial I/O is tuned to move data between selections that have the same dimensionality; avoid choosing subsets that have different ranks (as in example above) • Allocate a buffer of an appropriate size when reading data; use H5Tget_native_type and H5Tget_size to get the correct size of the data element in memory. November 3-5, 2009 HDF/HDF-EOS Workshop XIII 75 www.hdfgroup.org
  • 57. The HDF Group Thank You! November 3-5, 2009 HDF/HDF-EOS Workshop XIII 76 www.hdfgroup.org
  • 58. Acknowledgements This work was supported by cooperative agreement number NNX08AO77A from the National Aeronautics and Space Administration (NASA). Any opinions, findings, conclusions, or recommendations expressed in this material are those of the author[s] and do not necessarily reflect the views of the National Aeronautics and Space Administration. November 3-5, 2009 HDF/HDF-EOS Workshop XIII 77 www.hdfgroup.org
  • 59. The HDF Group Questions/comments? November 3-5, 2009 HDF/HDF-EOS Workshop XIII 78 www.hdfgroup.org

Hinweis der Redaktion

  1. Dumping DS with references may be slow since library has to dereference each element; on our to-do list
  2. H5Sselect_hyperslab: 1: dataspace identifier 2: selection operator to determine how the new selection is to be combined with the already existing selection for the dataspace. CUrrenlty on H5S_SELECT_SET operator is supported, which replaces the existing selection with the parameters from this call. Overlapping blocks are not supported with H5S_SELECT_SET. 3:start - starting coordinates. 0-beginning 4:stride: how many elements to move in each dimension. Stride of zero not supported: NULL==1 5:count: determines how many spaces to select in each dimension 6: block: determines size of the element block: if NULL then defaults to single emenet in each dimension. H5Sselect_elements: 1: dataspace identifier 2: H5S_SELECT_SET: (see above) 3:NUMP: number of elements selected 4:coord: 2-D array of size (dataspace rank0 by num_elements in szie. The order of the element coordinates in the coord array also specifies the order that the array elements are iterated when I/O is performed.