Skip to content

Commit

Permalink
rename gpu_deflate -> starflate
Browse files Browse the repository at this point in the history
Change-Id: Idde6233615ab528fd3d73c78a55d6a88df995d2a
  • Loading branch information
garymm committed Sep 17, 2023
1 parent 90fc166 commit 94c907b
Show file tree
Hide file tree
Showing 25 changed files with 59 additions and 54 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gpu-deflate
# starflate

Deflate on GPU
Deflate on various hardware platforms

## Set up

Expand Down Expand 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)
4 changes: 2 additions & 2 deletions huffman/src/bit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cassert>
#include <ostream>

namespace gpu_deflate::huffman {
namespace starflate::huffman {

/// A distinct type to represent a bit
///
Expand Down Expand Up @@ -78,4 +78,4 @@ consteval auto operator""_b(unsigned long long int n) -> bit

} // namespace literals

} // namespace gpu_deflate::huffman
} // namespace starflate::huffman
4 changes: 2 additions & 2 deletions huffman/src/bit_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <limits>
#include <ranges>

namespace gpu_deflate::huffman {
namespace starflate::huffman {
/// A non-owning span of bits. Allows for iteration over the individual bits.
class bit_span
{
Expand Down Expand Up @@ -101,4 +101,4 @@ class bit_span
return iterator{*this, bit_size_};
};
};
} // namespace gpu_deflate::huffman
} // namespace starflate::huffman
6 changes: 3 additions & 3 deletions huffman/src/code.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <ranges>
#include <utility>

namespace gpu_deflate::huffman {
namespace starflate::huffman {

/// A Huffman code
///
Expand Down Expand Up @@ -138,12 +138,12 @@ 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::size_t... Is>(std::index_sequence<Is...>) {
return (bit_shift(Bits, N - 1 - Is) | ...);
}(std::make_index_sequence<N>{})};
}

} // namespace literals
} // namespace gpu_deflate::huffman
} // namespace starflate::huffman
4 changes: 2 additions & 2 deletions huffman/src/decode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <iterator>

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
Expand Down Expand Up @@ -45,4 +45,4 @@ decode(const table<Symbol, Extent>& code_table, bit_span bits, O output) -> O
}
return output;
}
} // namespace gpu_deflate::huffman
} // namespace starflate::huffman
4 changes: 2 additions & 2 deletions huffman/src/detail/base_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <ranges>
#include <utility>

namespace gpu_deflate::huffman::detail {
namespace starflate::huffman::detail {

/// A view of elements cast to a base class
/// @tparam V underlying view
Expand Down Expand Up @@ -113,4 +113,4 @@ class base_view : public std::ranges::view_interface<base_view<V, B>>
//
//}

} // namespace gpu_deflate::huffman::detail
} // namespace starflate::huffman::detail
4 changes: 2 additions & 2 deletions huffman/src/detail/iterator_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <concepts>
#include <iterator>

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
Expand Down Expand Up @@ -104,4 +104,4 @@ struct iterator_interface
operator<=>(const iterator_interface&, const iterator_interface&) = default;
};

} // namespace gpu_deflate::huffman::detail
} // namespace starflate::huffman::detail
4 changes: 2 additions & 2 deletions huffman/src/detail/static_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdexcept>
#include <utility>

namespace gpu_deflate::huffman::detail {
namespace starflate::huffman::detail {

/// A simplified implementation of `static_vector`
///
Expand Down Expand Up @@ -88,4 +88,4 @@ class static_vector : std::array<T, Capacity>
constexpr auto cend() const noexcept -> const_iterator { return end(); }
};

} // namespace gpu_deflate::huffman::detail
} // namespace starflate::huffman::detail
4 changes: 2 additions & 2 deletions huffman/src/detail/table_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <cstddef>
#include <functional>

namespace gpu_deflate::huffman::detail {
namespace starflate::huffman::detail {

/// A node of a Huffman tree
///
Expand Down Expand Up @@ -133,4 +133,4 @@ class table_node : public encoding<Symbol>
}
};

} // namespace gpu_deflate::huffman::detail
} // namespace starflate::huffman::detail
4 changes: 2 additions & 2 deletions huffman/src/detail/table_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <type_traits>
#include <vector>

namespace gpu_deflate::huffman {
namespace starflate::huffman {

/// Disambiguation tag to specify a table is constructed with a code-symbol
/// mapping
Expand Down Expand Up @@ -129,4 +129,4 @@ class table_storage : table_storage_base_t<IntrusiveNode, Extent>
};

} // namespace detail
} // namespace gpu_deflate::huffman
} // namespace starflate::huffman
4 changes: 2 additions & 2 deletions huffman/src/encoding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <concepts>
#include <ostream>

namespace gpu_deflate::huffman {
namespace starflate::huffman {

/// A mapping between a symbol and a code
///
Expand Down Expand Up @@ -49,4 +49,4 @@ struct encoding : code
operator<=>(const encoding&, const encoding&) = default;
};

} // namespace gpu_deflate::huffman
} // namespace starflate::huffman
4 changes: 2 additions & 2 deletions huffman/src/table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <tuple>
#include <utility>

namespace gpu_deflate::huffman {
namespace starflate::huffman {

template <class T, std::size_t N>
using c_array = T[N];
Expand Down Expand Up @@ -329,4 +329,4 @@ template <class R>
table(table_contents_tag, const R&)
-> table<detail::tuple_arg_t<1, R>, detail::tuple_size_v<R>()>;

} // namespace gpu_deflate::huffman
} // namespace starflate::huffman
4 changes: 2 additions & 2 deletions huffman/test/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char, 6>{frequencies, eot};
auto ct = starflate::huffman::table<char, 6>{frequencies, eot};
benchmark::DoNotOptimize(ct);
}
}
Expand Down
6 changes: 3 additions & 3 deletions huffman/test/bench_results.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion huffman/test/bit_span_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") = [] {
Expand Down
2 changes: 1 addition & 1 deletion huffman/test/bit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") = [] {
Expand Down
2 changes: 1 addition & 1 deletion huffman/test/code_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion huffman/test/decode_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") = [] {
Expand Down
2 changes: 1 addition & 1 deletion huffman/test/table_find_code_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion huffman/test/table_from_contents_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") = [] {
Expand Down
2 changes: 1 addition & 1 deletion huffman/test/table_from_data_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<char, std::size_t>>{
Expand Down
2 changes: 1 addition & 1 deletion huffman/test/table_from_frequencies_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<char, std::size_t>>{
Expand Down
4 changes: 2 additions & 2 deletions src/decompress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <span>
#include <vector>

namespace gpu_deflate {
namespace starflate {

// error code enum
enum class Error : std::uint8_t
Expand All @@ -25,4 +25,4 @@ auto decompress(
return decompressed;
}

} // namespace gpu_deflate
} // namespace starflate
28 changes: 16 additions & 12 deletions version/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions version/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <string>

namespace gpu_deflate {
namespace starflate {
class Version
{
public:
Expand All @@ -11,4 +11,4 @@ class Version
static const std::string full_version_string;
static const bool isReleaseBuild;
};
} // namespace gpu_deflate
} // namespace starflate

0 comments on commit 94c907b

Please sign in to comment.