/* CVS info */ /* $Date: 2007/03/15 14:33:40 $ */ /* $Revision: 1.4 $ */ /* $RCSfile: driver.c,v $ */ /* $Name: rel_7 $ */ /* Depending on how this is conditionally compiled, it becomes the driver program for one of the 5 benchmarks. The beginning of the code checks the desired start time and determines if its reasonable. If it is, it then spin waits until the desired time and then calls the benchmark as a subroutine. The program also prints the wall clock start time, the finish time, and a more accurate elapsed time returned from the benchmark subroutine. The driver also does a first test as to whether or not the benchmark completed fast enough. If not, the test has failed. To pass the test, a benchmark must be run across the whole machine simultaneously. The duration of the test is the difference between the earliest start time and the last finish time. Job 'abc' is launch as follows abc jobid npes seed start_time ioserver_scratch_directory jobid an integer in the interval [0 - ( npes-1)] npes is the number of jobs in this RES session seed an integer used as a seed to the random number generator start_time a calendar time at which the jobs will start. This is derived from the time routine. */ #include #include #include #include #include #include // This number is used for labeling output and for creating // unique names for files. long jobid; #if defined( __BM_RFCC ) # define A_THRESHOLD ( 500 ) int read_from_cnode_cache(char* io_dir_name, double* el_time); #elif defined( __BM_MFI ) # define A_THRESHOLD ( 1500 ) int mmap_file_in(char* io_dir_name, double* el_time); #elif defined( __BM_RFIOSC ) # define A_THRESHOLD ( 2000 ) int read_from_ioserver_cache(char* io_dir_name, double* el_time); #elif defined( __BM_RFD ) # define A_THRESHOLD ( 2500 ) int read_from_disk(char* io_dir_name, double* el_time); #elif defined( __BM_WMF ) # define A_THRESHOLD (2500) int write_many_files(char* io_dir_name, double* el_time); #endif int main(int argc, char** argv){ long npes; // Number of total job = number of procesors long seed; long ran_io_svr; // A random IO server time_t start; // The start time char* io_sv_dirname; // name of the directory on the IO server time_t now; // int bm_stat; double el_time; // elapsed int passed = 1; long t_bytes; char hostname[500] = "unk_host" ; static char cvs_info[] = "BMARKGRP $Date: 2007/03/15 14:33:40 $ $Revision: 1.4 $ $RCSfile: driver.c,v $ $Name: rel_7 $"; jobid = atol(argv[ 1 ]); // Get arguments npes = atol(argv[ 2 ]); seed = atol(argv[ 3 ]); start = atol(argv[ 4 ]); io_sv_dirname = argv[ 5 ]; // Compile in the following if you need to cd to the scratch directory. // RESRUN does this #if CDIR errno = 0; if ( chdir( io_sv_dirname ) == -1 ){ exit( 1 ); } #endif now = time(NULL); if( start < 0 ){ start = now + 15; } if ( start < now ){ printf("%04ld ERROR: start time has already passed\n", jobid); exit(1); } if ( start > now+1800 ){ printf("%04ld ERROR: Start time more than a half hour in the future\n", jobid ); exit(1); } if ( start - now > 30 ){ sleep( (start - now) - 30); }; while( start > now ){ now = time(NULL); } // Initalize random number generator. Every job should // generate a different sequence srand((int)jobid+7); #if defined( __BM_RFCC ) printf("%04ld read_from_cnode_cache started %s", jobid, ctime(&now) ); bm_stat = read_from_cnode_cache(io_sv_dirname, &el_time); if (el_time > A_THRESHOLD ){ passed = 0; } #elif defined( __BM_MFI ) printf("%04ld mmap_file_in started %s", jobid, ctime(&now) ); bm_stat = mmap_file_in(io_sv_dirname, &el_time); if (el_time > A_THRESHOLD ){ passed = 0; } #elif defined( __BM_RFIOSC ) printf("%04ld read_from_ioserver_cache started %s", jobid, ctime(&now) ); bm_stat = read_from_ioserver_cache(io_sv_dirname, &el_time); if (el_time > A_THRESHOLD ){ passed = 0; } #elif defined( __BM_RFD ) printf("%04ld read_from_disk started %s", jobid, ctime(&now) ); bm_stat = read_from_disk(io_sv_dirname, &el_time); if (el_time > A_THRESHOLD ){ passed = 0; } #elif defined( __BM_WMF ) printf("%04ld write_many_files started %s", jobid, ctime(&now) ); bm_stat = write_many_files(io_sv_dirname, &el_time); if (el_time > A_THRESHOLD ){ passed = 0; } #endif if( bm_stat == -1 ){ printf("%04ld benchmark generated an error\n", jobid); } if ( gethostname(hostname, 500 ) == -1 ){ strncpy(hostname, "unk_host", 9 ); } printf("%04ld ", jobid); if ( passed ) printf("passed\n"); else printf("failed\n"); printf("%04ld %s ran %12.6lf sec\n", jobid, hostname, el_time ); printf("%04ld ended %s\n", jobid, ctime(&now) ); return 0; } // End Main