1 /* LzFindMt.h -- multithreaded Match finder for LZ algorithms
\r
2 2021-07-12 : Igor Pavlov : Public domain */
\r
4 #ifndef __LZ_FIND_MT_H
\r
5 #define __LZ_FIND_MT_H
\r
12 typedef struct _CMtSync
\r
14 UInt32 numProcessedBlocks;
\r
20 BoolInt csWasInitialized;
\r
21 BoolInt csWasEntered;
\r
24 BoolInt stopWriting;
\r
26 CAutoResetEvent canStart;
\r
27 CAutoResetEvent wasStopped;
\r
28 CSemaphore freeSemaphore;
\r
29 CSemaphore filledSemaphore;
\r
30 CCriticalSection cs;
\r
31 // UInt32 numBlocks_Sent;
\r
34 typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
\r
36 /* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
\r
37 #define kMtCacheLineDummy 128
\r
39 typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
\r
40 UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);
\r
42 typedef struct _CMatchFinderMt
\r
45 const Byte *pointerToCurPos;
\r
47 const UInt32 *btBufPos;
\r
48 const UInt32 *btBufPosLimit;
\r
50 UInt32 btNumAvailBytes;
\r
53 UInt32 fixedHashSize;
\r
54 // UInt32 hash4Mask;
\r
58 Mf_Mix_Matches MixMatchesFunc;
\r
59 UInt32 failure_LZ_BT; // failure in BT transfered to LZ
\r
60 // UInt32 failure_LZ_LZ; // failure in LZ tables
\r
61 UInt32 failureBuf[1];
\r
66 Byte btDummy[kMtCacheLineDummy];
\r
71 UInt32 hashBufPosLimit;
\r
72 UInt32 hashNumAvail;
\r
78 UInt32 numHashBytes;
\r
81 UInt32 cyclicBufferPos;
\r
82 UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
\r
87 /* Byte hashDummy[kMtCacheLineDummy]; */
\r
90 Mf_GetHeads GetHeadsFunc;
\r
91 CMatchFinder *MatchFinder;
\r
92 // CMatchFinder MatchFinder;
\r
96 void MatchFinderMt_Construct(CMatchFinderMt *p);
\r
97 void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc);
\r
99 SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
\r
100 UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc);
\r
101 void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder2 *vTable);
\r
103 /* call MatchFinderMt_InitMt() before IMatchFinder::Init() */
\r
104 SRes MatchFinderMt_InitMt(CMatchFinderMt *p);
\r
105 void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
\r