multi_compress 0.6.0 → 0.7.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +51 -0
- data/GET_STARTED.md +5 -3
- data/README.md +2 -2
- data/THIRD_PARTY_NOTICES.md +3 -3
- data/ext/multi_compress/exports.darwin +1 -0
- data/ext/multi_compress/exports.map +4 -0
- data/ext/multi_compress/extconf.rb +20 -0
- data/ext/multi_compress/multi_compress.c +352 -149
- data/ext/multi_compress/vendor/.vendored +2 -2
- data/ext/multi_compress/vendor/brotli/c/common/version.h +2 -2
- data/ext/multi_compress/vendor/brotli/c/dec/decode.c +59 -30
- data/ext/multi_compress/vendor/brotli/c/include/brotli/decode.h +1 -3
- data/ext/multi_compress/vendor/zstd/lib/BUCK +10 -5
- data/ext/multi_compress/vendor/zstd/lib/README.md +25 -5
- data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +6 -2
- data/ext/multi_compress/vendor/zstd/lib/common/bits.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +3 -3
- data/ext/multi_compress/vendor/zstd/lib/common/bmi2.h +40 -0
- data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +37 -11
- data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +7 -6
- data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +4 -3
- data/ext/multi_compress/vendor/zstd/lib/common/pool.c +16 -19
- data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +31 -0
- data/ext/multi_compress/vendor/zstd/lib/common/threading.c +16 -2
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +9 -0
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +4 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +300 -3
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +4 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +4 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +775 -214
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +35 -6
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +9 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +14 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +2 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +2 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +49 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +11 -11
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +11 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +16 -18
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.c +3 -3
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +64 -39
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +30 -2
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +78 -64
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +182 -18
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +59 -27
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +11 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +194 -93
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +225 -85
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +19 -2
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +136 -91
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.c +77 -77
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +48 -42
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +18 -14
- data/ext/multi_compress/vendor/zstd/lib/dll/example/build_package.bat +66 -20
- data/ext/multi_compress/vendor/zstd/lib/dll/example/fullbench-dll.vcxproj +10 -6
- data/ext/multi_compress/vendor/zstd/lib/install_oses.mk +17 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +10 -8
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +5 -364
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +4 -5
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +7 -3
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +8 -5
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +3 -3
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +1 -0
- data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +8 -7
- data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +1 -0
- data/ext/multi_compress/vendor/zstd/lib/module.modulemap +0 -21
- data/ext/multi_compress/vendor/zstd/lib/zstd.h +209 -112
- data/lib/multi_compress/active_record.rb +11 -5
- data/lib/multi_compress/codec.rb +164 -94
- data/lib/multi_compress/database/api.rb +42 -0
- data/lib/multi_compress/database/decoding.rb +42 -0
- data/lib/multi_compress/database/dictionary.rb +72 -0
- data/lib/multi_compress/database/encoding.rb +31 -0
- data/lib/multi_compress/database/header.rb +71 -0
- data/lib/multi_compress/database/operations.rb +73 -0
- data/lib/multi_compress/database/validation.rb +95 -0
- data/lib/multi_compress/database.rb +10 -282
- data/lib/multi_compress/db_deployment/bundle_archiver.rb +70 -0
- data/lib/multi_compress/db_deployment/bundle_metadata.rb +56 -0
- data/lib/multi_compress/db_deployment/bundle_stager.rb +62 -0
- data/lib/multi_compress/db_deployment/commands.rb +309 -0
- data/lib/multi_compress/db_deployment/deployment_bundle.rb +80 -0
- data/lib/multi_compress/db_deployment/deterministic_tar_writer.rb +76 -0
- data/lib/multi_compress/db_deployment/dictionary_registry.rb +244 -0
- data/lib/multi_compress/db_deployment/readable_view.rb +112 -0
- data/lib/multi_compress/db_deployment/readable_view_options.rb +51 -0
- data/lib/multi_compress/db_deployment/sql_identifiers.rb +45 -0
- data/lib/multi_compress/db_deployment.rb +10 -844
- data/lib/multi_compress/reader/buffer_operations.rb +57 -0
- data/lib/multi_compress/reader/read_operations.rb +69 -0
- data/lib/multi_compress/reader.rb +97 -0
- data/lib/multi_compress/stream_io.rb +13 -0
- data/lib/multi_compress/version.rb +1 -1
- data/lib/multi_compress/writer.rb +85 -0
- data/lib/multi_compress.rb +42 -333
- data/multi_compress.gemspec +2 -0
- data/mysql_udf/Makefile +12 -5
- data/mysql_udf/multi_compress_mysql.exports +6 -0
- data/postgres_extension/Makefile +2 -1
- data/postgres_extension/test/run_e2e.sh +28 -10
- metadata +30 -10
- data/ext/multi_compress/vendor/lz4/lib/Makefile +0 -244
- data/ext/multi_compress/vendor/lz4/lib/dll/example/Makefile +0 -63
- data/ext/multi_compress/vendor/zstd/lib/Makefile +0 -389
- data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +0 -48
|
@@ -142,19 +142,17 @@ POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
|
|
|
142
142
|
/* Allocate space for the thread handles */
|
|
143
143
|
ctx->threads = (ZSTD_pthread_t*)ZSTD_customCalloc(numThreads * sizeof(ZSTD_pthread_t), customMem);
|
|
144
144
|
ctx->threadCapacity = 0;
|
|
145
|
+
ctx->threadLimit = numThreads;
|
|
145
146
|
ctx->customMem = customMem;
|
|
146
147
|
/* Check for errors */
|
|
147
148
|
if (!ctx->threads || !ctx->queue) { POOL_free(ctx); return NULL; }
|
|
148
149
|
/* Initialize the threads */
|
|
149
|
-
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} }
|
|
156
|
-
ctx->threadCapacity = numThreads;
|
|
157
|
-
ctx->threadLimit = numThreads;
|
|
150
|
+
while (ctx->threadCapacity < numThreads) {
|
|
151
|
+
if (ZSTD_pthread_create(&ctx->threads[ctx->threadCapacity++], NULL, &POOL_thread, ctx)) {
|
|
152
|
+
--ctx->threadCapacity;
|
|
153
|
+
POOL_free(ctx);
|
|
154
|
+
return NULL;
|
|
155
|
+
}
|
|
158
156
|
}
|
|
159
157
|
return ctx;
|
|
160
158
|
}
|
|
@@ -220,23 +218,22 @@ static int POOL_resize_internal(POOL_ctx* ctx, size_t numThreads)
|
|
|
220
218
|
return 0;
|
|
221
219
|
}
|
|
222
220
|
/* numThreads > threadCapacity */
|
|
221
|
+
ctx->threadLimit = numThreads;
|
|
223
222
|
{ ZSTD_pthread_t* const threadPool = (ZSTD_pthread_t*)ZSTD_customCalloc(numThreads * sizeof(ZSTD_pthread_t), ctx->customMem);
|
|
224
223
|
if (!threadPool) return 1;
|
|
225
|
-
/*
|
|
224
|
+
/* extend existing thread pool */
|
|
226
225
|
ZSTD_memcpy(threadPool, ctx->threads, ctx->threadCapacity * sizeof(ZSTD_pthread_t));
|
|
227
226
|
ZSTD_customFree(ctx->threads, ctx->customMem);
|
|
228
227
|
ctx->threads = threadPool;
|
|
229
228
|
/* Initialize additional threads */
|
|
230
|
-
{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
229
|
+
while (ctx->threadCapacity < numThreads) {
|
|
230
|
+
if (ZSTD_pthread_create(&threadPool[ctx->threadCapacity++], NULL, &POOL_thread, ctx)) {
|
|
231
|
+
--ctx->threadCapacity;
|
|
232
|
+
return 1;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
237
236
|
/* successfully expanded */
|
|
238
|
-
ctx->threadCapacity = numThreads;
|
|
239
|
-
ctx->threadLimit = numThreads;
|
|
240
237
|
return 0;
|
|
241
238
|
}
|
|
242
239
|
|
|
@@ -102,6 +102,18 @@
|
|
|
102
102
|
# endif
|
|
103
103
|
#endif
|
|
104
104
|
|
|
105
|
+
/*
|
|
106
|
+
* The Linux kernel importer consumes the outer guard while preserving the
|
|
107
|
+
* distinction below. Normal x86 kernel objects can use the kernel CPU-feature
|
|
108
|
+
* policy, while preboot objects cannot use that infrastructure.
|
|
109
|
+
*/
|
|
110
|
+
#if defined(ZSTD_LINUX_KERNEL)
|
|
111
|
+
# if defined(__KERNEL__) && defined(CONFIG_X86) && \
|
|
112
|
+
!defined(__DISABLE_EXPORTS)
|
|
113
|
+
# define ZSTD_USE_KERNEL_CPU_FEATURES
|
|
114
|
+
# endif
|
|
115
|
+
#endif
|
|
116
|
+
|
|
105
117
|
/**
|
|
106
118
|
* Only enable assembly for GNU C compatible compilers,
|
|
107
119
|
* because other platforms may not support GAS assembly syntax.
|
|
@@ -168,4 +180,23 @@
|
|
|
168
180
|
# define ZSTD_CET_ENDBRANCH
|
|
169
181
|
#endif
|
|
170
182
|
|
|
183
|
+
/**
|
|
184
|
+
* ZSTD_IS_DETERMINISTIC_BUILD must be set to 0 if any compilation macro is
|
|
185
|
+
* active that impacts the compressed output.
|
|
186
|
+
*
|
|
187
|
+
* NOTE: ZSTD_MULTITHREAD is allowed to be set or unset.
|
|
188
|
+
*/
|
|
189
|
+
#if defined(ZSTD_CLEVEL_DEFAULT) \
|
|
190
|
+
|| defined(ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR) \
|
|
191
|
+
|| defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \
|
|
192
|
+
|| defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \
|
|
193
|
+
|| defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR) \
|
|
194
|
+
|| defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \
|
|
195
|
+
|| defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \
|
|
196
|
+
|| defined(ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR)
|
|
197
|
+
# define ZSTD_IS_DETERMINISTIC_BUILD 0
|
|
198
|
+
#else
|
|
199
|
+
# define ZSTD_IS_DETERMINISTIC_BUILD 1
|
|
200
|
+
#endif
|
|
201
|
+
|
|
171
202
|
#endif /* ZSTD_PORTABILITY_MACROS_H */
|
|
@@ -143,7 +143,14 @@ int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t con
|
|
|
143
143
|
*mutex = (pthread_mutex_t*)ZSTD_malloc(sizeof(pthread_mutex_t));
|
|
144
144
|
if (!*mutex)
|
|
145
145
|
return 1;
|
|
146
|
-
|
|
146
|
+
{
|
|
147
|
+
int const ret = pthread_mutex_init(*mutex, attr);
|
|
148
|
+
if (ret != 0) {
|
|
149
|
+
ZSTD_free(*mutex);
|
|
150
|
+
*mutex = NULL;
|
|
151
|
+
}
|
|
152
|
+
return ret;
|
|
153
|
+
}
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
int ZSTD_pthread_mutex_destroy(ZSTD_pthread_mutex_t* mutex)
|
|
@@ -164,7 +171,14 @@ int ZSTD_pthread_cond_init(ZSTD_pthread_cond_t* cond, pthread_condattr_t const*
|
|
|
164
171
|
*cond = (pthread_cond_t*)ZSTD_malloc(sizeof(pthread_cond_t));
|
|
165
172
|
if (!*cond)
|
|
166
173
|
return 1;
|
|
167
|
-
|
|
174
|
+
{
|
|
175
|
+
int const ret = pthread_cond_init(*cond, attr);
|
|
176
|
+
if (ret != 0) {
|
|
177
|
+
ZSTD_free(*cond);
|
|
178
|
+
*cond = NULL;
|
|
179
|
+
}
|
|
180
|
+
return ret;
|
|
181
|
+
}
|
|
168
182
|
}
|
|
169
183
|
|
|
170
184
|
int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond)
|
|
@@ -46,3 +46,12 @@ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
|
|
|
46
46
|
/*! ZSTD_getErrorString() :
|
|
47
47
|
* provides error code string from enum */
|
|
48
48
|
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
|
|
49
|
+
|
|
50
|
+
int ZSTD_isDeterministicBuild(void)
|
|
51
|
+
{
|
|
52
|
+
#if ZSTD_IS_DETERMINISTIC_BUILD
|
|
53
|
+
return 1;
|
|
54
|
+
#else
|
|
55
|
+
return 0;
|
|
56
|
+
#endif
|
|
57
|
+
}
|
|
@@ -168,7 +168,7 @@ static UNUSED_ATTR const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
|
|
|
168
168
|
* Shared functions to include for inlining
|
|
169
169
|
*********************************************/
|
|
170
170
|
static void ZSTD_copy8(void* dst, const void* src) {
|
|
171
|
-
#if defined(ZSTD_ARCH_ARM_NEON)
|
|
171
|
+
#if defined(ZSTD_ARCH_ARM_NEON) && !defined(__aarch64__)
|
|
172
172
|
vst1_u8((uint8_t*)dst, vld1_u8((const uint8_t*)src));
|
|
173
173
|
#else
|
|
174
174
|
ZSTD_memcpy(dst, src, 8);
|
|
@@ -185,6 +185,8 @@ static void ZSTD_copy16(void* dst, const void* src) {
|
|
|
185
185
|
vst1q_u8((uint8_t*)dst, vld1q_u8((const uint8_t*)src));
|
|
186
186
|
#elif defined(ZSTD_ARCH_X86_SSE2)
|
|
187
187
|
_mm_storeu_si128((__m128i*)dst, _mm_loadu_si128((const __m128i*)src));
|
|
188
|
+
#elif defined(ZSTD_ARCH_RISCV_RVV)
|
|
189
|
+
__riscv_vse8_v_u8m1((uint8_t*)dst, __riscv_vle8_v_u8m1((const uint8_t*)src, 16), 16);
|
|
188
190
|
#elif defined(__clang__)
|
|
189
191
|
ZSTD_memmove(dst, src, 16);
|
|
190
192
|
#else
|
|
@@ -213,7 +215,7 @@ typedef enum {
|
|
|
213
215
|
* The src buffer must be before the dst buffer.
|
|
214
216
|
*/
|
|
215
217
|
MEM_STATIC FORCE_INLINE_ATTR
|
|
216
|
-
void ZSTD_wildcopy(void* dst, const void* src,
|
|
218
|
+
void ZSTD_wildcopy(void* dst, const void* src, size_t length, ZSTD_overlap_e const ovtype)
|
|
217
219
|
{
|
|
218
220
|
ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
|
|
219
221
|
const BYTE* ip = (const BYTE*)src;
|
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
#include "../common/error_private.h" /* ERROR */
|
|
20
20
|
#include "hist.h"
|
|
21
21
|
|
|
22
|
+
#if defined(ZSTD_ARCH_ARM_SVE2)
|
|
23
|
+
#define HIST_FAST_THRESHOLD 500
|
|
24
|
+
#else
|
|
25
|
+
#define HIST_FAST_THRESHOLD 1500
|
|
26
|
+
#endif
|
|
27
|
+
|
|
22
28
|
|
|
23
29
|
/* --- Error management --- */
|
|
24
30
|
unsigned HIST_isError(size_t code) { return ERR_isError(code); }
|
|
@@ -65,6 +71,286 @@ unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
|
|
|
65
71
|
|
|
66
72
|
typedef enum { trustInput, checkMaxSymbolValue } HIST_checkInput_e;
|
|
67
73
|
|
|
74
|
+
#if defined(ZSTD_ARCH_ARM_SVE2)
|
|
75
|
+
/* U16 counters must hold even an all-identical chunk. Round the limit down
|
|
76
|
+
* to 16 bytes so zero-padding the final vector cannot overflow them. */
|
|
77
|
+
#define HIST_SVE2_MAX_CHUNK_SIZE ((1U << 16) - 16)
|
|
78
|
+
FORCE_INLINE_TEMPLATE size_t min_size(size_t a, size_t b) { return a < b ? a : b; }
|
|
79
|
+
|
|
80
|
+
static
|
|
81
|
+
svuint16_t HIST_count_6_sve2(const BYTE* const src, size_t size, U32* const dst,
|
|
82
|
+
const svuint8_t c0, const svuint8_t c1,
|
|
83
|
+
const svuint8_t c2, const svuint8_t c3,
|
|
84
|
+
const svuint8_t c4, const svuint8_t c5,
|
|
85
|
+
const svuint16_t histmax, size_t maxCount)
|
|
86
|
+
{
|
|
87
|
+
const svbool_t vl128 = svptrue_pat_b8(SV_VL16);
|
|
88
|
+
svuint16_t hh0 = svdup_n_u16(0);
|
|
89
|
+
svuint16_t hh1 = svdup_n_u16(0);
|
|
90
|
+
svuint16_t hh2 = svdup_n_u16(0);
|
|
91
|
+
svuint16_t hh3 = svdup_n_u16(0);
|
|
92
|
+
svuint16_t hh4 = svdup_n_u16(0);
|
|
93
|
+
svuint16_t hh5 = svdup_n_u16(0);
|
|
94
|
+
svuint16_t hh6 = svdup_n_u16(0);
|
|
95
|
+
svuint16_t hh7 = svdup_n_u16(0);
|
|
96
|
+
svuint16_t hh8 = svdup_n_u16(0);
|
|
97
|
+
svuint16_t hh9 = svdup_n_u16(0);
|
|
98
|
+
svuint16_t hha = svdup_n_u16(0);
|
|
99
|
+
svuint16_t hhb = svdup_n_u16(0);
|
|
100
|
+
|
|
101
|
+
size_t i = 0;
|
|
102
|
+
while (i < size) {
|
|
103
|
+
/* We can only accumulate 15 (15 * 16 <= 255) iterations of histogram
|
|
104
|
+
* in 8-bit accumulators! */
|
|
105
|
+
const size_t size240 = min_size(i + 240, size);
|
|
106
|
+
|
|
107
|
+
svbool_t pred = svwhilelt_b8_u64(i, size);
|
|
108
|
+
svuint8_t c = svld1rq_u8(pred, src + i);
|
|
109
|
+
svuint8_t h0 = svhistseg_u8(c0, c);
|
|
110
|
+
svuint8_t h1 = svhistseg_u8(c1, c);
|
|
111
|
+
svuint8_t h2 = svhistseg_u8(c2, c);
|
|
112
|
+
svuint8_t h3 = svhistseg_u8(c3, c);
|
|
113
|
+
svuint8_t h4 = svhistseg_u8(c4, c);
|
|
114
|
+
svuint8_t h5 = svhistseg_u8(c5, c);
|
|
115
|
+
|
|
116
|
+
for (i += 16; i < size240; i += 16) {
|
|
117
|
+
pred = svwhilelt_b8_u64(i, size);
|
|
118
|
+
c = svld1rq_u8(pred, src + i);
|
|
119
|
+
h0 = svadd_u8_x(vl128, h0, svhistseg_u8(c0, c));
|
|
120
|
+
h1 = svadd_u8_x(vl128, h1, svhistseg_u8(c1, c));
|
|
121
|
+
h2 = svadd_u8_x(vl128, h2, svhistseg_u8(c2, c));
|
|
122
|
+
h3 = svadd_u8_x(vl128, h3, svhistseg_u8(c3, c));
|
|
123
|
+
h4 = svadd_u8_x(vl128, h4, svhistseg_u8(c4, c));
|
|
124
|
+
h5 = svadd_u8_x(vl128, h5, svhistseg_u8(c5, c));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
hh0 = svaddwb_u16(hh0, h0);
|
|
128
|
+
hh1 = svaddwt_u16(hh1, h0);
|
|
129
|
+
hh2 = svaddwb_u16(hh2, h1);
|
|
130
|
+
hh3 = svaddwt_u16(hh3, h1);
|
|
131
|
+
hh4 = svaddwb_u16(hh4, h2);
|
|
132
|
+
hh5 = svaddwt_u16(hh5, h2);
|
|
133
|
+
hh6 = svaddwb_u16(hh6, h3);
|
|
134
|
+
hh7 = svaddwt_u16(hh7, h3);
|
|
135
|
+
hh8 = svaddwb_u16(hh8, h4);
|
|
136
|
+
hh9 = svaddwt_u16(hh9, h4);
|
|
137
|
+
hha = svaddwb_u16(hha, h5);
|
|
138
|
+
hhb = svaddwt_u16(hhb, h5);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
svst1_u32(svwhilelt_b32_u64( 0, maxCount), dst + 0, svshllb_n_u32(hh0, 0));
|
|
142
|
+
svst1_u32(svwhilelt_b32_u64( 4, maxCount), dst + 4, svshllt_n_u32(hh0, 0));
|
|
143
|
+
svst1_u32(svwhilelt_b32_u64( 8, maxCount), dst + 8, svshllb_n_u32(hh1, 0));
|
|
144
|
+
svst1_u32(svwhilelt_b32_u64(12, maxCount), dst + 12, svshllt_n_u32(hh1, 0));
|
|
145
|
+
svst1_u32(svwhilelt_b32_u64(16, maxCount), dst + 16, svshllb_n_u32(hh2, 0));
|
|
146
|
+
svst1_u32(svwhilelt_b32_u64(20, maxCount), dst + 20, svshllt_n_u32(hh2, 0));
|
|
147
|
+
svst1_u32(svwhilelt_b32_u64(24, maxCount), dst + 24, svshllb_n_u32(hh3, 0));
|
|
148
|
+
svst1_u32(svwhilelt_b32_u64(28, maxCount), dst + 28, svshllt_n_u32(hh3, 0));
|
|
149
|
+
svst1_u32(svwhilelt_b32_u64(32, maxCount), dst + 32, svshllb_n_u32(hh4, 0));
|
|
150
|
+
svst1_u32(svwhilelt_b32_u64(36, maxCount), dst + 36, svshllt_n_u32(hh4, 0));
|
|
151
|
+
svst1_u32(svwhilelt_b32_u64(40, maxCount), dst + 40, svshllb_n_u32(hh5, 0));
|
|
152
|
+
svst1_u32(svwhilelt_b32_u64(44, maxCount), dst + 44, svshllt_n_u32(hh5, 0));
|
|
153
|
+
svst1_u32(svwhilelt_b32_u64(48, maxCount), dst + 48, svshllb_n_u32(hh6, 0));
|
|
154
|
+
svst1_u32(svwhilelt_b32_u64(52, maxCount), dst + 52, svshllt_n_u32(hh6, 0));
|
|
155
|
+
svst1_u32(svwhilelt_b32_u64(56, maxCount), dst + 56, svshllb_n_u32(hh7, 0));
|
|
156
|
+
svst1_u32(svwhilelt_b32_u64(60, maxCount), dst + 60, svshllt_n_u32(hh7, 0));
|
|
157
|
+
svst1_u32(svwhilelt_b32_u64(64, maxCount), dst + 64, svshllb_n_u32(hh8, 0));
|
|
158
|
+
svst1_u32(svwhilelt_b32_u64(68, maxCount), dst + 68, svshllt_n_u32(hh8, 0));
|
|
159
|
+
svst1_u32(svwhilelt_b32_u64(72, maxCount), dst + 72, svshllb_n_u32(hh9, 0));
|
|
160
|
+
svst1_u32(svwhilelt_b32_u64(76, maxCount), dst + 76, svshllt_n_u32(hh9, 0));
|
|
161
|
+
svst1_u32(svwhilelt_b32_u64(80, maxCount), dst + 80, svshllb_n_u32(hha, 0));
|
|
162
|
+
svst1_u32(svwhilelt_b32_u64(84, maxCount), dst + 84, svshllt_n_u32(hha, 0));
|
|
163
|
+
svst1_u32(svwhilelt_b32_u64(88, maxCount), dst + 88, svshllb_n_u32(hhb, 0));
|
|
164
|
+
svst1_u32(svwhilelt_b32_u64(92, maxCount), dst + 92, svshllt_n_u32(hhb, 0));
|
|
165
|
+
|
|
166
|
+
hh0 = svmax_u16_x(vl128, hh0, hh1);
|
|
167
|
+
hh2 = svmax_u16_x(vl128, hh2, hh3);
|
|
168
|
+
hh4 = svmax_u16_x(vl128, hh4, hh5);
|
|
169
|
+
hh6 = svmax_u16_x(vl128, hh6, hh7);
|
|
170
|
+
hh8 = svmax_u16_x(vl128, hh8, hh9);
|
|
171
|
+
hha = svmax_u16_x(vl128, hha, hhb);
|
|
172
|
+
hh0 = svmax_u16_x(vl128, hh0, hh2);
|
|
173
|
+
hh4 = svmax_u16_x(vl128, hh4, hh6);
|
|
174
|
+
hh8 = svmax_u16_x(vl128, hh8, hha);
|
|
175
|
+
hh0 = svmax_u16_x(vl128, hh0, hh4);
|
|
176
|
+
hh8 = svmax_u16_x(vl128, hh8, histmax);
|
|
177
|
+
return svmax_u16_x(vl128, hh0, hh8);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
static size_t HIST_count_sve2_chunk(unsigned* count, unsigned* maxSymbolValuePtr,
|
|
181
|
+
const void* source, size_t sourceSize,
|
|
182
|
+
HIST_checkInput_e check)
|
|
183
|
+
{
|
|
184
|
+
const BYTE* ip = (const BYTE*)source;
|
|
185
|
+
const size_t maxCount = *maxSymbolValuePtr + 1;
|
|
186
|
+
|
|
187
|
+
assert(*maxSymbolValuePtr <= 255);
|
|
188
|
+
assert(sourceSize <= HIST_SVE2_MAX_CHUNK_SIZE);
|
|
189
|
+
if (!sourceSize) {
|
|
190
|
+
ZSTD_memset(count, 0, maxCount * sizeof(*count));
|
|
191
|
+
*maxSymbolValuePtr = 0;
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
{ const svbool_t vl128 = svptrue_pat_b8(SV_VL16);
|
|
196
|
+
const svuint8_t c0 = svreinterpret_u8(svindex_u32(0x0C040800, 0x01010101));
|
|
197
|
+
const svuint8_t c1 = svadd_n_u8_x(vl128, c0, 16);
|
|
198
|
+
const svuint8_t c2 = svadd_n_u8_x(vl128, c0, 32);
|
|
199
|
+
const svuint8_t c3 = svadd_n_u8_x(vl128, c1, 32);
|
|
200
|
+
|
|
201
|
+
svuint8_t symbolMax = svdup_n_u8(0);
|
|
202
|
+
svuint16_t hh0 = svdup_n_u16(0);
|
|
203
|
+
svuint16_t hh1 = svdup_n_u16(0);
|
|
204
|
+
svuint16_t hh2 = svdup_n_u16(0);
|
|
205
|
+
svuint16_t hh3 = svdup_n_u16(0);
|
|
206
|
+
svuint16_t hh4 = svdup_n_u16(0);
|
|
207
|
+
svuint16_t hh5 = svdup_n_u16(0);
|
|
208
|
+
svuint16_t hh6 = svdup_n_u16(0);
|
|
209
|
+
svuint16_t hh7 = svdup_n_u16(0);
|
|
210
|
+
svuint16_t max;
|
|
211
|
+
size_t maxSymbolValue;
|
|
212
|
+
|
|
213
|
+
size_t i = 0;
|
|
214
|
+
while (i < sourceSize) {
|
|
215
|
+
/* We can only accumulate 15 (15 * 16 <= 255) iterations of
|
|
216
|
+
* histogram in 8-bit accumulators! */
|
|
217
|
+
const size_t size240 = min_size(i + 240, sourceSize);
|
|
218
|
+
|
|
219
|
+
svbool_t pred = svwhilelt_b8_u64(i, sourceSize);
|
|
220
|
+
svuint8_t c = svld1rq_u8(pred, ip + i);
|
|
221
|
+
svuint8_t h0 = svhistseg_u8(c0, c);
|
|
222
|
+
svuint8_t h1 = svhistseg_u8(c1, c);
|
|
223
|
+
svuint8_t h2 = svhistseg_u8(c2, c);
|
|
224
|
+
svuint8_t h3 = svhistseg_u8(c3, c);
|
|
225
|
+
symbolMax = svmax_u8_x(vl128, symbolMax, c);
|
|
226
|
+
|
|
227
|
+
for (i += 16; i < size240; i += 16) {
|
|
228
|
+
pred = svwhilelt_b8_u64(i, sourceSize);
|
|
229
|
+
c = svld1rq_u8(pred, ip + i);
|
|
230
|
+
h0 = svadd_u8_x(vl128, h0, svhistseg_u8(c0, c));
|
|
231
|
+
h1 = svadd_u8_x(vl128, h1, svhistseg_u8(c1, c));
|
|
232
|
+
h2 = svadd_u8_x(vl128, h2, svhistseg_u8(c2, c));
|
|
233
|
+
h3 = svadd_u8_x(vl128, h3, svhistseg_u8(c3, c));
|
|
234
|
+
symbolMax = svmax_u8_x(vl128, symbolMax, c);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
hh0 = svaddwb_u16(hh0, h0);
|
|
238
|
+
hh1 = svaddwt_u16(hh1, h0);
|
|
239
|
+
hh2 = svaddwb_u16(hh2, h1);
|
|
240
|
+
hh3 = svaddwt_u16(hh3, h1);
|
|
241
|
+
hh4 = svaddwb_u16(hh4, h2);
|
|
242
|
+
hh5 = svaddwt_u16(hh5, h2);
|
|
243
|
+
hh6 = svaddwb_u16(hh6, h3);
|
|
244
|
+
hh7 = svaddwt_u16(hh7, h3);
|
|
245
|
+
}
|
|
246
|
+
maxSymbolValue = svmaxv_u8(vl128, symbolMax);
|
|
247
|
+
|
|
248
|
+
if (check && maxSymbolValue > *maxSymbolValuePtr) return ERROR(maxSymbolValue_tooSmall);
|
|
249
|
+
*maxSymbolValuePtr = maxSymbolValue;
|
|
250
|
+
|
|
251
|
+
/* If the buffer size is not divisible by 16, the last elements of the final
|
|
252
|
+
* vector register read will be zeros, and these elements must be subtracted
|
|
253
|
+
* from the histogram.
|
|
254
|
+
*/
|
|
255
|
+
hh0 = svsub_n_u16_m(svptrue_pat_b32(SV_VL1), hh0, -sourceSize & 15);
|
|
256
|
+
|
|
257
|
+
svst1_u32(svwhilelt_b32_u64( 0, maxCount), count + 0, svshllb_n_u32(hh0, 0));
|
|
258
|
+
svst1_u32(svwhilelt_b32_u64( 4, maxCount), count + 4, svshllt_n_u32(hh0, 0));
|
|
259
|
+
svst1_u32(svwhilelt_b32_u64( 8, maxCount), count + 8, svshllb_n_u32(hh1, 0));
|
|
260
|
+
svst1_u32(svwhilelt_b32_u64(12, maxCount), count + 12, svshllt_n_u32(hh1, 0));
|
|
261
|
+
svst1_u32(svwhilelt_b32_u64(16, maxCount), count + 16, svshllb_n_u32(hh2, 0));
|
|
262
|
+
svst1_u32(svwhilelt_b32_u64(20, maxCount), count + 20, svshllt_n_u32(hh2, 0));
|
|
263
|
+
svst1_u32(svwhilelt_b32_u64(24, maxCount), count + 24, svshllb_n_u32(hh3, 0));
|
|
264
|
+
svst1_u32(svwhilelt_b32_u64(28, maxCount), count + 28, svshllt_n_u32(hh3, 0));
|
|
265
|
+
svst1_u32(svwhilelt_b32_u64(32, maxCount), count + 32, svshllb_n_u32(hh4, 0));
|
|
266
|
+
svst1_u32(svwhilelt_b32_u64(36, maxCount), count + 36, svshllt_n_u32(hh4, 0));
|
|
267
|
+
svst1_u32(svwhilelt_b32_u64(40, maxCount), count + 40, svshllb_n_u32(hh5, 0));
|
|
268
|
+
svst1_u32(svwhilelt_b32_u64(44, maxCount), count + 44, svshllt_n_u32(hh5, 0));
|
|
269
|
+
svst1_u32(svwhilelt_b32_u64(48, maxCount), count + 48, svshllb_n_u32(hh6, 0));
|
|
270
|
+
svst1_u32(svwhilelt_b32_u64(52, maxCount), count + 52, svshllt_n_u32(hh6, 0));
|
|
271
|
+
svst1_u32(svwhilelt_b32_u64(56, maxCount), count + 56, svshllb_n_u32(hh7, 0));
|
|
272
|
+
svst1_u32(svwhilelt_b32_u64(60, maxCount), count + 60, svshllt_n_u32(hh7, 0));
|
|
273
|
+
|
|
274
|
+
hh0 = svmax_u16_x(vl128, hh0, hh1);
|
|
275
|
+
hh2 = svmax_u16_x(vl128, hh2, hh3);
|
|
276
|
+
hh4 = svmax_u16_x(vl128, hh4, hh5);
|
|
277
|
+
hh6 = svmax_u16_x(vl128, hh6, hh7);
|
|
278
|
+
hh0 = svmax_u16_x(vl128, hh0, hh2);
|
|
279
|
+
hh4 = svmax_u16_x(vl128, hh4, hh6);
|
|
280
|
+
max = svmax_u16_x(vl128, hh0, hh4);
|
|
281
|
+
|
|
282
|
+
maxSymbolValue = min_size(maxSymbolValue, maxCount);
|
|
283
|
+
if (maxSymbolValue >= 64) {
|
|
284
|
+
const svuint8_t c4 = svadd_n_u8_x(vl128, c0, 64);
|
|
285
|
+
const svuint8_t c5 = svadd_n_u8_x(vl128, c1, 64);
|
|
286
|
+
const svuint8_t c6 = svadd_n_u8_x(vl128, c2, 64);
|
|
287
|
+
const svuint8_t c7 = svadd_n_u8_x(vl128, c3, 64);
|
|
288
|
+
const svuint8_t c8 = svadd_n_u8_x(vl128, c0, 128);
|
|
289
|
+
const svuint8_t c9 = svadd_n_u8_x(vl128, c1, 128);
|
|
290
|
+
|
|
291
|
+
max = HIST_count_6_sve2(ip, sourceSize, count + 64, c4, c5, c6, c7,
|
|
292
|
+
c8, c9, max, maxCount - 64);
|
|
293
|
+
|
|
294
|
+
if (maxSymbolValue >= 160) {
|
|
295
|
+
const svuint8_t ca = svadd_n_u8_x(vl128, c2, 128);
|
|
296
|
+
const svuint8_t cb = svadd_n_u8_x(vl128, c3, 128);
|
|
297
|
+
const svuint8_t cc = svadd_n_u8_x(vl128, c4, 128);
|
|
298
|
+
const svuint8_t cd = svadd_n_u8_x(vl128, c5, 128);
|
|
299
|
+
const svuint8_t ce = svadd_n_u8_x(vl128, c6, 128);
|
|
300
|
+
const svuint8_t cf = svadd_n_u8_x(vl128, c7, 128);
|
|
301
|
+
|
|
302
|
+
max = HIST_count_6_sve2(ip, sourceSize, count + 160, ca, cb, cc,
|
|
303
|
+
cd, ce, cf, max, maxCount - 160);
|
|
304
|
+
} else if (maxCount > 160) {
|
|
305
|
+
ZSTD_memset(count + 160, 0, (maxCount - 160) * sizeof(*count));
|
|
306
|
+
}
|
|
307
|
+
} else if (maxCount > 64) {
|
|
308
|
+
ZSTD_memset(count + 64, 0, (maxCount - 64) * sizeof(*count));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return svmaxv_u16(vl128, max);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static size_t HIST_count_sve2(unsigned* count, unsigned* maxSymbolValuePtr,
|
|
316
|
+
const void* source, size_t sourceSize,
|
|
317
|
+
HIST_checkInput_e check)
|
|
318
|
+
{
|
|
319
|
+
if (sourceSize <= HIST_SVE2_MAX_CHUNK_SIZE)
|
|
320
|
+
return HIST_count_sve2_chunk(count, maxSymbolValuePtr, source, sourceSize, check);
|
|
321
|
+
|
|
322
|
+
{ const BYTE* const input = (const BYTE*)source;
|
|
323
|
+
unsigned const maxSymbolLimit = *maxSymbolValuePtr;
|
|
324
|
+
unsigned maxSymbolValue = maxSymbolLimit;
|
|
325
|
+
U32 chunkCounts[256];
|
|
326
|
+
size_t largestCount = HIST_count_sve2_chunk(count, &maxSymbolValue, input,
|
|
327
|
+
HIST_SVE2_MAX_CHUNK_SIZE, check);
|
|
328
|
+
size_t offset = HIST_SVE2_MAX_CHUNK_SIZE;
|
|
329
|
+
if (HIST_isError(largestCount)) return largestCount;
|
|
330
|
+
|
|
331
|
+
/* Merge each bounded histogram into U32 totals. Wrapping a present
|
|
332
|
+
* symbol to zero breaks Huffman coding, and undercounting breaks RLE. */
|
|
333
|
+
while (offset < sourceSize) {
|
|
334
|
+
size_t const chunkSize = min_size(sourceSize - offset, HIST_SVE2_MAX_CHUNK_SIZE);
|
|
335
|
+
unsigned chunkMaxSymbol = maxSymbolLimit;
|
|
336
|
+
size_t const result = HIST_count_sve2_chunk(chunkCounts, &chunkMaxSymbol,
|
|
337
|
+
input + offset, chunkSize, check);
|
|
338
|
+
unsigned symbol;
|
|
339
|
+
if (HIST_isError(result)) return result;
|
|
340
|
+
if (chunkMaxSymbol > maxSymbolValue) maxSymbolValue = chunkMaxSymbol;
|
|
341
|
+
for (symbol = 0; symbol <= chunkMaxSymbol; ++symbol) {
|
|
342
|
+
count[symbol] += chunkCounts[symbol];
|
|
343
|
+
if (count[symbol] > largestCount) largestCount = count[symbol];
|
|
344
|
+
}
|
|
345
|
+
offset += chunkSize;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
*maxSymbolValuePtr = maxSymbolValue;
|
|
349
|
+
return largestCount;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
#endif
|
|
353
|
+
|
|
68
354
|
/* HIST_count_parallel_wksp() :
|
|
69
355
|
* store histogram into 4 intermediate tables, recombined at the end.
|
|
70
356
|
* this design makes better use of OoO cpus,
|
|
@@ -73,8 +359,8 @@ typedef enum { trustInput, checkMaxSymbolValue } HIST_checkInput_e;
|
|
|
73
359
|
* `workSpace` must be a U32 table of size >= HIST_WKSP_SIZE_U32.
|
|
74
360
|
* @return : largest histogram frequency,
|
|
75
361
|
* or an error code (notably when histogram's alphabet is larger than *maxSymbolValuePtr) */
|
|
76
|
-
static
|
|
77
|
-
|
|
362
|
+
static UNUSED_ATTR
|
|
363
|
+
size_t HIST_count_parallel_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
|
78
364
|
const void* source, size_t sourceSize,
|
|
79
365
|
HIST_checkInput_e check,
|
|
80
366
|
U32* const workSpace)
|
|
@@ -151,11 +437,17 @@ size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
|
|
151
437
|
const void* source, size_t sourceSize,
|
|
152
438
|
void* workSpace, size_t workSpaceSize)
|
|
153
439
|
{
|
|
154
|
-
if (sourceSize <
|
|
440
|
+
if (sourceSize < HIST_FAST_THRESHOLD) /* heuristic threshold */
|
|
155
441
|
return HIST_count_simple(count, maxSymbolValuePtr, source, sourceSize);
|
|
442
|
+
#if defined(ZSTD_ARCH_ARM_SVE2)
|
|
443
|
+
(void)workSpace;
|
|
444
|
+
(void)workSpaceSize;
|
|
445
|
+
return HIST_count_sve2(count, maxSymbolValuePtr, source, sourceSize, trustInput);
|
|
446
|
+
#else
|
|
156
447
|
if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
|
|
157
448
|
if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
|
|
158
449
|
return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, trustInput, (U32*)workSpace);
|
|
450
|
+
#endif
|
|
159
451
|
}
|
|
160
452
|
|
|
161
453
|
/* HIST_count_wksp() :
|
|
@@ -165,10 +457,15 @@ size_t HIST_count_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
|
|
165
457
|
const void* source, size_t sourceSize,
|
|
166
458
|
void* workSpace, size_t workSpaceSize)
|
|
167
459
|
{
|
|
460
|
+
#if defined(ZSTD_ARCH_ARM_SVE2)
|
|
461
|
+
if (*maxSymbolValuePtr < 255)
|
|
462
|
+
return HIST_count_sve2(count, maxSymbolValuePtr, source, sourceSize, checkMaxSymbolValue);
|
|
463
|
+
#else
|
|
168
464
|
if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
|
|
169
465
|
if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
|
|
170
466
|
if (*maxSymbolValuePtr < 255)
|
|
171
467
|
return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, checkMaxSymbolValue, (U32*)workSpace);
|
|
468
|
+
#endif
|
|
172
469
|
*maxSymbolValuePtr = 255;
|
|
173
470
|
return HIST_countFast_wksp(count, maxSymbolValuePtr, source, sourceSize, workSpace, workSpaceSize);
|
|
174
471
|
}
|
|
@@ -35,7 +35,11 @@ unsigned HIST_isError(size_t code); /**< tells if a return value is an error co
|
|
|
35
35
|
|
|
36
36
|
/* --- advanced histogram functions --- */
|
|
37
37
|
|
|
38
|
+
#if defined(__ARM_FEATURE_SVE2)
|
|
39
|
+
#define HIST_WKSP_SIZE_U32 0
|
|
40
|
+
#else
|
|
38
41
|
#define HIST_WKSP_SIZE_U32 1024
|
|
42
|
+
#endif
|
|
39
43
|
#define HIST_WKSP_SIZE (HIST_WKSP_SIZE_U32 * sizeof(unsigned))
|
|
40
44
|
/** HIST_count_wksp() :
|
|
41
45
|
* Same as HIST_count(), but using an externally provided scratch buffer.
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* Includes
|
|
25
25
|
****************************************************************/
|
|
26
26
|
#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset */
|
|
27
|
+
#include "../common/bmi2.h"
|
|
27
28
|
#include "../common/compiler.h"
|
|
28
29
|
#include "../common/bitstream.h"
|
|
29
30
|
#include "hist.h"
|
|
@@ -425,6 +426,7 @@ static U32 HUF_setMaxHeight(nodeElt* huffNode, U32 lastNonNull, U32 targetNbBits
|
|
|
425
426
|
* gain back half the rank.
|
|
426
427
|
*/
|
|
427
428
|
U32 nBitsToDecrease = ZSTD_highbit32((U32)totalCost) + 1;
|
|
429
|
+
assert(nBitsToDecrease <= HUF_TABLELOG_MAX+1);
|
|
428
430
|
for ( ; nBitsToDecrease > 1; nBitsToDecrease--) {
|
|
429
431
|
U32 const highPos = rankLast[nBitsToDecrease];
|
|
430
432
|
U32 const lowPos = rankLast[nBitsToDecrease-1];
|
|
@@ -1140,9 +1142,10 @@ HUF_compress1X_usingCTable_internal(void* dst, size_t dstSize,
|
|
|
1140
1142
|
const void* src, size_t srcSize,
|
|
1141
1143
|
const HUF_CElt* CTable, const int flags)
|
|
1142
1144
|
{
|
|
1143
|
-
if (flags & HUF_flags_bmi2) {
|
|
1145
|
+
if (ZSTD_USE_BMI2(flags & HUF_flags_bmi2)) {
|
|
1144
1146
|
return HUF_compress1X_usingCTable_internal_bmi2(dst, dstSize, src, srcSize, CTable);
|
|
1145
1147
|
}
|
|
1148
|
+
(void)flags;
|
|
1146
1149
|
return HUF_compress1X_usingCTable_internal_default(dst, dstSize, src, srcSize, CTable);
|
|
1147
1150
|
}
|
|
1148
1151
|
|