Lines Matching refs:seed
93 static void RAND_bufferMaxSymb(U32* seed, void* ptr, size_t size, int maxSymb) in RAND_bufferMaxSymb() argument
99 op[i] = (BYTE) (RAND(seed) % (maxSymb + 1)); in RAND_bufferMaxSymb()
104 static void RAND_buffer(U32* seed, void* ptr, size_t size) in RAND_buffer() argument
110 MEM_writeLE32(op + i, RAND(seed)); in RAND_buffer()
113 op[i] = RAND(seed) & 0xff; in RAND_buffer()
118 static void RAND_bufferDist(U32* seed, BYTE* dist, void* ptr, size_t size) in RAND_bufferDist() argument
124 op[i] = dist[RAND(seed) % DISTSIZE]; in RAND_bufferDist()
131 static void RAND_genDist(U32* seed, BYTE* dist, double weight) in RAND_genDist() argument
135 BYTE symb = (BYTE) (RAND(seed) % 256); in RAND_genDist()
136 …BYTE step = (BYTE) ((RAND(seed) % 256) | 1); /* force it to be odd so it's relatively prime to 256… in RAND_genDist()
151 static inline U32 RAND_range(U32* seed, U32 min, U32 max) in RAND_range() argument
153 return (RAND(seed) % (max-min)) + min; in RAND_range()
159 static double RAND_exp(U32* seed, double mean) in RAND_exp() argument
161 double const u = RAND(seed) / (double) UINT_MAX; in RAND_exp()
258 static void writeFrameHeader(U32* seed, frame_t* frame, dictInfo info) in writeFrameHeader() argument
275 int const exponent = RAND(seed) % (MAX_WINDOW_LOG - 10); in writeFrameHeader()
276 int const mantissa = RAND(seed) % 8; in writeFrameHeader()
285 if (RAND(seed) & 7 && g_maxDecompressedSizeLog > 7) { in writeFrameHeader()
287 highBit = 1ULL << RAND_range(seed, 7, g_maxDecompressedSizeLog); in writeFrameHeader()
288 } else if (RAND(seed) & 3) { in writeFrameHeader()
290 highBit = 1ULL << RAND_range(seed, 0, MIN(7, 1U << g_maxDecompressedSizeLog)); in writeFrameHeader()
295 fh.contentSize = highBit ? highBit + (RAND(seed) % highBit) : 0; in writeFrameHeader()
298 contentSizeFlag = opts.contentSize | (RAND(seed) & 1); in writeFrameHeader()
300 if (contentSizeFlag && (fh.contentSize == 0 || !(RAND(seed) & 7))) { in writeFrameHeader()
315 fcsCode = minFcsCode + (RAND(seed) % (4 - minFcsCode)); in writeFrameHeader()
364 static size_t writeLiteralsBlockSimple(U32* seed, frame_t* frame, size_t contentSize) in writeLiteralsBlockSimple() argument
367 int const type = RAND(seed) % 2; in writeLiteralsBlockSimple()
368 int const sizeFormatDesc = RAND(seed) % 8; in writeLiteralsBlockSimple()
383 litSize = RAND(seed) % (maxLitSize + 1); in writeLiteralsBlockSimple()
409 RAND_buffer(seed, LITERAL_BUFFER, litSize); in writeLiteralsBlockSimple()
414 BYTE const symb = (BYTE) (RAND(seed) % 256); in writeLiteralsBlockSimple()
429 static size_t writeHufHeader(U32* seed, HUF_CElt* hufTable, void* dst, size_t dstSize, in writeHufHeader() argument
449 huffLog = RAND_range(seed, ZSTD_highbit32(maxSymbolValue)+1, huffLog+1); in writeHufHeader()
466 static size_t writeLiteralsBlockCompressed(U32* seed, frame_t* frame, size_t contentSize) in writeLiteralsBlockCompressed() argument
472 int const sizeFormat = RAND(seed) % 4; in writeLiteralsBlockCompressed()
507 litSize = RAND(seed) % (maxLitSize + 1); in writeLiteralsBlockCompressed()
514 if ((RAND(seed) & 3) || !frame->stats.hufInit) { in writeLiteralsBlockCompressed()
516 if (RAND(seed) & 3) { in writeLiteralsBlockCompressed()
518 double const weight = ((RAND(seed) % 90) + 10) / 100.0; in writeLiteralsBlockCompressed()
523 RAND_genDist(seed, frame->stats.hufDist, weight); in writeLiteralsBlockCompressed()
528 RAND_bufferMaxSymb(seed, frame->stats.hufDist, DISTSIZE, in writeLiteralsBlockCompressed()
531 RAND_bufferDist(seed, frame->stats.hufDist, LITERAL_BUFFER, in writeLiteralsBlockCompressed()
538 seed, frame->stats.hufTable, op, opend - op, in writeLiteralsBlockCompressed()
550 RAND_bufferDist(seed, frame->stats.hufDist, LITERAL_BUFFER, in writeLiteralsBlockCompressed()
613 static size_t writeLiteralsBlock(U32* seed, frame_t* frame, size_t contentSize) in writeLiteralsBlock() argument
616 if (RAND(seed) & 7 && contentSize >= 64) { in writeLiteralsBlock()
617 return writeLiteralsBlockCompressed(seed, frame, contentSize); in writeLiteralsBlock()
619 return writeLiteralsBlockSimple(seed, frame, contentSize); in writeLiteralsBlock()
636 static U32 generateSequences(U32* seed, frame_t* frame, seqStore_t* seqStore, in generateSequences() argument
654 numSequences = (RAND(seed) % maxSequences) + 1; in generateSequences()
666 ROUND(RAND_exp(seed, excessMatch / (double)(numSequences - i))); in generateSequences()
668 (RAND(seed) & 7) in generateSequences()
669 ? ROUND(RAND_exp(seed, in generateSequences()
686 if (RAND(seed) & 7) { in generateSequences()
689 offset = (RAND(seed) % in generateSequences()
693 …if (info.useDict && (RAND(seed) & 1) && i + 1 != numSequences && dataDecompressed < frame->header.… in generateSequences()
696 U32 lenPastStart = (RAND(seed) % info.dictContentSize) + 1; in generateSequences()
716 offsetCode = RAND(seed) % 3; in generateSequences()
801 static size_t writeSequences(U32* seed, frame_t* frame, seqStore_t* seqStorePtr, in writeSequences() argument
843 if (frame->stats.fseInit && !(RAND(seed) & 3) && in writeSequences()
853 } else if (!(RAND(seed) & 3)) { in writeSequences()
875 if (frame->stats.fseInit && !(RAND(seed) & 3) && in writeSequences()
883 } else if (!(RAND(seed) & 3)) { in writeSequences()
903 if (frame->stats.fseInit && !(RAND(seed) & 3) && in writeSequences()
911 } else if (!(RAND(seed) & 3)) { in writeSequences()
994 static size_t writeSequencesBlock(U32* seed, frame_t* frame, size_t contentSize, in writeSequencesBlock() argument
1004 numSequences = generateSequences(seed, frame, &seqStore, contentSize, literalsSize, info); in writeSequencesBlock()
1006 CHECKERR(writeSequences(seed, frame, &seqStore, numSequences)); in writeSequencesBlock()
1011 static size_t writeCompressedBlock(U32* seed, frame_t* frame, size_t contentSize, dictInfo info) in writeCompressedBlock() argument
1019 literalsSize = writeLiteralsBlock(seed, frame, contentSize); in writeCompressedBlock()
1023 nbSeq = writeSequencesBlock(seed, frame, contentSize, literalsSize, info); in writeCompressedBlock()
1030 static void writeBlock(U32* seed, frame_t* frame, size_t contentSize, in writeBlock() argument
1033 int const blockTypeDesc = RAND(seed) % 8; in writeBlock()
1047 RAND_buffer(seed, frame->src, contentSize); in writeBlock()
1055 BYTE const symbol = RAND(seed) & 0xff; in writeBlock()
1071 compressedSize = writeCompressedBlock(seed, frame, contentSize, info); in writeBlock()
1097 static void writeBlocks(U32* seed, frame_t* frame, dictInfo info) in writeBlocks() argument
1103 int const lastBlock = contentLeft > maxBlockSize ? 0 : !(RAND(seed) & 3); in writeBlocks()
1108 if (contentLeft > 0 && (RAND(seed) & 7)) { in writeBlocks()
1110 blockContentSize = RAND(seed) % (MIN(maxBlockSize, contentLeft)+1); in writeBlocks()
1111 } else if (contentLeft > maxBlockSize && (RAND(seed) & 1)) { in writeBlocks()
1120 writeBlock(seed, frame, blockContentSize, lastBlock, info); in writeBlocks()
1187 static U32 generateCompressedBlock(U32 seed, frame_t* frame, dictInfo info) in generateCompressedBlock() argument
1192 DISPLAYLEVEL(4, "block seed: %u\n", (unsigned)seed); in generateCompressedBlock()
1199 { int const exponent = RAND(&seed) % (MAX_WINDOW_LOG - 10); in generateCompressedBlock()
1200 int const mantissa = RAND(&seed) % 8; in generateCompressedBlock()
1207 if (RAND(&seed) & 15) { in generateCompressedBlock()
1210 } else if (RAND(&seed) & 7 && g_maxBlockSize >= (1U << 7)) { in generateCompressedBlock()
1212 blockContentSize = RAND(&seed) % (1U << 7); in generateCompressedBlock()
1215 blockContentSize = RAND(&seed) % maxBlockSize; in generateCompressedBlock()
1222 cSize = writeCompressedBlock(&seed, frame, blockContentSize, info); in generateCompressedBlock()
1233 return seed; in generateCompressedBlock()
1237 static U32 generateFrame(U32 seed, frame_t* fr, dictInfo info) in generateFrame() argument
1240 DISPLAYLEVEL(3, "frame seed: %u\n", (unsigned)seed); in generateFrame()
1243 writeFrameHeader(&seed, fr, info); in generateFrame()
1244 writeBlocks(&seed, fr, info); in generateFrame()
1247 return seed; in generateFrame()
1254 static int genRandomDict(U32 dictID, U32 seed, size_t dictSize, BYTE* fullDict) in genRandomDict() argument
1297 RAND_buffer(&seed, (void*)dictContent, dictContentSize); in genRandomDict()
1388 static size_t testDecodeWithDict(U32 seed, genType_e genType) in testDecodeWithDict() argument
1391 size_t const dictSize = RAND(&seed) % (10 << 20) + ZDICT_DICTSIZE_MIN + ZDICT_CONTENTSIZE_MIN; in testDecodeWithDict()
1392 U32 const dictID = RAND(&seed); in testDecodeWithDict()
1400 if (genRandomDict(dictID, seed, dictSize, fullDict)) { /* return 0 on success */ in testDecodeWithDict()
1421 generateFrame(seed, &fr, info); in testDecodeWithDict()
1427 generateCompressedBlock(seed, &fr, info); in testDecodeWithDict()
1476 static int runBlockTest(U32* seed) in runBlockTest() argument
1479 U32 const seedCopy = *seed; in runBlockTest()
1481 *seed = generateCompressedBlock(*seed, &fr, info); in runBlockTest()
1492 { size_t const r = testDecodeWithDict(*seed, gt_block); in runBlockTest()
1502 static int runFrameTest(U32* seed) in runFrameTest() argument
1505 U32 const seedCopy = *seed; in runFrameTest()
1507 *seed = generateFrame(*seed, &fr, info); in runFrameTest()
1524 { size_t const r = testDecodeWithDict(*seed, gt_frame); /* avoid big dictionaries */ in runFrameTest()
1534 static int runTestMode(U32 seed, unsigned numFiles, unsigned const testDurationS, in runTestMode() argument
1544 DISPLAY("seed: %u\n", (unsigned)seed); in runTestMode()
1553 runFrameTest(&seed) : in runTestMode()
1554 runBlockTest(&seed); in runTestMode()
1569 static int generateFile(U32 seed, const char* const path, in generateFile() argument
1574 DISPLAY("seed: %u\n", (unsigned)seed); in generateFile()
1578 generateFrame(seed, &fr, info); in generateFile()
1580 generateCompressedBlock(seed, &fr, info); in generateFile()
1590 static int generateCorpus(U32 seed, unsigned numFiles, const char* const path, in generateCorpus() argument
1596 DISPLAY("seed: %u\n", (unsigned)seed); in generateCorpus()
1605 seed = generateFrame(seed, &fr, info); in generateCorpus()
1607 seed = generateCompressedBlock(seed, &fr, info); in generateCorpus()
1631 static int generateCorpusWithDict(U32 seed, unsigned numFiles, const char* const path, in generateCorpusWithDict() argument
1637 U32 const dictID = RAND(&seed); in generateCorpusWithDict()
1653 { int const ret = genRandomDict(dictID, seed, dictSize, fullDict); in generateCorpusWithDict()
1684 seed = generateFrame(seed, &fr, info); in generateCorpusWithDict()
1686 seed = generateCompressedBlock(seed, &fr, info); in generateCorpusWithDict()
1808 U32 seed = 0; in main() local
1845 seed = readInt(&argument); in main()
1904 seed = makeSeed(); in main()
1908 return runTestMode(seed, numFiles, testDuration, genType); in main()
1924 return generateFile(seed, path, origPath, genType); in main()
1926 return generateCorpus(seed, numFiles, path, origPath, genType); in main()
1929 return generateCorpusWithDict(seed, numFiles, path, origPath, dictSize, genType); in main()