From b1aefcf73a301530e354c3bdc0ad5650bda65320 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 7 Sep 2018 12:03:44 +0200 Subject: [PATCH] Integer Type System: Refactor Refactor the integer type system to support all fundamental C/C++ integer types: `short`, `int`, `long`, `long long` plus the unsigned versions of those. Fixed size ints are aliases of the above, leading to issues on OSX and MSVC since there is no fixed int alias for "long" in the old design. --- CHANGELOG.rst | 1 + examples/7_extended_write_serial.cpp | 2 +- include/openPMD/Datatype.hpp | 76 ++++--- include/openPMD/IO/ADIOS/ADIOS1Auxiliary.hpp | 24 +-- include/openPMD/IO/HDF5/HDF5Auxiliary.hpp | 94 +++++---- include/openPMD/ParticleSpecies.hpp | 4 +- include/openPMD/auxiliary/Memory.hpp | 68 +++--- include/openPMD/backend/Attribute.hpp | 20 +- src/Datatype.cpp | 60 +++--- src/IO/ADIOS/CommonADIOS1IOHandler.cpp | 210 +++++++++++-------- src/IO/HDF5/HDF5IOHandler.cpp | 142 +++++++------ src/ParticlePatches.cpp | 2 +- src/RecordComponent.cpp | 16 +- src/Series.cpp | 2 +- src/backend/Attributable.cpp | 60 +++--- src/binding/python/Attributable.cpp | 28 +-- src/binding/python/BaseRecordComponent.cpp | 24 +-- src/binding/python/Datatype.cpp | 24 +-- src/binding/python/RecordComponent.cpp | 60 +++--- test/CoreTest.cpp | 80 +++---- test/SerialIOTest.cpp | 26 +-- 21 files changed, 579 insertions(+), 444 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c8c788c448..9fb025a256 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,7 @@ Features Bug Fixes """"""""" +- Refactor integer type system #337 - ``Dataset``: ``setCompression`` warning and error logic #326 - avoid impact on unrelated classes in invasive tests #324 - Python diff --git a/examples/7_extended_write_serial.cpp b/examples/7_extended_write_serial.cpp index 30a2fe2556..3ae8304af4 100644 --- a/examples/7_extended_write_serial.cpp +++ b/examples/7_extended_write_serial.cpp @@ -142,7 +142,7 @@ write2() d = Dataset(dtype, mpiDims); electrons["positionOffset"]["x"].resetDataset(d); - Dataset dset = Dataset(Datatype::UINT64, {2}); + Dataset dset = Dataset(determineDatatype(), {2}); electrons.particlePatches["numParticles"][RecordComponent::SCALAR].resetDataset(dset); electrons.particlePatches["numParticlesOffset"][RecordComponent::SCALAR].resetDataset(dset); diff --git a/include/openPMD/Datatype.hpp b/include/openPMD/Datatype.hpp index ade7fcacb8..7413f5fb26 100644 --- a/include/openPMD/Datatype.hpp +++ b/include/openPMD/Datatype.hpp @@ -34,19 +34,21 @@ namespace openPMD */ enum class Datatype : int { - CHAR = 0, UCHAR, - INT16, INT32, INT64, - UINT16, UINT32, UINT64, + CHAR = 0, UCHAR, // SCHAR, + SHORT, INT, LONG, LONGLONG, + USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONG_DOUBLE, STRING, VEC_CHAR, - VEC_INT16, - VEC_INT32, - VEC_INT64, + VEC_SHORT, + VEC_INT, + VEC_LONG, + VEC_LONGLONG, VEC_UCHAR, - VEC_UINT16, - VEC_UINT32, - VEC_UINT64, + VEC_USHORT, + VEC_UINT, + VEC_ULONG, + VEC_ULONGLONG, VEC_FLOAT, VEC_DOUBLE, VEC_LONG_DOUBLE, @@ -111,24 +113,28 @@ determineDatatype() using DT = Datatype; if( decay_equiv< T, char >::value ){ return DT::CHAR; } if( decay_equiv< T, unsigned char >::value ){ return DT::UCHAR; } - if( decay_equiv< T, int16_t >::value ){ return DT::INT16; } - if( decay_equiv< T, int32_t >::value ){ return DT::INT32; } - if( decay_equiv< T, int64_t >::value ){ return DT::INT64; } - if( decay_equiv< T, uint16_t >::value ){ return DT::UINT16; } - if( decay_equiv< T, uint32_t >::value ){ return DT::UINT32; } - if( decay_equiv< T, uint64_t >::value ){ return DT::UINT64; } + if( decay_equiv< T, short >::value ){ return DT::SHORT; } + if( decay_equiv< T, int >::value ){ return DT::INT; } + if( decay_equiv< T, long >::value ){ return DT::LONG; } + if( decay_equiv< T, long long >::value ){ return DT::LONGLONG; } + if( decay_equiv< T, unsigned short >::value ){ return DT::USHORT; } + if( decay_equiv< T, unsigned int >::value ){ return DT::UINT; } + if( decay_equiv< T, unsigned long >::value ){ return DT::ULONG; } + if( decay_equiv< T, unsigned long long >::value ){ return DT::ULONGLONG; } if( decay_equiv< T, float >::value ){ return DT::FLOAT; } if( decay_equiv< T, double >::value ){ return DT::DOUBLE; } if( decay_equiv< T, long double >::value ){ return DT::LONG_DOUBLE; } if( decay_equiv< T, std::string >::value ){ return DT::STRING; } if( decay_equiv< T, std::vector< char > >::value ){ return DT::VEC_CHAR; } - if( decay_equiv< T, std::vector< int16_t > >::value ){ return DT::VEC_INT16; } - if( decay_equiv< T, std::vector< int32_t > >::value ){ return DT::VEC_INT32; } - if( decay_equiv< T, std::vector< int64_t > >::value ){ return DT::VEC_INT64; } + if( decay_equiv< T, std::vector< short > >::value ){ return DT::VEC_SHORT; } + if( decay_equiv< T, std::vector< int > >::value ){ return DT::VEC_INT; } + if( decay_equiv< T, std::vector< long > >::value ){ return DT::VEC_LONG; } + if( decay_equiv< T, std::vector< long long > >::value ){ return DT::VEC_LONGLONG; } if( decay_equiv< T, std::vector< unsigned char > >::value ){ return DT::VEC_UCHAR; } - if( decay_equiv< T, std::vector< uint16_t > >::value ){ return DT::VEC_UINT16; } - if( decay_equiv< T, std::vector< uint32_t > >::value ){ return DT::VEC_UINT32; } - if( decay_equiv< T, std::vector< uint64_t > >::value ){ return DT::VEC_UINT64; } + if( decay_equiv< T, std::vector< unsigned short > >::value ){ return DT::VEC_USHORT; } + if( decay_equiv< T, std::vector< unsigned int > >::value ){ return DT::VEC_UINT; } + if( decay_equiv< T, std::vector< unsigned long > >::value ){ return DT::VEC_ULONG; } + if( decay_equiv< T, std::vector< unsigned long long > >::value ){ return DT::VEC_ULONGLONG; } if( decay_equiv< T, std::vector< float > >::value ){ return DT::VEC_FLOAT; } if( decay_equiv< T, std::vector< double > >::value ){ return DT::VEC_DOUBLE; } if( decay_equiv< T, std::vector< long double > >::value ){ return DT::VEC_LONG_DOUBLE; } @@ -150,24 +156,28 @@ determineDatatype(std::shared_ptr< T >) using DT = Datatype; if( decay_equiv< T, char >::value ){ return DT::CHAR; } if( decay_equiv< T, unsigned char >::value ){ return DT::UCHAR; } - if( decay_equiv< T, int16_t >::value ){ return DT::INT16; } - if( decay_equiv< T, int32_t >::value ){ return DT::INT32; } - if( decay_equiv< T, int64_t >::value ){ return DT::INT64; } - if( decay_equiv< T, uint16_t >::value ){ return DT::UINT16; } - if( decay_equiv< T, uint32_t >::value ){ return DT::UINT32; } - if( decay_equiv< T, uint64_t >::value ){ return DT::UINT64; } + if( decay_equiv< T, short >::value ){ return DT::SHORT; } + if( decay_equiv< T, int >::value ){ return DT::INT; } + if( decay_equiv< T, long >::value ){ return DT::LONG; } + if( decay_equiv< T, long long >::value ){ return DT::LONGLONG; } + if( decay_equiv< T, unsigned short >::value ){ return DT::USHORT; } + if( decay_equiv< T, unsigned int >::value ){ return DT::UINT; } + if( decay_equiv< T, unsigned long >::value ){ return DT::ULONG; } + if( decay_equiv< T, unsigned long long >::value ){ return DT::ULONGLONG; } if( decay_equiv< T, float >::value ){ return DT::FLOAT; } if( decay_equiv< T, double >::value ){ return DT::DOUBLE; } if( decay_equiv< T, long double >::value ){ return DT::LONG_DOUBLE; } if( decay_equiv< T, std::string >::value ){ return DT::STRING; } if( decay_equiv< T, std::vector< char > >::value ){ return DT::VEC_CHAR; } - if( decay_equiv< T, std::vector< int16_t > >::value ){ return DT::VEC_INT16; } - if( decay_equiv< T, std::vector< int32_t > >::value ){ return DT::VEC_INT32; } - if( decay_equiv< T, std::vector< int64_t > >::value ){ return DT::VEC_INT64; } + if( decay_equiv< T, std::vector< short > >::value ){ return DT::VEC_SHORT; } + if( decay_equiv< T, std::vector< int > >::value ){ return DT::VEC_INT; } + if( decay_equiv< T, std::vector< long > >::value ){ return DT::VEC_LONG; } + if( decay_equiv< T, std::vector< long long > >::value ){ return DT::VEC_LONGLONG; } if( decay_equiv< T, std::vector< unsigned char > >::value ){ return DT::VEC_UCHAR; } - if( decay_equiv< T, std::vector< uint16_t > >::value ){ return DT::VEC_UINT16; } - if( decay_equiv< T, std::vector< uint32_t > >::value ){ return DT::VEC_UINT32; } - if( decay_equiv< T, std::vector< uint64_t > >::value ){ return DT::VEC_UINT64; } + if( decay_equiv< T, std::vector< unsigned short > >::value ){ return DT::VEC_USHORT; } + if( decay_equiv< T, std::vector< unsigned int > >::value ){ return DT::VEC_UINT; } + if( decay_equiv< T, std::vector< unsigned long > >::value ){ return DT::VEC_ULONG; } + if( decay_equiv< T, std::vector< unsigned long long > >::value ){ return DT::VEC_ULONGLONG; } if( decay_equiv< T, std::vector< float > >::value ){ return DT::VEC_FLOAT; } if( decay_equiv< T, std::vector< double > >::value ){ return DT::VEC_DOUBLE; } if( decay_equiv< T, std::vector< long double > >::value ){ return DT::VEC_LONG_DOUBLE; } diff --git a/include/openPMD/IO/ADIOS/ADIOS1Auxiliary.hpp b/include/openPMD/IO/ADIOS/ADIOS1Auxiliary.hpp index 02fc5e5995..7af448d5c7 100644 --- a/include/openPMD/IO/ADIOS/ADIOS1Auxiliary.hpp +++ b/include/openPMD/IO/ADIOS/ADIOS1Auxiliary.hpp @@ -87,23 +87,23 @@ getBP1DataType(Datatype dtype) case DT::VEC_UCHAR: case DT::BOOL: return adios_unsigned_byte; - case DT::INT16: - case DT::VEC_INT16: + case DT::SHORT: + case DT::VEC_SHORT: return adios_short; - case DT::INT32: - case DT::VEC_INT32: + case DT::INT: + case DT::VEC_INT: return adios_integer; - case DT::INT64: - case DT::VEC_INT64: + case DT::LONG: + case DT::VEC_LONG: return adios_long; - case DT::UINT16: - case DT::VEC_UINT16: + case DT::USHORT: + case DT::VEC_USHORT: return adios_unsigned_short; - case DT::UINT32: - case DT::VEC_UINT32: + case DT::UINT: + case DT::VEC_UINT: return adios_unsigned_integer; - case DT::UINT64: - case DT::VEC_UINT64: + case DT::ULONG: + case DT::VEC_ULONG: return adios_unsigned_long; case DT::FLOAT: case DT::VEC_FLOAT: diff --git a/include/openPMD/IO/HDF5/HDF5Auxiliary.hpp b/include/openPMD/IO/HDF5/HDF5Auxiliary.hpp index ce7553543e..ab9cfb6a5c 100644 --- a/include/openPMD/IO/HDF5/HDF5Auxiliary.hpp +++ b/include/openPMD/IO/HDF5/HDF5Auxiliary.hpp @@ -44,24 +44,30 @@ getH5DataType(Attribute const& att) case DT::UCHAR: case DT::VEC_UCHAR: return H5Tcopy(H5T_NATIVE_UCHAR); - case DT::INT16: - case DT::VEC_INT16: - return H5Tcopy(H5T_NATIVE_INT16); - case DT::INT32: - case DT::VEC_INT32: - return H5Tcopy(H5T_NATIVE_INT32); - case DT::INT64: - case DT::VEC_INT64: - return H5Tcopy(H5T_NATIVE_INT64); - case DT::UINT16: - case DT::VEC_UINT16: - return H5Tcopy(H5T_NATIVE_UINT16); - case DT::UINT32: - case DT::VEC_UINT32: - return H5Tcopy(H5T_NATIVE_UINT32); - case DT::UINT64: - case DT::VEC_UINT64: - return H5Tcopy(H5T_NATIVE_UINT64); + case DT::SHORT: + case DT::VEC_SHORT: + return H5Tcopy(H5T_NATIVE_SHORT); + case DT::INT: + case DT::VEC_INT: + return H5Tcopy(H5T_NATIVE_INT); + case DT::LONG: + case DT::VEC_LONG: + return H5Tcopy(H5T_NATIVE_LONG); + case DT::LONGLONG: + case DT::VEC_LONGLONG: + return H5Tcopy(H5T_NATIVE_LLONG); + case DT::USHORT: + case DT::VEC_USHORT: + return H5Tcopy(H5T_NATIVE_USHORT); + case DT::UINT: + case DT::VEC_UINT: + return H5Tcopy(H5T_NATIVE_UINT); + case DT::ULONG: + case DT::VEC_ULONG: + return H5Tcopy(H5T_NATIVE_ULONG); + case DT::ULONGLONG: + case DT::VEC_ULONGLONG: + return H5Tcopy(H5T_NATIVE_ULLONG); case DT::FLOAT: case DT::VEC_FLOAT: return H5Tcopy(H5T_NATIVE_FLOAT); @@ -106,12 +112,14 @@ getH5DataSpace(Attribute const& att) { case DT::CHAR: case DT::UCHAR: - case DT::INT16: - case DT::INT32: - case DT::INT64: - case DT::UINT16: - case DT::UINT32: - case DT::UINT64: + case DT::SHORT: + case DT::INT: + case DT::LONG: + case DT::LONGLONG: + case DT::USHORT: + case DT::UINT: + case DT::ULONG: + case DT::ULONGLONG: case DT::FLOAT: case DT::DOUBLE: case DT::LONG_DOUBLE: @@ -125,24 +133,31 @@ getH5DataSpace(Attribute const& att) H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); return vec_t_id; } - case DT::VEC_INT16: + case DT::VEC_SHORT: { hid_t vec_t_id = H5Screate(H5S_SIMPLE); - hsize_t dims[1] = {att.get< std::vector< int16_t > >().size()}; + hsize_t dims[1] = {att.get< std::vector< short > >().size()}; H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); return vec_t_id; } - case DT::VEC_INT32: + case DT::VEC_INT: { hid_t vec_t_id = H5Screate(H5S_SIMPLE); - hsize_t dims[1] = {att.get< std::vector< int32_t > >().size()}; + hsize_t dims[1] = {att.get< std::vector< int > >().size()}; H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); return vec_t_id; } - case DT::VEC_INT64: + case DT::VEC_LONG: { hid_t vec_t_id = H5Screate(H5S_SIMPLE); - hsize_t dims[1] = {att.get< std::vector< int64_t > >().size()}; + hsize_t dims[1] = {att.get< std::vector< long > >().size()}; + H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); + return vec_t_id; + } + case DT::VEC_LONGLONG: + { + hid_t vec_t_id = H5Screate(H5S_SIMPLE); + hsize_t dims[1] = {att.get< std::vector< long long > >().size()}; H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); return vec_t_id; } @@ -153,24 +168,31 @@ getH5DataSpace(Attribute const& att) H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); return vec_t_id; } - case DT::VEC_UINT16: + case DT::VEC_USHORT: + { + hid_t vec_t_id = H5Screate(H5S_SIMPLE); + hsize_t dims[1] = {att.get< std::vector< unsigned short > >().size()}; + H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); + return vec_t_id; + } + case DT::VEC_UINT: { hid_t vec_t_id = H5Screate(H5S_SIMPLE); - hsize_t dims[1] = {att.get< std::vector< uint16_t > >().size()}; + hsize_t dims[1] = {att.get< std::vector< unsigned int > >().size()}; H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); return vec_t_id; } - case DT::VEC_UINT32: + case DT::VEC_ULONG: { hid_t vec_t_id = H5Screate(H5S_SIMPLE); - hsize_t dims[1] = {att.get< std::vector< uint32_t > >().size()}; + hsize_t dims[1] = {att.get< std::vector< unsigned long > >().size()}; H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); return vec_t_id; } - case DT::VEC_UINT64: + case DT::VEC_ULONGLONG: { hid_t vec_t_id = H5Screate(H5S_SIMPLE); - hsize_t dims[1] = {att.get< std::vector< uint64_t > >().size()}; + hsize_t dims[1] = {att.get< std::vector< unsigned long long > >().size()}; H5Sset_extent_simple(vec_t_id, 1, dims, nullptr); return vec_t_id; } diff --git a/include/openPMD/ParticleSpecies.hpp b/include/openPMD/ParticleSpecies.hpp index 9fb6891f63..ff073d2f86 100644 --- a/include/openPMD/ParticleSpecies.hpp +++ b/include/openPMD/ParticleSpecies.hpp @@ -62,11 +62,11 @@ namespace traits auto& np = ret.particlePatches["numParticles"]; auto& npc = np[RecordComponent::SCALAR]; - npc.resetDataset(Dataset(Datatype::UINT64, {1})); + npc.resetDataset(Dataset(determineDatatype(), {1})); npc.parent = np.parent; auto& npo = ret.particlePatches["numParticlesOffset"]; auto& npoc = npo[RecordComponent::SCALAR]; - npoc.resetDataset(Dataset(Datatype::UINT64, {1})); + npoc.resetDataset(Dataset(determineDatatype(), {1})); npoc.parent = npo.parent; } }; diff --git a/include/openPMD/auxiliary/Memory.hpp b/include/openPMD/auxiliary/Memory.hpp index 49a02078df..5fd6333f1e 100644 --- a/include/openPMD/auxiliary/Memory.hpp +++ b/include/openPMD/auxiliary/Memory.hpp @@ -75,35 +75,45 @@ allocatePtr(Datatype dtype, uint64_t numPoints) data = new float[numPoints]; del = [](void* p){ delete[] static_cast< float* >(p); }; break; - case DT::VEC_INT16: - case DT::INT16: - data = new int16_t[numPoints]; - del = [](void* p){ delete[] static_cast< int16_t* >(p); }; - break; - case DT::VEC_INT32: - case DT::INT32: - data = new int32_t[numPoints]; - del = [](void* p){ delete[] static_cast< int32_t* >(p); }; - break; - case DT::VEC_INT64: - case DT::INT64: - data = new int64_t[numPoints]; - del = [](void* p){ delete[] static_cast< int64_t* >(p); }; - break; - case DT::VEC_UINT16: - case DT::UINT16: - data = new uint16_t[numPoints]; - del = [](void* p){ delete[] static_cast< uint16_t* >(p); }; - break; - case DT::VEC_UINT32: - case DT::UINT32: - data = new uint32_t[numPoints]; - del = [](void* p){ delete[] static_cast< uint32_t* >(p); }; - break; - case DT::VEC_UINT64: - case DT::UINT64: - data = new uint64_t[numPoints]; - del = [](void* p){ delete[] static_cast< uint64_t* >(p); }; + case DT::VEC_SHORT: + case DT::SHORT: + data = new short[numPoints]; + del = [](void* p){ delete[] static_cast< short* >(p); }; + break; + case DT::VEC_INT: + case DT::INT: + data = new int[numPoints]; + del = [](void* p){ delete[] static_cast< int* >(p); }; + break; + case DT::VEC_LONG: + case DT::LONG: + data = new long[numPoints]; + del = [](void* p){ delete[] static_cast< long* >(p); }; + break; + case DT::VEC_LONGLONG: + case DT::LONGLONG: + data = new long long[numPoints]; + del = [](void* p){ delete[] static_cast< long long* >(p); }; + break; + case DT::VEC_USHORT: + case DT::USHORT: + data = new unsigned short[numPoints]; + del = [](void* p){ delete[] static_cast< unsigned short* >(p); }; + break; + case DT::VEC_UINT: + case DT::UINT: + data = new unsigned int[numPoints]; + del = [](void* p){ delete[] static_cast< unsigned int* >(p); }; + break; + case DT::VEC_ULONG: + case DT::ULONG: + data = new unsigned long[numPoints]; + del = [](void* p){ delete[] static_cast< unsigned long* >(p); }; + break; + case DT::VEC_ULONGLONG: + case DT::ULONGLONG: + data = new unsigned long long[numPoints]; + del = [](void* p){ delete[] static_cast< unsigned long long* >(p); }; break; case DT::VEC_CHAR: case DT::CHAR: diff --git a/include/openPMD/backend/Attribute.hpp b/include/openPMD/backend/Attribute.hpp index 77e26aca32..f25b463059 100644 --- a/include/openPMD/backend/Attribute.hpp +++ b/include/openPMD/backend/Attribute.hpp @@ -42,19 +42,21 @@ namespace openPMD * modifications to Datatype. */ using Attribute = auxiliary::Variant< Datatype, - char, unsigned char, - int16_t, int32_t, int64_t, - uint16_t, uint32_t, uint64_t, + char, unsigned char, // signed char, + short, int, long, long long, + unsigned short, unsigned int, unsigned long, unsigned long long, float, double, long double, std::string, std::vector< char >, - std::vector< int16_t >, - std::vector< int32_t >, - std::vector< int64_t >, + std::vector< short >, + std::vector< int >, + std::vector< long >, + std::vector< long long >, std::vector< unsigned char >, - std::vector< uint16_t >, - std::vector< uint32_t >, - std::vector< uint64_t >, + std::vector< unsigned short >, + std::vector< unsigned int >, + std::vector< unsigned long >, + std::vector< unsigned long long >, std::vector< float >, std::vector< double >, std::vector< long double >, diff --git a/src/Datatype.cpp b/src/Datatype.cpp index 385925c4c4..60384cc4bc 100644 --- a/src/Datatype.cpp +++ b/src/Datatype.cpp @@ -35,23 +35,29 @@ std::operator<<(std::ostream& os, openPMD::Datatype d) case DT::UCHAR: os << "UCHAR"; break; - case DT::INT16: - os << "INT16"; + case DT::SHORT: + os << "SHORT"; break; - case DT::INT32: - os << "INT32"; + case DT::INT: + os << "INT"; break; - case DT::INT64: - os << "INT64"; + case DT::LONG: + os << "LONG"; break; - case DT::UINT16: - os << "UINT16"; + case DT::LONGLONG: + os << "LONGLONG"; break; - case DT::UINT32: - os << "UINT32"; + case DT::USHORT: + os << "USHORT"; break; - case DT::UINT64: - os << "UINT64"; + case DT::UINT: + os << "UINT"; + break; + case DT::ULONG: + os << "ULONG"; + break; + case DT::ULONGLONG: + os << "ULONGLONG"; break; case DT::FLOAT: os << "FLOAT"; @@ -68,26 +74,32 @@ std::operator<<(std::ostream& os, openPMD::Datatype d) case DT::VEC_CHAR: os << "VEC_CHAR"; break; - case DT::VEC_INT16: - os << "VEC_INT16"; + case DT::VEC_SHORT: + os << "VEC_SHORT"; break; - case DT::VEC_INT32: - os << "VEC_INT32"; + case DT::VEC_INT: + os << "VEC_INT"; break; - case DT::VEC_INT64: - os << "VEC_INT64"; + case DT::VEC_LONG: + os << "VEC_LONG"; + break; + case DT::VEC_LONGLONG: + os << "VEC_LONGLONG"; break; case DT::VEC_UCHAR: os << "VEC_UCHAR"; break; - case DT::VEC_UINT16: - os << "VEC_UINT16"; + case DT::VEC_USHORT: + os << "VEC_USHORT"; + break; + case DT::VEC_UINT: + os << "VEC_UINT"; break; - case DT::VEC_UINT32: - os << "VEC_UINT32"; + case DT::VEC_ULONG: + os << "VEC_ULONG"; break; - case DT::VEC_UINT64: - os << "VEC_UINT64"; + case DT::VEC_ULONGLONG: + os << "VEC_ULONGLONG"; break; case DT::VEC_FLOAT: os << "VEC_FLOAT"; diff --git a/src/IO/ADIOS/CommonADIOS1IOHandler.cpp b/src/IO/ADIOS/CommonADIOS1IOHandler.cpp index b5accbcbf0..5c34c9715d 100644 --- a/src/IO/ADIOS/CommonADIOS1IOHandler.cpp +++ b/src/IO/ADIOS/CommonADIOS1IOHandler.cpp @@ -46,27 +46,31 @@ CommonADIOS1IOHandlerImpl::flush_attribute(int64_t group, std::string const& nam case DT::VEC_CHAR: nelems = att.get< std::vector< char > >().size(); break; - case DT::VEC_INT16: - nelems = att.get< std::vector< int16_t > >().size(); + case DT::VEC_SHORT: + nelems = att.get< std::vector< short > >().size(); break; - case DT::VEC_INT32: - nelems = att.get< std::vector< int32_t > >().size(); + case DT::VEC_INT: + nelems = att.get< std::vector< int > >().size(); break; - case DT::VEC_INT64: - nelems = att.get< std::vector< int64_t > >().size(); + case DT::VEC_LONG: + nelems = att.get< std::vector< long > >().size(); break; + // no adios_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case DT::VEC_UCHAR: nelems = att.get< std::vector< unsigned char > >().size(); break; - case DT::VEC_UINT16: - nelems = att.get< std::vector< uint16_t > >().size(); + case DT::VEC_USHORT: + nelems = att.get< std::vector< unsigned short > >().size(); break; - case DT::VEC_UINT32: - nelems = att.get< std::vector< uint32_t > >().size(); + case DT::VEC_UINT: + nelems = att.get< std::vector< unsigned int > >().size(); break; - case DT::VEC_UINT64: - nelems = att.get< std::vector< uint64_t > >().size(); + case DT::VEC_ULONG: + nelems = att.get< std::vector< unsigned long > >().size(); break; + // no adios_unsigned_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case DT::VEC_FLOAT: nelems = att.get< std::vector< float > >().size(); break; @@ -105,42 +109,46 @@ CommonADIOS1IOHandlerImpl::flush_attribute(int64_t group, std::string const& nam *ptr = att.get< unsigned char >(); break; } - case DT::INT16: + case DT::SHORT: { - auto ptr = reinterpret_cast< int16_t* >(values.get()); - *ptr = att.get< int16_t >(); + auto ptr = reinterpret_cast< short* >(values.get()); + *ptr = att.get< short >(); break; } - case DT::INT32: + case DT::INT: { - auto ptr = reinterpret_cast< int32_t* >(values.get()); - *ptr = att.get< int32_t >(); + auto ptr = reinterpret_cast< int* >(values.get()); + *ptr = att.get< int >(); break; } - case DT::INT64: + case DT::LONG: { - auto ptr = reinterpret_cast< int64_t* >(values.get()); - *ptr = att.get< int64_t >(); + auto ptr = reinterpret_cast< long* >(values.get()); + *ptr = att.get< long >(); break; } - case DT::UINT16: + // no adios_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 + case DT::USHORT: { - auto ptr = reinterpret_cast< uint16_t* >(values.get()); + auto ptr = reinterpret_cast< unsigned short* >(values.get()); *ptr = att.get< uint16_t >(); break; } - case DT::UINT32: + case DT::UINT: { - auto ptr = reinterpret_cast< uint32_t* >(values.get()); - *ptr = att.get< uint32_t >(); + auto ptr = reinterpret_cast< unsigned int* >(values.get()); + *ptr = att.get< unsigned int >(); break; } - case DT::UINT64: + case DT::ULONG: { - auto ptr = reinterpret_cast< uint64_t* >(values.get()); - *ptr = att.get< uint64_t >(); + auto ptr = reinterpret_cast< unsigned long* >(values.get()); + *ptr = att.get< unsigned long >(); break; } + // no adios_unsigned_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case DT::FLOAT: { auto ptr = reinterpret_cast< float* >(values.get()); @@ -174,30 +182,32 @@ CommonADIOS1IOHandlerImpl::flush_attribute(int64_t group, std::string const& nam ptr[i] = vec[i]; break; } - case DT::VEC_INT16: + case DT::VEC_SHORT: { - auto ptr = reinterpret_cast< int16_t* >(values.get()); - auto const& vec = att.get< std::vector< int16_t > >(); + auto ptr = reinterpret_cast< short* >(values.get()); + auto const& vec = att.get< std::vector< short > >(); for( size_t i = 0; i < vec.size(); ++i ) ptr[i] = vec[i]; break; } - case DT::VEC_INT32: + case DT::VEC_INT: { - auto ptr = reinterpret_cast< int32_t* >(values.get()); - auto const& vec = att.get< std::vector< int32_t > >(); + auto ptr = reinterpret_cast< int* >(values.get()); + auto const& vec = att.get< std::vector< int > >(); for( size_t i = 0; i < vec.size(); ++i ) ptr[i] = vec[i]; break; } - case DT::VEC_INT64: + case DT::VEC_LONG: { - auto ptr = reinterpret_cast< int64_t* >(values.get()); - auto const& vec = att.get< std::vector< int64_t > >(); + auto ptr = reinterpret_cast< long* >(values.get()); + auto const& vec = att.get< std::vector< long > >(); for( size_t i = 0; i < vec.size(); ++i ) ptr[i] = vec[i]; break; } + // no adios_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case DT::VEC_UCHAR: { auto ptr = reinterpret_cast< unsigned char* >(values.get()); @@ -206,30 +216,32 @@ CommonADIOS1IOHandlerImpl::flush_attribute(int64_t group, std::string const& nam ptr[i] = vec[i]; break; } - case DT::VEC_UINT16: + case DT::VEC_USHORT: { - auto ptr = reinterpret_cast< uint16_t* >(values.get()); - auto const& vec = att.get< std::vector< uint16_t > >(); + auto ptr = reinterpret_cast< unsigned short* >(values.get()); + auto const& vec = att.get< std::vector< unsigned short > >(); for( size_t i = 0; i < vec.size(); ++i ) ptr[i] = vec[i]; break; } - case DT::VEC_UINT32: + case DT::VEC_UINT: { - auto ptr = reinterpret_cast< uint32_t* >(values.get()); - auto const& vec = att.get< std::vector< uint32_t > >(); + auto ptr = reinterpret_cast< unsigned int* >(values.get()); + auto const& vec = att.get< std::vector< unsigned int > >(); for( size_t i = 0; i < vec.size(); ++i ) ptr[i] = vec[i]; break; } - case DT::VEC_UINT64: + case DT::VEC_ULONG: { - auto ptr = reinterpret_cast< uint64_t* >(values.get()); - auto const& vec = att.get< std::vector< uint64_t > >(); + auto ptr = reinterpret_cast< unsigned long* >(values.get()); + auto const& vec = att.get< std::vector< unsigned long > >(); for( size_t i = 0; i < vec.size(); ++i ) ptr[i] = vec[i]; break; } + // no adios_unsigned_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case DT::VEC_FLOAT: { auto ptr = reinterpret_cast< float* >(values.get()); @@ -540,26 +552,30 @@ CommonADIOS1IOHandlerImpl::openDataset(Writable* writable, dtype = DT::CHAR; break; case adios_short: - dtype = DT::INT16; + dtype = DT::SHORT; break; case adios_integer: - dtype = DT::INT32; + dtype = DT::INT; break; case adios_long: - dtype = DT::INT64; + dtype = DT::LONG; break; + // no adios_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case adios_unsigned_byte: dtype = DT::UCHAR; break; case adios_unsigned_short: - dtype = DT::UINT16; + dtype = DT::USHORT; break; case adios_unsigned_integer: - dtype = DT::UINT32; + dtype = DT::UINT; break; case adios_unsigned_long: - dtype = DT::UINT64; + dtype = DT::ULONG; break; + // no adios_unsigned_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case adios_real: dtype = DT::FLOAT; break; @@ -723,16 +739,20 @@ CommonADIOS1IOHandlerImpl::readDataset(Writable* writable, using DT = Datatype; case DT::DOUBLE: case DT::FLOAT: - case DT::INT16: - case DT::INT32: - case DT::INT64: - case DT::UINT16: - case DT::UINT32: - case DT::UINT64: + case DT::SHORT: + case DT::INT: + case DT::LONG: + case DT::USHORT: + case DT::UINT: + case DT::ULONG: case DT::CHAR: case DT::UCHAR: case DT::BOOL: break; + case DT::LONGLONG: + throw std::runtime_error("ADIOS1 does not implement 'long long'"); + case DT::ULONGLONG: + throw std::runtime_error("ADIOS1 does not implement 'unsigned long long'"); case DT::UNDEFINED: throw std::runtime_error("Unknown Attribute datatype (ADIOS1 Dataset read)"); case DT::DATATYPE: @@ -808,6 +828,8 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, case adios_long: size /= 8; break; + // no adios_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case adios_unsigned_byte: break; case adios_unsigned_short: @@ -819,6 +841,8 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, case adios_unsigned_long: size /= 8; break; + // no adios_unsigned_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case adios_real: size /= 4; break; @@ -852,33 +876,37 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, a = Attribute(*reinterpret_cast< char* >(data)); break; case adios_short: - dtype = DT::INT16; - a = Attribute(*reinterpret_cast< int16_t* >(data)); + dtype = DT::SHORT; + a = Attribute(*reinterpret_cast< short* >(data)); break; case adios_integer: - dtype = DT::INT32; - a = Attribute(*reinterpret_cast< int32_t* >(data)); + dtype = DT::INT; + a = Attribute(*reinterpret_cast< int* >(data)); break; case adios_long: - dtype = DT::INT64; - a = Attribute(*reinterpret_cast< int64_t* >(data)); + dtype = DT::LONG; + a = Attribute(*reinterpret_cast< long* >(data)); break; + // no adios_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case adios_unsigned_byte: dtype = DT::UCHAR; a = Attribute(*reinterpret_cast< unsigned char* >(data)); break; case adios_unsigned_short: - dtype = DT::UINT16; - a = Attribute(*reinterpret_cast< uint16_t* >(data)); + dtype = DT::USHORT; + a = Attribute(*reinterpret_cast< unsigned short* >(data)); break; case adios_unsigned_integer: - dtype = DT::UINT32; - a = Attribute(*reinterpret_cast< uint32_t* >(data)); + dtype = DT::UINT; + a = Attribute(*reinterpret_cast< unsigned int* >(data)); break; case adios_unsigned_long: - dtype = DT::UINT64; - a = Attribute(*reinterpret_cast< uint64_t* >(data)); + dtype = DT::ULONG; + a = Attribute(*reinterpret_cast< unsigned long* >(data)); break; + // no adios_unsigned_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case adios_real: dtype = DT::FLOAT; a = Attribute(*reinterpret_cast< float* >(data)); @@ -925,9 +953,9 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, } case adios_short: { - dtype = DT::VEC_INT16; - auto i16 = reinterpret_cast< int16_t* >(data); - std::vector< int16_t > vi; + dtype = DT::VEC_SHORT; + auto i16 = reinterpret_cast< short* >(data); + std::vector< short > vi; vi.resize(size); for( int i = 0; i < size; ++i ) vi[i] = i16[i]; @@ -936,9 +964,9 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, } case adios_integer: { - dtype = DT::VEC_INT32; - auto i32 = reinterpret_cast< int32_t* >(data); - std::vector< int32_t > vi; + dtype = DT::VEC_INT; + auto i32 = reinterpret_cast< int* >(data); + std::vector< int > vi; vi.resize(size); for( int i = 0; i < size; ++i ) vi[i] = i32[i]; @@ -947,15 +975,17 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, } case adios_long: { - dtype = DT::VEC_INT64; - auto i64 = reinterpret_cast< int64_t* >(data); - std::vector< int64_t > vi; + dtype = DT::VEC_LONG; + auto i64 = reinterpret_cast< long* >(data); + std::vector< long > vi; vi.resize(size); for( int i = 0; i < size; ++i ) vi[i] = i64[i]; a = Attribute(vi); break; } + // no adios_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case adios_unsigned_byte: { dtype = DT::VEC_UCHAR; @@ -969,9 +999,9 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, } case adios_unsigned_short: { - dtype = DT::VEC_UINT16; - auto ui16 = reinterpret_cast< uint16_t* >(data); - std::vector< uint16_t > vi; + dtype = DT::VEC_USHORT; + auto ui16 = reinterpret_cast< unsigned short* >(data); + std::vector< unsigned short > vi; vi.resize(size); for( int i = 0; i < size; ++i ) vi[i] = ui16[i]; @@ -980,9 +1010,9 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, } case adios_unsigned_integer: { - dtype = DT::VEC_UINT32; - auto ui32 = reinterpret_cast< uint32_t* >(data); - std::vector< uint32_t > vi; + dtype = DT::VEC_UINT; + auto ui32 = reinterpret_cast< unsigned int* >(data); + std::vector< unsigned int > vi; vi.resize(size); for( int i = 0; i < size; ++i ) vi[i] = ui32[i]; @@ -991,15 +1021,17 @@ CommonADIOS1IOHandlerImpl::readAttribute(Writable* writable, } case adios_unsigned_long: { - dtype = DT::VEC_UINT64; - auto ui64 = reinterpret_cast< uint64_t* >(data); - std::vector< uint64_t > vi; + dtype = DT::VEC_ULONG; + auto ui64 = reinterpret_cast< unsigned long* >(data); + std::vector< unsigned long > vi; vi.resize(size); for( int i = 0; i < size; ++i ) vi[i] = ui64[i]; a = Attribute(vi); break; } + // no adios_unsigned_long_long in ADIOS 1.13.1 + // https://github.com/ornladios/ADIOS/issues/187 case adios_real: { dtype = DT::VEC_FLOAT; diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index fda35c1187..59e1c4cf67 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -448,22 +448,22 @@ HDF5IOHandlerImpl::openDataset(Writable* writable, d = DT::CHAR; else if( H5Tequal(dataset_type, H5T_NATIVE_UCHAR) ) d = DT::UCHAR; - else if( H5Tequal(dataset_type, H5T_NATIVE_INT16) ) - d = DT::INT16; - else if( H5Tequal(dataset_type, H5T_NATIVE_INT32) ) - d = DT::INT32; - else if( H5Tequal(dataset_type, H5T_NATIVE_INT64) ) - d = DT::INT64; + else if( H5Tequal(dataset_type, H5T_NATIVE_SHORT) ) + d = DT::SHORT; + else if( H5Tequal(dataset_type, H5T_NATIVE_INT) ) + d = DT::INT; + else if( H5Tequal(dataset_type, H5T_NATIVE_LONG) ) + d = DT::LONG; else if( H5Tequal(dataset_type, H5T_NATIVE_FLOAT) ) d = DT::FLOAT; else if( H5Tequal(dataset_type, H5T_NATIVE_DOUBLE) ) d = DT::DOUBLE; - else if( H5Tequal(dataset_type, H5T_NATIVE_UINT16) ) - d = DT::UINT16; - else if( H5Tequal(dataset_type, H5T_NATIVE_UINT32) ) - d = DT::UINT32; - else if( H5Tequal(dataset_type, H5T_NATIVE_UINT64) ) - d = DT::UINT64; + else if( H5Tequal(dataset_type, H5T_NATIVE_USHORT) ) + d = DT::USHORT; + else if( H5Tequal(dataset_type, H5T_NATIVE_UINT) ) + d = DT::UINT; + else if( H5Tequal(dataset_type, H5T_NATIVE_ULONG) ) + d = DT::ULONG; else if( H5Tget_class(dataset_type) == H5T_STRING ) d = DT::STRING; else @@ -698,12 +698,12 @@ HDF5IOHandlerImpl::writeDataset(Writable* writable, using DT = Datatype; case DT::DOUBLE: case DT::FLOAT: - case DT::INT16: - case DT::INT32: - case DT::INT64: - case DT::UINT16: - case DT::UINT32: - case DT::UINT64: + case DT::SHORT: + case DT::INT: + case DT::LONG: + case DT::USHORT: + case DT::UINT: + case DT::ULONG: case DT::CHAR: case DT::UCHAR: case DT::BOOL: @@ -795,39 +795,51 @@ HDF5IOHandlerImpl::writeAttribute(Writable* writable, status = H5Awrite(attribute_id, dataType, &u); break; } - case DT::INT16: + case DT::SHORT: { - int16_t i = att.get< int16_t >(); + short i = att.get< short >(); status = H5Awrite(attribute_id, dataType, &i); break; } - case DT::INT32: + case DT::INT: { - int32_t i = att.get< int32_t >(); + int i = att.get< int >(); status = H5Awrite(attribute_id, dataType, &i); break; } - case DT::INT64: + case DT::LONG: { - int64_t i = att.get< int64_t >(); + long i = att.get< long >(); status = H5Awrite(attribute_id, dataType, &i); break; } - case DT::UINT16: + case DT::LONGLONG: { - uint16_t u = att.get< uint16_t >(); + long long i = att.get< long long >(); + status = H5Awrite(attribute_id, dataType, &i); + break; + } + case DT::USHORT: + { + unsigned short u = att.get< unsigned short >(); + status = H5Awrite(attribute_id, dataType, &u); + break; + } + case DT::UINT: + { + unsigned int u = att.get< unsigned int >(); status = H5Awrite(attribute_id, dataType, &u); break; } - case DT::UINT32: + case DT::ULONG: { - uint32_t u = att.get< uint32_t >(); + unsigned long u = att.get< unsigned long >(); status = H5Awrite(attribute_id, dataType, &u); break; } - case DT::UINT64: + case DT::ULONGLONG: { - uint64_t u = att.get< uint64_t >(); + unsigned long u = att.get< unsigned long >(); status = H5Awrite(attribute_id, dataType, &u); break; } @@ -859,40 +871,50 @@ HDF5IOHandlerImpl::writeAttribute(Writable* writable, dataType, att.get< std::vector< char > >().data()); break; - case DT::VEC_INT16: + case DT::VEC_SHORT: + status = H5Awrite(attribute_id, + dataType, + att.get< std::vector< short > >().data()); + break; + case DT::VEC_INT: status = H5Awrite(attribute_id, dataType, - att.get< std::vector< int16_t > >().data()); + att.get< std::vector< int > >().data()); break; - case DT::VEC_INT32: + case DT::VEC_LONG: status = H5Awrite(attribute_id, dataType, - att.get< std::vector< int32_t > >().data()); + att.get< std::vector< long > >().data()); break; - case DT::VEC_INT64: + case DT::VEC_LONGLONG: status = H5Awrite(attribute_id, dataType, - att.get< std::vector< int64_t > >().data()); + att.get< std::vector< long long > >().data()); break; case DT::VEC_UCHAR: status = H5Awrite(attribute_id, dataType, att.get< std::vector< unsigned char > >().data()); break; - case DT::VEC_UINT16: + case DT::VEC_USHORT: + status = H5Awrite(attribute_id, + dataType, + att.get< std::vector< unsigned short > >().data()); + break; + case DT::VEC_UINT: status = H5Awrite(attribute_id, dataType, - att.get< std::vector< uint16_t > >().data()); + att.get< std::vector< unsigned int > >().data()); break; - case DT::VEC_UINT32: + case DT::VEC_ULONG: status = H5Awrite(attribute_id, dataType, - att.get< std::vector< uint32_t > >().data()); + att.get< std::vector< unsigned long > >().data()); break; - case DT::VEC_UINT64: + case DT::VEC_ULONGLONG: status = H5Awrite(attribute_id, dataType, - att.get< std::vector< uint64_t > >().data()); + att.get< std::vector< unsigned long long > >().data()); break; case DT::VEC_FLOAT: status = H5Awrite(attribute_id, @@ -995,12 +1017,12 @@ HDF5IOHandlerImpl::readDataset(Writable* writable, using DT = Datatype; case DT::DOUBLE: case DT::FLOAT: - case DT::INT16: - case DT::INT32: - case DT::INT64: - case DT::UINT16: - case DT::UINT32: - case DT::UINT64: + case DT::SHORT: + case DT::INT: + case DT::LONG: + case DT::USHORT: + case DT::UINT: + case DT::ULONG: case DT::CHAR: case DT::UCHAR: case DT::BOOL: @@ -1083,42 +1105,42 @@ HDF5IOHandlerImpl::readAttribute(Writable* writable, attr_type, &u); a = Attribute(u); - } else if( H5Tequal(attr_type, H5T_NATIVE_INT16) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_SHORT) ) { int16_t i; status = H5Aread(attr_id, attr_type, &i); a = Attribute(i); - } else if( H5Tequal(attr_type, H5T_NATIVE_INT32) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_INT) ) { int32_t i; status = H5Aread(attr_id, attr_type, &i); a = Attribute(i); - } else if( H5Tequal(attr_type, H5T_NATIVE_INT64) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_LONG) ) { int64_t i; status = H5Aread(attr_id, attr_type, &i); a = Attribute(i); - } else if( H5Tequal(attr_type, H5T_NATIVE_UINT16) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_USHORT) ) { uint16_t u; status = H5Aread(attr_id, attr_type, &u); a = Attribute(u); - } else if( H5Tequal(attr_type, H5T_NATIVE_UINT32) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_UINT) ) { uint32_t u; status = H5Aread(attr_id, attr_type, &u); a = Attribute(u); - } else if( H5Tequal(attr_type, H5T_NATIVE_UINT64) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_ULONG) ) { uint64_t u; status = H5Aread(attr_id, @@ -1213,42 +1235,42 @@ HDF5IOHandlerImpl::readAttribute(Writable* writable, attr_type, vu.data()); a = Attribute(vu); - } else if( H5Tequal(attr_type, H5T_NATIVE_INT16) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_SHORT) ) { std::vector< int16_t > vint16(dims[0], 0); status = H5Aread(attr_id, attr_type, vint16.data()); a = Attribute(vint16); - } else if( H5Tequal(attr_type, H5T_NATIVE_INT32) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_INT) ) { std::vector< int32_t > vint32(dims[0], 0); status = H5Aread(attr_id, attr_type, vint32.data()); a = Attribute(vint32); - } else if( H5Tequal(attr_type, H5T_NATIVE_INT64) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_LONG) ) { std::vector< int64_t > vint64(dims[0], 0); status = H5Aread(attr_id, attr_type, vint64.data()); a = Attribute(vint64); - } else if( H5Tequal(attr_type, H5T_NATIVE_UINT16) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_USHORT) ) { std::vector< uint16_t > vuint16(dims[0], 0); status = H5Aread(attr_id, attr_type, vuint16.data()); a = Attribute(vuint16); - } else if( H5Tequal(attr_type, H5T_NATIVE_UINT32) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_UINT) ) { std::vector< uint32_t > vuint32(dims[0], 0); status = H5Aread(attr_id, attr_type, vuint32.data()); a = Attribute(vuint32); - } else if( H5Tequal(attr_type, H5T_NATIVE_UINT64) ) + } else if( H5Tequal(attr_type, H5T_NATIVE_ULONG) ) { std::vector< uint64_t > vuint64(dims[0], 0); status = H5Aread(attr_id, diff --git a/src/ParticlePatches.cpp b/src/ParticlePatches.cpp index f32a09c895..4f0034b277 100644 --- a/src/ParticlePatches.cpp +++ b/src/ParticlePatches.cpp @@ -69,7 +69,7 @@ ParticlePatches::read() IOHandler->flush(); using DT = Datatype; - if( DT::UINT64 != *dOpen.dtype ) + if( DT::ULONG != *dOpen.dtype ) throw std::runtime_error("Unexpected datatype for " + component_name); /* allow all attributes to be set */ diff --git a/src/RecordComponent.cpp b/src/RecordComponent.cpp index d85e29d90e..0dbe249215 100644 --- a/src/RecordComponent.cpp +++ b/src/RecordComponent.cpp @@ -176,22 +176,22 @@ RecordComponent::readBase() case DT::FLOAT: makeConstant(a.get< float >()); break; - case DT::INT16: + case DT::SHORT: makeConstant(a.get< int16_t >()); break; - case DT::INT32: + case DT::INT: makeConstant(a.get< int32_t >()); break; - case DT::INT64: + case DT::LONG: makeConstant(a.get< int64_t >()); break; - case DT::UINT16: + case DT::USHORT: makeConstant(a.get< uint16_t >()); break; - case DT::UINT32: + case DT::UINT: makeConstant(a.get< uint32_t >()); break; - case DT::UINT64: + case DT::ULONG: makeConstant(a.get< uint64_t >()); break; case DT::CHAR: @@ -215,10 +215,10 @@ RecordComponent::readBase() Extent e; switch( *aRead.dtype ) { - case DT::UINT64: + case DT::ULONG: e.push_back(a.get< uint64_t >()); break; - case DT::VEC_UINT64: + case DT::VEC_ULONG: for( auto const& val : a.get< std::vector< uint64_t > >() ) e.push_back(val); break; diff --git a/src/Series.cpp b/src/Series.cpp index b30fe8e4e9..14b0e3a561 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -768,7 +768,7 @@ Series::readBase() aRead.name = "openPMDextension"; IOHandler->enqueue(IOTask(this, aRead)); IOHandler->flush(); - if( *aRead.dtype == DT::UINT32 ) + if( *aRead.dtype == DT::UINT ) setOpenPMDextension(Attribute(*aRead.resource).get< uint32_t >()); else throw std::runtime_error("Unexpected Attribute datatype for 'openPMDextension'"); diff --git a/src/backend/Attributable.cpp b/src/backend/Attributable.cpp index 763e386118..8c50f9f894 100644 --- a/src/backend/Attributable.cpp +++ b/src/backend/Attributable.cpp @@ -186,23 +186,29 @@ Attributable::readAttributes() case DT::UCHAR: setAttribute(att, a.get< unsigned char >()); break; - case DT::INT16: - setAttribute(att, a.get< int16_t >()); + case DT::SHORT: + setAttribute(att, a.get< short >()); break; - case DT::INT32: - setAttribute(att, a.get< int32_t >()); + case DT::INT: + setAttribute(att, a.get< int >()); break; - case DT::INT64: - setAttribute(att, a.get< int64_t >()); + case DT::LONG: + setAttribute(att, a.get< long >()); break; - case DT::UINT16: - setAttribute(att, a.get< uint16_t >()); + case DT::LONGLONG: + setAttribute(att, a.get< long long >()); break; - case DT::UINT32: - setAttribute(att, a.get< uint32_t >()); + case DT::USHORT: + setAttribute(att, a.get< unsigned short >()); break; - case DT::UINT64: - setAttribute(att, a.get< uint64_t >()); + case DT::UINT: + setAttribute(att, a.get< unsigned int >()); + break; + case DT::ULONG: + setAttribute(att, a.get< unsigned long >()); + break; + case DT::ULONGLONG: + setAttribute(att, a.get< unsigned long long >()); break; case DT::FLOAT: setAttribute(att, a.get< float >()); @@ -219,26 +225,32 @@ Attributable::readAttributes() case DT::VEC_CHAR: setAttribute(att, a.get< std::vector< char > >()); break; - case DT::VEC_INT16: - setAttribute(att, a.get< std::vector< int16_t > >()); + case DT::VEC_SHORT: + setAttribute(att, a.get< std::vector< short > >()); break; - case DT::VEC_INT32: - setAttribute(att, a.get< std::vector< int32_t > >()); + case DT::VEC_INT: + setAttribute(att, a.get< std::vector< int > >()); break; - case DT::VEC_INT64: - setAttribute(att, a.get< std::vector< int64_t > >()); + case DT::VEC_LONG: + setAttribute(att, a.get< std::vector< long > >()); + break; + case DT::VEC_LONGLONG: + setAttribute(att, a.get< std::vector< long long > >()); break; case DT::VEC_UCHAR: setAttribute(att, a.get< std::vector< unsigned char > >()); break; - case DT::VEC_UINT16: - setAttribute(att, a.get< std::vector< uint16_t > >()); + case DT::VEC_USHORT: + setAttribute(att, a.get< std::vector< unsigned short > >()); + break; + case DT::VEC_UINT: + setAttribute(att, a.get< std::vector< unsigned int > >()); break; - case DT::VEC_UINT32: - setAttribute(att, a.get< std::vector< uint32_t > >()); + case DT::VEC_ULONG: + setAttribute(att, a.get< std::vector< unsigned long > >()); break; - case DT::VEC_UINT64: - setAttribute(att, a.get< std::vector< uint64_t > >()); + case DT::VEC_ULONGLONG: + setAttribute(att, a.get< std::vector< unsigned long long > >()); break; case DT::VEC_FLOAT: setAttribute(att, a.get< std::vector< float > >()); diff --git a/src/binding/python/Attributable.cpp b/src/binding/python/Attributable.cpp index 3e84074457..7142d53b69 100644 --- a/src/binding/python/Attributable.cpp +++ b/src/binding/python/Attributable.cpp @@ -73,24 +73,28 @@ void init_Attributable(py::module &m) { // C++ pass-through API .def("set_attribute", &Attributable::setAttribute< char >) .def("set_attribute", &Attributable::setAttribute< unsigned char >) - .def("set_attribute", &Attributable::setAttribute< int16_t >) - .def("set_attribute", &Attributable::setAttribute< int32_t >) - .def("set_attribute", &Attributable::setAttribute< int64_t >) - .def("set_attribute", &Attributable::setAttribute< uint16_t >) - .def("set_attribute", &Attributable::setAttribute< uint32_t >) - .def("set_attribute", &Attributable::setAttribute< uint64_t >) + .def("set_attribute", &Attributable::setAttribute< short >) + .def("set_attribute", &Attributable::setAttribute< int >) + .def("set_attribute", &Attributable::setAttribute< long >) + .def("set_attribute", &Attributable::setAttribute< long long >) + .def("set_attribute", &Attributable::setAttribute< unsigned short >) + .def("set_attribute", &Attributable::setAttribute< unsigned int >) + .def("set_attribute", &Attributable::setAttribute< unsigned long >) + .def("set_attribute", &Attributable::setAttribute< unsigned long long >) .def("set_attribute", &Attributable::setAttribute< float >) .def("set_attribute", &Attributable::setAttribute< double >) .def("set_attribute", &Attributable::setAttribute< long double >) .def("set_attribute", &Attributable::setAttribute< std::string >) .def("set_attribute", &Attributable::setAttribute< std::vector< char > >) .def("set_attribute", &Attributable::setAttribute< std::vector< unsigned char > >) - .def("set_attribute", &Attributable::setAttribute< std::vector< int16_t > >) - .def("set_attribute", &Attributable::setAttribute< std::vector< int32_t > >) - .def("set_attribute", &Attributable::setAttribute< std::vector< int64_t > >) - .def("set_attribute", &Attributable::setAttribute< std::vector< uint16_t > >) - .def("set_attribute", &Attributable::setAttribute< std::vector< uint32_t > >) - .def("set_attribute", &Attributable::setAttribute< std::vector< uint64_t > >) + .def("set_attribute", &Attributable::setAttribute< std::vector< short > >) + .def("set_attribute", &Attributable::setAttribute< std::vector< int > >) + .def("set_attribute", &Attributable::setAttribute< std::vector< long > >) + .def("set_attribute", &Attributable::setAttribute< std::vector< long long > >) + .def("set_attribute", &Attributable::setAttribute< std::vector< unsigned short > >) + .def("set_attribute", &Attributable::setAttribute< std::vector< unsigned int > >) + .def("set_attribute", &Attributable::setAttribute< std::vector< unsigned long > >) + .def("set_attribute", &Attributable::setAttribute< std::vector< unsigned long long > >) .def("set_attribute", &Attributable::setAttribute< std::vector< float > >) .def("set_attribute", &Attributable::setAttribute< std::vector< double > >) .def("set_attribute", &Attributable::setAttribute< std::vector< long double > >) diff --git a/src/binding/python/BaseRecordComponent.cpp b/src/binding/python/BaseRecordComponent.cpp index f1fc64c862..d8b9220d04 100644 --- a/src/binding/python/BaseRecordComponent.cpp +++ b/src/binding/python/BaseRecordComponent.cpp @@ -53,17 +53,17 @@ void init_BaseRecordComponent(py::module &m) { return py::dtype("b"); else if( brc.getDatatype() == DT::UCHAR ) return py::dtype("B"); - else if( brc.getDatatype() == DT::INT16 ) + else if( brc.getDatatype() == DT::SHORT ) return py::dtype("int16"); - else if( brc.getDatatype() == DT::INT32 ) + else if( brc.getDatatype() == DT::INT ) return py::dtype("int32"); - else if( brc.getDatatype() == DT::INT64 ) + else if( brc.getDatatype() == DT::LONG ) return py::dtype("int64"); - else if( brc.getDatatype() == DT::UINT16 ) + else if( brc.getDatatype() == DT::USHORT ) return py::dtype("uint16"); - else if( brc.getDatatype() == DT::UINT32 ) + else if( brc.getDatatype() == DT::UINT ) return py::dtype("uint32"); - else if( brc.getDatatype() == DT::UINT64 ) + else if( brc.getDatatype() == DT::ULONG ) return py::dtype("uint64"); else if( brc.getDatatype() == DT::LONG_DOUBLE ) return py::dtype("longdouble"); @@ -76,19 +76,19 @@ void init_BaseRecordComponent(py::module &m) { return py::dtype("string_"); else if( brc.getDatatype() == DT::VEC_CHAR ) return py::dtype(""); - else if( brc.getDatatype() == DT::VEC_INT16 ) + else if( brc.getDatatype() == DT::VEC_SHORT ) return py::dtype(""); - else if( brc.getDatatype() == DT::VEC_INT32 ) + else if( brc.getDatatype() == DT::VEC_INT ) return py::dtype(""); - else if( brc.getDatatype() == DT::VEC_INT64 ) + else if( brc.getDatatype() == DT::VEC_LONG ) return py::dtype(""); else if( brc.getDatatype() == DT::VEC_UCHAR ) return py::dtype(""); - else if( brc.getDatatype() == DT::VEC_UINT16 ) + else if( brc.getDatatype() == DT::VEC_USHORT ) return py::dtype(""); - else if( brc.getDatatype() == DT::VEC_UINT32 ) + else if( brc.getDatatype() == DT::VEC_UINT ) return py::dtype(""); - else if( brc.getDatatype() == DT::VEC_UINT64 ) + else if( brc.getDatatype() == DT::VEC_ULONG ) return py::dtype(""); else if( brc.getDatatype() == DT::ARR_DBL_7 ) return py::dtype(""); diff --git a/src/binding/python/Datatype.cpp b/src/binding/python/Datatype.cpp index 2387e009f4..debaa09f55 100644 --- a/src/binding/python/Datatype.cpp +++ b/src/binding/python/Datatype.cpp @@ -31,24 +31,24 @@ void init_Datatype(py::module &m) { py::enum_(m, "Datatype", py::arithmetic()) .value("CHAR", Datatype::CHAR) .value("UCHAR", Datatype::UCHAR) - .value("INT16", Datatype::INT16) - .value("INT32", Datatype::INT32) - .value("INT64", Datatype::INT64) - .value("UINT16", Datatype::UINT16) - .value("UINT32", Datatype::UINT32) - .value("UINT64", Datatype::UINT64) + .value("SHORT", Datatype::SHORT) + .value("INT", Datatype::INT) + .value("LONG", Datatype::LONG) + .value("USHORT", Datatype::USHORT) + .value("UINT", Datatype::UINT) + .value("ULONG", Datatype::ULONG) .value("FLOAT", Datatype::FLOAT) .value("DOUBLE", Datatype::DOUBLE) .value("LONG_DOUBLE", Datatype::LONG_DOUBLE) .value("STRING", Datatype::STRING) .value("VEC_CHAR", Datatype::VEC_CHAR) - .value("VEC_INT16", Datatype::VEC_INT16) - .value("VEC_INT32", Datatype::VEC_INT32) - .value("VEC_INT64", Datatype::VEC_INT64) + .value("VEC_SHORT", Datatype::VEC_SHORT) + .value("VEC_INT", Datatype::VEC_INT) + .value("VEC_LONG", Datatype::VEC_LONG) .value("VEC_UCHAR", Datatype::VEC_UCHAR) - .value("VEC_UINT16", Datatype::VEC_UINT16) - .value("VEC_UINT32", Datatype::VEC_UINT32) - .value("VEC_UINT64", Datatype::VEC_UINT64) + .value("VEC_USHORT", Datatype::VEC_USHORT) + .value("VEC_UINT", Datatype::VEC_UINT) + .value("VEC_ULONG", Datatype::VEC_ULONG) .value("VEC_FLOAT", Datatype::VEC_FLOAT) .value("VEC_DOUBLE", Datatype::VEC_DOUBLE) .value("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE) diff --git a/src/binding/python/RecordComponent.cpp b/src/binding/python/RecordComponent.cpp index cf13afbaef..674d6d0d42 100644 --- a/src/binding/python/RecordComponent.cpp +++ b/src/binding/python/RecordComponent.cpp @@ -115,12 +115,12 @@ void init_RecordComponent(py::module &m) { if( r.getDatatype() == Datatype::CHAR ) dtype = py::dtype("b"); else if( r.getDatatype() == Datatype::UCHAR ) dtype = py::dtype("B"); - else if( r.getDatatype() == Datatype::INT16 ) dtype = py::dtype("int16"); - else if( r.getDatatype() == Datatype::INT32 ) dtype = py::dtype("int32"); - else if( r.getDatatype() == Datatype::INT64 ) dtype = py::dtype("int64"); - else if( r.getDatatype() == Datatype::UINT16 ) dtype = py::dtype("uint16"); - else if( r.getDatatype() == Datatype::UINT32 ) dtype = py::dtype("uint32"); - else if( r.getDatatype() == Datatype::UINT64 ) dtype = py::dtype("uint64"); + else if( r.getDatatype() == Datatype::SHORT ) dtype = py::dtype("int16"); + else if( r.getDatatype() == Datatype::INT ) dtype = py::dtype("int32"); + else if( r.getDatatype() == Datatype::LONG ) dtype = py::dtype("int64"); + else if( r.getDatatype() == Datatype::USHORT ) dtype = py::dtype("uint16"); + else if( r.getDatatype() == Datatype::UINT ) dtype = py::dtype("uint32"); + else if( r.getDatatype() == Datatype::ULONG ) dtype = py::dtype("uint64"); else if( r.getDatatype() == Datatype::LONG_DOUBLE ) dtype = py::dtype("longdouble"); else if( r.getDatatype() == Datatype::DOUBLE ) dtype = py::dtype("double"); else if( r.getDatatype() == Datatype::FLOAT ) dtype = py::dtype("float"); @@ -128,13 +128,13 @@ void init_RecordComponent(py::module &m) { /* @todo .value("STRING", Datatype::STRING) .value("VEC_CHAR", Datatype::VEC_CHAR) - .value("VEC_INT16", Datatype::VEC_INT16) - .value("VEC_INT32", Datatype::VEC_INT32) - .value("VEC_INT64", Datatype::VEC_INT64) + .value("VEC_SHORT", Datatype::VEC_SHORT) + .value("VEC_INT", Datatype::VEC_INT) + .value("VEC_LONG", Datatype::VEC_LONG) .value("VEC_UCHAR", Datatype::VEC_UCHAR) - .value("VEC_UINT16", Datatype::VEC_UINT16) - .value("VEC_UINT32", Datatype::VEC_UINT32) - .value("VEC_UINT64", Datatype::VEC_UINT64) + .value("VEC_USHORT", Datatype::VEC_USHORT) + .value("VEC_UINT", Datatype::VEC_UINT) + .value("VEC_ULONG", Datatype::VEC_ULONG) .value("VEC_FLOAT", Datatype::VEC_FLOAT) .value("VEC_DOUBLE", Datatype::VEC_DOUBLE) .value("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE) @@ -152,17 +152,17 @@ void init_RecordComponent(py::module &m) { r.loadChunk(offset, extent, shareRaw((char*) a.mutable_data())); else if( r.getDatatype() == Datatype::UCHAR ) r.loadChunk(offset, extent, shareRaw((unsigned char*) a.mutable_data())); - else if( r.getDatatype() == Datatype::INT16 ) + else if( r.getDatatype() == Datatype::SHORT ) r.loadChunk(offset, extent, shareRaw((int16_t*) a.mutable_data())); - else if( r.getDatatype() == Datatype::INT32 ) + else if( r.getDatatype() == Datatype::INT ) r.loadChunk(offset, extent, shareRaw((int32_t*) a.mutable_data())); - else if( r.getDatatype() == Datatype::INT64 ) + else if( r.getDatatype() == Datatype::LONG ) r.loadChunk(offset, extent, shareRaw((int64_t*) a.mutable_data())); - else if( r.getDatatype() == Datatype::UINT16 ) + else if( r.getDatatype() == Datatype::USHORT ) r.loadChunk(offset, extent, shareRaw((uint16_t*) a.mutable_data())); - else if( r.getDatatype() == Datatype::UINT32 ) + else if( r.getDatatype() == Datatype::UINT ) r.loadChunk(offset, extent, shareRaw((uint32_t*) a.mutable_data())); - else if( r.getDatatype() == Datatype::UINT64 ) + else if( r.getDatatype() == Datatype::ULONG ) r.loadChunk(offset, extent, shareRaw((uint64_t*) a.mutable_data())); else if( r.getDatatype() == Datatype::LONG_DOUBLE ) r.loadChunk(offset, extent, shareRaw((long double*) a.mutable_data())); @@ -174,13 +174,13 @@ void init_RecordComponent(py::module &m) { /* @todo .value("STRING", Datatype::STRING) .value("VEC_CHAR", Datatype::VEC_CHAR) - .value("VEC_INT16", Datatype::VEC_INT16) - .value("VEC_INT32", Datatype::VEC_INT32) - .value("VEC_INT64", Datatype::VEC_INT64) + .value("VEC_SHORT", Datatype::VEC_SHORT) + .value("VEC_INT", Datatype::VEC_INT) + .value("VEC_LONG", Datatype::VEC_LONG) .value("VEC_UCHAR", Datatype::VEC_UCHAR) - .value("VEC_UINT16", Datatype::VEC_UINT16) - .value("VEC_UINT32", Datatype::VEC_UINT32) - .value("VEC_UINT64", Datatype::VEC_UINT64) + .value("VEC_USHORT", Datatype::VEC_USHORT) + .value("VEC_UINT", Datatype::VEC_UINT) + .value("VEC_ULONG", Datatype::VEC_ULONG) .value("VEC_FLOAT", Datatype::VEC_FLOAT) .value("VEC_DOUBLE", Datatype::VEC_DOUBLE) .value("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE) @@ -238,13 +238,13 @@ void init_RecordComponent(py::module &m) { /* @todo .value("STRING", Datatype::STRING) .value("VEC_CHAR", Datatype::VEC_CHAR) - .value("VEC_INT16", Datatype::VEC_INT16) - .value("VEC_INT32", Datatype::VEC_INT32) - .value("VEC_INT64", Datatype::VEC_INT64) + .value("VEC_SHORT", Datatype::VEC_SHORT) + .value("VEC_INT", Datatype::VEC_INT) + .value("VEC_LONG", Datatype::VEC_LONG) .value("VEC_UCHAR", Datatype::VEC_UCHAR) - .value("VEC_UINT16", Datatype::VEC_UINT16) - .value("VEC_UINT32", Datatype::VEC_UINT32) - .value("VEC_UINT64", Datatype::VEC_UINT64) + .value("VEC_USHORT", Datatype::VEC_USHORT) + .value("VEC_UINT", Datatype::VEC_UINT) + .value("VEC_ULONG", Datatype::VEC_ULONG) .value("VEC_FLOAT", Datatype::VEC_FLOAT) .value("VEC_DOUBLE", Datatype::VEC_DOUBLE) .value("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE) diff --git a/test/CoreTest.cpp b/test/CoreTest.cpp index 6647a01c3b..9772f0e97a 100644 --- a/test/CoreTest.cpp +++ b/test/CoreTest.cpp @@ -23,18 +23,22 @@ TEST_CASE( "attribute_dtype_test", "[core]" ) REQUIRE(Datatype::CHAR == a.dtype); a = Attribute(static_cast< unsigned char >(' ')); REQUIRE(Datatype::UCHAR == a.dtype); - a = Attribute(static_cast< int16_t >(0)); - REQUIRE(Datatype::INT16 == a.dtype); - a = Attribute(static_cast< int32_t >(0)); - REQUIRE(Datatype::INT32 == a.dtype); - a = Attribute(static_cast< int64_t >(0)); - REQUIRE(Datatype::INT64 == a.dtype); - a = Attribute(static_cast< uint16_t >(0)); - REQUIRE(Datatype::UINT16 == a.dtype); - a = Attribute(static_cast< uint32_t >(0)); - REQUIRE(Datatype::UINT32 == a.dtype); - a = Attribute(static_cast< uint64_t >(0)); - REQUIRE(Datatype::UINT64 == a.dtype); + a = Attribute(static_cast< short >(0)); + REQUIRE(Datatype::SHORT == a.dtype); + a = Attribute(static_cast< int >(0)); + REQUIRE(Datatype::INT == a.dtype); + a = Attribute(static_cast< long >(0)); + REQUIRE(Datatype::LONG == a.dtype); + a = Attribute(static_cast< long long >(0)); + REQUIRE(Datatype::LONGLONG == a.dtype); + a = Attribute(static_cast< unsigned short >(0)); + REQUIRE(Datatype::USHORT == a.dtype); + a = Attribute(static_cast< unsigned int >(0)); + REQUIRE(Datatype::UINT == a.dtype); + a = Attribute(static_cast< unsigned long >(0)); + REQUIRE(Datatype::ULONG == a.dtype); + a = Attribute(static_cast< unsigned long long >(0)); + REQUIRE(Datatype::ULONGLONG == a.dtype); a = Attribute(static_cast< float >(0.)); REQUIRE(Datatype::FLOAT == a.dtype); a = Attribute(static_cast< double >(0.)); @@ -45,20 +49,24 @@ TEST_CASE( "attribute_dtype_test", "[core]" ) REQUIRE(Datatype::STRING == a.dtype); a = Attribute(std::vector< char >()); REQUIRE(Datatype::VEC_CHAR == a.dtype); - a = Attribute(std::vector< int16_t >()); - REQUIRE(Datatype::VEC_INT16 == a.dtype); - a = Attribute(std::vector< int32_t >()); - REQUIRE(Datatype::VEC_INT32 == a.dtype); - a = Attribute(std::vector< int64_t >()); - REQUIRE(Datatype::VEC_INT64 == a.dtype); + a = Attribute(std::vector< short >()); + REQUIRE(Datatype::VEC_SHORT == a.dtype); + a = Attribute(std::vector< int >()); + REQUIRE(Datatype::VEC_INT == a.dtype); + a = Attribute(std::vector< long >()); + REQUIRE(Datatype::VEC_LONG == a.dtype); + a = Attribute(std::vector< long long >()); + REQUIRE(Datatype::VEC_LONGLONG == a.dtype); a = Attribute(std::vector< unsigned char >()); REQUIRE(Datatype::VEC_UCHAR == a.dtype); - a = Attribute(std::vector< uint16_t >()); - REQUIRE(Datatype::VEC_UINT16 == a.dtype); - a = Attribute(std::vector< uint32_t >()); - REQUIRE(Datatype::VEC_UINT32 == a.dtype); - a = Attribute(std::vector< uint64_t >()); - REQUIRE(Datatype::VEC_UINT64 == a.dtype); + a = Attribute(std::vector< unsigned short >()); + REQUIRE(Datatype::VEC_USHORT == a.dtype); + a = Attribute(std::vector< unsigned int >()); + REQUIRE(Datatype::VEC_UINT == a.dtype); + a = Attribute(std::vector< unsigned long >()); + REQUIRE(Datatype::VEC_ULONG == a.dtype); + a = Attribute(std::vector< unsigned long long >()); + REQUIRE(Datatype::VEC_ULONGLONG == a.dtype); a = Attribute(std::vector< float >()); REQUIRE(Datatype::VEC_FLOAT == a.dtype); a = Attribute(std::vector< double >()); @@ -487,9 +495,9 @@ TEST_CASE( "wrapper_test", "[core]" ) REQUIRE(o.iterationEncoding() == IterationEncoding::groupBased); REQUIRE(o.name() == "other_name"); - o.iterations[1].meshes["E"]["x"].resetDataset(Dataset(Datatype::UINT16, {42})); + o.iterations[1].meshes["E"]["x"].resetDataset(Dataset(Datatype::USHORT, {42})); MeshRecordComponent mrc = o.iterations[1].meshes["E"]["x"]; - REQUIRE(mrc.getDatatype() == Datatype::UINT16); + REQUIRE(mrc.getDatatype() == Datatype::USHORT); REQUIRE(mrc.getExtent() == Extent{42}); mrc.resetDataset(Dataset(Datatype::LONG_DOUBLE, {7})); REQUIRE(o.iterations[1].meshes["E"]["x"].getDatatype() == Datatype::LONG_DOUBLE); @@ -536,7 +544,7 @@ TEST_CASE( "wrapper_test", "[core]" ) o.iterations[5].meshes["E"]["y"].resetDataset(Dataset(Datatype::DOUBLE, {1})); int wrongData = 42; REQUIRE_THROWS_WITH(o.iterations[5].meshes["E"]["y"].storeChunk({0}, {1}, shareRaw(&wrongData)), - Catch::Equals("Datatypes of chunk data (INT32) and dataset (DOUBLE) do not match.")); + Catch::Equals("Datatypes of chunk data (INT) and dataset (DOUBLE) do not match.")); std::shared_ptr< double > storeData = std::make_shared< double >(44); o.iterations[5].meshes["E"]["y"].storeChunk({0}, {1}, storeData); #if openPMD_USE_INVASIVE_TESTS @@ -549,12 +557,12 @@ TEST_CASE( "wrapper_test", "[core]" ) REQUIRE(mrc3.m_chunks->empty()); #endif - o.iterations[6].particles["electrons"].particlePatches["numParticles"][RecordComponent::SCALAR].resetDataset(Dataset(Datatype::UINT64, {4})); + o.iterations[6].particles["electrons"].particlePatches["numParticles"][RecordComponent::SCALAR].resetDataset(Dataset(Datatype::ULONG, {4})); auto dset = Dataset(Datatype::DOUBLE, {1}); o.iterations[6].particles["electrons"]["position"][RecordComponent::SCALAR].resetDataset(dset); o.iterations[6].particles["electrons"]["positionOffset"][RecordComponent::SCALAR].resetDataset(dset); ParticlePatches pp = o.iterations[6].particles["electrons"].particlePatches; - REQUIRE(pp["numParticles"][RecordComponent::SCALAR].getDatatype() == Datatype::UINT64); + REQUIRE(pp["numParticles"][RecordComponent::SCALAR].getDatatype() == Datatype::ULONG); REQUIRE(pp["numParticles"][RecordComponent::SCALAR].getExtent() == Extent{4}); pp["prop"]["x"].resetDataset(Dataset(Datatype::DOUBLE, {7})); REQUIRE(o.iterations[6].particles["electrons"].particlePatches["prop"]["x"].getDatatype() == Datatype::DOUBLE); @@ -571,7 +579,7 @@ TEST_CASE( "wrapper_test", "[core]" ) REQUIRE(pp["numParticles"][RecordComponent::SCALAR].m_chunks->size() == 1); #endif REQUIRE_THROWS_WITH(o.iterations[6].particles["electrons"].particlePatches["numParticles"][RecordComponent::SCALAR].store(idx+1, 42.), - Catch::Equals("Datatypes of chunk data (DOUBLE) and dataset (UINT64) do not match.")); + Catch::Equals("Datatypes of chunk data (DOUBLE) and dataset (ULONG) do not match.")); o.iterations[6].particles["electrons"].particlePatches["numParticles"][RecordComponent::SCALAR].store(idx+1, val+1); #if openPMD_USE_INVASIVE_TESTS REQUIRE(o.iterations[6].particles["electrons"].particlePatches["numParticles"][RecordComponent::SCALAR].m_chunks->size() == 2); @@ -589,7 +597,7 @@ TEST_CASE( "use_count_test", "[core]" ) Series o = Series("./new_openpmd_output", AccessType::CREATE); MeshRecordComponent mrc = o.iterations[1].meshes["E"]["x"]; - mrc.resetDataset(Dataset(Datatype::UINT16, {42})); + mrc.resetDataset(Dataset(determineDatatype(), {42})); std::shared_ptr< uint16_t > storeData = std::make_shared< uint16_t >(44); REQUIRE(storeData.use_count() == 1); mrc.storeChunk({0}, {1}, storeData); @@ -602,7 +610,7 @@ TEST_CASE( "use_count_test", "[core]" ) auto dset = Dataset(Datatype::DOUBLE, {1}); o.iterations[6].particles["electrons"]["position"][RecordComponent::SCALAR].resetDataset(dset); o.iterations[6].particles["electrons"]["positionOffset"][RecordComponent::SCALAR].resetDataset(dset); - pprc.resetDataset(Dataset(Datatype::UINT64, {4})); + pprc.resetDataset(Dataset(determineDatatype(), {4})); pprc.store(0, static_cast< uint64_t >(1)); REQUIRE(static_cast< Parameter< Operation::WRITE_DATASET >* >(pprc.m_chunks->front().parameter.get())->data.use_count() == 1); #endif @@ -625,14 +633,14 @@ TEST_CASE( "zero_extent_component", "[core]" ) auto E_x = o.iterations[1].meshes["E"]["x"]; E_x.setComment("Datasets with zero extent in any dimension are not allowed."); - REQUIRE_THROWS_WITH(E_x.resetDataset(Dataset(Datatype::INT64, {0})), + REQUIRE_THROWS_WITH(E_x.resetDataset(Dataset(Datatype::LONG, {0})), Catch::Equals("Dataset extent must not be zero in any dimension.")); - REQUIRE_THROWS_WITH(E_x.resetDataset(Dataset(Datatype::INT64, {1, 0})), + REQUIRE_THROWS_WITH(E_x.resetDataset(Dataset(Datatype::LONG, {1, 0})), Catch::Equals("Dataset extent must not be zero in any dimension.")); - REQUIRE_THROWS_WITH(E_x.resetDataset(Dataset(Datatype::INT64, {0, 1})), + REQUIRE_THROWS_WITH(E_x.resetDataset(Dataset(Datatype::LONG, {0, 1})), Catch::Equals("Dataset extent must not be zero in any dimension.")); E_x.setComment("Datasets must contain dimensions."); - REQUIRE_THROWS_WITH(E_x.resetDataset(Dataset(Datatype::INT64, {})), + REQUIRE_THROWS_WITH(E_x.resetDataset(Dataset(Datatype::LONG, {})), Catch::Equals("Dataset extent must be at least 1D.")); E_x.resetDataset(Dataset(Datatype::DOUBLE, {1})); } diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 5a45a55d4b..77ff113bb2 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -749,19 +749,19 @@ TEST_CASE( "hzdr_hdf5_sample_content_test", "[serial][hdf5]" ) RecordComponent& e_positionOffset_x = e_positionOffset["x"]; REQUIRE(e_positionOffset_x.unitSI() == 2.599999993753294e-07); - REQUIRE(e_positionOffset_x.getDatatype() == Datatype::INT32); + REQUIRE(e_positionOffset_x.getDatatype() == Datatype::INT); REQUIRE(e_positionOffset_x.getExtent() == e); REQUIRE(e_positionOffset_x.getDimensionality() == 1); RecordComponent& e_positionOffset_y = e_positionOffset["y"]; REQUIRE(e_positionOffset_y.unitSI() == 4.4299999435019118e-08); - REQUIRE(e_positionOffset_y.getDatatype() == Datatype::INT32); + REQUIRE(e_positionOffset_y.getDatatype() == Datatype::INT); REQUIRE(e_positionOffset_y.getExtent() == e); REQUIRE(e_positionOffset_y.getDimensionality() == 1); RecordComponent& e_positionOffset_z = e_positionOffset["z"]; REQUIRE(e_positionOffset_z.unitSI() == 2.599999993753294e-07); - REQUIRE(e_positionOffset_z.getDatatype() == Datatype::INT32); + REQUIRE(e_positionOffset_z.getDatatype() == Datatype::INT); REQUIRE(e_positionOffset_z.getExtent() == e); REQUIRE(e_positionOffset_z.getDimensionality() == 1); @@ -798,15 +798,15 @@ TEST_CASE( "hzdr_hdf5_sample_content_test", "[serial][hdf5]" ) PatchRecordComponent& e_extent_x = e_extent["x"]; REQUIRE(e_extent_x.unitSI() == 2.599999993753294e-07); - REQUIRE(e_extent_x.getDatatype() == Datatype::UINT64); + REQUIRE(e_extent_x.getDatatype() == Datatype::ULONG); PatchRecordComponent& e_extent_y = e_extent["y"]; REQUIRE(e_extent_y.unitSI() == 4.429999943501912e-08); - REQUIRE(e_extent_y.getDatatype() == Datatype::UINT64); + REQUIRE(e_extent_y.getDatatype() == Datatype::ULONG); PatchRecordComponent& e_extent_z = e_extent["z"]; REQUIRE(e_extent_z.unitSI() == 2.599999993753294e-07); - REQUIRE(e_extent_z.getDatatype() == Datatype::UINT64); + REQUIRE(e_extent_z.getDatatype() == Datatype::ULONG); std::shared_ptr< uint64_t > data; e_extent_z.load(0, data); @@ -818,7 +818,7 @@ TEST_CASE( "hzdr_hdf5_sample_content_test", "[serial][hdf5]" ) REQUIRE(e_numParticles.count(RecordComponent::SCALAR) == 1); PatchRecordComponent& e_numParticles_scalar = e_numParticles[RecordComponent::SCALAR]; - REQUIRE(e_numParticles_scalar.getDatatype() == Datatype::UINT64); + REQUIRE(e_numParticles_scalar.getDatatype() == Datatype::ULONG); e_numParticles_scalar.load(0, data); o.flush(); @@ -829,7 +829,7 @@ TEST_CASE( "hzdr_hdf5_sample_content_test", "[serial][hdf5]" ) REQUIRE(e_numParticlesOffset.count(RecordComponent::SCALAR) == 1); PatchRecordComponent& e_numParticlesOffset_scalar = e_numParticlesOffset[RecordComponent::SCALAR]; - REQUIRE(e_numParticlesOffset_scalar.getDatatype() == Datatype::UINT64); + REQUIRE(e_numParticlesOffset_scalar.getDatatype() == Datatype::ULONG); PatchRecord& e_offset = e_patches["offset"]; REQUIRE(e_offset.unitDimension() == ud); @@ -841,15 +841,15 @@ TEST_CASE( "hzdr_hdf5_sample_content_test", "[serial][hdf5]" ) PatchRecordComponent& e_offset_x = e_offset["x"]; REQUIRE(e_offset_x.unitSI() == 2.599999993753294e-07); - REQUIRE(e_offset_x.getDatatype() == Datatype::UINT64); + REQUIRE(e_offset_x.getDatatype() == Datatype::ULONG); PatchRecordComponent& e_offset_y = e_offset["y"]; REQUIRE(e_offset_y.unitSI() == 4.429999943501912e-08); - REQUIRE(e_offset_y.getDatatype() == Datatype::UINT64); + REQUIRE(e_offset_y.getDatatype() == Datatype::ULONG); PatchRecordComponent& e_offset_z = e_offset["z"]; REQUIRE(e_offset_z.unitSI() == 2.599999993753294e-07); - REQUIRE(e_offset_z.getDatatype() == Datatype::UINT64); + REQUIRE(e_offset_z.getDatatype() == Datatype::ULONG); } catch (no_such_file_error& e) { std::cerr << "HZDR sample not accessible. (" << e.what() << ")\n"; @@ -1197,7 +1197,7 @@ TEST_CASE( "hdf5_fileBased_write_test", "[serial][hdf5]" ) auto& posOff_x = posOff.at("x"); REQUIRE(posOff_x.unitSI() == 1.); REQUIRE(posOff_x.getExtent() == ext); - REQUIRE(posOff_x.getDatatype() == Datatype::UINT64); + REQUIRE(posOff_x.getDatatype() == Datatype::ULONG); auto position = pos_x.loadChunk< double >({0}, {4}); auto position_raw = position.get(); @@ -1746,7 +1746,7 @@ TEST_CASE( "adios1_fileBased_write_test", "[serial][adios1]" ) REQUIRE(species.at("position").at("x").getExtent() == Extent{4}); REQUIRE(species.at("positionOffset").size() == 1); REQUIRE(species.at("positionOffset").count("x") == 1); - REQUIRE(species.at("positionOffset").at("x").getDatatype() == Datatype::UINT64); + REQUIRE(species.at("positionOffset").at("x").getDatatype() == Datatype::ULONG); REQUIRE(species.at("positionOffset").at("x").getDimensionality() == 1); REQUIRE(species.at("positionOffset").at("x").getExtent() == Extent{4});