explodethosebits 0.3.0__cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. etb/__init__.py +351 -0
  2. etb/__init__.pyi +976 -0
  3. etb/_etb.cpython-39-x86_64-linux-gnu.so +0 -0
  4. etb/_version.py +34 -0
  5. etb/py.typed +2 -0
  6. explodethosebits-0.3.0.dist-info/METADATA +405 -0
  7. explodethosebits-0.3.0.dist-info/RECORD +88 -0
  8. explodethosebits-0.3.0.dist-info/WHEEL +6 -0
  9. explodethosebits-0.3.0.dist-info/licenses/LICENSE +21 -0
  10. explodethosebits-0.3.0.dist-info/sboms/auditwheel.cdx.json +1 -0
  11. explodethosebits.libs/libcudart-c3a75b33.so.12.8.90 +0 -0
  12. include/etb/bit_coordinate.hpp +45 -0
  13. include/etb/bit_extraction.hpp +79 -0
  14. include/etb/bit_pruning.hpp +122 -0
  15. include/etb/config.hpp +284 -0
  16. include/etb/cuda/arch_optimizations.cuh +358 -0
  17. include/etb/cuda/blackwell_optimizations.cuh +300 -0
  18. include/etb/cuda/cuda_common.cuh +265 -0
  19. include/etb/cuda/etb_cuda.cuh +200 -0
  20. include/etb/cuda/gpu_memory.cuh +406 -0
  21. include/etb/cuda/heuristics_kernel.cuh +315 -0
  22. include/etb/cuda/path_generator_kernel.cuh +272 -0
  23. include/etb/cuda/prefix_pruner_kernel.cuh +370 -0
  24. include/etb/cuda/signature_kernel.cuh +328 -0
  25. include/etb/early_stopping.hpp +246 -0
  26. include/etb/etb.hpp +20 -0
  27. include/etb/heuristics.hpp +165 -0
  28. include/etb/memoization.hpp +285 -0
  29. include/etb/path.hpp +86 -0
  30. include/etb/path_count.hpp +87 -0
  31. include/etb/path_generator.hpp +175 -0
  32. include/etb/prefix_trie.hpp +339 -0
  33. include/etb/reporting.hpp +437 -0
  34. include/etb/scoring.hpp +269 -0
  35. include/etb/signature.hpp +190 -0
  36. include/gmock/gmock-actions.h +2297 -0
  37. include/gmock/gmock-cardinalities.h +159 -0
  38. include/gmock/gmock-function-mocker.h +518 -0
  39. include/gmock/gmock-matchers.h +5623 -0
  40. include/gmock/gmock-more-actions.h +658 -0
  41. include/gmock/gmock-more-matchers.h +120 -0
  42. include/gmock/gmock-nice-strict.h +277 -0
  43. include/gmock/gmock-spec-builders.h +2148 -0
  44. include/gmock/gmock.h +96 -0
  45. include/gmock/internal/custom/README.md +18 -0
  46. include/gmock/internal/custom/gmock-generated-actions.h +7 -0
  47. include/gmock/internal/custom/gmock-matchers.h +37 -0
  48. include/gmock/internal/custom/gmock-port.h +40 -0
  49. include/gmock/internal/gmock-internal-utils.h +487 -0
  50. include/gmock/internal/gmock-port.h +139 -0
  51. include/gmock/internal/gmock-pp.h +279 -0
  52. include/gtest/gtest-assertion-result.h +237 -0
  53. include/gtest/gtest-death-test.h +345 -0
  54. include/gtest/gtest-matchers.h +923 -0
  55. include/gtest/gtest-message.h +252 -0
  56. include/gtest/gtest-param-test.h +546 -0
  57. include/gtest/gtest-printers.h +1161 -0
  58. include/gtest/gtest-spi.h +250 -0
  59. include/gtest/gtest-test-part.h +192 -0
  60. include/gtest/gtest-typed-test.h +331 -0
  61. include/gtest/gtest.h +2321 -0
  62. include/gtest/gtest_pred_impl.h +279 -0
  63. include/gtest/gtest_prod.h +60 -0
  64. include/gtest/internal/custom/README.md +44 -0
  65. include/gtest/internal/custom/gtest-port.h +37 -0
  66. include/gtest/internal/custom/gtest-printers.h +42 -0
  67. include/gtest/internal/custom/gtest.h +37 -0
  68. include/gtest/internal/gtest-death-test-internal.h +307 -0
  69. include/gtest/internal/gtest-filepath.h +227 -0
  70. include/gtest/internal/gtest-internal.h +1560 -0
  71. include/gtest/internal/gtest-param-util.h +1026 -0
  72. include/gtest/internal/gtest-port-arch.h +122 -0
  73. include/gtest/internal/gtest-port.h +2481 -0
  74. include/gtest/internal/gtest-string.h +178 -0
  75. include/gtest/internal/gtest-type-util.h +220 -0
  76. lib/libetb_core.a +0 -0
  77. lib64/cmake/GTest/GTestConfig.cmake +33 -0
  78. lib64/cmake/GTest/GTestConfigVersion.cmake +43 -0
  79. lib64/cmake/GTest/GTestTargets-release.cmake +49 -0
  80. lib64/cmake/GTest/GTestTargets.cmake +139 -0
  81. lib64/libgmock.a +0 -0
  82. lib64/libgmock_main.a +0 -0
  83. lib64/libgtest.a +0 -0
  84. lib64/libgtest_main.a +0 -0
  85. lib64/pkgconfig/gmock.pc +10 -0
  86. lib64/pkgconfig/gmock_main.pc +10 -0
  87. lib64/pkgconfig/gtest.pc +9 -0
  88. lib64/pkgconfig/gtest_main.pc +10 -0
