diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2021-12-27 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2022-03-18 15:35:13 +0500 |
commit | f19f813537c7aea1c20749c914e756b54a9c3cf5 (patch) | |
tree | 816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /C/LzFindMt.h | |
parent | 98e06a519b63b81986abe76d28887f6984a7732b (diff) | |
download | 7zip-21.07.tar.gz 7zip-21.07.tar.bz2 7zip-21.07.zip |
'21.07'21.07
Diffstat (limited to 'C/LzFindMt.h')
-rw-r--r-- | C/LzFindMt.h | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/C/LzFindMt.h b/C/LzFindMt.h new file mode 100644 index 0000000..660b724 --- /dev/null +++ b/C/LzFindMt.h | |||
@@ -0,0 +1,109 @@ | |||
1 | /* LzFindMt.h -- multithreaded Match finder for LZ algorithms | ||
2 | 2021-07-12 : Igor Pavlov : Public domain */ | ||
3 | |||
4 | #ifndef __LZ_FIND_MT_H | ||
5 | #define __LZ_FIND_MT_H | ||
6 | |||
7 | #include "LzFind.h" | ||
8 | #include "Threads.h" | ||
9 | |||
10 | EXTERN_C_BEGIN | ||
11 | |||
12 | typedef struct _CMtSync | ||
13 | { | ||
14 | UInt32 numProcessedBlocks; | ||
15 | CThread thread; | ||
16 | UInt64 affinity; | ||
17 | |||
18 | BoolInt wasCreated; | ||
19 | BoolInt needStart; | ||
20 | BoolInt csWasInitialized; | ||
21 | BoolInt csWasEntered; | ||
22 | |||
23 | BoolInt exit; | ||
24 | BoolInt stopWriting; | ||
25 | |||
26 | CAutoResetEvent canStart; | ||
27 | CAutoResetEvent wasStopped; | ||
28 | CSemaphore freeSemaphore; | ||
29 | CSemaphore filledSemaphore; | ||
30 | CCriticalSection cs; | ||
31 | // UInt32 numBlocks_Sent; | ||
32 | } CMtSync; | ||
33 | |||
34 | typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances); | ||
35 | |||
36 | /* kMtCacheLineDummy must be >= size_of_CPU_cache_line */ | ||
37 | #define kMtCacheLineDummy 128 | ||
38 | |||
39 | typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos, | ||
40 | UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc); | ||
41 | |||
42 | typedef struct _CMatchFinderMt | ||
43 | { | ||
44 | /* LZ */ | ||
45 | const Byte *pointerToCurPos; | ||
46 | UInt32 *btBuf; | ||
47 | const UInt32 *btBufPos; | ||
48 | const UInt32 *btBufPosLimit; | ||
49 | UInt32 lzPos; | ||
50 | UInt32 btNumAvailBytes; | ||
51 | |||
52 | UInt32 *hash; | ||
53 | UInt32 fixedHashSize; | ||
54 | // UInt32 hash4Mask; | ||
55 | UInt32 historySize; | ||
56 | const UInt32 *crc; | ||
57 | |||
58 | Mf_Mix_Matches MixMatchesFunc; | ||
59 | UInt32 failure_LZ_BT; // failure in BT transfered to LZ | ||
60 | // UInt32 failure_LZ_LZ; // failure in LZ tables | ||
61 | UInt32 failureBuf[1]; | ||
62 | // UInt32 crc[256]; | ||
63 | |||
64 | /* LZ + BT */ | ||
65 | CMtSync btSync; | ||
66 | Byte btDummy[kMtCacheLineDummy]; | ||
67 | |||
68 | /* BT */ | ||
69 | UInt32 *hashBuf; | ||
70 | UInt32 hashBufPos; | ||
71 | UInt32 hashBufPosLimit; | ||
72 | UInt32 hashNumAvail; | ||
73 | UInt32 failure_BT; | ||
74 | |||
75 | |||
76 | CLzRef *son; | ||
77 | UInt32 matchMaxLen; | ||
78 | UInt32 numHashBytes; | ||
79 | UInt32 pos; | ||
80 | const Byte *buffer; | ||
81 | UInt32 cyclicBufferPos; | ||
82 | UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ | ||
83 | UInt32 cutValue; | ||
84 | |||
85 | /* BT + Hash */ | ||
86 | CMtSync hashSync; | ||
87 | /* Byte hashDummy[kMtCacheLineDummy]; */ | ||
88 | |||
89 | /* Hash */ | ||
90 | Mf_GetHeads GetHeadsFunc; | ||
91 | CMatchFinder *MatchFinder; | ||
92 | // CMatchFinder MatchFinder; | ||
93 | } CMatchFinderMt; | ||
94 | |||
95 | // only for Mt part | ||
96 | void MatchFinderMt_Construct(CMatchFinderMt *p); | ||
97 | void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc); | ||
98 | |||
99 | SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, | ||
100 | UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc); | ||
101 | void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder2 *vTable); | ||
102 | |||
103 | /* call MatchFinderMt_InitMt() before IMatchFinder::Init() */ | ||
104 | SRes MatchFinderMt_InitMt(CMatchFinderMt *p); | ||
105 | void MatchFinderMt_ReleaseStream(CMatchFinderMt *p); | ||
106 | |||
107 | EXTERN_C_END | ||
108 | |||
109 | #endif | ||