sync paramgrill with HC starting at level 2

This commit is contained in:
Yann Collet
2015-10-29 17:08:03 +01:00
parent 2acb5d3d48
commit 71bcdb5c1f
4 changed files with 40 additions and 35 deletions
-22
View File
@@ -223,28 +223,6 @@ const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
***************************************/
unsigned ZSTD_versionNumber (void) { return ZSTD_VERSION_NUMBER; }
static unsigned ZSTD_highbit(U32 val)
{
# if defined(_MSC_VER) /* Visual */
unsigned long r;
_BitScanReverse(&r, val);
return (unsigned)r;
# elif defined(__GNUC__) && (GCC_VERSION >= 304) /* GCC Intrinsic */
return 31 - __builtin_clz(val);
# else /* Software version */
static const int DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
U32 v = val;
int r;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
r = DeBruijnClz[(U32)(v * 0x07C4ACDDU) >> 27];
return r;
# endif
}
/* *******************************************************
* Compression
+26 -4
View File
@@ -1,5 +1,5 @@
/*
zstd_CCommon - common functions
zstd_internal - common functions to include
Header File for include
Copyright (C) 2014-2015, Yann Collet.
@@ -44,11 +44,33 @@ extern "C" {
#include "error.h"
/* *************************************
* Function body to include
***************************************/
/* **************************************
* Function body to include for inlining
****************************************/
static size_t ZSTD_read_ARCH(const void* p) { size_t r; memcpy(&r, p, sizeof(r)); return r; }
static unsigned ZSTD_highbit(U32 val)
{
# if defined(_MSC_VER) /* Visual */
unsigned long r;
_BitScanReverse(&r, val);
return (unsigned)r;
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
return 31 - __builtin_clz(val);
# else /* Software version */
static const int DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
U32 v = val;
int r;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
r = DeBruijnClz[(U32)(v * 0x07C4ACDDU) >> 27];
return r;
# endif
}
MEM_STATIC unsigned ZSTD_NbCommonBytes (register size_t val)
{
if (MEM_isLittleEndian())
+5
View File
@@ -439,6 +439,11 @@ size_t ZSTD_HC_compress_advanced (ZSTD_HC_CCtx* ctx,
BYTE* const ostart = (BYTE*)dst;
BYTE* op = ostart;
/* correct params, to use less memory */
U32 srcLog = ZSTD_highbit((U32)srcSize-1) + 1;
if (params.windowLog > srcLog) params.windowLog = srcLog;
if (params.chainLog > srcLog) params.chainLog = srcLog;
/* Header */
size_t oSize = ZSTD_HC_compressBegin_advanced(ctx, dst, maxDstSize, params);
if(ZSTD_isError(oSize)) return oSize;
+9 -9
View File
@@ -648,8 +648,8 @@ static void BMK_selectRandomStart(
const void* srcBuffer, size_t srcSize,
ZSTD_HC_CCtx* ctx)
{
U32 id = FUZ_rand(&g_rand) % (ZSTD_HC_MAX_CLEVEL+1);
if ((id==0) || (winners[id].params.windowLog==0))
U32 id = (FUZ_rand(&g_rand) % ZSTD_HC_MAX_CLEVEL) + 1;
if ((id<2) || (winners[id].params.windowLog==0))
{
/* totally random entry */
ZSTD_HC_parameters p;
@@ -693,24 +693,24 @@ static void BMK_benchMem(void* srcBuffer, size_t srcSize)
g_cSpeedTarget[1] = g_target * 1000;
else
{
/* baseline config for level 1 */
/* baseline config for level 2 */
BMK_result_t testResult;
params = seedParams[1];
params = seedParams[2];
params.windowLog = MIN(srcLog, params.windowLog);
params.chainLog = MIN(params.windowLog, params.chainLog);
params.searchLog = MIN(params.chainLog, params.searchLog);
BMK_benchParam(&testResult, srcBuffer, srcSize, ctx, params);
g_cSpeedTarget[1] = (testResult.cSpeed * 15) >> 4;
g_cSpeedTarget[2] = (testResult.cSpeed * 15) >> 4;
}
/* establish speed objectives (relative to level 1) */
for (i=2; i<=ZSTD_HC_MAX_CLEVEL; i++)
/* establish speed objectives (relative to level 2) */
for (i=3; i<=ZSTD_HC_MAX_CLEVEL; i++)
g_cSpeedTarget[i] = (g_cSpeedTarget[i-1] * 13) >> 4;
/* populate initial solution */
{
const int maxSeeds = g_noSeed ? 1 : ZSTD_HC_MAX_CLEVEL;
for (i=1; i<=maxSeeds; i++)
const int maxSeeds = g_noSeed ? 2 : ZSTD_HC_MAX_CLEVEL;
for (i=2; i<=maxSeeds; i++)
{
params = seedParams[i];
params.windowLog = MIN(srcLog, params.windowLog);