/* CVS info */ /* $Date: 2007/03/13 17:06:56 $ */ /* $Revision: 1.5 $ */ /* $RCSfile: io_b_1thru4.c,v $ */ /* $Name: rel_7 $ */ /* This file contains all of the actual benchmarks. The makefile will produce 5 programs by conditionally compiling the same source. Bench2 and Bench3 are virtually the same. The main difference has to do with the size of the input files. The comments at the beginning of each subroutine have a brief description of what each program does. The benchmarks measures the following: Caching local to a compute node Caching local to an IO server Reading from disc with no caching How well mmaps performs How well the system can handle a large number of writes */ #include #include #include #include #include #include #include #include #include #include #include "data_sizes.h" #include "iobench.h" // Global extern long jobid; // Permissions 0666 everone can read and write #define BM_PERMS (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) // Open for read and write #define BM_FLAGS (O_RDWR) #define W_BM_PERMS (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) #define W_BM_FLAGS (O_WRONLY|O_CREAT|O_EXCL) static void syserror(int line, char* file, const char* func, char* msg){ fprintf(stderr,"%04ld %s", jobid, msg); fprintf(stderr,"%s ", strerror( errno ) ); fprintf(stderr,"in function %s in file %s at line %d\n", func, file, line ); } #define SYSERROR(MSG) syserror(__LINE__, __FILE__, __func__, MSG) char io_dir_name[4096]; char io_file_name[4096]; char* part = "abc"; double wall(void); static void mk_unique_nm(char* , char* , int); #if defined( __BM_RFCC ) // Each job reads same 150M file from its ioserver // File name is .../cnode_caching_150M int read_from_cnode_cache(char* io_dir_name, double* el_time){ ssize_t nr; int par_rd; double t0; int fd; int i; char version[] = "FIOPB_VER_4/06"; static char cvs_info[] = "BMARKGRP $Date: 2007/03/13 17:06:56 $ $Revision: 1.5 $ $RCSfile: io_b_1thru4.c,v $ $Name: rel_7 $"; sprintf(io_file_name,"%s/cnode_caching_150M", io_dir_name); #ifdef DBG printf("dir name = %s file name = %s\n", io_dir_name, io_file_name); #endif t0 = wall(); if( (fd = bm_open(io_file_name , BM_FLAGS, BM_PERMS) ) == -1){ fprintf(stderr,"%04ld Read_from_cnode_cache, initial open of file %s failed\n", jobid,io_file_name ); return -1; } for(i=0; i<64; i++){ #ifdef PRG fprintf(stderr,"file number %d\n", i); #endif if ( bm_read( fd, io_buffer, BF_SZ ) == -1 ){ SYSERROR("READING FILE: "); ch_p_reads(); //check for partial reads (not and error) fprintf(stderr,"%04ld ,Read_from_cnode_cache read number %d, file %s\n", jobid, i, io_file_name ); return -1; } } if( bm_close( fd ) == -1 ){ SYSERROR("B1A CLOSE FILE: "); fprintf(stderr,"bench 1a , file %s\n", io_file_name ); return -1; } *el_time = wall() - t0; return 0; } #elif defined( __BM_MFI ) int mmap_file_in(char* io_dir_name, double* el_time){ double t0; // Each job mmaps the 750M file 'mmap_file_input_750M' from its ioserver and reads // a byte from each page. This is done 16 times int fdin; int i, j; char *src, *dst, sum=0; long pgsz, pages; struct stat statbuf; static char cvs_info[] = "BMARKGRP $Date: 2007/03/13 17:06:56 $ $Revision: 1.5 $ $RCSfile: io_b_1thru4.c,v $ $Name: rel_7 $"; if ( (pgsz = sysconf( _SC_PAGE_SIZE )) == -1L){ fprintf(stderr,"%04ld mmap_file_in: sysconf can't find page size\n", jobid ); exit( 1 ); } sprintf(io_file_name, "%s/mmap_file_input_750M", io_dir_name); #ifdef DBG printf("dir name = %s file name = %s\n", io_dir_name, io_file_name); #endif t0 = wall(); for (i=0; i<16; i++){ #ifdef PRG fprintf(stderr,"map repetition %d\n", i); #endif if ( (fdin = open(io_file_name, O_RDONLY)) < 0){ fprintf(stderr,"%04ld mmap_file_in , can't open file %s\n", jobid, io_file_name ); return -1; } if (fstat(fdin, &statbuf) < 0){ fprintf(stderr,"%04ld mmap_file_in , fstat error on file %s failed\n", jobid, io_file_name ); return -1; } pages = statbuf.st_size/pgsz; errno = 0; if (( src = mmap( 0, statbuf.st_size, PROT_READ, MAP_FILE|MAP_SHARED , fdin, 0)) == MAP_FAILED ){ SYSERROR("mmap_file_input_750M: "); fprintf(stderr,"mmap_file_in , file %s\n", io_file_name ); return -1; } // Touch each page of memory by reading a byte for(j=0; j