1 /* LzFindMt.h -- multithreaded Match finder for LZ algorithms
\r
2 2009-02-07 : Igor Pavlov : Public domain */
\r
4 #ifndef __LZ_FIND_MT_H
\r
5 #define __LZ_FIND_MT_H
\r
14 #define kMtHashBlockSize (1 << 13)
\r
15 #define kMtHashNumBlocks (1 << 3)
\r
16 #define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
\r
18 #define kMtBtBlockSize (1 << 14)
\r
19 #define kMtBtNumBlocks (1 << 6)
\r
20 #define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)
\r
22 typedef struct _CMtSync
\r
30 CAutoResetEvent canStart;
\r
31 CAutoResetEvent wasStarted;
\r
32 CAutoResetEvent wasStopped;
\r
33 CSemaphore freeSemaphore;
\r
34 CSemaphore filledSemaphore;
\r
35 Bool csWasInitialized;
\r
37 CCriticalSection cs;
\r
38 UInt32 numProcessedBlocks;
\r
41 typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
\r
43 /* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
\r
44 #define kMtCacheLineDummy 128
\r
46 typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
\r
47 UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);
\r
49 typedef struct _CMatchFinderMt
\r
52 const Byte *pointerToCurPos;
\r
55 UInt32 btBufPosLimit;
\r
57 UInt32 btNumAvailBytes;
\r
60 UInt32 fixedHashSize;
\r
64 Mf_Mix_Matches MixMatchesFunc;
\r
68 Byte btDummy[kMtCacheLineDummy];
\r
73 UInt32 hashBufPosLimit;
\r
74 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
94 void MatchFinderMt_Construct(CMatchFinderMt *p);
\r
95 void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc);
\r
96 SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
\r
97 UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc);
\r
98 void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);
\r
99 void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
\r