Stream classes¶
To perform encoding and decoding operations with data, ZFP requires both the dimensions of the data array and the parameters that determine the compression mode of the encode/decode.
oneDTL implementation must provide two classes to encapsulate these parameters: zfp_field
and zfp_compressed_stream
.
zfp_field¶
-
template<typename DataT, std::uint32_t Dimension>
class oneapi::dtl::data_compression::zfp_field¶ Class for storing uncompressed array for ZFP algorithm.
- tparam DataT
field data type (supported types: float)
- tparam Dimension
dimension of field (supported value: 3)
Public Functions
-
zfp_field(const buffer_t &buffer, const range_t &size)¶
Constructs a new zfp field object.
- Parameters
buffer – input/output buffer for field
size – size of field by each dimension
zfp_compressed_stream¶
-
template<typename DataT, std::uint32_t Dimension>
class oneapi::dtl::data_compression::zfp_compressed_stream¶ Class for ZFP compressed stream representation.
- tparam DataT
Input field datatype (supported types: float)
- tparam Dimension
Input field dimension (supported value: 3)
Public Types
-
template<typename AccessDataT, sycl::access::mode AccessMode, sycl::access::target AccessTarget = sycl::access::target::global_buffer>
using stream_accessor_t = sycl::accessor<AccessDataT, 1U, AccessMode, AccessTarget>¶ Alias template for the accessor using 1D sycl::buffer.
- Template Parameters
AccessDataT – the given access type
AccessMode – the given access mode (sycl::access::mode)
-
using base_unit_t = std::uint32_t¶
Type alias for base element of compressed stream.
Public Functions
-
zfp_compressed_stream(const sycl::range<Dimension> &input_size, const zfp_fixed_rate<DataT, Dimension> &compr_mode, zfp_index_type type, std::size_t granularity = 0)¶
Constructs a new zfp compressed stream object for fix rate mode.
- Parameters
input_size – size of input field
compr_mode – compression parameters
type – type of index array
granularity – count of blocks for each chunk
-
template<sycl::access::mode AccessMode, sycl::access::target AccessTarget = sycl::access::target::global_buffer>
auto get_stream_access(sycl::handler &command_group_handler) -> stream_accessor_t<base_unit_t, AccessMode, AccessTarget>¶ Returns the accessor for the buffer object that stores the compressed stream data.
- Template Parameters
AccessMode – the given access mode (sycl::access::mode)
AccessTarget – the type of device to get access
- Parameters
command_group_handler – the given command group handler (an object of sycl::handler type)
- Returns
The accessor for the buffer object that stores the compressed stream data.
-
template<sycl::access::mode AccessMode>
auto get_stream_access() -> stream_accessor_t<base_unit_t, AccessMode, sycl::access::target::host_buffer>¶ Returns the accessor for the buffer object that stores the compressed stream data.
- Template Parameters
AccessMode – the given access mode (sycl::access::mode)
- Returns
The accessor for the buffer object that stores the compressed stream data.
-
template<sycl::access::mode AccessMode, sycl::access::target AccessTarget = sycl::access::target::global_buffer>
auto get_stream_size_access(sycl::handler &command_group_handler) -> stream_accessor_t<std::size_t, AccessMode, AccessTarget>¶ Returns the accessor for the size of buffer that stores the compressed stream data.
- Template Parameters
AccessMode – the given access mode (sycl::access::mode)
AccessTarget – the type of device to get access
- Parameters
command_group_handler – the given command group handler (an object of sycl::handler type)
- Returns
The accessor for the buffer object that stores the compressed stream data.
-
template<sycl::access::mode AccessMode>
auto get_stream_size_access() -> stream_accessor_t<std::size_t, AccessMode, sycl::access::target::host_buffer>¶ Returns the accessor for the size of buffer that stores the compressed stream data.
- Template Parameters
AccessMode – the given access mode (sycl::access::mode)
- Returns
The accessor for the buffer object that stores the compressed stream data.
-
inline std::uint32_t get_max_bits() const¶
Get the maximum bits count for compressed block.
- Returns
Maximum bits count for compressed block
-
inline std::uint32_t get_min_bits() const¶
Get the minimum bits count for compressed block.
- Returns
Minimum bits count for compressed block
-
inline std::uint32_t get_max_prec() const¶
Get the maximum level of precision.
- Returns
Maximum level of precision
-
inline int get_min_exp() const¶
Get the minimum level of exponent.
- Returns
Minimum level of exponent
-
inline std::size_t get_granularity() const¶
Get the count of blocks stored in single chunk.
- Returns
Count of blocks stored in single chunk
-
inline std::size_t get_stream_size() const¶
Get size of compressed stream.
- Returns
Size of stream in bytes
Additional counting functions used by the zfp_compressed_stream
shall be provided:
-
template<std::uint32_t Dimension>
inline std::size_t oneapi::dtl::data_compression::calc_blocks_count(const sycl::range<Dimension> &input_size)¶ Calculates count of blocks in zfp field.
- Template Parameters
Dimension – model dimension
- Parameters
input_size – size of input field
- Returns
Count of blocks
-
template<std::uint32_t Dimension>
inline std::size_t oneapi::dtl::data_compression::calc_chunks_count(const sycl::range<Dimension> &input_size, std::size_t granularity)¶ Calculates count of chunks in zfp stream.
- Template Parameters
Dimension – model dimension
- Parameters
input_size – size of input field
granularity – count of blocks in one chunk
- Returns
Count of chunks
-
template<typename BaseUnitType, std::uint32_t Dimension>
inline std::size_t oneapi::dtl::data_compression::calc_stream_size(const sycl::range<Dimension> &input_size, std::uint32_t max_bits)¶ Calculates stream size for fixed rate mode.
- Template Parameters
BaseUnitType – element type in compressed stream
Dimension – model dimension
- Parameters
input_size – size of input field
max_bits – maximum count of bits for compressed chunk store
- Returns
Count of elements in compressed stream