no message

svn path=/trunk/boinc/; revision=1547
This commit is contained in:
Dan Werthimer 2003-06-19 18:19:35 +00:00
parent 868dfe3152
commit ea23f9827a
7 changed files with 58 additions and 91 deletions

View File

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

View File

@ -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<NUM_DOUBLES;i++) {
a[i] = a[i-1] / 2.0;
b[i] = b[i-1] * 2.0;
a[i] = a[i-1] / 2.0;
b[i] = b[i-1] * 2.0;
}
actual_iters = 0;
@ -315,13 +314,13 @@ double double_flop_test(int iterations, int print_debug) {
for (n=0;(n<iterations)&&run_test;n++) {
for (j=0;j<D_LOOP_ITERS;j+=((NUM_DOUBLES*4)+1)) {
dp = 0;
for (i=0;i<NUM_DOUBLES;i++) { // 2*NUM_DOUBLES flops
dp += a[i]*b[i]; // 2 flops
for (i=0;i<NUM_DOUBLES;i++) { // 2*NUM_DOUBLES flops
dp += a[i]*b[i]; // 2 flops
}
dp /= (float)NUM_DOUBLES; // 1 flop
for (i=0;i<NUM_DOUBLES;i++) { // 2*NUM_DOUBLES flops
a[i] *= dp; // 1 flop
b[i] *= dp; // 1 flop
dp /= (float)NUM_DOUBLES; // 1 flop
for (i=0;i<NUM_DOUBLES;i++) { // 2*NUM_DOUBLES flops
a[i] *= dp; // 1 flop
b[i] *= dp; // 1 flop
}
}
actual_iters++;
@ -336,36 +335,32 @@ double double_flop_test(int iterations, int print_debug) {
time_total = 0; // this is just a kludge
}
n_ops_per_sec = D_LOOP_ITERS*actual_iters/((double)time_total/CLOCKS_PER_SEC);
flops_per_sec = D_LOOP_ITERS*actual_iters/((double)time_total/CLOCKS_PER_SEC);
calc_error = 0;
temp = 1;
// Check to make sure all the values are the same as when we started
for (i=0;i<NUM_DOUBLES;i++) {
if ((double)a[i] != (float)temp) calc_error = 1;
if ((double)a[i] != (float)temp) error = ERR_BENCHMARK_FAILED;
temp /= 2;
}
if (calc_error) n_ops_per_sec *= -1;
if (print_debug) {
for (i=0;i<NUM_DOUBLES;i++) {
printf("%3d: %.50f\n", i, a[i]);
}
}
return n_ops_per_sec;
return error;
}
// One iteration == 1,000,000 integer operations
// If time_total is negative, there was an error in the calculation,
// meaning there is probably something wrong with the CPU
double int_op_test(int iterations, int print_debug) {
int int_op_test(int iterations, double &iops_per_sec, int print_debug) {
int a[NUM_INTS], temp, actual_iters;
clock_t time_start, time_total;
double n_ops_per_sec;
int i,j,k,calc_error;
int i,j,k,error = 0;
if (iterations<0) {
fprintf(stderr, "error: int_op_test: negative iterations\n");
return ERR_NEG;
@ -430,39 +425,35 @@ double int_op_test(int iterations, int print_debug) {
time_total = 0; // this is just a kludge
}
n_ops_per_sec = I_LOOP_ITERS*actual_iters/((double)time_total/CLOCKS_PER_SEC);
iops_per_sec = I_LOOP_ITERS*actual_iters/((double)time_total/CLOCKS_PER_SEC);
calc_error = 0;
temp = 1;
// Check to make sure all the values are the same as when we started
for (i=0;i<NUM_INTS;i++) {
if (a[i] != temp) calc_error = 1;
if (a[i] != temp) error = ERR_BENCHMARK_FAILED;
temp *= 2;
}
if (calc_error) n_ops_per_sec *= -1;
if (print_debug) {
for (i=0;i<NUM_INTS;i++) {
printf("%3d: %d\n", i, a[i]);
}
}
return n_ops_per_sec;
return error;
}
// If return value is negative, there was an error in the copying,
// meaning there is probably something wrong with the CPU
//
double bandwidth_test(int iterations, int print_debug) {
int bandwidth_test(int iterations, double &bytes_per_sec, int print_debug) {
// a, b, and c are arrays of doubles we will copy around to test memory bandwidth
double *a, *b, *c;
// aVal and bVal are the values of all elements of a and b.
double aVal, bVal;
double n_bytes_per_sec;
// Start and stop times for the clock
clock_t time_start, time_total;
int i,j,n,copy_error,actual_iters;
int i,j,n,actual_iters, error = 0;
if (iterations<0) {
fprintf(stderr, "error: bandwidth_test: negative iterations\n");
return ERR_NEG;
@ -516,20 +507,17 @@ double bandwidth_test(int iterations, int print_debug) {
time_total = 0; // this is just a kludge
}
n_bytes_per_sec = 2.0*6.0*MEM_SIZE*actual_iters*sizeof(double)/((double)time_total/CLOCKS_PER_SEC);
bytes_per_sec = 2.0*6.0*MEM_SIZE*actual_iters*sizeof(double)/((double)time_total/CLOCKS_PER_SEC);
copy_error = 0;
for (i=0;i<MEM_SIZE;i++) {
if (a[i] != aVal+i || b[i] != bVal+i) copy_error = 1;
if (a[i] != aVal+i || b[i] != bVal+i) error = ERR_BENCHMARK_FAILED;
}
if (copy_error) n_bytes_per_sec *= -1;
free(a);
free(b);
free(c);
return n_bytes_per_sec;
return error;
}
// TODO: handle errors here
@ -552,7 +540,7 @@ int set_test_timer(double num_secs) {
int destroy_test_timer() {
#ifdef _WIN32
timeKillEvent(speed_timer_id);
timeKillEvent(speed_timer_id);
#endif
return 0;
}

View File

@ -43,13 +43,13 @@
#define CPU_BENCHMARKS_ERROR 3
int check_cache_size( int mem_size );
double double_flop_test( int iterations, int print_debug );
double int_op_test( int iterations, int print_debug );
double bandwidth_test( int iterations, int print_debug );
int double_flop_test( int iterations, double &flops_per_sec, int print_debug );
int int_op_test( int iterations, double &iops_per_sec, int print_debug );
int bandwidth_test( int iterations, double &bytes_per_sec, int print_debug );
void run_test_suite( double num_secs_per_test );
double run_double_prec_test( double num_secs );
double run_int_test( double num_secs );
double run_mem_bandwidth_test( double num_secs );
int run_double_prec_test( double num_secs, double &flops_per_sec );
int run_int_test( double num_secs, double &iops_per_sec );
int run_mem_bandwidth_test( double num_secs, double &bytes_per_sec );
int set_test_timer(double num_secs);
int destroy_test_timer();

View File

@ -23,10 +23,9 @@
#include <winsock.h>
#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;

View File

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

View File

@ -66,3 +66,4 @@
// an output file was bigger than max_nbytes
#define ERR_GETRUSAGE -132
// getrusage failed
#define ERR_BENCHMARK_FAILED -133

View File

@ -49,9 +49,13 @@
#endif
#ifdef _WIN32
#include <windows.h>
#include <io.h>
#include <winsock.h>
#include <direct.h>
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);