diff --git a/README.md b/README.md index f93904e..c217ff8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# gpu-deflate +# starflate -Deflate on GPU +Deflate on various hardware platforms ## Set up @@ -52,6 +52,7 @@ Otherwise, copy the clangd args from the [.vscode/settings.json](.vscode/setting ## References * [DEFLATE Compressed Data Format Specification version 1.3](https://tools.ietf.org/html/rfc1951) +* [Simple-DEFLATE-decompressor](https://github.com/nayuki/Simple-DEFLATE-decompressor) * [pyflate](https://github.com/garymm/pyflate) * [An Explanation of the Deflate Algorithm](https://zlib.net/feldspar.html) * [LZ77 Specification](https://www.cs.duke.edu/courses/spring03/cps296.5/papers/ziv_lempel_1977_universal_algorithm.pdf) diff --git a/huffman/src/bit.hpp b/huffman/src/bit.hpp index a0fc4f4..8fdbf1f 100644 --- a/huffman/src/bit.hpp +++ b/huffman/src/bit.hpp @@ -4,7 +4,7 @@ #include #include -namespace gpu_deflate::huffman { +namespace starflate::huffman { /// A distinct type to represent a bit /// @@ -78,4 +78,4 @@ consteval auto operator""_b(unsigned long long int n) -> bit } // namespace literals -} // namespace gpu_deflate::huffman +} // namespace starflate::huffman diff --git a/huffman/src/bit_span.hpp b/huffman/src/bit_span.hpp index 18da285..f313bf5 100644 --- a/huffman/src/bit_span.hpp +++ b/huffman/src/bit_span.hpp @@ -11,7 +11,7 @@ #include #include -namespace gpu_deflate::huffman { +namespace starflate::huffman { /// A non-owning span of bits. Allows for iteration over the individual bits. class bit_span { @@ -101,4 +101,4 @@ class bit_span return iterator{*this, bit_size_}; }; }; -} // namespace gpu_deflate::huffman +} // namespace starflate::huffman diff --git a/huffman/src/code.hpp b/huffman/src/code.hpp index dd03067..893814a 100644 --- a/huffman/src/code.hpp +++ b/huffman/src/code.hpp @@ -11,7 +11,7 @@ #include #include -namespace gpu_deflate::huffman { +namespace starflate::huffman { /// A Huffman code /// @@ -138,7 +138,7 @@ consteval auto operator""_c() -> code { constexpr auto N = sizeof...(Bits); - using ::gpu_deflate::huffman::detail::bit_shift; + using ::starflate::huffman::detail::bit_shift; return {N, [](std::index_sequence) { return (bit_shift(Bits, N - 1 - Is) | ...); @@ -146,4 +146,4 @@ consteval auto operator""_c() -> code } } // namespace literals -} // namespace gpu_deflate::huffman +} // namespace starflate::huffman diff --git a/huffman/src/decode.hpp b/huffman/src/decode.hpp index 84a912b..d78bfa5 100644 --- a/huffman/src/decode.hpp +++ b/huffman/src/decode.hpp @@ -5,7 +5,7 @@ #include -namespace gpu_deflate::huffman { +namespace starflate::huffman { /// Decodes a bit stream using a code table. /// /// If a code from \p bits is not found in \p code_table, the @@ -45,4 +45,4 @@ decode(const table& code_table, bit_span bits, O output) -> O } return output; } -} // namespace gpu_deflate::huffman +} // namespace starflate::huffman diff --git a/huffman/src/detail/base_view.hpp b/huffman/src/detail/base_view.hpp index 7e84445..060f004 100644 --- a/huffman/src/detail/base_view.hpp +++ b/huffman/src/detail/base_view.hpp @@ -7,7 +7,7 @@ #include #include -namespace gpu_deflate::huffman::detail { +namespace starflate::huffman::detail { /// A view of elements cast to a base class /// @tparam V underlying view @@ -113,4 +113,4 @@ class base_view : public std::ranges::view_interface> // //} -} // namespace gpu_deflate::huffman::detail +} // namespace starflate::huffman::detail diff --git a/huffman/src/detail/iterator_interface.hpp b/huffman/src/detail/iterator_interface.hpp index c0a718a..fed1828 100644 --- a/huffman/src/detail/iterator_interface.hpp +++ b/huffman/src/detail/iterator_interface.hpp @@ -3,7 +3,7 @@ #include #include -namespace gpu_deflate::huffman::detail { +namespace starflate::huffman::detail { /// CRTP helper class used to synthesize operations for a random access iterator /// @tparam D derived iterator type @@ -104,4 +104,4 @@ struct iterator_interface operator<=>(const iterator_interface&, const iterator_interface&) = default; }; -} // namespace gpu_deflate::huffman::detail +} // namespace starflate::huffman::detail diff --git a/huffman/src/detail/static_vector.hpp b/huffman/src/detail/static_vector.hpp index fb98d7a..368845a 100644 --- a/huffman/src/detail/static_vector.hpp +++ b/huffman/src/detail/static_vector.hpp @@ -7,7 +7,7 @@ #include #include -namespace gpu_deflate::huffman::detail { +namespace starflate::huffman::detail { /// A simplified implementation of `static_vector` /// @@ -88,4 +88,4 @@ class static_vector : std::array constexpr auto cend() const noexcept -> const_iterator { return end(); } }; -} // namespace gpu_deflate::huffman::detail +} // namespace starflate::huffman::detail diff --git a/huffman/src/detail/table_node.hpp b/huffman/src/detail/table_node.hpp index 4312cae..4383eaa 100644 --- a/huffman/src/detail/table_node.hpp +++ b/huffman/src/detail/table_node.hpp @@ -9,7 +9,7 @@ #include #include -namespace gpu_deflate::huffman::detail { +namespace starflate::huffman::detail { /// A node of a Huffman tree /// @@ -133,4 +133,4 @@ class table_node : public encoding } }; -} // namespace gpu_deflate::huffman::detail +} // namespace starflate::huffman::detail diff --git a/huffman/src/detail/table_storage.hpp b/huffman/src/detail/table_storage.hpp index 10c83b6..c19a4b7 100644 --- a/huffman/src/detail/table_storage.hpp +++ b/huffman/src/detail/table_storage.hpp @@ -13,7 +13,7 @@ #include #include -namespace gpu_deflate::huffman { +namespace starflate::huffman { /// Disambiguation tag to specify a table is constructed with a code-symbol /// mapping @@ -129,4 +129,4 @@ class table_storage : table_storage_base_t }; } // namespace detail -} // namespace gpu_deflate::huffman +} // namespace starflate::huffman diff --git a/huffman/src/encoding.hpp b/huffman/src/encoding.hpp index fbb8097..bbc5c14 100644 --- a/huffman/src/encoding.hpp +++ b/huffman/src/encoding.hpp @@ -5,7 +5,7 @@ #include #include -namespace gpu_deflate::huffman { +namespace starflate::huffman { /// A mapping between a symbol and a code /// @@ -49,4 +49,4 @@ struct encoding : code operator<=>(const encoding&, const encoding&) = default; }; -} // namespace gpu_deflate::huffman +} // namespace starflate::huffman diff --git a/huffman/src/table.hpp b/huffman/src/table.hpp index 5fc9eb3..a4157aa 100644 --- a/huffman/src/table.hpp +++ b/huffman/src/table.hpp @@ -18,7 +18,7 @@ #include #include -namespace gpu_deflate::huffman { +namespace starflate::huffman { template using c_array = T[N]; @@ -329,4 +329,4 @@ template table(table_contents_tag, const R&) -> table, detail::tuple_size_v()>; -} // namespace gpu_deflate::huffman +} // namespace starflate::huffman diff --git a/huffman/test/bench.cpp b/huffman/test/bench.cpp index 0beced6..8144190 100644 --- a/huffman/test/bench.cpp +++ b/huffman/test/bench.cpp @@ -15,10 +15,10 @@ void BM_CodeTable(benchmark::State& state) {{'e', 100}, {'n', 20}, {'x', 1}, {'i', 40}, {'q', 3}}}; constexpr auto eot = char{4}; - state.SetLabel(gpu_deflate::Version::full_version_string); + state.SetLabel(starflate::Version::full_version_string); for (auto _ : state) { // NOLINTNEXTLINE(readability-magic-numbers) - auto ct = gpu_deflate::huffman::table{frequencies, eot}; + auto ct = starflate::huffman::table{frequencies, eot}; benchmark::DoNotOptimize(ct); } } diff --git a/huffman/test/bench_results.md b/huffman/test/bench_results.md index 83a5380..d51738e 100644 --- a/huffman/test/bench_results.md +++ b/huffman/test/bench_results.md @@ -4,6 +4,6 @@ | name | iterations | real_time (ns) | cpu_time (ns) | comment | | - | - | - | -| -| -| BM_CodeTable | 588879 | 1174.2 | 1174.12 | [d44ffea96815292b517603334895e58c2cd9ea62](https://github.com/garymm/gpu-deflate/tree/d44ffea96815292b517603334895e58c2cd9ea62) (initial impl based on [dahuffman](https://github.com/soxofaan/dahuffman/)) | -| BM_CodeTable | 8931647 |79.1927 | 79.1827 | [52bdee03371059ab181b2af63bbe729598c62928](https://github.com/garymm/gpu-deflate/tree/52bdee03371059ab181b2af63bbe729598c62928) (replace merging priority queues with in-place rotations) -| BM_CodeTable | 16829634 |41.5 | 41.5 | [efd83290046d9f7118b7d7563b99c33a604a9626](https://github.com/garymm/gpu-deflate/tree/efd83290046d9f7118b7d7563b99c33a604a9626) (use std::array, avoid heap allocation altogether) +| BM_CodeTable | 588879 | 1174.2 | 1174.12 | [d44ffea96815292b517603334895e58c2cd9ea62](https://github.com/garymm/starflate/tree/d44ffea96815292b517603334895e58c2cd9ea62) (initial impl based on [dahuffman](https://github.com/soxofaan/dahuffman/)) | +| BM_CodeTable | 8931647 |79.1927 | 79.1827 | [52bdee03371059ab181b2af63bbe729598c62928](https://github.com/garymm/starflate/tree/52bdee03371059ab181b2af63bbe729598c62928) (replace merging priority queues with in-place rotations) +| BM_CodeTable | 16829634 |41.5 | 41.5 | [efd83290046d9f7118b7d7563b99c33a604a9626](https://github.com/garymm/starflate/tree/efd83290046d9f7118b7d7563b99c33a604a9626) (use std::array, avoid heap allocation altogether) diff --git a/huffman/test/bit_span_test.cpp b/huffman/test/bit_span_test.cpp index 5048ee2..6d2c3c0 100644 --- a/huffman/test/bit_span_test.cpp +++ b/huffman/test/bit_span_test.cpp @@ -13,7 +13,7 @@ auto main() -> int using ::boost::ut::expect; using ::boost::ut::test; - namespace huffman = ::gpu_deflate::huffman; + namespace huffman = ::starflate::huffman; using namespace huffman::literals; test("basic") = [] { diff --git a/huffman/test/bit_test.cpp b/huffman/test/bit_test.cpp index f1aea80..f082115 100644 --- a/huffman/test/bit_test.cpp +++ b/huffman/test/bit_test.cpp @@ -13,7 +13,7 @@ auto main() -> int using ::boost::ut::expect; using ::boost::ut::test; - namespace huffman = ::gpu_deflate::huffman; + namespace huffman = ::starflate::huffman; using namespace huffman::literals; test("bit is truthy") = [] { diff --git a/huffman/test/code_test.cpp b/huffman/test/code_test.cpp index 248ca17..39860aa 100644 --- a/huffman/test/code_test.cpp +++ b/huffman/test/code_test.cpp @@ -11,7 +11,7 @@ auto main() -> int using ::boost::ut::expect; using ::boost::ut::test; - namespace huffman = ::gpu_deflate::huffman; + namespace huffman = ::starflate::huffman; using namespace huffman::literals; static const auto to_string = [](huffman::code code) { diff --git a/huffman/test/decode_test.cpp b/huffman/test/decode_test.cpp index 96d0588..b3f7ea0 100644 --- a/huffman/test/decode_test.cpp +++ b/huffman/test/decode_test.cpp @@ -14,7 +14,7 @@ auto main() -> int using ::boost::ut::expect; using ::boost::ut::test; - namespace huffman = ::gpu_deflate::huffman; + namespace huffman = ::starflate::huffman; using namespace huffman::literals; test("basic") = [] { diff --git a/huffman/test/table_find_code_test.cpp b/huffman/test/table_find_code_test.cpp index 319f83a..a9f1d1d 100644 --- a/huffman/test/table_find_code_test.cpp +++ b/huffman/test/table_find_code_test.cpp @@ -10,7 +10,7 @@ auto main() -> int using ::boost::ut::expect; using ::boost::ut::test; - namespace huffman = ::gpu_deflate::huffman; + namespace huffman = ::starflate::huffman; using namespace huffman::literals; static constexpr auto table1 = // clang-format off diff --git a/huffman/test/table_from_contents_test.cpp b/huffman/test/table_from_contents_test.cpp index 88b4b63..95382f6 100644 --- a/huffman/test/table_from_contents_test.cpp +++ b/huffman/test/table_from_contents_test.cpp @@ -13,7 +13,7 @@ auto main() -> int using ::boost::ut::expect; using ::boost::ut::test; - namespace huffman = ::gpu_deflate::huffman; + namespace huffman = ::starflate::huffman; using namespace huffman::literals; test("code table constructible from code-symbol mapping") = [] { diff --git a/huffman/test/table_from_data_test.cpp b/huffman/test/table_from_data_test.cpp index 10ac843..59fa7de 100644 --- a/huffman/test/table_from_data_test.cpp +++ b/huffman/test/table_from_data_test.cpp @@ -18,7 +18,7 @@ auto main() -> int { using namespace ::boost::ut; - namespace huffman = ::gpu_deflate::huffman; + namespace huffman = ::starflate::huffman; test("code table constructible from symbol sequence") = [] { const auto frequencies = std::vector>{ diff --git a/huffman/test/table_from_frequencies_test.cpp b/huffman/test/table_from_frequencies_test.cpp index 880eb12..237af36 100644 --- a/huffman/test/table_from_frequencies_test.cpp +++ b/huffman/test/table_from_frequencies_test.cpp @@ -51,7 +51,7 @@ auto main() -> int { using namespace ::boost::ut; - namespace huffman = ::gpu_deflate::huffman; + namespace huffman = ::starflate::huffman; test("code table is printable") = [] { const auto frequencies = std::vector>{ diff --git a/src/decompress.hpp b/src/decompress.hpp index 18a550c..9a67ce9 100644 --- a/src/decompress.hpp +++ b/src/decompress.hpp @@ -7,7 +7,7 @@ #include #include -namespace gpu_deflate { +namespace starflate { // error code enum enum class Error : std::uint8_t @@ -25,4 +25,4 @@ auto decompress( return decompressed; } -} // namespace gpu_deflate +} // namespace starflate diff --git a/version/version.cpp b/version/version.cpp index 9ac15dd..89531f7 100644 --- a/version/version.cpp +++ b/version/version.cpp @@ -2,19 +2,20 @@ /** * This file is *MAGIC* - * When we compile if from Bazel, we do magical substitutions to some variables defined in CAPS in this file. - * See `version/Build` for up-to-date list of substitutions. + * When we compile if from Bazel, we do magical substitutions to some variables + * defined in CAPS in this file. See `version/Build` for up-to-date list of + * substitutions. * - * This file takes them and packages them to a API that is more pleasant to work with. + * This file takes them and packages them to a API that is more pleasant to + * work with. */ using namespace std; -namespace gpu_deflate { +namespace starflate { // NOTE: bazel ignores build flags for this. // this means that: we can't use c++14\c++11 features here // and this code has no debugger support - #ifdef NDEBUG constexpr bool is_release_build = true; #else @@ -26,16 +27,19 @@ constexpr string_view build_vcs_revision = STABLE_VCS_REVISION; const bool Version::isReleaseBuild = is_release_build; -string makeVCSStatus() { - return build_vcs_modified ? "-dirty" : ""; +string makeVCSStatus() +{ + return build_vcs_modified ? "-dirty" : ""; } const string Version::build_vcs_status = makeVCSStatus(); -string makeVCSRevision() { - return string(build_vcs_revision); +string makeVCSRevision() +{ + return string(build_vcs_revision); } const string Version::build_vcs_revision = makeVCSRevision(); -const string Version::full_version_string = (Version::isReleaseBuild ? ""s : "(non-release) "s) + - Version::build_vcs_revision + Version::build_vcs_status; -} +const string Version::full_version_string = + (Version::isReleaseBuild ? ""s : "(non-release) "s) + + Version::build_vcs_revision + Version::build_vcs_status; +} // namespace starflate diff --git a/version/version.hpp b/version/version.hpp index ca6f275..3234771 100644 --- a/version/version.hpp +++ b/version/version.hpp @@ -2,7 +2,7 @@ #include -namespace gpu_deflate { +namespace starflate { class Version { public: @@ -11,4 +11,4 @@ class Version static const std::string full_version_string; static const bool isReleaseBuild; }; -} // namespace gpu_deflate +} // namespace starflate