1 /* LzFindMt.h -- multithreaded Match finder for LZ algorithms
\r
2 2015-05-03 : Igor Pavlov : Public domain */
\r
4 #ifndef __LZ_FIND_MT_H
\r
5 #define __LZ_FIND_MT_H
\r
12 #define kMtHashBlockSize (1 << 13)
\r
13 #define kMtHashNumBlocks (1 << 3)
\r
14 #define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
\r
16 #define kMtBtBlockSize (1 << 14)
\r
17 #define kMtBtNumBlocks (1 << 6)
\r
18 #define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)
\r
20 typedef struct _CMtSync
\r
28 CAutoResetEvent canStart;
\r
29 CAutoResetEvent wasStarted;
\r
30 CAutoResetEvent wasStopped;
\r
31 CSemaphore freeSemaphore;
\r
32 CSemaphore filledSemaphore;
\r
33 Bool csWasInitialized;
\r
35 CCriticalSection cs;
\r
36 UInt32 numProcessedBlocks;
\r
39 typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
\r
41 /* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
\r
42 #define kMtCacheLineDummy 128
\r
44 typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
\r
45 UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);
\r
47 typedef struct _CMatchFinderMt
\r
50 const Byte *pointerToCurPos;
\r
53 UInt32 btBufPosLimit;
\r
55 UInt32 btNumAvailBytes;
\r
58 UInt32 fixedHashSize;
\r
62 Mf_Mix_Matches MixMatchesFunc;
\r
66 Byte btDummy[kMtCacheLineDummy];
\r
71 UInt32 hashBufPosLimit;
\r
72 UInt32 hashNumAvail;
\r
76 UInt32 numHashBytes;
\r
79 UInt32 cyclicBufferPos;
\r
80 UInt32 cyclicBufferSize; /* it must be historySize + 1 */
\r
85 /* Byte hashDummy[kMtCacheLineDummy]; */
\r
88 Mf_GetHeads GetHeadsFunc;
\r
89 CMatchFinder *MatchFinder;
\r
92 void MatchFinderMt_Construct(CMatchFinderMt *p);
\r
93 void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc);
\r
94 SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
\r
95 UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc);
\r
96 void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);
\r
97 void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
\r