diff --git a/checkin_notes b/checkin_notes index 2565fdf612..5282906786 100644 --- a/checkin_notes +++ b/checkin_notes @@ -3152,3 +3152,12 @@ David 19 Mar 2009 client/ rr_sim.cpp work_fetch.cpp,h + +Rom 19 Mar 2009 + - client: initial support for detecting the CPU L2 cache + size on Windows. + + client/ + client_state.cpp + cs_benchmark.cpp + hostinfo_win.cpp diff --git a/client/client_state.cpp b/client/client_state.cpp index 377870736f..f34e190115 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -153,10 +153,16 @@ void CLIENT_STATE::show_proxy_info() { void CLIENT_STATE::show_host_info() { char buf[256], buf2[256]; + + nbytes_to_string(host_info.m_cache, 0, buf, sizeof(buf)); msg_printf(NULL, MSG_INFO, "Processor: %d %s %s", host_info.p_ncpus, host_info.p_vendor, host_info.p_model ); + msg_printf(NULL, MSG_INFO, + "Processor: %s cache", + buf + ); msg_printf(NULL, MSG_INFO, "Processor features: %s", host_info.p_features ); diff --git a/client/cs_benchmark.cpp b/client/cs_benchmark.cpp index 04168bbefd..50b99377ab 100644 --- a/client/cs_benchmark.cpp +++ b/client/cs_benchmark.cpp @@ -177,7 +177,6 @@ int cpu_benchmarks(BENCHMARK_DESC* bdp) { } host_info.p_iops = vax_mips*1e6; host_info.p_membw = 1e9; - host_info.m_cache = 1e6; // TODO: measure the cache #ifdef _WIN32 } bdp->host_info = host_info; @@ -464,7 +463,6 @@ bool CLIENT_STATE::cpu_benchmarks_poll() { double p_fpops = 0; double p_iops = 0; double p_membw = 0; - double m_cache = 0; for (i=0; i 0) { host_info.p_fpops = p_fpops; } else { @@ -499,7 +495,6 @@ bool CLIENT_STATE::cpu_benchmarks_poll() { msg_printf(NULL, MSG_INTERNAL_ERROR, "Benchmark: int unexpectedly zero; ignoring"); } host_info.p_membw = p_membw; - host_info.m_cache = m_cache; print_benchmark_results(); } @@ -529,7 +524,7 @@ void CLIENT_STATE::print_benchmark_results() { #if 0 msg_printf( NULL, MSG_INFO, "Benchmark results: %.0f million bytes/sec memory bandwidth%s", - host_info.p_membw/1e6, (host_info.p_membw_err?" [ERROR]":"") + host_info.p_membw/1e6, (host_info.p_membw_err?" [ERROR]":"") ); #endif } diff --git a/client/hostinfo_win.cpp b/client/hostinfo_win.cpp index 48822ac948..ba07814c35 100644 --- a/client/hostinfo_win.cpp +++ b/client/hostinfo_win.cpp @@ -16,8 +16,9 @@ // along with BOINC. If not, see . #include "boinc_win.h" -#define COMPILE_MULTIMON_STUBS -#include +#ifndef __CYGWIN__ +#include +#endif #include "client_types.h" #include "filesys.h" @@ -152,18 +153,6 @@ typedef struct _MYMEMORYSTATUSEX { typedef BOOL (WINAPI *MYGLOBALMEMORYSTATUSEX)(LPMYMEMORYSTATUSEX lpBuffer); -// Traverse the video adapters and flag them as potiential accelerators. -struct INTERNALMONITORINFO -{ - DWORD cb; - TCHAR DeviceName[32]; - TCHAR DeviceString[128]; - DWORD StateFlags; - TCHAR DeviceID[128]; - TCHAR DeviceKey[128]; -}; - - // Returns the number of seconds difference from UTC // int get_timezone(int& timezone) { @@ -651,9 +640,10 @@ BOOL is_processor_feature_supported(DWORD feature) { // int get_processor_info( char* p_vendor, int p_vendor_size, char* p_model, int p_model_size, - char* p_features, int p_features_size + char* p_features, int p_features_size, double& p_cache ) { + int CPUInfo[4] = {-1}; char vendorName[256], processorName[256], identifierName[256], capabilities[256], temp_model[256]; HKEY hKey = NULL; LONG retval = 0; @@ -695,20 +685,28 @@ int get_processor_info( } strip_whitespace(capabilities); - + +#ifndef __CYGWIN__ + // determine CPU cache size + // see: http://msdn.microsoft.com/en-us/library/hskdteyh(VS.80).aspx + __cpuid(CPUInfo, 0x80000006); + p_cache = (double)((CPUInfo[2] >> 16) & 0xffff) * 1024; +#endif + + retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Hardware\\Description\\System\\CentralProcessor\\0", 0, KEY_QUERY_VALUE, &hKey); if(retval == ERROR_SUCCESS) { // Win9x and WinNT store different information in these field. // NT Examples: - // ProcessorNameString: Intel(R) Xeon(TM) CPU 3.06GHz - // Identifier: x86 Family 15 Model 2 Stepping 7 - // VendorIdentifier: GenuineIntel - // ~MHz: 3056 + // ProcessorNameString: Intel(R) Xeon(TM) CPU 3.06GHz + // Identifier: x86 Family 15 Model 2 Stepping 7 + // VendorIdentifier: GenuineIntel + // ~MHz: 3056 // 9X Examples: - // ProcessorNameString: - // Identifier: Pentium(r) Processor - // ~MHz: - // VendorIdentifier: GenuineIntel + // ProcessorNameString: + // Identifier: Pentium(r) Processor + // ~MHz: + // VendorIdentifier: GenuineIntel // Look in various places for processor information, add'l // entries suggested by mark mcclure @@ -786,7 +784,8 @@ int HOST_INFO::get_host_info() { get_processor_info( p_vendor, sizeof(p_vendor), p_model, sizeof(p_model), - p_features, sizeof(p_features) + p_features, sizeof(p_features), + m_cache ); get_processor_count(p_ncpus); get_local_network_info();