|
FEAT 3
Finite Element Analysis Toolbox
|
Data Array Pack namespace. More...
Classes | |
| struct | SwapHelper |
| auxiliary helper class: swaps the bytes of an 8/16/32/64/128 byte type More... | |
| struct | SwapHelper< 1 > |
| struct | SwapHelper< 16 > |
| struct | SwapHelper< 2 > |
| struct | SwapHelper< 4 > |
| struct | SwapHelper< 8 > |
| struct | TypeHelper |
| struct | TypeHelper< FEAT::Type::FloatingClass, true > |
| struct | TypeHelper< FEAT::Type::IntegralClass, false > |
| struct | TypeHelper< FEAT::Type::IntegralClass, true > |
Typedefs | |
| using | f16 = Half |
| 16-bit floating point type More... | |
| using | f32 = float |
| 32-bit floating point type More... | |
| using | f64 = double |
| 64-bit floating point type More... | |
| using | i16 = std::int16_t |
| 16-bit signed integer type More... | |
| using | i32 = std::int32_t |
| 32-bit signed integer type More... | |
| using | i64 = std::int64_t |
| 64-bit signed integer type More... | |
| using | i8 = std::int8_t |
| 8-bit signed integer type More... | |
| using | u16 = std::uint16_t |
| 16-bit unsigned integer type More... | |
| using | u32 = std::uint32_t |
| 32-bit unsigned integer type More... | |
| using | u64 = std::uint64_t |
| 64-bit unsigned integer type More... | |
| using | u8 = std::uint8_t |
| 8-bit unsigned integer type More... | |
Enumerations | |
| enum class | Type : u16 { None = 0x0000 , Mask_T = 0x0FFF , Mask_Z = 0x8000 , Mask_P = 0x2000 , Type_I = 0x0010 , Type_U = 0x0020 , Type_F = 0x0030 , I8 = 0x0011 , I16 = 0x0012 , I32 = 0x0013 , I64 = 0x0014 , U8 = 0x0021 , U16 = 0x0022 , U32 = 0x0023 , U64 = 0x0024 , F16 = 0x0032 , F32 = 0x0033 , F64 = 0x0034 , F128 = 0x0035 , ZI8 = 0x8011 , ZI16 = 0x8012 , ZI32 = 0x8013 , ZI64 = 0x8014 , ZU8 = 0x8021 , ZU16 = 0x8022 , ZU32 = 0x8023 , ZU64 = 0x8024 , ZF16 = 0x8032 , ZF32 = 0x8033 , ZF64 = 0x8034 , ZF128 = 0x8035 , PF32 = 0x2033 , PF64 = 0x2034 } |
| bitmask for zfp header More... | |
Functions | |
| template<typename T_ > | |
| std::size_t | decode (T_ *dst, void *buf, std::size_t count, std::size_t buf_size, Pack::Type pack_type, bool swap_bytes) |
| Decodes an array from a packed buffer. More... | |
| template std::size_t | decode< f32 > (f32 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< f64 > (f64 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< i16 > (i16 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< i32 > (i32 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< i64 > (i64 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< i8 > (i8 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< long long > (long long *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< u16 > (u16 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< u32 > (u32 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< u64 > (u64 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template std::size_t | decode< u8 > (u8 *, void *, std::size_t, std::size_t, Pack::Type, bool) |
| template<typename T_ > | |
| static std::size_t | decode_raw (T_ *dst, const void *buf, const std::size_t count, const Pack::Type pack_type, bool swap_bytes) |
| Decodes an array from a packed buffer without compression support. More... | |
| template<typename T_ > | |
| Pack::Type | deduct_type () |
Deduct the (raw) Pack::Type from a given data type T_. More... | |
| template Pack::Type | deduct_type< f32 > () |
| template Pack::Type | deduct_type< f64 > () |
| template Pack::Type | deduct_type< i16 > () |
| template Pack::Type | deduct_type< i32 > () |
| template Pack::Type | deduct_type< i64 > () |
| template Pack::Type | deduct_type< i8 > () |
| template Pack::Type | deduct_type< u16 > () |
| template Pack::Type | deduct_type< u32 > () |
| template Pack::Type | deduct_type< u64 > () |
| template Pack::Type | deduct_type< u8 > () |
| std::size_t | element_size (const Pack::Type type) |
| Returns the size of a Pack::Type element in bytes. More... | |
| template<typename T_ > | |
| std::size_t | encode (void *buf, const T_ *src, std::size_t buf_size, std::size_t count, Pack::Type pack_type, bool swap_bytes, double tolerance=1e-16) |
| Encodes an array into a packed buffer. More... | |
| template std::size_t | encode< f32 > (void *, const f32 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< f64 > (void *, const f64 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< i16 > (void *, const i16 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< i32 > (void *, const i32 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< i64 > (void *, const i64 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< i8 > (void *, const i8 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< long long > (void *, const long long *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< u16 > (void *, const u16 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< u32 > (void *, const u32 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< u64 > (void *, const u64 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template std::size_t | encode< u8 > (void *, const u8 *, std::size_t, std::size_t, Pack::Type, bool, double) |
| template<typename T_ > | |
| static std::size_t | encode_raw (void *buf, const T_ *src, const std::size_t count, const Pack::Type pack_type, bool swap_bytes) |
| Encodes an array into a packed buffer without compression support. More... | |
| std::size_t | estimate_size (std::size_t count, Pack::Type type, double tolerance=1e-16) |
| Computes the estimated (upper bound) pack buffer size for an array. More... | |
| template<typename T_ > | |
| static std::size_t | lossless_decode (T_ *dst, const void *buf, const std::size_t count, const std::size_t buf_size, const Pack::Type pack_type, bool swap_bytes) |
| Decodes an array from a packed buffer. More... | |
| template<typename T_ > | |
| static std::size_t | lossless_encode (void *buf, const T_ *src, const std::size_t buf_size, const std::size_t count, const Pack::Type pack_type, bool swap_bytes) |
| Encodes an array into a packed buffer. More... | |
| template<typename T_ > | |
| static std::size_t | lossy_decode (T_ *dst, void *buf, const std::size_t count, const std::size_t buf_size, const Pack::Type pack_type, bool swap_bytes) |
| Decodes an array from a packed buffer with lossy saved compression data. More... | |
| template<typename T_ > | |
| static std::size_t | lossy_encode (void *buf, T_ *src, const std::size_t buf_size, const std::size_t count, const Pack::Type pack_type, bool swap_bytes, const double tolerance) |
| Encodes an array into a packed buffer. More... | |
| static std::size_t | lossy_estimate_size (const std::size_t count, const Pack::Type type, const double tolerance) |
| Computes the estimated (upper bound) pack buffer size for an array for lossy compression. More... | |
| Pack::Type | operator& (Pack::Type a, Pack::Type b) |
| bit-wise AND operator for Pack::Type More... | |
| std::ostream & | operator<< (std::ostream &os, Pack::Type t) |
| stream output operator for Pack::Type More... | |
| std::istream & | operator>> (std::istream &is, Pack::Type &t) |
| stream input operator for Pack::Type More... | |
| Pack::Type | operator| (Pack::Type a, Pack::Type b) |
| bit-wise OR operator for Pack::Type More... | |
| template<typename X_ , typename T_ > | |
| static std::size_t | xdecode (T_ *dest, const void *buf, const std::size_t count, bool swap_bytes) |
| Encodes an array by converting each of its elements to a desired type. More... | |
| template<typename X_ , typename T_ > | |
| static std::size_t | xencode (void *buf, const T_ *src, const std::size_t count, bool swap_bytes) |
| Encodes an array by converting each of its elements to a desired type. More... | |
| template<typename X_ > | |
| X_ | xswap (X_ x) |
| Swaps the bytes of an object. More... | |
Data Array Pack namespace.
This namespace encapsulates various functions than provide means of packing and unpacking data arrays as well as compression and decompression of buffers using the third-party library zlib or lossy compression and decompression of buffers using the third-party library zfp.
| using FEAT::Pack::f16 = typedef Half |
| using FEAT::Pack::f32 = typedef float |
| using FEAT::Pack::f64 = typedef double |
| using FEAT::Pack::i16 = typedef std::int16_t |
| using FEAT::Pack::i32 = typedef std::int32_t |
| using FEAT::Pack::i64 = typedef std::int64_t |
| using FEAT::Pack::i8 = typedef std::int8_t |
| using FEAT::Pack::u16 = typedef std::uint16_t |
| using FEAT::Pack::u32 = typedef std::uint32_t |
| using FEAT::Pack::u64 = typedef std::uint64_t |
| using FEAT::Pack::u8 = typedef std::uint8_t |
|
strong |
| std::size_t FEAT::Pack::decode | ( | T_ * | dst, |
| void * | buf, | ||
| std::size_t | count, | ||
| std::size_t | buf_size, | ||
| Pack::Type | pack_type, | ||
| bool | swap_bytes | ||
| ) |
Decodes an array from a packed buffer.
Instantiated for i{8,16,32,64}, u{8,16,32,64}, f{16,32,64,128}.
| [out] | dst | A pointer to the output array that is to be unpacked. Must not be nullptr. |
| [in] | buf | A pointer to the input buffer. Must not be nullptr. |
| [in] | count | The number of output array elements. |
| [in] | buf_size | The size of the input buffer buf in bytes. |
| [in] | pack_type | The input buffer pack type. |
| [in] | swap_bytes | Specifies whether to swap the pack type bytes. |
Definition at line 680 of file pack.cpp.
References decode_raw(), lossless_decode(), lossy_decode(), and XASSERT.
Referenced by FEAT::LAFEM::Container< DT_, IT_ >::_deserialize().
|
static |
Decodes an array from a packed buffer without compression support.
| [out] | dst | A pointer to the output array that is to be unpacked. Must not be nullptr. |
| [in] | buf | A pointer to the input buffer. Must not be nullptr. |
| [in] | count | The number of output array elements. |
| [in] | pack_type | The input buffer pack type. |
| [in] | swap_bytes | Specifies whether to swap the pack type bytes. |
Definition at line 443 of file pack.cpp.
References XASSERT, and XASSERTM.
Referenced by decode(), lossless_decode(), and lossy_decode().
| Pack::Type FEAT::Pack::deduct_type | ( | ) |
Deduct the (raw) Pack::Type from a given data type T_.
Instantiated for i{8,16,32,64}, u{8,16,32,64}, f{16,32,64,128}.
| T_ | The type whose Pack::Type value is to be determined. |
T_ or Pack::Type::None, if T_ does not represent a type from the Pack::Type enum.
|
inline |
Returns the size of a Pack::Type element in bytes.
| [in] | type | The type whose element size is to be determined |
type is not a valid data type Definition at line 267 of file pack.hpp.
Referenced by estimate_size(), lossless_decode(), lossless_encode(), lossy_decode(), and lossy_encode().
| std::size_t FEAT::Pack::encode | ( | void * | buf, |
| const T_ * | src, | ||
| std::size_t | buf_size, | ||
| std::size_t | count, | ||
| Pack::Type | pack_type, | ||
| bool | swap_bytes, | ||
| double | tolerance = 1e-16 |
||
| ) |
Encodes an array into a packed buffer.
Instantiated for i{8,16,32,64}, u{8,16,32,64}, f{16,32,64,128}.
| [out] | buf | A pointer to the output buffer. Must not be nullptr. |
| [in] | src | A pointer to the input array that is to be packed. Must not be nullptr. |
| [in] | buf_size | The size of the output buffer buf in bytes. Must be at least as big as the estimated buffer size. |
| [in] | count | The number of input array elements. |
| [in] | pack_type | The desired output buffer pack type. |
| [in] | swap_bytes | Specifies whether to swap the pack type bytes. |
| [in] | tolerance | Optional paramter: The desired maximum error for lossy compression. |
Definition at line 566 of file pack.cpp.
References encode_raw(), lossless_encode(), lossy_encode(), and XASSERT.
|
static |
Encodes an array into a packed buffer without compression support.
| [out] | buf | A pointer to the output buffer. Must not be nullptr. |
| [in] | src | A pointer to the input array that is to be packed. Must not be nullptr. |
| [in] | count | The number of input array elements. |
| [in] | pack_type | The desired output buffer pack type. |
| [in] | swap_bytes | Specifies whether to swap the pack type bytes. |
Definition at line 394 of file pack.cpp.
References XASSERT, and XASSERTM.
Referenced by encode(), lossless_encode(), and lossy_encode().
| std::size_t FEAT::Pack::estimate_size | ( | std::size_t | count, |
| Pack::Type | type, | ||
| double | tolerance = 1e-16 |
||
| ) |
Computes the estimated (upper bound) pack buffer size for an array.
| [in] | count | The number of array elements to be packed. |
| [in] | type | The packed type of the array elements. |
Definition at line 543 of file pack.cpp.
References element_size(), lossy_estimate_size(), and XASSERTM.
Referenced by FEAT::LAFEM::Container< DT_, IT_ >::_serialize(), and FEAT::LAFEM::Container< DT_, IT_ >::_serialized_size().
|
static |
Decodes an array from a packed buffer.
| [out] | dst | A pointer to the output array that is to be unpacked. Must not be nullptr. |
| [in] | buf | A pointer to the input buffer. Must not be nullptr. |
| [in] | count | The number of output array elements. |
| [in] | buf_size | The size of the input buffer buf in bytes. |
| [in] | pack_type | The input buffer pack type. |
| [in] | swap_bytes | Specifies whether to swap the pack type bytes. |
Definition at line 745 of file pack.cpp.
References decode_raw(), element_size(), and XABORTM.
Referenced by decode().
|
static |
Encodes an array into a packed buffer.
| [out] | buf | A pointer to the output buffer. Must not be nullptr. |
| [in] | src | A pointer to the input array that is to be packed. Must not be nullptr. |
| [in] | buf_size | The size of the output buffer buf in bytes. Must be at least as big as the estimated buffer size. |
| [in] | count | The number of input array elements. |
| [in] | pack_type | The desired output buffer pack type. |
| [in] | swap_bytes | Specifies whether to swap the pack type bytes. |
Definition at line 633 of file pack.cpp.
References element_size(), encode_raw(), and XABORTM.
Referenced by encode().
|
static |
Decodes an array from a packed buffer with lossy saved compression data.
| [out] | dst | A pointer to the output array that is to be unpacked. Must not be nullptr. |
| [in] | buf | A pointer to the input buffer. Must not be nullptr. |
| [in] | count | The number of output array elements. |
| [in] | buf_size | The size of the input buffer buf in bytes. |
| [in] | pack_type | The input buffer pack type. |
| [in] | swap_bytes | Specifies whether to swap the pack type bytes. |
Definition at line 937 of file pack.cpp.
References decode_raw(), element_size(), FEAT::stringify(), XABORTM, XASSERT, and XASSERTM.
Referenced by decode().
|
static |
Encodes an array into a packed buffer.
| [out] | buf | A pointer to the output buffer. Must not be nullptr. |
| [in] | src | A pointer to the input array that is to be packed. Must not be nullptr. |
| [in] | buf_size | The size of the output buffer buf in bytes. Must be at least as big as the estimated buffer size. |
| [in] | count | The number of input array elements. |
| [in] | pack_type | The desired output buffer pack type. |
| [in] | swap_bytes | Specifies whether to swap the pack type bytes. |
| [in] | tolerance | The desired maximum error of compressed data. |
Definition at line 825 of file pack.cpp.
References element_size(), encode_raw(), XABORTM, and XASSERT.
Referenced by encode().
|
static |
Computes the estimated (upper bound) pack buffer size for an array for lossy compression.
| [in] | src | A pointer to the input array that is to be packed. Must not be nullptr. |
| [in] | count | The number of input array elements. |
| [in] | tolerance | The desired maximum error of compressed data. |
Definition at line 486 of file pack.cpp.
References XABORTM, and XASSERT.
Referenced by estimate_size().
|
inline |
bit-wise AND operator for Pack::Type
|
inline |
stream output operator for Pack::Type
|
inline |
stream input operator for Pack::Type
Definition at line 189 of file pack.hpp.
References FEAT::String::compare_no_case().
|
inline |
bit-wise OR operator for Pack::Type
|
static |
Encodes an array by converting each of its elements to a desired type.
Effectively, this function performs dest[i] = T_(((X_*)buf)[i]) for all i < count.
| X_ | The type of the encoded source array buffer buf whose elements are to be converted |
| T_ | The type of the destination array dest |
| [out] | dest | The destination array that receives the converted array elements |
| [in] | buf | The source buffer whose elements of type X_ are to be converted. This buffer is assumed to be at least sizeof(X_)*count bytes in size. |
| [in] | count | The number of elements in the destination array dest. |
| [in] | swap_bytes | Specifies whether the bytes in the source buffer buf are to be swapped before conversion. |
sizeof(X_)*count. Definition at line 184 of file pack.cpp.
References xswap().
|
static |
Encodes an array by converting each of its elements to a desired type.
Effectively, this function performs ((X_*)buf)[i] = X_(src[i]) for all i < count.
| X_ | The desired type of the encoded destination array buffer buf |
| T_ | The type of the source array src whose elements are to be converted. |
| [out] | buf | The destination buffer that receives the array elements of type X_. This buffer is assumed to be at least sizeof(X_)*count bytes in size. |
| [in] | src | The source array whose elements of type T_ are to be converted |
| [in] | count | The number of elements in the source array src. |
| [in] | swap_bytes | Specifies whether the bytes in the destination buffer buf are to be swapped after conversion. |
sizeof(X_)*count. Definition at line 133 of file pack.cpp.
References xswap().