diff options
Diffstat (limited to 'CPP/Windows/System.h')
-rw-r--r-- | CPP/Windows/System.h | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/CPP/Windows/System.h b/CPP/Windows/System.h index b17111c..0c80373 100644 --- a/CPP/Windows/System.h +++ b/CPP/Windows/System.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #include "../Common/MyTypes.h" | 11 | #include "../Common/MyTypes.h" |
12 | #include "../Common/MyVector.h" | ||
12 | #include "../Common/MyWindows.h" | 13 | #include "../Common/MyWindows.h" |
13 | 14 | ||
14 | namespace NWindows { | 15 | namespace NWindows { |
@@ -16,6 +17,34 @@ namespace NSystem { | |||
16 | 17 | ||
17 | #ifdef _WIN32 | 18 | #ifdef _WIN32 |
18 | 19 | ||
20 | struct CCpuGroups | ||
21 | { | ||
22 | CRecordVector<UInt32> GroupSizes; | ||
23 | UInt32 NumThreadsTotal; // sum of threads in all groups | ||
24 | // bool Is_Win11_Groups; // useless | ||
25 | |||
26 | void Get_GroupSize_Min_Max(UInt32 &minSize, UInt32 &maxSize) const | ||
27 | { | ||
28 | unsigned num = GroupSizes.Size(); | ||
29 | UInt32 minSize2 = 0, maxSize2 = 0; | ||
30 | if (num) | ||
31 | { | ||
32 | minSize2 = (UInt32)0 - 1; | ||
33 | do | ||
34 | { | ||
35 | const UInt32 v = GroupSizes[--num]; | ||
36 | if (minSize2 > v) minSize2 = v; | ||
37 | if (maxSize2 < v) maxSize2 = v; | ||
38 | } | ||
39 | while (num); | ||
40 | } | ||
41 | minSize = minSize2; | ||
42 | maxSize = maxSize2; | ||
43 | } | ||
44 | bool Load(); | ||
45 | CCpuGroups(): NumThreadsTotal(0) {} | ||
46 | }; | ||
47 | |||
19 | UInt32 CountAffinity(DWORD_PTR mask); | 48 | UInt32 CountAffinity(DWORD_PTR mask); |
20 | 49 | ||
21 | struct CProcessAffinity | 50 | struct CProcessAffinity |
@@ -25,14 +54,28 @@ struct CProcessAffinity | |||
25 | DWORD_PTR processAffinityMask; | 54 | DWORD_PTR processAffinityMask; |
26 | DWORD_PTR systemAffinityMask; | 55 | DWORD_PTR systemAffinityMask; |
27 | 56 | ||
57 | CCpuGroups Groups; | ||
58 | bool IsGroupMode; | ||
59 | /* | ||
60 | IsGroupMode == true, if | ||
61 | Groups.GroupSizes.Size() > 1) && { dafalt affinity was not changed } | ||
62 | IsGroupMode == false, if single group or affinity was changed | ||
63 | */ | ||
64 | |||
65 | UInt32 Load_and_GetNumberOfThreads(); | ||
66 | |||
28 | void InitST() | 67 | void InitST() |
29 | { | 68 | { |
30 | // numProcessThreads = 1; | 69 | // numProcessThreads = 1; |
31 | // numSysThreads = 1; | 70 | // numSysThreads = 1; |
32 | processAffinityMask = 1; | 71 | processAffinityMask = 1; |
33 | systemAffinityMask = 1; | 72 | systemAffinityMask = 1; |
73 | IsGroupMode = false; | ||
74 | // Groups.NumThreadsTotal = 0; | ||
75 | // Groups.Is_Win11_Groups = false; | ||
34 | } | 76 | } |
35 | 77 | ||
78 | /* | ||
36 | void CpuZero() | 79 | void CpuZero() |
37 | { | 80 | { |
38 | processAffinityMask = 0; | 81 | processAffinityMask = 0; |
@@ -42,9 +85,23 @@ struct CProcessAffinity | |||
42 | { | 85 | { |
43 | processAffinityMask |= ((DWORD_PTR)1 << cpuIndex); | 86 | processAffinityMask |= ((DWORD_PTR)1 << cpuIndex); |
44 | } | 87 | } |
88 | */ | ||
45 | 89 | ||
46 | UInt32 GetNumProcessThreads() const { return CountAffinity(processAffinityMask); } | 90 | UInt32 GetNumProcessThreads() const |
47 | UInt32 GetNumSystemThreads() const { return CountAffinity(systemAffinityMask); } | 91 | { |
92 | if (IsGroupMode) | ||
93 | return Groups.NumThreadsTotal; | ||
94 | // IsGroupMode == false | ||
95 | // so we don't want to use groups | ||
96 | // we return number of threads in default primary group: | ||
97 | return CountAffinity(processAffinityMask); | ||
98 | } | ||
99 | UInt32 GetNumSystemThreads() const | ||
100 | { | ||
101 | if (Groups.GroupSizes.Size() > 1 && Groups.NumThreadsTotal) | ||
102 | return Groups.NumThreadsTotal; | ||
103 | return CountAffinity(systemAffinityMask); | ||
104 | } | ||
48 | 105 | ||
49 | BOOL Get(); | 106 | BOOL Get(); |
50 | 107 | ||
@@ -122,7 +179,7 @@ struct CProcessAffinity | |||
122 | 179 | ||
123 | UInt32 GetNumberOfProcessors(); | 180 | UInt32 GetNumberOfProcessors(); |
124 | 181 | ||
125 | bool GetRamSize(UInt64 &size); // returns false, if unknown ram size | 182 | bool GetRamSize(size_t &size); // returns false, if unknown ram size |
126 | 183 | ||
127 | unsigned long Get_File_OPEN_MAX(); | 184 | unsigned long Get_File_OPEN_MAX(); |
128 | unsigned Get_File_OPEN_MAX_Reduced_for_3_tasks(); | 185 | unsigned Get_File_OPEN_MAX_Reduced_for_3_tasks(); |