mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-30 08:42:00 +00:00 
			
		
		
		
	llama-bench : add support for getting cpu info on Windows (#8824)
* Add support for getting cpu info on Windows for llama_bench * refactor --------- Co-authored-by: slaren <slarengh@gmail.com>
This commit is contained in:
		| @@ -27,6 +27,14 @@ | |||||||
| #include "ggml-cann.h" | #include "ggml-cann.h" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #ifdef _WIN32 | ||||||
|  | #define WIN32_LEAN_AND_MEAN | ||||||
|  | #ifndef NOMINMAX | ||||||
|  | #   define NOMINMAX | ||||||
|  | #endif | ||||||
|  | #include <windows.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| // utils | // utils | ||||||
| static uint64_t get_time_ns() { | static uint64_t get_time_ns() { | ||||||
|     using clock = std::chrono::high_resolution_clock; |     using clock = std::chrono::high_resolution_clock; | ||||||
| @@ -96,6 +104,27 @@ static std::string get_cpu_info() { | |||||||
|         } |         } | ||||||
|         fclose(f); |         fclose(f); | ||||||
|     } |     } | ||||||
|  | #elif defined(_WIN32) | ||||||
|  |     HKEY hKey; | ||||||
|  |     if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, | ||||||
|  |                      TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), | ||||||
|  |                      0, | ||||||
|  |                      KEY_READ, | ||||||
|  |                      &hKey) != ERROR_SUCCESS) { | ||||||
|  |         // fail to open registry key | ||||||
|  |         return ""; | ||||||
|  |     } | ||||||
|  |     char cpu_brand[256]; | ||||||
|  |     DWORD cpu_brand_size = sizeof(cpu_brand); | ||||||
|  |     if (RegQueryValueExA(hKey, | ||||||
|  |                         TEXT("ProcessorNameString"), | ||||||
|  |                         NULL, | ||||||
|  |                         NULL, | ||||||
|  |                         (LPBYTE)cpu_brand, | ||||||
|  |                         &cpu_brand_size) == ERROR_SUCCESS) { | ||||||
|  |         id.assign(cpu_brand, cpu_brand_size); | ||||||
|  |     } | ||||||
|  |     RegCloseKey(hKey); | ||||||
| #endif | #endif | ||||||
|     // TODO: other platforms |     // TODO: other platforms | ||||||
|     return id; |     return id; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zhenwei Jin
					Zhenwei Jin