From ea23f9827afdcec5e9a32d6359929a2461cedd44 Mon Sep 17 00:00:00 2001 From: Dan Werthimer Date: Thu, 19 Jun 2003 18:19:35 +0000 Subject: [PATCH] no message svn path=/trunk/boinc/; revision=1547 --- client/client_state.C | 10 ++-- client/speed_stats.C | 88 ++++++++++++++------------------ client/speed_stats.h | 12 ++--- client/win/hostinfo_win.cpp | 30 +---------- client/win/wingui_mainwindow.cpp | 2 +- lib/error_numbers.h | 1 + lib/filesys.C | 6 ++- 7 files changed, 58 insertions(+), 91 deletions(-) diff --git a/client/client_state.C b/client/client_state.C index fe98aeb772..4556e55045 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -377,7 +377,7 @@ int CLIENT_STATE::cpu_benchmarks() { fpop_test_secs ); } - host_info.p_fpops = run_double_prec_test(fpop_test_secs); + run_double_prec_test(fpop_test_secs, host_info.p_fpops); if (log_flags.measurement_debug) { printf( @@ -385,7 +385,7 @@ int CLIENT_STATE::cpu_benchmarks() { iop_test_secs ); } - host_info.p_iops = run_int_test(iop_test_secs); + run_int_test(iop_test_secs, host_info.p_iops); if (log_flags.measurement_debug) { printf( @@ -393,7 +393,7 @@ int CLIENT_STATE::cpu_benchmarks() { mem_test_secs ); } - host_info.p_membw = run_mem_bandwidth_test(mem_test_secs); + run_mem_bandwidth_test(mem_test_secs, host_info.p_membw); // need to check cache!! host_info.m_cache = 1e6; @@ -504,8 +504,8 @@ int CLIENT_STATE::current_disk_usage(double& size) { double CLIENT_STATE::estimate_cpu_time(WORKUNIT& wu) { double x; - x = abs(wu.rsc_fpops/host_info.p_fpops); - x += abs(wu.rsc_iops/host_info.p_iops); + x = wu.rsc_fpops/host_info.p_fpops; + x += wu.rsc_iops/host_info.p_iops; return x; } diff --git a/client/speed_stats.C b/client/speed_stats.C index fdd15f9903..ee5f8d8641 100644 --- a/client/speed_stats.C +++ b/client/speed_stats.C @@ -222,8 +222,8 @@ int check_cache_size(int mem_size) { // Run the test of double precision math speed for num_secs seconds // -double run_double_prec_test(double num_secs) { - double df_measurement; +int run_double_prec_test(double num_secs, double &flops_per_sec) { + int retval; if (num_secs<0) { fprintf(stderr, "error: run_double_prec_test: negative num_secs\n"); @@ -233,17 +233,17 @@ double run_double_prec_test(double num_secs) { // Setup a timer to interrupt the tests in num_secs set_test_timer(num_secs); - df_measurement = (int)double_flop_test(0, 0); + retval = (int)double_flop_test(0, flops_per_sec, 0); destroy_test_timer(); - return df_measurement; + return retval; } // Run the test of integer math speed for num_secs seconds // -double run_int_test(double num_secs) { - double int_measurement; +int run_int_test(double num_secs, double &iops_per_sec) { + int retval; if (num_secs<0) { fprintf(stderr, "error: run_int_test: negative num_secs\n"); @@ -253,17 +253,17 @@ double run_int_test(double num_secs) { // Setup a timer to interrupt the tests in num_secs set_test_timer(num_secs); - int_measurement = (int)int_op_test(0, 0); + retval = (int)int_op_test(0, iops_per_sec, 0); destroy_test_timer(); - return int_measurement; + return retval; } // Run the test of memory bandwidth speed for num_secs seconds // -double run_mem_bandwidth_test(double num_secs) { - double bw_measurement; +int run_mem_bandwidth_test(double num_secs, double &bytes_per_sec) { + int retval; if (num_secs<0) { fprintf(stderr, "error: run_mem_bandwidth_test: negative num_secs\n"); @@ -273,22 +273,21 @@ double run_mem_bandwidth_test(double num_secs) { // Setup a timer to interrupt the tests in num_secs set_test_timer(num_secs); - bw_measurement = (int)bandwidth_test(0, 0); + retval = (int)bandwidth_test(0, bytes_per_sec, 0); destroy_test_timer(); - return bw_measurement; + return retval; } // One iteration == D_LOOP_ITERS (1,000,000) floating point operations // If time_total is negative, there was an error in the calculation, // meaning there is probably something wrong with the CPU -double double_flop_test(int iterations, int print_debug) { - double a[NUM_DOUBLES],b[NUM_DOUBLES],dp; - int i,n,j,actual_iters; - double temp,n_ops_per_sec; - clock_t time_start, time_total,calc_error; +int double_flop_test(int iterations, double &flops_per_sec, int print_debug) { + double a[NUM_DOUBLES], b[NUM_DOUBLES], dp, temp; + int i,n,j,actual_iters, error = 0; + clock_t time_start, time_total; if (iterations<0) { fprintf(stderr, "error: double_flop_test: negative iterations\n"); @@ -304,8 +303,8 @@ double double_flop_test(int iterations, int print_debug) { a[0] = b[0] = 1.0; for (i=1;i #include "client_types.h" #include "hostinfo.h" +#include "filesys.h" #include "util.h" -typedef BOOL (CALLBACK* FreeFn)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); - // Returns the number of seconds difference from UTC // int get_timezone(void) { @@ -36,31 +35,6 @@ int get_timezone(void) { return (tzi.Bias * 60); } -// Returns total and free space on current disk (in bytes) -// -void get_host_disk_info( double &total_space, double &free_space ) { - FreeFn pGetDiskFreeSpaceEx; - pGetDiskFreeSpaceEx = (FreeFn)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetDiskFreeSpaceExA"); - if(pGetDiskFreeSpaceEx) { - ULARGE_INTEGER TotalNumberOfFreeBytes; - ULARGE_INTEGER TotalNumberOfBytes; - pGetDiskFreeSpaceEx(NULL, NULL, &TotalNumberOfBytes, &TotalNumberOfFreeBytes); - unsigned int uMB; - uMB = TotalNumberOfFreeBytes.QuadPart / (1024 * 1024); - free_space = uMB * 1024.0 * 1024.0; - uMB = TotalNumberOfBytes.QuadPart / (1024 * 1024); - total_space = uMB * 1024.0 * 1024.0; - } else { - DWORD dwSectPerClust; - DWORD dwBytesPerSect; - DWORD dwFreeClusters; - DWORD dwTotalClusters; - GetDiskFreeSpace(NULL, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters); - free_space = (double)dwFreeClusters * dwSectPerClust * dwBytesPerSect; - total_space = (double)dwTotalClusters * dwSectPerClust * dwBytesPerSect; - } -} - // Gets windows specific host information (not complete) // int get_host_info(HOST_INFO& host) { @@ -178,7 +152,7 @@ int get_host_info(HOST_INFO& host) { break; } - get_host_disk_info(host.d_total, host.d_free); + get_filesystem_info(host.d_total, host.d_free); // Open the WinSock dll so we can get host info WORD wVersionRequested; diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index 011ebb557b..9b07a13c92 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -417,7 +417,7 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* pcs) // update usage double xDiskTotal; - double xDiskFree; get_host_disk_info(xDiskTotal, xDiskFree); + double xDiskFree; get_filesystem_info(xDiskTotal, xDiskFree); double xDiskUsed = xDiskTotal - xDiskFree; double xDiskAllow; gstate.allowed_disk_usage(xDiskAllow); xDiskAllow = xDiskFree - xDiskAllow; double xDiskUsage; gstate.current_disk_usage(xDiskUsage); diff --git a/lib/error_numbers.h b/lib/error_numbers.h index ef70f0f6ba..a16c7f7e45 100755 --- a/lib/error_numbers.h +++ b/lib/error_numbers.h @@ -66,3 +66,4 @@ // an output file was bigger than max_nbytes #define ERR_GETRUSAGE -132 // getrusage failed +#define ERR_BENCHMARK_FAILED -133 diff --git a/lib/filesys.C b/lib/filesys.C index f86ff4b90d..097f4e4805 100755 --- a/lib/filesys.C +++ b/lib/filesys.C @@ -49,9 +49,13 @@ #endif #ifdef _WIN32 +#include #include #include #include + +typedef BOOL (CALLBACK* FreeFn)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); + #endif #include "util.h" @@ -288,7 +292,7 @@ int get_filesystem_info(double &total_space, double &free_space) { ULARGE_INTEGER TotalNumberOfFreeBytes; ULARGE_INTEGER TotalNumberOfBytes; pGetDiskFreeSpaceEx(NULL, NULL, &TotalNumberOfBytes, &TotalNumberOfFreeBytes); - unsigned int uMB; + signed __int64 uMB; uMB = TotalNumberOfFreeBytes.QuadPart / (1024 * 1024); free_space = uMB * 1024.0 * 1024.0; uMB = TotalNumberOfBytes.QuadPart / (1024 * 1024);