File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 27
27
#include " ggml-cann.h"
28
28
#endif
29
29
30
+ #ifdef _WIN32
31
+ #define WIN32_LEAN_AND_MEAN
32
+ #ifndef NOMINMAX
33
+ # define NOMINMAX
34
+ #endif
35
+ #include < windows.h>
36
+ #endif
37
+
30
38
// utils
31
39
static uint64_t get_time_ns () {
32
40
using clock = std::chrono::high_resolution_clock;
@@ -96,6 +104,27 @@ static std::string get_cpu_info() {
96
104
}
97
105
fclose (f);
98
106
}
107
+ #elif defined(_WIN32)
108
+ HKEY hKey;
109
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
110
+ TEXT (" HARDWARE\\ DESCRIPTION\\ System\\ CentralProcessor\\ 0" ),
111
+ 0 ,
112
+ KEY_READ,
113
+ &hKey) != ERROR_SUCCESS) {
114
+ // fail to open registry key
115
+ return " " ;
116
+ }
117
+ char cpu_brand[256 ];
118
+ DWORD cpu_brand_size = sizeof (cpu_brand);
119
+ if (RegQueryValueExA (hKey,
120
+ TEXT (" ProcessorNameString" ),
121
+ NULL ,
122
+ NULL ,
123
+ (LPBYTE)cpu_brand,
124
+ &cpu_brand_size) == ERROR_SUCCESS) {
125
+ id.assign (cpu_brand, cpu_brand_size);
126
+ }
127
+ RegCloseKey (hKey);
99
128
#endif
100
129
// TODO: other platforms
101
130
return id;
You can’t perform that action at this time.
0 commit comments