1 /* LzFindMt.h -- multithreaded Match finder for LZ algorithms
2 2008-10-04 : Igor Pavlov : Public domain */
10 #define kMtHashBlockSize (1 << 13)
11 #define kMtHashNumBlocks (1 << 3)
12 #define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
14 #define kMtBtBlockSize (1 << 14)
15 #define kMtBtNumBlocks (1 << 6)
16 #define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)
18 typedef struct _CMtSync
26 CAutoResetEvent canStart
;
27 CAutoResetEvent wasStarted
;
28 CAutoResetEvent wasStopped
;
29 CSemaphore freeSemaphore
;
30 CSemaphore filledSemaphore
;
31 Bool csWasInitialized
;
34 UInt32 numProcessedBlocks
;
37 typedef UInt32
* (*Mf_Mix_Matches
)(void *p
, UInt32 matchMinPos
, UInt32
*distances
);
39 /* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
40 #define kMtCacheLineDummy 128
42 typedef void (*Mf_GetHeads
)(const Byte
*buffer
, UInt32 pos
,
43 UInt32
*hash
, UInt32 hashMask
, UInt32
*heads
, UInt32 numHeads
, const UInt32
*crc
);
45 typedef struct _CMatchFinderMt
48 const Byte
*pointerToCurPos
;
53 UInt32 btNumAvailBytes
;
60 Mf_Mix_Matches MixMatchesFunc
;
64 Byte btDummy
[kMtCacheLineDummy
];
69 UInt32 hashBufPosLimit
;
77 UInt32 cyclicBufferPos
;
78 UInt32 cyclicBufferSize
; /* it must be historySize + 1 */
83 /* Byte hashDummy[kMtCacheLineDummy]; */
86 Mf_GetHeads GetHeadsFunc
;
87 CMatchFinder
*MatchFinder
;
90 void MatchFinderMt_Construct(CMatchFinderMt
*p
);
91 void MatchFinderMt_Destruct(CMatchFinderMt
*p
, ISzAlloc
*alloc
);
92 SRes
MatchFinderMt_Create(CMatchFinderMt
*p
, UInt32 historySize
, UInt32 keepAddBufferBefore
,
93 UInt32 matchMaxLen
, UInt32 keepAddBufferAfter
, ISzAlloc
*alloc
);
94 void MatchFinderMt_CreateVTable(CMatchFinderMt
*p
, IMatchFinder
*vTable
);
95 void MatchFinderMt_ReleaseStream(CMatchFinderMt
*p
);