Fixed paramgrill

This commit is contained in:
Yann Collet 2016-06-01 18:59:55 +02:00
parent 70d1301d6e
commit eb70043e59

View File

@ -600,22 +600,22 @@ static void playAround(FILE* f, winnerInfo_t* winners,
} }
static void potentialRandomParams(ZSTD_compressionParameters* p, U32 inverseChance) static ZSTD_compressionParameters randomParams(void)
{ {
U32 chance = (FUZ_rand(&g_rand) % (inverseChance+1)); ZSTD_compressionParameters p;
U32 validated = 0; U32 validated = 0;
if (!chance)
while (!validated) { while (!validated) {
/* totally random entry */ /* totally random entry */
p->chainLog = FUZ_rand(&g_rand) % (ZSTD_CHAINLOG_MAX+1 - ZSTD_CHAINLOG_MIN) + ZSTD_CHAINLOG_MIN; p.chainLog = FUZ_rand(&g_rand) % (ZSTD_CHAINLOG_MAX+1 - ZSTD_CHAINLOG_MIN) + ZSTD_CHAINLOG_MIN;
p->hashLog = FUZ_rand(&g_rand) % (ZSTD_HASHLOG_MAX+1 - ZSTD_HASHLOG_MIN) + ZSTD_HASHLOG_MIN; p.hashLog = FUZ_rand(&g_rand) % (ZSTD_HASHLOG_MAX+1 - ZSTD_HASHLOG_MIN) + ZSTD_HASHLOG_MIN;
p->searchLog = FUZ_rand(&g_rand) % (ZSTD_SEARCHLOG_MAX+1 - ZSTD_SEARCHLOG_MIN) + ZSTD_SEARCHLOG_MIN; p.searchLog = FUZ_rand(&g_rand) % (ZSTD_SEARCHLOG_MAX+1 - ZSTD_SEARCHLOG_MIN) + ZSTD_SEARCHLOG_MIN;
p->windowLog = FUZ_rand(&g_rand) % (ZSTD_WINDOWLOG_MAX+1 - ZSTD_WINDOWLOG_MIN) + ZSTD_WINDOWLOG_MIN; p.windowLog = FUZ_rand(&g_rand) % (ZSTD_WINDOWLOG_MAX+1 - ZSTD_WINDOWLOG_MIN) + ZSTD_WINDOWLOG_MIN;
p->searchLength=FUZ_rand(&g_rand) % (ZSTD_SEARCHLENGTH_MAX+1 - ZSTD_SEARCHLENGTH_MIN) + ZSTD_SEARCHLENGTH_MIN; p.searchLength=FUZ_rand(&g_rand) % (ZSTD_SEARCHLENGTH_MAX+1 - ZSTD_SEARCHLENGTH_MIN) + ZSTD_SEARCHLENGTH_MIN;
p->targetLength=FUZ_rand(&g_rand) % (ZSTD_TARGETLENGTH_MAX+1 - ZSTD_TARGETLENGTH_MIN) + ZSTD_TARGETLENGTH_MIN; p.targetLength=FUZ_rand(&g_rand) % (ZSTD_TARGETLENGTH_MAX+1 - ZSTD_TARGETLENGTH_MIN) + ZSTD_TARGETLENGTH_MIN;
p->strategy = (ZSTD_strategy) (FUZ_rand(&g_rand) % (ZSTD_btopt +1)); p.strategy = (ZSTD_strategy) (FUZ_rand(&g_rand) % (ZSTD_btopt +1));
validated = !ZSTD_isError(ZSTD_checkCParams(*p)); validated = !ZSTD_isError(ZSTD_checkCParams(p));
} }
return p;
} }
static void BMK_selectRandomStart( static void BMK_selectRandomStart(
@ -623,12 +623,10 @@ static void BMK_selectRandomStart(
const void* srcBuffer, size_t srcSize, const void* srcBuffer, size_t srcSize,
ZSTD_CCtx* ctx) ZSTD_CCtx* ctx)
{ {
U32 id = (FUZ_rand(&g_rand) % (ZSTD_maxCLevel()+1)); U32 const id = (FUZ_rand(&g_rand) % (ZSTD_maxCLevel()+1));
if ((id==0) || (winners[id].params.windowLog==0)) { if ((id==0) || (winners[id].params.windowLog==0)) {
/* totally random entry */ /* totally random entry */
ZSTD_compressionParameters p; ZSTD_compressionParameters const p = ZSTD_adjustCParams(randomParams(), srcSize, 0);
potentialRandomParams(&p, 1);
ZSTD_adjustCParams(&p, srcSize, 0);
playAround(f, winners, p, srcBuffer, srcSize, ctx); playAround(f, winners, p, srcBuffer, srcSize, ctx);
} }
else else
@ -649,7 +647,7 @@ static void BMK_benchMem(void* srcBuffer, size_t srcSize)
if (g_singleRun) { if (g_singleRun) {
BMK_result_t testResult; BMK_result_t testResult;
ZSTD_adjustCParams(&g_params, srcSize, 0); g_params = ZSTD_adjustCParams(g_params, srcSize, 0);
BMK_benchParam(&testResult, srcBuffer, srcSize, ctx, g_params); BMK_benchParam(&testResult, srcBuffer, srcSize, ctx, g_params);
DISPLAY("\n"); DISPLAY("\n");
return; return;
@ -861,7 +859,7 @@ int optimizeForSize(char* inFileName)
do { do {
params = winner.params; params = winner.params;
paramVariation(&params); paramVariation(&params);
potentialRandomParams(&params, 16); if ((FUZ_rand(&g_rand) & 15) == 1) params = randomParams();
/* exclude faster if already played set of params */ /* exclude faster if already played set of params */
if (FUZ_rand(&g_rand) & ((1 << NB_TESTS_PLAYED(params))-1)) continue; if (FUZ_rand(&g_rand) & ((1 << NB_TESTS_PLAYED(params))-1)) continue;