- client: initial support for detecting the CPU L2 cache

size on Windows.
        
    client/
        client_state.cpp
        cs_benchmark.cpp
        hostinfo_win.cpp

svn path=/trunk/boinc/; revision=17637
This commit is contained in:
Rom Walton 2009-03-20 01:46:29 +00:00
parent c53defdd19
commit 696dfba813
4 changed files with 40 additions and 31 deletions

View File

@ -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

View File

@ -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
);

View File

@ -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<bm_ncpus; i++) {
if (log_flags.benchmark_debug) {
msg_printf(0, MSG_INFO,
@ -482,12 +480,10 @@ bool CLIENT_STATE::cpu_benchmarks_poll() {
p_iops += benchmark_descs[i].host_info.p_iops;
#endif
p_membw += benchmark_descs[i].host_info.p_membw;
m_cache += benchmark_descs[i].host_info.m_cache;
}
p_fpops /= bm_ncpus;
p_iops /= bm_ncpus;
p_membw /= bm_ncpus;
m_cache /= bm_ncpus;
if (p_fpops > 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
}

View File

@ -16,8 +16,9 @@
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#include "boinc_win.h"
#define COMPILE_MULTIMON_STUBS
#include <multimon.h>
#ifndef __CYGWIN__
#include <intrin.h>
#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: <Not Defined>
// Identifier: Pentium(r) Processor
// ~MHz: <Not Defined>
// VendorIdentifier: GenuineIntel
// ProcessorNameString: <Not Defined>
// Identifier: Pentium(r) Processor
// ~MHz: <Not Defined>
// 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();