@@ -0,0 +1,175 @@
1
+ #ifndef ETB_PATH_GENERATOR_HPP
2
+ #define ETB_PATH_GENERATOR_HPP
3
+
4
+ #include "path.hpp"
5
+ #include "bit_coordinate.hpp"
6
+ #include "bit_pruning.hpp"
7
+ #include <vector>
8
+ #include <cstdint>
9
+ #include <optional>
10
+ #include <stack>
11
+
12
+ namespace etb {
13
+
14
+ /**
15
+ * Configuration for the path generator.
16
+ */
17
+ struct PathGeneratorConfig {
18
+ uint32_t input_length; // Length of input byte array
19
+ uint32_t max_path_length; // Maximum path length (0 = unlimited up to input_length)
20
+ uint32_t starting_byte_index; // Starting byte index for path generation
21
+ uint8_t bit_mask; // Bit mask for allowed bit positions (0xFF = all bits)
22
+
23
+ PathGeneratorConfig(uint32_t len)
24
+ : input_length(len)
25
+ , max_path_length(0)
26
+ , starting_byte_index(0)
27
+ , bit_mask(0xFF)
28
+ {}
29
+
30
+ /**
31
+ * Apply a BitPruningConfig to this generator config.
32
+ * @param pruning_config The bit pruning configuration to apply
33
+ */
34
+ void apply_bit_pruning(const BitPruningConfig& pruning_config) {
35
+ bit_mask = pruning_config.get_mask();
36
+ }
37
+
38
+ /**
39
+ * Create a PathGeneratorConfig with bit pruning applied.
40
+ * @param len Input length
41
+ * @param pruning_config The bit pruning configuration
42
+ */
43
+ PathGeneratorConfig(uint32_t len, const BitPruningConfig& pruning_config)
44
+ : input_length(len)
45
+ , max_path_length(0)
46
+ , starting_byte_index(0)
47
+ , bit_mask(pruning_config.get_mask())
48
+ {}
49
+ };
50
+
51
+ /**
52
+ * Lazy path generator using iterator pattern.
53
+ * Generates all valid forward-only traversal paths on-demand.
54
+ *
55
+ * The generator explores paths depth-first, yielding each complete path
56
+ * before backtracking to explore alternatives.
57
+ *
58
+ * Forward-only constraint: Each coordinate in a path must have a strictly
59
+ * greater byte_index than the previous coordinate.
60
+ */
61
+ class PathGenerator {
62
+ public:
63
+ /**
64
+ * Construct a path generator for the given input length.
65
+ * @param input_length Length of the input byte array
66
+ */
67
+ explicit PathGenerator(uint32_t input_length);
68
+
69
+ /**
70
+ * Construct a path generator with custom configuration.
71
+ * @param config Generator configuration
72
+ */
73
+ explicit PathGenerator(const PathGeneratorConfig& config);
74
+
75
+ /**
76
+ * Check if there are more paths to generate.
77
+ * @return true if next() will return a valid path
78
+ */
79
+ bool has_next() const;
80
+
81
+ /**
82
+ * Generate the next path.
83
+ * @return The next path, or std::nullopt if no more paths
84
+ */
85
+ std::optional<Path> next();
86
+
87
+ /**
88
+ * Reset the generator to start from the beginning.
89
+ */
90
+ void reset();
91
+
92
+ /**
93
+ * Get the current configuration.
94
+ */
95
+ const PathGeneratorConfig& config() const { return config_; }
96
+
97
+ /**
98
+ * Get the number of paths generated so far.
99
+ */
100
+ uint64_t paths_generated() const { return paths_generated_; }
101
+
102
+ private:
103
+ PathGeneratorConfig config_;
104
+
105
+ // State for iterative depth-first traversal
106
+ struct StackFrame {
107
+ uint32_t byte_index;
108
+ uint8_t bit_position;
109
+ bool explored; // Have we yielded a path ending here?
110
+ };
111
+
112
+ std::stack<StackFrame> stack_;
113
+ Path current_path_;
114
+ uint64_t paths_generated_;
115
+ bool exhausted_;
116
+ bool first_call_;
117
+
118
+ // Helper to check if a bit position is allowed by the mask
119
+ bool is_bit_allowed(uint8_t bit_pos) const;
120
+
121
+ // Get the next allowed bit position starting from pos
122
+ int next_allowed_bit(uint8_t start_pos) const;
123
+
124
+ // Initialize the stack for a fresh start
125
+ void initialize_stack();
126
+
127
+ // Advance to the next state
128
+ void advance();
129
+ };
130
+
131
+ /**
132
+ * Iterator adapter for PathGenerator to support range-based for loops.
133
+ */
134
+ class PathIterator {
135
+ public:
136
+ using iterator_category = std::input_iterator_tag;
137
+ using value_type = Path;
138
+ using difference_type = std::ptrdiff_t;
139
+ using pointer = const Path*;
140
+ using reference = const Path&;
141
+
142
+ PathIterator() : generator_(nullptr), current_path_(std::nullopt) {}
143
+ explicit PathIterator(PathGenerator* gen);
144
+
145
+ reference operator*() const { return *current_path_; }
146
+ pointer operator->() const { return &(*current_path_); }
147
+
148
+ PathIterator& operator++();
149
+ PathIterator operator++(int);
150
+
151
+ bool operator==(const PathIterator& other) const;
152
+ bool operator!=(const PathIterator& other) const { return !(*this == other); }
153
+
154
+ private:
155
+ PathGenerator* generator_;
156
+ std::optional<Path> current_path_;
157
+ };
158
+
159
+ /**
160
+ * Range adapter for PathGenerator to support range-based for loops.
161
+ */
162
+ class PathRange {
163
+ public:
164
+ explicit PathRange(PathGenerator& gen) : generator_(gen) {}
165
+
166
+ PathIterator begin() { return PathIterator(&generator_); }
167
+ PathIterator end() { return PathIterator(); }
168
+
169
+ private:
170
+ PathGenerator& generator_;
171
+ };
172
+
173
+ } // namespace etb
174
+
175
+ #endif // ETB_PATH_GENERATOR_HPP
@@ -0,0 +1,339 @@
1
+ #ifndef ETB_PREFIX_TRIE_HPP
2
+ #define ETB_PREFIX_TRIE_HPP
3
+
4
+ #include <cstdint>
5
+ #include <cstddef>
6
+ #include <vector>
7
+ #include <atomic>
8
+ #include <mutex>
9
+
10
+ namespace etb {
11
+
12
+ /**
13
+ * Status of a prefix trie node.
14
+ */
15
+ enum class PrefixStatus : uint8_t {
16
+ UNKNOWN = 0, // Not yet evaluated
17
+ VALID = 1, // Prefix passed heuristics, continue exploring
18
+ PRUNED = 2 // Prefix failed heuristics, eliminate all children
19
+ };
20
+
21
+ /**
22
+ * Prefix trie node with flat array layout for GPU compatibility.
23
+ * Each node represents a reconstructed byte value at a specific depth.
24
+ */
25
+ struct PrefixTrieNode {
26
+ uint8_t reconstructed_byte; // Byte value at this node
27
+ PrefixStatus status; // UNKNOWN, VALID, or PRUNED
28
+ float best_score; // Best heuristic score seen at this prefix
29
+ uint32_t children_offset; // Offset to children array (256 children max per byte value)
30
+ uint32_t visit_count; // For adaptive threshold adjustment
31
+ uint32_t parent_index; // Index of parent node (0 for root)
32
+
33
+ PrefixTrieNode()
34
+ : reconstructed_byte(0)
35
+ , status(PrefixStatus::UNKNOWN)
36
+ , best_score(0.0f)
37
+ , children_offset(0)
38
+ , visit_count(0)
39
+ , parent_index(0) {}
40
+
41
+ PrefixTrieNode(uint8_t byte_val, uint32_t parent)
42
+ : reconstructed_byte(byte_val)
43
+ , status(PrefixStatus::UNKNOWN)
44
+ , best_score(0.0f)
45
+ , children_offset(0)
46
+ , visit_count(0)
47
+ , parent_index(parent) {}
48
+ };
49
+
50
+ /**
51
+ * Configuration for the prefix trie.
52
+ */
53
+ struct PrefixTrieConfig {
54
+ uint32_t max_depth; // Maximum depth of the trie (default: 16)
55
+ uint32_t initial_capacity; // Initial node capacity (default: 4096)
56
+ float prune_threshold; // Score threshold below which to prune (default: 0.3)
57
+ uint32_t branch_prune_count; // Number of failed branches to trigger level prune (default: 6)
58
+
59
+ PrefixTrieConfig()
60
+ : max_depth(16)
61
+ , initial_capacity(4096)
62
+ , prune_threshold(0.3f)
63
+ , branch_prune_count(6) {}
64
+ };
65
+
66
+ /**
67
+ * Statistics for prefix trie operations.
68
+ */
69
+ struct PrefixTrieStats {
70
+ uint64_t total_lookups;
71
+ uint64_t cache_hits;
72
+ uint64_t nodes_created;
73
+ uint64_t nodes_pruned;
74
+ uint64_t children_eliminated;
75
+ std::vector<uint32_t> valid_branches_per_level;
76
+ std::vector<uint32_t> pruned_branches_per_level;
77
+
78
+ PrefixTrieStats()
79
+ : total_lookups(0)
80
+ , cache_hits(0)
81
+ , nodes_created(0)
82
+ , nodes_pruned(0)
83
+ , children_eliminated(0) {}
84
+
85
+ void reset() {
86
+ total_lookups = 0;
87
+ cache_hits = 0;
88
+ nodes_created = 0;
89
+ nodes_pruned = 0;
90
+ children_eliminated = 0;
91
+ valid_branches_per_level.clear();
92
+ pruned_branches_per_level.clear();
93
+ }
94
+ };
95
+
96
+
97
+ /**
98
+ * Prefix Trie - GPU-compatible trie for O(1) prefix lookup and pruning.
99
+ *
100
+ * Uses a flat array layout with breadth-first ordering for coalesced
101
+ * memory access patterns on GPU. Supports atomic status updates for
102
+ * concurrent access.
103
+ *
104
+ * Requirements: 5.5 - Trie-based prefix tracking for O(1) prefix lookup
105
+ */
106
+ class PrefixTrie {
107
+ public:
108
+ /**
109
+ * Construct with default configuration.
110
+ */
111
+ PrefixTrie();
112
+
113
+ /**
114
+ * Construct with custom configuration.
115
+ * @param config Trie configuration
116
+ */
117
+ explicit PrefixTrie(const PrefixTrieConfig& config);
118
+
119
+ /**
120
+ * Look up a prefix in the trie.
121
+ * @param prefix Byte sequence representing the prefix
122
+ * @param length Length of the prefix
123
+ * @return Pointer to the node if found, nullptr if not found
124
+ */
125
+ const PrefixTrieNode* lookup(const uint8_t* prefix, size_t length) const;
126
+
127
+ /**
128
+ * Look up a prefix in the trie (vector overload).
129
+ * @param prefix Byte sequence representing the prefix
130
+ * @return Pointer to the node if found, nullptr if not found
131
+ */
132
+ const PrefixTrieNode* lookup(const std::vector<uint8_t>& prefix) const;
133
+
134
+ /**
135
+ * Insert or update a prefix in the trie.
136
+ * @param prefix Byte sequence representing the prefix
137
+ * @param length Length of the prefix
138
+ * @param status Status to set for the node
139
+ * @param score Heuristic score for the prefix
140
+ * @return Index of the inserted/updated node
141
+ */
142
+ uint32_t insert(const uint8_t* prefix, size_t length,
143
+ PrefixStatus status, float score);
144
+
145
+ /**
146
+ * Insert or update a prefix in the trie (vector overload).
147
+ * @param prefix Byte sequence representing the prefix
148
+ * @param status Status to set for the node
149
+ * @param score Heuristic score for the prefix
150
+ * @return Index of the inserted/updated node
151
+ */
152
+ uint32_t insert(const std::vector<uint8_t>& prefix,
153
+ PrefixStatus status, float score);
154
+
155
+ /**
156
+ * Update the status of an existing node atomically.
157
+ * @param node_index Index of the node to update
158
+ * @param status New status
159
+ * @return true if update succeeded, false if node doesn't exist
160
+ */
161
+ bool update_status(uint32_t node_index, PrefixStatus status);
162
+
163
+ /**
164
+ * Update the best score of an existing node.
165
+ * @param node_index Index of the node to update
166
+ * @param score New score (only updates if higher than current)
167
+ * @return true if update succeeded
168
+ */
169
+ bool update_score(uint32_t node_index, float score);
170
+
171
+ /**
172
+ * Mark a prefix as pruned and eliminate all children.
173
+ * @param prefix Byte sequence representing the prefix
174
+ * @param length Length of the prefix
175
+ * @return Number of children eliminated
176
+ */
177
+ uint64_t prune(const uint8_t* prefix, size_t length);
178
+
179
+ /**
180
+ * Mark a prefix as pruned and eliminate all children (vector overload).
181
+ * @param prefix Byte sequence representing the prefix
182
+ * @return Number of children eliminated
183
+ */
184
+ uint64_t prune(const std::vector<uint8_t>& prefix);
185
+
186
+ /**
187
+ * Check if a prefix or any of its ancestors is pruned.
188
+ * @param prefix Byte sequence representing the prefix
189
+ * @param length Length of the prefix
190
+ * @return true if the prefix should be skipped due to pruning
191
+ */
192
+ bool is_pruned(const uint8_t* prefix, size_t length) const;
193
+
194
+ /**
195
+ * Check if a prefix or any of its ancestors is pruned (vector overload).
196
+ * @param prefix Byte sequence representing the prefix
197
+ * @return true if the prefix should be skipped due to pruning
198
+ */
199
+ bool is_pruned(const std::vector<uint8_t>& prefix) const;
200
+
201
+ /**
202
+ * Get the number of valid branches at a specific level.
203
+ * @param level Depth level (0 = root children)
204
+ * @return Number of valid (non-pruned) branches
205
+ */
206
+ uint32_t get_valid_branch_count(uint32_t level) const;
207
+
208
+ /**
209
+ * Get the number of pruned branches at a specific level.
210
+ * @param level Depth level (0 = root children)
211
+ * @return Number of pruned branches
212
+ */
213
+ uint32_t get_pruned_branch_count(uint32_t level) const;
214
+
215
+ /**
216
+ * Calculate the effective branching factor.
217
+ * @return Average number of valid branches per level
218
+ */
219
+ float get_effective_branching_factor() const;
220
+
221
+ /**
222
+ * Get the total number of nodes in the trie.
223
+ */
224
+ size_t node_count() const { return nodes_.size(); }
225
+
226
+ /**
227
+ * Get the maximum depth of the trie.
228
+ */
229
+ uint32_t max_depth() const { return config_.max_depth; }
230
+
231
+ /**
232
+ * Get the configuration.
233
+ */
234
+ const PrefixTrieConfig& get_config() const { return config_; }
235
+
236
+ /**
237
+ * Get statistics about trie operations.
238
+ */
239
+ const PrefixTrieStats& get_statistics() const { return stats_; }
240
+
241
+ /**
242
+ * Reset statistics.
243
+ */
244
+ void reset_statistics();
245
+
246
+ /**
247
+ * Clear all nodes and reset the trie.
248
+ */
249
+ void clear();
250
+
251
+ /**
252
+ * Get read-only access to the underlying node array.
253
+ * Useful for GPU memory transfer.
254
+ */
255
+ const std::vector<PrefixTrieNode>& nodes() const { return nodes_; }
256
+
257
+ /**
258
+ * Get a node by index.
259
+ * @param index Node index
260
+ * @return Pointer to node or nullptr if invalid index
261
+ */
262
+ const PrefixTrieNode* get_node(uint32_t index) const;
263
+
264
+ /**
265
+ * Check if a level should trigger aggressive pruning based on failure rate.
266
+ * When branch_prune_count (default 6) out of 8 branches fail at a level,
267
+ * this returns true to indicate the level should be more aggressively pruned.
268
+ * @param level Depth level to check
269
+ * @return true if pruning threshold exceeded at this level
270
+ */
271
+ bool should_prune_level(uint32_t level) const;
272
+
273
+ /**
274
+ * Evaluate a prefix and automatically prune if score is below threshold.
275
+ * @param prefix Byte sequence representing the prefix
276
+ * @param length Length of the prefix
277
+ * @param score Heuristic score for the prefix
278
+ * @return true if prefix was pruned, false if it remains valid
279
+ */
280
+ bool evaluate_and_prune(const uint8_t* prefix, size_t length, float score);
281
+
282
+ /**
283
+ * Evaluate a prefix and automatically prune if score is below threshold (vector overload).
284
+ * @param prefix Byte sequence representing the prefix
285
+ * @param score Heuristic score for the prefix
286
+ * @return true if prefix was pruned, false if it remains valid
287
+ */
288
+ bool evaluate_and_prune(const std::vector<uint8_t>& prefix, float score);
289
+
290
+ /**
291
+ * Get the total number of branches (valid + pruned) at a level.
292
+ * @param level Depth level
293
+ * @return Total branch count
294
+ */
295
+ uint32_t get_total_branch_count(uint32_t level) const;
296
+
297
+ private:
298
+ PrefixTrieConfig config_;
299
+ std::vector<PrefixTrieNode> nodes_;
300
+ mutable PrefixTrieStats stats_;
301
+ mutable std::mutex mutex_; // For thread-safe operations
302
+
303
+ // Root node is at index 0, children start at index 1
304
+ static constexpr uint32_t ROOT_INDEX = 0;
305
+ static constexpr uint32_t INVALID_INDEX = UINT32_MAX;
306
+ static constexpr uint32_t CHILDREN_PER_NODE = 256; // One for each byte value
307
+
308
+ /**
309
+ * Find or create a child node for a given byte value.
310
+ * @param parent_index Index of the parent node
311
+ * @param byte_value Byte value for the child
312
+ * @return Index of the child node
313
+ */
314
+ uint32_t find_or_create_child(uint32_t parent_index, uint8_t byte_value);
315
+
316
+ /**
317
+ * Get the child index for a given parent and byte value.
318
+ * @param parent_index Index of the parent node
319
+ * @param byte_value Byte value for the child
320
+ * @return Index of the child node or INVALID_INDEX if not found
321
+ */
322
+ uint32_t get_child_index(uint32_t parent_index, uint8_t byte_value) const;
323
+
324
+ /**
325
+ * Recursively mark all descendants as pruned.
326
+ * @param node_index Index of the node whose children to prune
327
+ * @return Number of nodes pruned
328
+ */
329
+ uint64_t prune_descendants(uint32_t node_index);
330
+
331
+ /**
332
+ * Ensure branch tracking vectors are sized for the given level.
333
+ */
334
+ void ensure_level_tracking(uint32_t level);
335
+ };
336
+
337
+ } // namespace etb
338
+
339
+ #endif // ETB_PREFIX_TRIE_HPP