Questions About Bitfield Type

Hello, everyone.

I'm a HDF library developer. I'm trying to add support for bitfield data type to H5Tget_native_type in the library. H5Tget_native_type currently returns an error message for it. I wonder how we should interpret bitfield type. Does the byte order matter? How is it different from unsigned integer? What is its native type? Could you give me your opinions?

One suggestion among our group is to remove the byte order information and let H5Tget_native_type simply return a copy of the bitfield type. The bitfield data is a bit sequence opaque to the library. The interpretation is totally up to the user. That will change the library's current behavior.

Thanks.

Ray

I need to clarify the current design of the library. The library has predefined bitfield datatypes with byte order as below:

H5T_STD_B8BE
H5T_STD_B8LE
H5T_STD_B16BE
H5T_STD_B16LE
H5T_STD_B32BE
H5T_STD_B32LE
H5T_STD_B64BE
H5T_STD_B64LE

H5T_NATIVE_B8
H5T_NATIVE_B16
H5T_NATIVE_B32
H5T_NATIVE_B64

Internally, the library does byte order conversion between memory and file. The suggestion I mentioned earlier is to remove the byte order information and its conversion. The library will store whatever the user writes. This makes the bitfield type more like the opaque type, not like the integer type.

I hope this helps people understand the situation.

Ray

Raymond Lu wrote:

···

Hello, everyone.

I'm a HDF library developer. I'm trying to add support for bitfield data type to H5Tget_native_type in the library. H5Tget_native_type currently returns an error message for it. I wonder how we should interpret bitfield type. Does the byte order matter? How is it different from unsigned integer? What is its native type? Could you give me your opinions?

One suggestion among our group is to remove the byte order information and let H5Tget_native_type simply return a copy of the bitfield type. The bitfield data is a bit sequence opaque to the library. The interpretation is totally up to the user. That will change the library's current behavior.

Thanks.

Ray

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Hello Ray,

  I would suggest to follow the behavior of std::vector<bool> :

http://www.sgi.com/tech/stl/bit_vector.html

It should be possible to write a std::vector<bool> directly to
an HDF5 dataset and read it from there, with no data conversion
required.

cheers,
  Werner

···

On Thu, 03 Dec 2009 10:06:11 -0600, Raymond Lu <songyulu@hdfgroup.org> wrote:

Hello, everyone.

I'm a HDF library developer. I'm trying to add support for bitfield
data type to H5Tget_native_type in the library. H5Tget_native_type
currently returns an error message for it. I wonder how we should
interpret bitfield type. Does the byte order matter? How is it
different from unsigned integer? What is its native type? Could you
give me your opinions?

One suggestion among our group is to remove the byte order information
and let H5Tget_native_type simply return a copy of the bitfield type.
The bitfield data is a bit sequence opaque to the library. The
interpretation is totally up to the user. That will change the
library's current behavior.

Thanks.

Ray

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Laboratory for Creative Arts and Technology (LCAT)
Center for Computation & Technology at Louisiana State University (CCT/LSU)
211 Johnston Hall, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

A Thursday 03 December 2009 17:06:11 Raymond Lu escrigué:

Hello, everyone.

I'm a HDF library developer. I'm trying to add support for bitfield
data type to H5Tget_native_type in the library. H5Tget_native_type
currently returns an error message for it. I wonder how we should
interpret bitfield type. Does the byte order matter? How is it
different from unsigned integer? What is its native type? Could you
give me your opinions?

One suggestion among our group is to remove the byte order information
and let H5Tget_native_type simply return a copy of the bitfield type.
The bitfield data is a bit sequence opaque to the library. The
interpretation is totally up to the user. That will change the
library's current behavior.

I completely agree with this vision. So my vote is +1 here.

···

--
Francesc Alted

Hello Werner, Ray,

In the next C++ standard vector<bool> will use proper bools instead of bits.
So I think it is better not to rely on vector<bool> for bitsets.

In our software we read/write a bitset as a sequence of uchars. This is to avoid byte ordering problems.

What does bitfield support mean if it is entirely up to the user to interpret the data? In that way it is not different from a simple sequence of bytes.

Cheers,
Ger

···

On Thu, Dec 3, 2009 at 7:11 PM, in message <op.u4djhyzgzis4y7@tardis>, "Werner Benger" <werner@cct.lsu.edu> wrote:

Hello Ray,

  I would suggest to follow the behavior of std::vector<bool> :

http://www.sgi.com/tech/stl/bit_vector.html

It should be possible to write a std::vector<bool> directly to
an HDF5 dataset and read it from there, with no data conversion
required.

cheers,
  Werner

On Thu, 03 Dec 2009 10:06:11 -0600, Raymond Lu <songyulu@hdfgroup.org> wrote:

Hello, everyone.

I'm a HDF library developer. I'm trying to add support for bitfield
data type to H5Tget_native_type in the library. H5Tget_native_type
currently returns an error message for it. I wonder how we should
interpret bitfield type. Does the byte order matter? How is it
different from unsigned integer? What is its native type? Could you
give me your opinions?

One suggestion among our group is to remove the byte order information
and let H5Tget_native_type simply return a copy of the bitfield type.
The bitfield data is a bit sequence opaque to the library. The
interpretation is totally up to the user. That will change the
library's current behavior.

Thanks.

Ray

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org