| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #pragma once
|
|
|
| #include <cstdint>
|
| #include <stdexcept>
|
| #include <string>
|
|
|
| #include "nvcomp.h"
|
|
|
| namespace nvcomp {
|
|
|
| |
| |
|
|
| enum class nvcompFormatType_t : uint8_t {
|
| LZ4 = 0,
|
| Snappy = 1,
|
| ANS = 2,
|
| GDeflate = 3,
|
| Cascaded = 4,
|
| Bitcomp = 5,
|
| Zstd = 6,
|
| Deflate = 7,
|
| Gzip = 8,
|
| NotSupportedError = 255
|
| };
|
|
|
| |
| |
|
|
| class NVCompException : public std::runtime_error
|
| {
|
| public:
|
| |
| |
| |
| |
| |
|
|
| NVCompException(nvcompStatus_t err, const std::string& msg) :
|
| std::runtime_error(msg + " : code=" + std::to_string(err) + "."),
|
| m_err(err)
|
| {}
|
|
|
| nvcompStatus_t get_error() const noexcept
|
| {
|
| return m_err;
|
| }
|
|
|
| private:
|
| nvcompStatus_t m_err;
|
| };
|
|
|
| #ifndef DOXYGEN_SHOULD_SKIP_THIS
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| template <typename T>
|
| __device__ __host__ constexpr nvcompType_t TypeOfConst() noexcept
|
| {
|
| return std::is_same<T, int8_t>::value ?
|
| NVCOMP_TYPE_CHAR : (
|
| std::is_same<T, uint8_t>::value ?
|
| NVCOMP_TYPE_UCHAR : (
|
| std::is_same<T, int16_t>::value ?
|
| NVCOMP_TYPE_SHORT : (
|
| std::is_same<T, uint16_t>::value ?
|
| NVCOMP_TYPE_USHORT : (
|
| std::is_same<T, int32_t>::value ?
|
| NVCOMP_TYPE_INT : (
|
| std::is_same<T, uint32_t>::value ?
|
| NVCOMP_TYPE_UINT : (
|
| std::is_same<T, int64_t>::value ?
|
| NVCOMP_TYPE_LONGLONG : (
|
| std::is_same<T, uint64_t>::value ?
|
| NVCOMP_TYPE_ULONGLONG : (
|
| NVCOMP_TYPE_BITS
|
| ))))))));
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| template <typename T>
|
| inline nvcompType_t TypeOf()
|
| {
|
| auto type = TypeOfConst<T>();
|
| if (type != NVCOMP_TYPE_BITS) {
|
| return type;
|
| }
|
| throw NVCompException(
|
| nvcompErrorNotSupported, "nvCOMP does not support the given type.");
|
| }
|
|
|
| #endif
|
|
|
| }
|
|
|