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