|
PAPI
5.1.0.2
|
00001 /************************************************************************/ 00002 /* Original Author: */ 00003 /* William Norcott (wnorcott@us.oracle.com) */ 00004 /* 4 Dunlap Drive */ 00005 /* Nashua, NH 03060 */ 00006 /* */ 00007 /************************************************************************/ 00008 /* Enhancements by: */ 00009 /* Don Capps (capps@iozone.org) */ 00010 /* 7417 Crenshaw */ 00011 /* Plano, TX 75025 */ 00012 /* */ 00013 /************************************************************************/ 00014 /* Copyright 1991, 1992, 1994, 1998, 2000, 2001 William D. Norcott */ 00015 /************************************************************************/ 00016 /* */ 00017 /* Iozone is based on the original work done by William Norrcot. It has */ 00018 /* been enhanced so that it provides a more complete filesystem */ 00019 /* characterization. */ 00020 /* Its purpose is to provide automated filesystem characterization. */ 00021 /* Enhancements have been made by: */ 00022 /* */ 00023 /* Don Capps capps@iozone.org */ 00024 /* */ 00025 /* Iozone can perform single stream and multi stream I/O */ 00026 /* also it now performs read, write, re-read, re-write, */ 00027 /* read backwards, read/write random, re-read record, */ 00028 /* pread, re-pread, re-pwrite, preadv, re-preadv, pwritev, */ 00029 /* stride read, and re-pwritev,mmap, POSIX async I/O, NFS */ 00030 /* cluster testing and much more. */ 00031 /* */ 00032 /* The frontend now uses getopt() and the user can control many more */ 00033 /* of the actions. */ 00034 /* */ 00035 /* */ 00036 /************************************************************************/ 00037 /* THIS SOFTWARE IS PROVIDED BY DON CAPPS AND THE IOZONE CREW "AS IS */ 00038 /* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */ 00039 /* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */ 00040 /* PARTICULAR PURPOSE ARE DISCLAIMED. */ 00041 /* */ 00042 /* IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY */ 00043 /* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL */ 00044 /* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ 00045 /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS */ 00046 /* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER */ 00047 /* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR */ 00048 /* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE. */ 00049 /************************************************************************/ 00050 00051 /************************************************************************/ 00052 /* For the beginner... */ 00053 /* */ 00054 /* 1. make linux (linux, hpux, convex, hpux_no_ansi) */ 00055 /* 2. type ./iozone -Ra */ 00056 /* */ 00057 /* Hint: Type make (it will give you a list of valid targets) */ 00058 /* */ 00059 /************************************************************************/ 00060 00061 00062 /* The version number */ 00063 #define THISVERSION " Version $Revision$" 00064 00065 #if defined(linux) 00066 #define _GNU_SOURCE 00067 #endif 00068 /* Include for Cygnus development environment for Windows */ 00069 #if defined (Windows) 00070 #include <windows.h> 00071 #include <errno.h> 00072 #else 00073 #if defined(linux) || defined(solaris) || defined(macosx) || defined(__AIX__) || defined(FreeBSD) || defined(_HPUX_SOURCE) 00074 #include <errno.h> 00075 #else 00076 extern int errno; /* imported for errors */ 00077 extern int h_errno; /* imported for errors */ 00078 #endif 00079 #endif 00080 00081 00082 #include <sys/types.h> 00083 #include <sys/stat.h> 00084 #if defined (__LP64__) || defined(OSF_64) || defined(__alpha__) || defined(__arch64__) || defined(_LP64) || defined(__s390x__) || defined(__AMD64__) 00085 #define MODE "\tCompiled for 64 bit mode." 00086 #define _64BIT_ARCH_ 00087 #else 00088 #define MODE "\tCompiled for 32 bit mode." 00089 #endif 00090 00091 #ifndef NO_THREADS 00092 #include <pthread.h> 00093 #endif 00094 00095 #if defined(HAVE_ANSIC_C) && defined(linux) 00096 #include <stdlib.h> 00097 #include <sys/wait.h> 00098 #endif 00099 00100 #ifdef HAVE_PROTO 00101 #include "proto.h" 00102 #else 00103 int atoi(); 00104 int close(); 00105 int unlink(); 00106 int main(); 00107 void record_command_line(); 00108 #if !defined(linux) 00109 int wait(); 00110 #endif 00111 int fsync(); 00112 void srand48(); 00113 long lrand48(); 00114 void create_list(); 00115 void Poll(); 00116 void print_header(); 00117 void Kill(); 00118 long long l_min(); 00119 long long l_max(); 00120 long long mythread_create(); 00121 int gen_new_buf(); 00122 void touch_dedup(); 00123 void init_by_array64(unsigned long long *, unsigned long long ); 00124 unsigned long long genrand64_int64(void); 00125 #endif 00126 00127 #include <fcntl.h> 00128 00129 char *help[] = { 00130 " Usage: iozone [-s filesize_Kb] [-r record_size_Kb] [-f [path]filename] [-h]", 00131 " [-i test] [-E] [-p] [-a] [-A] [-z] [-Z] [-m] [-M] [-t children]", 00132 " [-l min_number_procs] [-u max_number_procs] [-v] [-R] [-x] [-o]", 00133 " [-d microseconds] [-F path1 path2...] [-V pattern] [-j stride]", 00134 " [-T] [-C] [-B] [-D] [-G] [-I] [-H depth] [-k depth] [-U mount_point]", 00135 " [-S cache_size] [-O] [-L cacheline_size] [-K] [-g maxfilesize_Kb]", 00136 " [-n minfilesize_Kb] [-N] [-Q] [-P start_cpu] [-e] [-c] [-b Excel.xls]", 00137 " [-J milliseconds] [-X write_telemetry_filename] [-w] [-W]", 00138 " [-Y read_telemetry_filename] [-y minrecsize_Kb] [-q maxrecsize_Kb]", 00139 " [-+u] [-+m cluster_filename] [-+d] [-+x multiplier] [-+p # ]", 00140 " [-+r] [-+t] [-+X] [-+Z] [-+w percent dedupable] [-+y percent_interior_dedup]", 00141 " [-+C percent_dedup_within]", 00142 " ", 00143 " -a Auto mode", 00144 " -A Auto2 mode", 00145 " -b Filename Create Excel worksheet file", 00146 " -B Use mmap() files", 00147 " -c Include close in the timing calculations", 00148 " -C Show bytes transferred by each child in throughput testing", 00149 " -d # Microsecond delay out of barrier", 00150 " -D Use msync(MS_ASYNC) on mmap files", 00151 " -e Include flush (fsync,fflush) in the timing calculations", 00152 " -E Run extension tests", 00153 " -f filename to use", 00154 " -F filenames for each process/thread in throughput test", 00155 " -g # Set maximum file size (in Kbytes) for auto mode (or #m or #g)", 00156 " -G Use msync(MS_SYNC) on mmap files", 00157 " -h help", 00158 " -H # Use POSIX async I/O with # async operations", 00159 " -i # Test to run (0=write/rewrite, 1=read/re-read, 2=random-read/write", 00160 " 3=Read-backwards, 4=Re-write-record, 5=stride-read, 6=fwrite/re-fwrite", 00161 " 7=fread/Re-fread, 8=random_mix, 9=pwrite/Re-pwrite, 10=pread/Re-pread", 00162 " 11=pwritev/Re-pwritev, 12=preadv/Re-preadv)", 00163 " -I Use VxFS VX_DIRECT, O_DIRECT,or O_DIRECTIO for all file operations", 00164 " -j # Set stride of file accesses to (# * record size)", 00165 " -J # milliseconds of compute cycle before each I/O operation", 00166 " -k # Use POSIX async I/O (no bcopy) with # async operations", 00167 " -K Create jitter in the access pattern for readers", 00168 " -l # Lower limit on number of processes to run", 00169 " -L # Set processor cache line size to value (in bytes)", 00170 " -m Use multiple buffers", 00171 " -M Report uname -a output", 00172 " -n # Set minimum file size (in Kbytes) for auto mode (or #m or #g)", 00173 " -N Report results in microseconds per operation", 00174 " -o Writes are synch (O_SYNC)", 00175 " -O Give results in ops/sec.", 00176 " -p Purge on", 00177 " -P # Bind processes/threads to processors, starting with this cpu", 00178 " -q # Set maximum record size (in Kbytes) for auto mode (or #m or #g)", 00179 " -Q Create offset/latency files", 00180 " -r # record size in Kb", 00181 " or -r #k .. size in Kb", 00182 " or -r #m .. size in Mb", 00183 " or -r #g .. size in Gb", 00184 " -R Generate Excel report", 00185 " -s # file size in Kb", 00186 " or -s #k .. size in Kb", 00187 " or -s #m .. size in Mb", 00188 " or -s #g .. size in Gb", 00189 " -S # Set processor cache size to value (in Kbytes)", 00190 " -t # Number of threads or processes to use in throughput test", 00191 " -T Use POSIX pthreads for throughput tests", 00192 " -u # Upper limit on number of processes to run", 00193 " -U Mount point to remount between tests", 00194 " -v version information", 00195 " -V # Verify data pattern write/read", 00196 " -w Do not unlink temporary file", 00197 " -W Lock file when reading or writing", 00198 " -x Turn off stone-walling", 00199 " -X filename Write telemetry file. Contains lines with (offset reclen compute_time) in ascii", 00200 " -y # Set minimum record size (in Kbytes) for auto mode (or #m or #g)", 00201 " -Y filename Read telemetry file. Contains lines with (offset reclen compute_time) in ascii", 00202 " -z Used in conjunction with -a to test all possible record sizes", 00203 " -Z Enable mixing of mmap I/O and file I/O", 00204 " -+E Use existing non-Iozone file for read-only testing", 00205 " -+K Sony special. Manual control of test 8.", 00206 " -+m Cluster_filename Enable Cluster testing", 00207 " -+d File I/O diagnostic mode. (To troubleshoot a broken file I/O subsystem)", 00208 " -+u Enable CPU utilization output (Experimental)", 00209 " -+x # Multiplier to use for incrementing file and record sizes", 00210 " -+p # Percentage of mix to be reads", 00211 " -+r Enable O_RSYNC|O_SYNC for all testing.", 00212 " -+t Enable network performance test. Requires -+m ", 00213 " -+n No retests selected.", 00214 " -+k Use constant aggregate data set size.", 00215 " -+q Delay in seconds between tests.", 00216 " -+l Enable record locking mode.", 00217 " -+L Enable record locking mode, with shared file.", 00218 " -+B Sequential mixed workload.", 00219 #if defined(O_DSYNC) 00220 " -+D Enable O_DSYNC mode.", 00221 #endif 00222 #ifndef NO_MADVISE 00223 " -+A # Enable madvise. 0 = normal, 1=random, 2=sequential", 00224 " 3=dontneed, 4=willneed", 00225 #endif 00226 " -+N Do not truncate existing files on sequential writes.", 00227 " -+S # Dedup-able data is limited to sharing within each numerically", 00228 " identified file set", 00229 " -+V Enable shared file. No locking.", 00230 #if defined(Windows) 00231 " -+U Windows Unbufferd I/O API (Very Experimental)", 00232 #endif 00233 " -+X Enable short circuit mode for filesystem testing ONLY", 00234 " ALL Results are NOT valid in this mode.", 00235 " -+Z Enable old data set compatibility mode. WARNING.. Published", 00236 " hacks may invalidate these results and generate bogus, high", 00237 " values for results.", 00238 " -+w ## Percent of dedup-able data in buffers.", 00239 " -+y ## Percent of dedup-able within & across files in buffers.", 00240 " -+C ## Percent of dedup-able within & not across files in buffers.", 00241 " -+H Hostname Hostname of the PIT server.", 00242 " -+P Service Service of the PIT server.", 00243 " -+z Enable latency histogram logging.", 00244 "" }; 00245 00246 char *head1[] = { 00247 " 'Iozone' Filesystem Benchmark Program", 00248 " ", 00249 THISVERSION, 00250 MODE, 00251 " ", 00252 " Original Author: William Norcott (wnorcott@us.oracle.com)", 00253 " 4 Dunlap Drive", 00254 " Nashua, NH 03060", 00255 " ", 00256 " Enhancements: Don Capps (capps@iozone.org)", 00257 " 7417 Crenshaw", 00258 " Plano, TX 75025", 00259 " ", 00260 " Copyright 1991, 1992, 1994, 1998, 1999, 2002 William D. Norcott", 00261 " ", 00262 " License to freely use and distribute this software is hereby granted ", 00263 " by the author, subject to the condition that this copyright notice ", 00264 " remains intact. The author retains the exclusive right to publish ", 00265 " derivative works based on this work, including, but not limited to, ", 00266 " revised versions of this work", 00267 " ", 00268 " Other contributors:", 00269 " ", 00270 " Don Capps (Network Appliance) capps@iozone.org", 00271 " ", 00272 ""}; 00273 00274 /****************************************************************** 00275 00276 INCLUDE FILES (system-dependent) 00277 00278 ******************************************************************/ 00279 #include <sys/mman.h> 00280 #include <stdio.h> 00281 #include <signal.h> 00282 #include <unistd.h> 00283 00284 #include <fcntl.h> 00285 #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__DragonFly__) 00286 #include <malloc.h> 00287 #endif 00288 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__DragonFly__) 00289 #include <stdlib.h> 00290 #include <string.h> 00291 #endif 00292 00293 #if defined (__FreeBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__APPLE__) || defined(__DragonFly__) 00294 #ifndef O_SYNC 00295 #define O_SYNC O_FSYNC 00296 #endif 00297 #endif 00298 00299 #if defined (__FreeBSD__) 00300 #ifndef O_RSYNC 00301 #define O_RSYNC O_FSYNC 00302 #endif 00303 #endif 00304 00305 #if ((defined(solaris) && defined(__LP64__)) || defined(__s390x__)) 00306 /* If we are building for 64-bit Solaris, all functions that return pointers 00307 * must be declared before they are used; otherwise the compiler will assume 00308 * that they return ints and the top 32 bits of the pointer will be lost, 00309 * causing segmentation faults. The following includes take care of this. 00310 * It should be safe to add these for all other OSs too, but we're only 00311 * doing it for Solaris now in case another OS turns out to be a special case. 00312 */ 00313 #include <strings.h> 00314 #include <stdlib.h> 00315 #include <sys/socket.h> 00316 #include <netinet/in.h> 00317 #include <arpa/inet.h> 00318 00319 #endif 00320 #if ( defined(solaris) && defined(studio11) ) 00321 #include <strings.h> 00322 #include <stdlib.h> 00323 #endif 00324 00325 #if defined(OSFV5) || defined(linux) 00326 #include <string.h> 00327 #endif 00328 00329 #if defined(linux) 00330 #include <sys/socket.h> 00331 #include <netinet/in.h> 00332 #include <arpa/inet.h> 00333 #endif 00334 00335 #ifndef MAP_FAILED 00336 #define MAP_FAILED -1 00337 #endif 00338 00339 #ifdef generic 00340 typedef long long off64_t; 00341 #endif 00342 00343 #if defined(__DragonFly__) 00344 #define __off64_t_defined 00345 typedef off_t off64_t; 00346 #endif 00347 00348 00349 #ifndef solaris 00350 #ifndef off64_t 00351 #ifndef _OFF64_T 00352 #ifndef __AIX__ 00353 #ifndef __off64_t_defined 00354 #ifndef SCO_Unixware_gcc 00355 #ifndef UWIN 00356 #ifndef __DragonFly__ 00357 typedef long long off64_t; 00358 #endif 00359 #endif 00360 #endif 00361 #endif 00362 #endif 00363 #endif 00364 #endif 00365 #endif 00366 00367 #ifdef __AIX__ 00368 #include <fcntl.h> 00369 #endif 00370 00371 #ifdef VXFS 00372 #include <sys/fs/vx_ioctl.h> 00373 #endif 00374 00375 #ifdef unix 00376 #if defined (__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) \ 00377 || defined(_SUA_) 00378 #include <sys/time.h> 00379 #endif 00380 #include <sys/times.h> 00381 #include <sys/file.h> 00382 #include <sys/resource.h> 00383 #ifndef NULL 00384 #define NULL 0 00385 #endif 00386 00387 #ifndef nolimits 00388 #include <limits.h> 00389 #endif 00390 #endif 00391 00392 #ifdef HAVE_ANSIC_C 00393 #define VOLATILE volatile 00394 #else 00395 #define VOLATILE 00396 #endif 00397 00398 #include <sys/time.h> 00399 00400 #ifdef SHARED_MEM 00401 #include <sys/shm.h> 00402 #endif 00403 00404 #if defined(bsd4_2) && !defined(MS_SYNC) 00405 #define MS_SYNC 0 00406 #define MS_ASYNC 0 00407 #endif 00408 00409 #if defined(bsd4_4) || defined(__DragonFly__) 00410 #define MAP_ANONYMOUS MAP_ANON 00411 #endif 00412 00413 #if defined(SCO_Unixware_gcc) || defined(solaris) || defined(UWIN) || defined(SCO) 00414 #define MAP_FILE (0) 00415 #endif 00416 00417 #if defined(IRIX) || defined(IRIX64) || defined(Windows) || defined(bsd4_2) || defined(bsd4_4) || defined(SCO) || defined(Solaris) || defined(SCO_Unixware_gcc) 00418 long long page_size = 4096; 00419 #define GOT_PAGESIZE 1 00420 #elif defined(NBPG) 00421 long long page_size = NBPG; 00422 #define GOT_PAGESIZE 1 00423 #elif defined(old_linux) 00424 #include <asm/page.h> 00425 long long page_size = PAGE_SIZE; 00426 #define GOT_PAGESIZE 1 00427 #elif !defined(GOT_PAGESIZE) 00428 long long page_size = 4096; /* Used when all else fails */ 00429 #endif 00430 00431 #ifdef HAVE_PREAD 00432 #ifdef HAVE_PREADV 00433 #define PVECMAX 16 00434 00435 #ifdef _HPUX_SOURCE 00436 #define PER_VECTOR_OFFSET 00437 #include <sys/puio.h> 00438 struct piovec piov[PVECMAX]; 00439 #else 00440 #include <sys/uio.h> 00441 struct iovec piov[PVECMAX]; 00442 #define piov_base iov_base 00443 #define piov_len iov_len 00444 #endif 00445 00446 #endif 00447 #endif 00448 00449 #define DEDUPSEED 0x2719362 00450 00451 00452 /* 00453 * In multi thread/process throughput mode each child keeps track of 00454 * statistics and communicates them through various flavors of 00455 * shared memory, and via messages. 00456 */ 00457 struct child_stats { 00458 long long flag; /* control space */ 00459 long long flag1; /* pad */ 00460 float walltime; /* child elapsed time */ 00461 float cputime; /* child CPU time */ 00462 float throughput; /* Throughput in either kb/sec or ops/sec */ 00463 float actual; /* Either actual kb read or # of ops performed */ 00464 } VOLATILE *child_stat; 00465 00466 /* 00467 * Used for cpu time statistics. 00468 */ 00469 struct runtime { 00470 float walltime; 00471 float cputime; 00472 float cpuutil; 00473 }; 00474 00475 #ifdef __convex_spp 00476 #include <sys/cnx_ail.h> 00477 #endif 00478 00479 #include <sys/socket.h> 00480 #include <netinet/in.h> 00481 #include <netdb.h> 00482 00483 00484 /* 00485 * Messages the controlling process sends to children. 00486 * Internal representation that is arch specific. 00487 * This is used when using the network distributed mode. 00488 */ 00489 struct client_command { 00490 char c_host_name[100]; 00491 char c_pit_hostname[40]; 00492 char c_pit_service[8]; 00493 char c_client_name[100]; 00494 char c_working_dir[200]; 00495 char c_file_name[200]; 00496 char c_path_dir[200]; 00497 char c_execute_name[200]; 00498 char c_write_traj_filename[200]; 00499 char c_read_traj_filename[200]; 00500 int c_oflag; 00501 int c_mfflag; 00502 int c_unbuffered; 00503 int c_noretest; 00504 int c_notruncate; 00505 int c_read_sync; 00506 int c_jflag; 00507 int c_async_flag; 00508 int c_k_flag; 00509 int c_h_flag; 00510 int c_mflag; 00511 int c_pflag; 00512 int c_stride_flag; 00513 int c_verify; 00514 int c_sverify; 00515 int c_odsync; 00516 int c_diag_v; 00517 int c_dedup; 00518 int c_dedup_interior; 00519 int c_dedup_compress; 00520 int c_dedup_mseed; 00521 int c_hist_summary; 00522 int c_op_rate; 00523 int c_op_rate_flag; 00524 int c_Q_flag; 00525 int c_L_flag; 00526 int c_OPS_flag; 00527 int c_mmapflag; 00528 int c_mmapasflag; 00529 int c_mmapnsflag; 00530 int c_mmapssflag; 00531 int c_no_copy_flag; 00532 int c_include_close; 00533 int c_include_flush; 00534 int c_disrupt_flag; 00535 int c_compute_flag; 00536 int c_xflag; 00537 int c_MS_flag; 00538 int c_mmap_mix; 00539 int c_Kplus_flag; 00540 int c_stop_flag; 00541 int c_w_traj_flag; 00542 int c_r_traj_flag; 00543 int c_direct_flag; 00544 int c_cpuutilflag; 00545 int c_seq_mix; 00546 int c_client_number; 00547 int c_command; 00548 int c_testnum; 00549 int c_no_unlink; 00550 int c_no_write; 00551 int c_file_lock; 00552 int c_rec_lock; 00553 int c_Kplus_readers; 00554 int c_multiplier; 00555 int c_share_file; 00556 int c_pattern; 00557 int c_version; 00558 int c_base_time; 00559 int c_num_child; 00560 int c_pct_read; 00561 int c_advise_op; 00562 int c_advise_flag; 00563 int c_restf; 00564 int c_mygen; 00565 long long c_stride; 00566 long long c_rest_val; 00567 long long c_delay; 00568 long long c_purge; 00569 long long c_fetchon; 00570 long long c_numrecs64; 00571 long long c_reclen; 00572 long long c_child_flag; 00573 long long c_delay_start; 00574 long long c_depth; 00575 float c_compute_time; 00576 }; 00577 00578 /* 00579 * All data in this is in string format for portability in a 00580 * hetrogeneous environment. 00581 * 00582 * Messages that the master will send to the clients 00583 * over the socket. This provides neutral format 00584 * so that heterogeneous clusters will work. 00585 * This is used when using the network distributed mode. 00586 * WARNING !!! This data structure MUST not be bigger 00587 * than 1448 bytes or fragmentation will kick your butt. 00588 */ 00589 struct client_neutral_command { 00590 char c_host_name[100]; 00591 char c_pit_hostname[40]; 00592 char c_pit_service[8]; 00593 char c_client_name[100]; 00594 char c_working_dir[200]; 00595 char c_file_name[200]; 00596 char c_path_dir[200]; 00597 char c_execute_name[200]; 00598 char c_write_traj_filename[200]; 00599 char c_read_traj_filename[200]; 00600 char c_oflag[2]; 00601 char c_mfflag[2]; 00602 char c_unbuffered[2]; 00603 char c_noretest[2]; 00604 char c_notruncate[2]; 00605 char c_read_sync[2]; 00606 char c_jflag[2]; 00607 char c_async_flag[2]; 00608 char c_k_flag[2]; 00609 char c_h_flag[2]; 00610 char c_mflag[2]; 00611 char c_pflag[2]; 00612 char c_stride_flag[2]; 00613 char c_verify[2]; 00614 char c_sverify[2]; 00615 char c_odsync[2]; 00616 char c_diag_v[2]; 00617 char c_dedup[4]; 00618 char c_dedup_interior[4]; 00619 char c_dedup_compress[4]; 00620 char c_dedup_mseed[4]; 00621 char c_hist_summary[4]; 00622 char c_op_rate[4]; 00623 char c_op_rate_flag[2]; 00624 char c_Q_flag[2]; 00625 char c_L_flag[2]; 00626 char c_OPS_flag[2]; 00627 char c_mmapflag[2]; 00628 char c_mmapasflag[2]; 00629 char c_mmapnsflag[2]; 00630 char c_mmapssflag[2]; 00631 char c_no_copy_flag[2]; 00632 char c_include_close[2]; 00633 char c_include_flush[2]; 00634 char c_disrupt_flag[2]; 00635 char c_compute_flag[2]; 00636 char c_stop_flag[2]; 00637 char c_xflag[2]; 00638 char c_MS_flag[2]; 00639 char c_mmap_mix[2]; 00640 char c_Kplus_flag[2]; 00641 char c_w_traj_flag[2]; /* small int */ 00642 char c_r_traj_flag[2]; /* small int */ 00643 char c_direct_flag[2]; /* small int */ 00644 char c_cpuutilflag[2]; /* small int */ 00645 char c_seq_mix[2]; /* small int */ 00646 char c_stride[10]; /* small long long */ 00647 char c_rest_val[10]; /* small long long */ 00648 char c_purge[10]; /* very small long long */ 00649 char c_fetchon[10]; /* very small long long */ 00650 char c_multiplier[10]; /* small int */ 00651 char c_share_file[10]; /* small int */ 00652 char c_file_lock[10]; /* small int */ 00653 char c_rec_lock[10]; /* small int */ 00654 char c_Kplus_readers[10]; /* small int */ 00655 char c_client_number[20]; /* int */ 00656 char c_command[20]; /* int */ 00657 char c_testnum[20]; /* int */ 00658 char c_no_unlink[4]; /* int */ 00659 char c_no_write[4]; /* int */ 00660 char c_pattern[20]; /* int */ 00661 char c_version[20]; /* int */ 00662 char c_base_time[20]; /* int */ 00663 char c_num_child[20]; /* int */ 00664 char c_pct_read[6]; /* small int */ 00665 char c_advise_op[4]; /* small int */ 00666 char c_advise_flag[4]; /* small int */ 00667 char c_restf[4]; /* small int */ 00668 char c_mygen[20]; /* long */ 00669 char c_depth[20]; /* small long long */ 00670 char c_child_flag[40]; /* small long long */ 00671 char c_delay[80]; /* long long */ 00672 char c_numrecs64[80]; /* long long */ 00673 char c_reclen[80]; /* long long */ 00674 char c_delay_start[80]; /* long long */ 00675 char c_compute_time[80]; /* float */ 00676 }; 00677 00678 /* 00679 * Messages the clients will send to the master. 00680 * Internal representation on each client and the master. 00681 * This is used when using the network distributed mode. 00682 */ 00683 struct master_command { 00684 char m_host_name[100]; 00685 char m_client_name[100]; 00686 char m_stop_flag; 00687 int m_client_number; 00688 int m_client_error; 00689 int m_child_port; 00690 int m_child_async_port; 00691 int m_command; 00692 int m_testnum; 00693 int m_version; 00694 int m_mygen; 00695 float m_throughput; 00696 float m_cputime; 00697 float m_walltime; 00698 float m_actual; 00699 long long m_child_flag; 00700 }; 00701 00702 /* 00703 * Messages that the clients will send to the master 00704 * over the socket. This provides neutral format 00705 * so that heterogeneous clusters will work. 00706 * This is used when using the network distributed mode. 00707 */ 00708 struct master_neutral_command { 00709 char m_host_name[100]; 00710 char m_client_name[100]; 00711 char m_client_number[20]; /* int */ 00712 char m_client_error[20]; /* int */ 00713 char m_stop_flag[4]; /* char +space */ 00714 char m_child_port[20]; /* int */ 00715 char m_child_async_port[20]; /* int */ 00716 char m_command[20]; /* int */ 00717 char m_testnum[20]; /* int */ 00718 char m_version[20]; /* int */ 00719 char m_mygen[20]; /* int */ 00720 char m_throughput[80]; /* float */ 00721 char m_cputime[80]; /* float */ 00722 char m_walltime[80]; /* float */ 00723 char m_actual[80]; /* float */ 00724 char m_child_flag[80]; /* long long */ 00725 }; 00726 00727 00728 /* 00729 * Possible values for the commands sent to the master 00730 */ 00731 #define R_CHILD_JOIN 1 00732 #define R_STAT_DATA 2 00733 #define R_FLAG_DATA 3 00734 00735 /* 00736 * Possible values for the master's commands sent to a client 00737 * 00738 * The R_FLAG_DATA is also used by the master to tell the 00739 * client to update its flags. 00740 */ 00741 #define R_JOIN_ACK 4 00742 #define R_STOP_FLAG 5 00743 #define R_TERMINATE 6 00744 #define R_DEATH 7 00745 00746 00747 /* These are the defaults for the processor. They can be 00748 * over written by the command line options. 00749 */ 00750 #define CACHE_LINE_SIZE 32 00751 #define CACHE_SIZE ( 1024 * 1024 ) 00752 00753 00754 #define MEG (1024 * 1024) 00755 00756 /* 00757 * For stride testing use a prime number to avoid stripe 00758 * wrap hitting the same spindle. 00759 */ 00760 #define STRIDE 17 00761 00762 00763 00764 /************************************************************************/ 00765 /* */ 00766 /* DEFINED CONSTANTS */ 00767 /* */ 00768 /* Never add a comment to the end of a #define. Some compilers will */ 00769 /* choke and fail the compile. */ 00770 /************************************************************************/ 00771 00772 /* 00773 * Size of buffer for capturing the machine's name. 00774 */ 00775 #define IBUFSIZE 100 00776 /* 00777 * How many I/Os before a non-uniform access. 00778 */ 00779 #define DISRUPT 100 00780 00781 /* 00782 * Set the crossover size. This is where the small transfers 00783 * are skipped to save time. There is an option to 00784 * disable the skipping. 00785 */ 00786 #define LARGE_REC 65536 00787 00788 /* Default number of kilobytes in file */ 00789 #define KILOBYTES 512 00790 00791 /* Default number of bytes in a record */ 00792 #define RECLEN 1024 00793 00794 /* Default size of file in bytes*/ 00795 #define FILESIZE (KILOBYTES*1024) 00796 00797 /* Default number of records */ 00798 #define NUMRECS FILESIZE/RECLEN 00799 00800 #ifdef __bsdi__ 00801 /* At 8 Meg switch to large records */ 00802 #define CROSSOVER (8*1024) 00803 /*maximum buffer size*/ 00804 #define MAXBUFFERSIZE (8*1024*1024) 00805 #else 00806 /* At 16 Meg switch to large records */ 00807 #define CROSSOVER (16*1024) 00808 /* Maximum buffer size*/ 00809 #define MAXBUFFERSIZE (16*1024*1024) 00810 #endif 00811 00812 /* Maximum number of children. Threads/procs/clients */ 00813 #define MAXSTREAMS 256 00814 00815 /* Minimum buffer size */ 00816 #define MINBUFFERSIZE 128 00817 /* If things ran way too fast */ 00818 #define TOOFAST 10 00819 /* Set the maximum number of types of tests */ 00820 #define MAXTESTS 12 00821 /* Default fill pattern for verification */ 00822 #define PATTERN get_pattern(); 00823 #define PATTERN1 0xBB 00824 /* Used for Excel internal tables */ 00825 #define MAX_X 100 00826 /* Used for Excel internal tables */ 00827 #define MAX_Y 512 00828 00829 #define USAGE "\tUsage: For usage information type iozone -h \n\n" 00830 00831 00832 /* Maximum number of characters in filename */ 00833 #define MAXNAMESIZE 1000 00834 00835 /* 00836 * Define the typical output that the user will see on their 00837 * screen. 00838 */ 00839 #ifdef NO_PRINT_LLD 00840 #ifdef HAVE_PREAD 00841 #include <sys/times.h> 00842 #if defined(HAVE_PREAD) && defined(HAVE_PREADV) 00843 #define CONTROL_STRING1 "%16ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld%9ld%10ld%10ld%9ld\n" 00844 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s%10s%10s%9s%9s\n" 00845 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n" 00846 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n" 00847 #else 00848 #define CONTROL_STRING1 "%16ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld\n" 00849 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s\n" 00850 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s\n" 00851 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n" 00852 #endif 00853 #else 00854 #define CONTROL_STRING1 "%16ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld\n" 00855 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n" 00856 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n" 00857 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n" 00858 #endif 00859 #endif 00860 00861 #ifndef NO_PRINT_LLD 00862 #ifdef HAVE_PREAD 00863 #include <sys/times.h> 00864 #if defined(HAVE_PREAD) && defined(HAVE_PREADV) 00865 #define CONTROL_STRING1 "%16lld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld%9ld%10ld%10ld%9ld\n" 00866 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s%10s%10s%9s%9s\n" 00867 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n" 00868 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n" 00869 #else 00870 #define CONTROL_STRING1 "%16lld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld\n" 00871 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s\n" 00872 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n" 00873 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n" 00874 #endif 00875 #else 00876 #define CONTROL_STRING1 "%16lld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%8ld%9ld%9ld\n" 00877 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n" 00878 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n" 00879 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n" 00880 #endif 00881 #endif 00882 00883 /* 00884 For 'auto mode', these defines determine the number of iterations 00885 to perform for both the file size and the record length. 00886 */ 00887 00888 /* Start with 64 kbyte minimum file size by default */ 00889 #define KILOBYTES_START 64 00890 /* Default maximum file size. This is 512 Mbytes */ 00891 #define KILOBYTES_END (1024*512) 00892 /* Default starting record size */ 00893 #define RECLEN_START 4096 00894 /* Default maximum record size */ 00895 #define RECLEN_END (MAXBUFFERSIZE) 00896 /* Multiplier for each itteration on file and record size */ 00897 #define MULTIPLIER 2 00898 00899 /* 00900 * Assign numeric values to each of the tests. 00901 */ 00902 #define WRITER_TEST 0 00903 #define READER_TEST 1 00904 #define RANDOM_RW_TEST 2 00905 #define REVERSE_TEST 3 00906 #define REWRITE_REC_TEST 4 00907 #define STRIDE_READ_TEST 5 00908 #define FWRITER_TEST 6 00909 #define FREADER_TEST 7 00910 #define RANDOM_MIX_TEST 8 00911 #ifdef HAVE_PREAD 00912 #define PWRITER_TEST 9 00913 #define PREADER_TEST 10 00914 #endif /* HAVE_PREAD */ 00915 #ifdef HAVE_PREADV 00916 #define PWRITEV_TEST 11 00917 #define PREADV_TEST 12 00918 #endif /* HAVE_PREADV */ 00919 00920 #define WRITER_MASK (1 << WRITER_TEST) 00921 #define READER_MASK (1 << READER_TEST) 00922 #define RANDOM_RW_MASK (1 << RANDOM_RW_TEST) 00923 #define RANDOM_MIX_MASK (1 << RANDOM_MIX_TEST) 00924 #define REVERSE_MASK (1 << REVERSE_TEST) 00925 #define REWRITE_REC_MASK (1 << REWRITE_REC_TEST) 00926 #define STRIDE_READ_MASK (1 << STRIDE_READ_TEST) 00927 #define FWRITER_MASK (1 << FWRITER_TEST) 00928 #define FREADER_MASK (1 << FREADER_TEST) 00929 #ifdef HAVE_PREAD 00930 #define PWRITER_MASK (1 << PWRITER_TEST) 00931 #define PREADER_MASK (1 << PREADER_TEST) 00932 #endif /* HAVE_PREAD */ 00933 #ifdef HAVE_PREADV 00934 #define PWRITEV_MASK (1 << PWRITEV_TEST) 00935 #define PREADV_MASK (1 << PREADV_TEST) 00936 #endif /* HAVE_PREADV */ 00937 00938 /* 00939 * child_stat->flag values and transitions 00940 */ 00941 /* Parent initializes children to HOLD */ 00942 #define CHILD_STATE_HOLD 0 00943 /* Child tells master when it's READY */ 00944 #define CHILD_STATE_READY 1 00945 /* Parent tells child to BEGIN */ 00946 #define CHILD_STATE_BEGIN 2 00947 /* Child tells parent that it's DONE */ 00948 #define CHILD_STATE_DONE 3 00949 00950 #define MERSENNE 00951 00952 /******************************************************************/ 00953 /* */ 00954 /* FUNCTION DECLARATIONS */ 00955 /* */ 00956 /******************************************************************/ 00957 char *initfile(); 00958 /*int pit_gettimeofday( struct timeval *, struct timezone *, char *, char *);*/ 00959 int pit_gettimeofday( ); 00960 static int openSckt( const char *, const char *, unsigned int ); 00961 static void pit( int, struct timeval *); 00962 void mmap_end(); 00963 void alloc_pbuf(); 00964 void auto_test(); /* perform automatic test series */ 00965 void show_help(); /* show development help */ 00966 static double time_so_far(); /* time since start of program */ 00967 #ifdef unix 00968 static double utime_so_far(); /* user time */ 00969 static double stime_so_far(); /* system time */ 00970 static double clk_tck(); /* Get clocks/tick */ 00971 static double cputime_so_far(); 00972 #else 00973 #define cputime_so_far() time_so_far() 00974 #endif 00975 static double time_so_far1(); /* time since start of program */ 00976 void get_resolution(); 00977 void get_rusage_resolution(); 00978 void signal_handler(); /* clean up if user interrupts us */ 00979 void begin(); /* The main worker in the app */ 00980 void fetchit(); /* Prime on chip cache */ 00981 void purgeit(); /* Purge on chip cache */ 00982 void throughput_test(); /* Multi process throughput */ 00983 void multi_throughput_test(); /* Multi process throughput */ 00984 void prepage(); /* Pre-fault user buffer */ 00985 void get_date(); 00986 int get_pattern(); /* Set pattern based on version */ 00987 #ifdef HAVE_ANSIC_C 00988 float do_compute(float); /* compute cycle simulation */ 00989 #else 00990 float do_compute(); /* compute cycle simulation */ 00991 #endif 00992 void write_perf_test(); /* write/rewrite test */ 00993 void fwrite_perf_test(); /* fwrite/refwrite test */ 00994 void fread_perf_test(); /* fread/refread test */ 00995 void read_perf_test(); /* read/reread test */ 00996 void mix_perf_test(); /* read/reread test */ 00997 void random_perf_test(); /* random read/write test */ 00998 void reverse_perf_test(); /* reverse read test */ 00999 void rewriterec_perf_test(); /* rewrite record test */ 01000 void read_stride_perf_test(); /* read with stride test */ 01001 #ifdef HAVE_PREAD 01002 void pread_perf_test(); /* pread/re-pread test */ 01003 void pwrite_perf_test(); /* pwrite/re-pwrite test */ 01004 #endif /* HAVE_PREAD */ 01005 #ifdef HAVE_PREADV 01006 void preadv_perf_test(); /* preadv/re-preadv test */ 01007 void pwritev_perf_test(); /* pwritev/re-pwritev test */ 01008 #endif /* HAVE_PREADV */ 01009 void store_dvalue(); /* Store doubles array */ 01010 void dump_excel(); 01011 void dump_throughput(); 01012 int sp_start_child_send(); 01013 int sp_start_master_listen(); 01014 #ifdef HAVE_ANSIC_C 01015 #if defined (HAVE_PREAD) && defined(_LARGEFILE64_SOURCE) 01016 ssize_t pwrite64(); 01017 ssize_t pread64(); 01018 #endif 01019 #if !defined(linux) 01020 char *getenv(); 01021 char *inet_ntoa(); 01022 int system(); 01023 #endif 01024 void my_nap(); 01025 void my_unap(); 01026 int thread_exit(); 01027 #ifdef ASYNC_IO 01028 size_t async_write(); 01029 void async_release(); 01030 int async_read(); 01031 int async_read_no_copy(); 01032 size_t async_write_no_copy(); 01033 void end_async(); 01034 void async_init(); 01035 #else 01036 size_t async_write(); 01037 size_t async_write_no_copy(); 01038 void async_release(); 01039 #endif 01040 void do_float(); 01041 int create_xls(); 01042 void close_xls(); 01043 void do_label(); 01044 int mylockf(int, int, int); 01045 int mylockr(int,int, int, off64_t, off64_t); 01046 int rand(void); 01047 void srand(unsigned int); 01048 int get_client_info(void); 01049 void exit(int); 01050 void find_remote_shell(char *); 01051 void find_external_mon(char *,char *); 01052 void start_monitor(char *); 01053 void stop_monitor(char *); 01054 void takeoff_cache(); 01055 void del_cache(); 01056 void fill_area(long long *, long long *, long long); 01057 void fill_buffer(char *,long long ,long long ,char, long long ); 01058 void store_value(off64_t); 01059 void store_times(double, double); 01060 static double cpu_util(double, double); 01061 void dump_cputimes(void); 01062 void purge_buffer_cache(void); 01063 char *alloc_mem(long long,int); 01064 void *(thread_rwrite_test)(void *); 01065 void *(thread_write_test)(void *); 01066 void *(thread_fwrite_test)(void *); 01067 void *(thread_fread_test)(void *); 01068 void *(thread_read_test)(void*); 01069 #ifdef HAVE_PREAD 01070 void *(thread_pread_test)(void*); 01071 void *(thread_pwrite_test)(void*); 01072 #endif 01073 void *(thread_cleanup_test)(void*); 01074 void *(thread_cleanup_quick)(void*); 01075 void *(thread_ranread_test)(void *); 01076 void *(thread_mix_test)(void *); 01077 void *(thread_ranwrite_test)(void *); 01078 void *(thread_rread_test)(void *); 01079 void *(thread_reverse_read_test)(void *); 01080 void *(thread_stride_read_test)(void *); 01081 void *(thread_set_base)(void *); 01082 void *(thread_join)(long long, void *); 01083 void disrupt(int); 01084 #if defined(Windows) 01085 void disruptw(HANDLE); 01086 #endif 01087 long long get_traj(FILE *, long long *, float *, long); 01088 void create_temp(off64_t, long long ); 01089 FILE *open_w_traj(void); 01090 FILE *open_r_traj(void); 01091 void traj_vers(void); 01092 void r_traj_size(void); 01093 long long w_traj_size(void); 01094 void init_file_sizes(); 01095 off64_t get_next_file_size(off64_t); 01096 void add_file_size(off64_t); 01097 void init_file_sizes( off64_t, off64_t); 01098 off64_t get_next_record_size(off64_t); 01099 void add_record_size(off64_t); 01100 void init_record_sizes( off64_t, off64_t); 01101 void del_record_sizes( void ); 01102 void hist_insert(double ); 01103 void dump_hist(char *,int ); 01104 void do_speed_check(int); 01105 #else 01106 void do_speed_check(); 01107 #if !defined(linux) 01108 char *getenv(); 01109 char *inet_ntoa(); 01110 int system(); 01111 #endif 01112 void my_nap(); 01113 void my_unap(); 01114 int thread_exit(); 01115 void close_xls(); 01116 void do_label(); 01117 int create_xls(); 01118 void do_float(); 01119 #ifdef ASYNC_IO 01120 void async_release(); 01121 size_t async_write(); 01122 size_t async_write_no_copy(); 01123 int async_read(); 01124 int async_read_no_copy(); 01125 #endif 01126 int mylockf(); 01127 int mylockr(); 01128 int rand(); 01129 void srand(); 01130 int get_client_info(); 01131 void exit(); 01132 void find_remote_shell(); 01133 void traj_vers(); 01134 void r_traj_size(); 01135 long long w_traj_size(); 01136 FILE *open_w_traj(); 01137 FILE *open_r_traj(); 01138 void create_temp(); 01139 void fill_buffer(); 01140 char *alloc_mem(); 01141 void *(thread_rwrite_test)(); 01142 void *(thread_write_test)(); 01143 void *(thread_fwrite_test)(); 01144 void *(thread_fread_test)(); 01145 void *(thread_read_test)(); 01146 void *(thread_cleanup_test)(); 01147 void *(thread_ranread_test)(); 01148 void *(thread_mix_test)(); 01149 void *(thread_ranwrite_test)(); 01150 void *(thread_rread_test)(); 01151 void *(thread_reverse_read_test)(); 01152 void *(thread_stride_read_test)(); 01153 void *(thread_set_base)(); 01154 void *(thread_join)(); 01155 void disrupt(); 01156 long long get_traj(); 01157 void init_file_sizes(); 01158 off64_t get_next_file_size(); 01159 void add_file_size(); 01160 void init_record_sizes(); 01161 off64_t get_next_record_size(); 01162 void add_record_size(); 01163 void dump_cputimes(); 01164 static double cpu_util(); 01165 void del_record_sizes(); 01166 void hist_insert(); 01167 void dump_hist(); 01168 #endif 01169 01170 #ifdef _LARGEFILE64_SOURCE 01171 #define I_LSEEK(x,y,z) lseek64(x,(off64_t)(y),z) 01172 #define I_OPEN(x,y,z) open64(x,(int)(y),(int)(z)) 01173 #define I_CREAT(x,y) creat64(x,(int)(y)) 01174 #define I_FOPEN(x,y) fopen64(x,y) 01175 #define I_STAT(x,y) stat64(x,y) 01176 #ifdef HAVE_PREAD 01177 #define I_PREAD(a,b,c,d) pread64(a,b,(size_t)(c),(off64_t)(d)) 01178 #define I_PWRITE(a,b,c,d) pwrite64(a,b,(size_t)(c),(off64_t)(d)) 01179 #endif 01180 #define I_MMAP(a,b,c,d,e,f) mmap64((void *)(a),(size_t)(b),(int)(c),(int)(d),(int)(e),(off64_t)(f)) 01181 #else 01182 #define I_LSEEK(x,y,z) lseek(x,(off_t)(y),z) 01183 #define I_OPEN(x,y,z) open(x,(int)(y),(int)(z)) 01184 #define I_CREAT(x,y) creat(x,(int)(y)) 01185 #define I_FOPEN(x,y) fopen(x,y) 01186 #define I_STAT(x,y) stat(x,y) 01187 #ifdef HAVE_PREAD 01188 #define I_PREAD(a,b,c,d) pread(a,b,(size_t)(c),(off_t)(d)) 01189 #define I_PWRITE(a,b,c,d) pwrite(a,b,(size_t)(c),(off_t)(d)) 01190 #endif 01191 #define I_MMAP(a,b,c,d,e,f) mmap((void *)(a),(size_t)(b),(int)(c),(int)(d),(int)(e),(off_t)(f)) 01192 #endif 01193 01194 01195 /************************************************************************/ 01196 /* The list of tests to be called. */ 01197 /************************************************************************/ 01198 void (*func[])() = { 01199 write_perf_test, 01200 read_perf_test, 01201 random_perf_test, 01202 reverse_perf_test, 01203 rewriterec_perf_test, 01204 read_stride_perf_test, 01205 fwrite_perf_test, 01206 fread_perf_test, 01207 mix_perf_test 01208 #ifdef HAVE_PREAD 01209 , 01210 pwrite_perf_test, 01211 pread_perf_test 01212 #ifdef HAVE_PREADV 01213 , 01214 pwritev_perf_test, 01215 preadv_perf_test 01216 #endif /* HAVE_PREADV */ 01217 #endif /* HAVE_PREAD */ 01218 }; 01219 01220 /* 01221 char *test_output[] = {" ", 01222 " ", 01223 " ", 01224 " ", 01225 " ", 01226 " ", 01227 " ", 01228 " ", 01229 " ", 01230 " ", 01231 " ", 01232 " \n" }; 01233 */ 01234 char *test_output[] = {" ", 01235 " ", 01236 " ", 01237 " ", 01238 " ", 01239 " ", 01240 " ", 01241 " ", 01242 "", 01243 " ", 01244 " ", 01245 " ", 01246 " ", 01247 " ", 01248 " ", 01249 " \n" }; 01250 long long test_soutput[] = {2,2,2,1,1,1,2,2,2,2,2,2,2,2}; 01251 01252 01253 /******************************************************************/ 01254 /* */ 01255 /* GLOBAL VARIABLES */ 01256 /* */ 01257 /*******************************************************************/ 01258 01259 /* 01260 * Set the size of the shared memory segment for the children 01261 * to put their results. 01262 */ 01263 #define SHMSIZE ((( sizeof(struct child_stats) * MAXSTREAMS) )+4096 ) 01264 /* 01265 * Pointer to the shared memory segment. 01266 */ 01267 VOLATILE struct child_stats *shmaddr; 01268 double totaltime,total_time, temp_time ,total_kilos; 01269 off64_t report_array[MAX_X][MAX_Y]; 01270 double report_darray[MAX_X][MAXSTREAMS]; 01271 double time_res,cputime_res; 01272 long long throughput_array[MAX_X]; /* Filesize & record size are constants */ 01273 short current_x, current_y; 01274 long long orig_size; 01275 long long max_x, max_y; 01276 unsigned long long goodkilos; 01277 off64_t kilobytes64 = (off64_t)KILOBYTES; 01278 long long goodrecl; 01279 off64_t offset = 0; /*offset for random I/O */ 01280 off64_t offset64 = 0; /*offset for random I/O */ 01281 off64_t filebytes64; 01282 off64_t r_range[100]; 01283 off64_t s_range[100]; 01284 int t_range[100]; 01285 int t_count = 0; 01286 int r_count,s_count; 01287 char *barray[MAXSTREAMS]; 01288 char *haveshm; 01289 extern int optind; 01290 long long onetime, auto_mode, sfd, multi_buffer; 01291 int fd; 01292 int sp_msfd,sp_mrfd,sp_csfd,sp_crfd; 01293 int begin_proc,num_processors,ioz_processor_bind; 01294 long long res_prob,rec_prob; 01295 char silent,read_sync; 01296 char master_iozone, client_iozone,distributed; 01297 int bif_fd,s_count; 01298 int bif_row,bif_column; 01299 int dedup_mseed = 1; 01300 int hist_summary; 01301 int op_rate; 01302 int op_rate_flag; 01303 char aflag, Eflag, hflag, Rflag, rflag, sflag; 01304 char diag_v,sent_stop,dedup,dedup_interior,dedup_compress; 01305 char *dedup_ibuf; 01306 char *dedup_temp; 01307 char bif_flag; 01308 int rlocking; 01309 int share_file; 01310 int ecount; 01311 char gflag,nflag; 01312 char yflag,qflag; 01313 #ifdef Windows 01314 char *build_name = "Windows"; 01315 #else 01316 char *build_name = NAME; 01317 #endif 01318 char imon_start[256],imon_stop[256]; 01319 char imon_sync; 01320 char trflag; 01321 char cpuutilflag; 01322 char seq_mix; 01323 long base_time; 01324 long long mint, maxt; 01325 long long w_traj_ops, r_traj_ops, w_traj_fsize,r_traj_fsize; 01326 long long r_traj_ops_completed,r_traj_bytes_completed; 01327 long long w_traj_ops_completed,w_traj_bytes_completed; 01328 int w_traj_items, r_traj_items; 01329 char fflag, Uflag,uflag,lflag,include_tflag; 01330 struct runtime runtimes [MAX_X] [MAX_Y]; /* in parallel with report_array[][] */ 01331 long long include_test[50]; 01332 long long include_mask; 01333 char RWONLYflag, NOCROSSflag; /*auto mode 2 - kcollins 8-21-96*/ 01334 char mfflag; 01335 long long status, x, y, childids[MAXSTREAMS+1], myid, num_child; 01336 int pct_read,speed_code; 01337 #ifndef NO_THREADS 01338 pthread_t p_childids[MAXSTREAMS+1]; 01339 #endif 01340 off64_t next64; 01341 char wol_opened, rol_opened; 01342 FILE *wqfd,*rwqfd,*rqfd,*rrqfd; 01343 01344 extern char *optarg; 01345 #ifndef __AIX__ 01346 long long ret; 01347 #else 01348 short ret; 01349 #endif 01350 struct size_entry { 01351 struct size_entry *next; 01352 off64_t size; 01353 }; 01354 struct size_entry *size_list=0; 01355 struct size_entry *rec_size_list=0; 01356 off64_t maximum_file_size; 01357 off64_t minimum_file_size; 01358 01359 char bif_filename [MAXNAMESIZE]; /* name of biff file */ 01360 char filename [MAXNAMESIZE]; /* name of temporary file */ 01361 char mountname [MAXNAMESIZE]; /* name of device */ 01362 char dummyfile [MAXSTREAMS][MAXNAMESIZE]; /* name of dummy file */ 01363 char dummyfile1 [MAXNAMESIZE]; /* name of dummy file */ 01364 char *filearray[MAXSTREAMS]; /* array of file names */ 01365 char tfile[] = "iozone"; 01366 char *buffer,*buffer1, *mbuffer,*mainbuffer; 01367 FILE *pi,*r_traj_fd,*w_traj_fd; 01368 VOLATILE char *pbuffer; 01369 char *default_filename="iozone.tmp"; /*default name of temporary file*/ 01370 VOLATILE char stoptime; 01371 char Cflag; 01372 char use_thread = 0; 01373 long long debug1=0; 01374 long long debug=0; 01375 unsigned long cache_size=CACHE_SIZE; 01376 unsigned long cache_line_size=CACHE_LINE_SIZE; 01377 long long *pstatus; 01378 off64_t min_file_size = KILOBYTES_START; 01379 off64_t max_file_size = KILOBYTES_END; 01380 long long min_rec_size = RECLEN_START; 01381 long long max_rec_size = RECLEN_END; 01382 long long orig_min_rec_size = RECLEN_START; 01383 long long orig_max_rec_size = RECLEN_END; 01384 long long xover = CROSSOVER; 01385 char *throughput_tests[] = {"Initial write","Rewrite","Read","Re-read", 01386 "Reverse Read","Stride read","Random read","Mixed workload","Random write","Pwrite","Pread","Fwrite","Fread"}; 01387 char command_line[1024] = "\0"; 01388 #ifdef unix 01389 double sc_clk_tck; 01390 #endif 01391 01392 int argcsave; 01393 char **argvsave; 01394 char splash[80][80]; 01395 int splash_line; 01396 char client_filename[256]; 01397 char remote_shell[256]; 01398 int client_error; 01399 01400 char pit_hostname[40]; 01401 char pit_service[8]; 01402 int junk; 01403 01404 /* 01405 * Host ports used to listen, and handle errors. 01406 */ 01407 #define HOST_LIST_PORT 20000 01408 #define HOST_ESEND_PORT (HOST_LIST_PORT+MAXSTREAMS) 01409 #define HOST_ASEND_PORT (HOST_ESEND_PORT+MAXSTREAMS) 01410 int controlling_host_port = HOST_LIST_PORT; 01411 01412 /* 01413 * Childs ports used to listen, and handle errors. 01414 */ 01415 #define CHILD_ESEND_PORT (HOST_ASEND_PORT+MAXSTREAMS) 01416 #define CHILD_LIST_PORT (CHILD_ESEND_PORT+MAXSTREAMS) 01417 01418 /* Childs async message port. Used for stop flag and terminate */ 01419 #define CHILD_ALIST_PORT (CHILD_LIST_PORT+MAXSTREAMS) 01420 01421 /* Ports for the network speed code */ 01422 #define SP_CHILD_LISTEN_PORT 31000 01423 #define SP_CHILD_ESEND_PORT (SP_CHILD_LISTEN_PORT+10) 01424 #define SP_MASTER_LISTEN_PORT (SP_CHILD_ESEND_PORT+10) 01425 #define SP_MASTER_ESEND_PORT (SP_MASTER_LISTEN_PORT+10) 01426 #define SP_MASTER_RESULTS_PORT (SP_MASTER_ESEND_PORT+10) 01427 01428 01429 #define THREAD_WRITE_TEST 1 01430 #define THREAD_REWRITE_TEST 2 01431 #define THREAD_READ_TEST 3 01432 #define THREAD_REREAD_TEST 4 01433 #define THREAD_STRIDE_TEST 5 01434 #define THREAD_RANDOM_READ_TEST 6 01435 #define THREAD_RANDOM_WRITE_TEST 7 01436 #define THREAD_REVERSE_READ_TEST 8 01437 #define THREAD_RANDOM_MIX_TEST 9 01438 #define THREAD_PWRITE_TEST 10 01439 #define THREAD_PREAD_TEST 11 01440 #define THREAD_FWRITE_TEST 12 01441 #define THREAD_FREAD_TEST 13 01442 #define THREAD_CLEANUP_TEST 14 01443 01444 /* 01445 * Child states that the master is tracking. 01446 * The master uses these to determine how to shutdown 01447 * the clients when some fool hits control-C. 01448 */ 01449 #define C_STATE_ZERO 1 01450 #define C_STATE_WAIT_WHO 2 01451 #define C_STATE_WAIT_BARRIER 3 01452 01453 01454 int c_port,a_port; /* port number */ 01455 int child_port; /* Virtualized due to fork */ 01456 int child_async_port; /* Virtualized due to fork */ 01457 int client_listen_pid; /* Virtualized due to fork */ 01458 int master_join_count; /* How many children have joined */ 01459 int l_sock,l_async_sock; /* Sockets for listening */ 01460 char master_rcv_buf[4096]; /* Master's receive buffer */ 01461 int master_listen_pid; /* Pid of the master's async listener proc */ 01462 char master_send_buf[4096]; /* Master's send buffer */ 01463 char child_rcv_buf[4096]; /* Child's receive buffer */ 01464 char child_async_rcv_buf[4096]; /* Child's async recieve buffer */ 01465 char child_send_buf[4096]; /* Child's send buffer */ 01466 int child_send_socket; /* Child's send socket */ 01467 int child_listen_socket; /* Child's listener socket */ 01468 int child_listen_socket_async; /* Child's async listener socket */ 01469 int master_send_socket; /* Needs to be an array. One for each child*/ 01470 int master_send_sockets[MAXSTREAMS]; /* Needs to be an array. One for each child*/ 01471 int master_send_async_sockets[MAXSTREAMS]; /* Needs to be an array. One for each child*/ 01472 int master_listen_port; /* Master's listener port number */ 01473 int master_listen_socket; /* Master's listener socket */ 01474 int clients_found; /* Number of clients found in the client file */ 01475 FILE *newstdin, *newstdout, *newstderr; /* used for debug in cluster mode.*/ 01476 char toutput[20][20]; /* Used to help format the output */ 01477 int toutputindex; /* Index to the current output line */ 01478 int cdebug = 0; /* Use to turn on child/client debugging in cluster mode. */ 01479 int mdebug = 0; /* Use to turn on master debug in cluster mode */ 01480 int aggflag; /* Used to indicate constant aggregate data set size */ 01481 struct sockaddr_in child_sync_sock, child_async_sock; 01482 01483 /* 01484 * Change this whenever you change the message format of master or client. 01485 */ 01486 int proto_version = 25; 01487 01488 /******************************************************************************/ 01489 /* Tele-port zone. These variables are updated on the clients when one is */ 01490 /* using cluster mode. (-+m) */ 01491 /* Do not touch these unless you have become one with the universe !! */ 01492 /******************************************************************************/ 01493 char controlling_host_name[100]; 01494 struct child_ident { 01495 char child_name[100]; 01496 char workdir[200]; 01497 char execute_path[200]; 01498 char file_name[200]; 01499 int state; 01500 int child_number; 01501 int child_port; 01502 int child_async_port; 01503 int master_socket_num; 01504 int master_async_socket_num; 01505 }child_idents[MAXSTREAMS]; 01506 int Kplus_readers; 01507 char write_traj_filename [MAXNAMESIZE]; /* name of write telemetry file */ 01508 char read_traj_filename [MAXNAMESIZE]; /* name of read telemetry file */ 01509 char oflag,jflag,k_flag,h_flag,mflag,pflag,unbuffered,Kplus_flag; 01510 char noretest; 01511 char notruncate; /* turn off truncation of files */ 01512 char async_flag,stride_flag,mmapflag,mmapasflag,mmapssflag,mmapnsflag,mmap_mix; 01513 char verify = 1; 01514 int restf; 01515 char sverify = 1; 01516 char odsync = 0; 01517 char Q_flag,OPS_flag; 01518 char L_flag=0; 01519 char no_copy_flag,include_close,include_flush; 01520 char disrupt_flag,compute_flag,xflag,Z_flag, X_flag; 01521 int no_unlink = 0; 01522 int no_write = 0; 01523 int r_traj_flag,w_traj_flag; 01524 int mygen; 01525 char MS_flag; 01526 int advise_op,advise_flag; 01527 int direct_flag; 01528 int current_client_number; 01529 long long chid; 01530 int file_lock; 01531 unsigned int pattern; 01532 long long stride = STRIDE; 01533 long long delay,purge,fetchon; 01534 off64_t numrecs64 = (off64_t)NUMRECS; 01535 long long reclen = RECLEN; 01536 long long delay_start,depth; 01537 VOLATILE char *stop_flag; /* Used to stop all children */ 01538 float compute_time; 01539 int multiplier = MULTIPLIER; 01540 long long rest_val; 01541 #if defined(Windows) 01542 HANDLE hand; 01543 #endif 01544 01545 /******************************************************************************/ 01546 /* End of Tele-port zone. */ 01547 /******************************************************************************/ 01548 01549 01550 /* 01551 * Prototypes 01552 * Sort of... Full prototypes break non-ansi C compilers. No protos is 01553 * a bit sloppy, so the compromise is this. 01554 */ 01555 void child_send(); 01556 int start_child_listen(); 01557 int start_child_listen_async(); 01558 void start_child_listen_loop(); 01559 void child_listen(); 01560 void child_listen_async(); 01561 void stop_child_send(); 01562 void stop_child_listen(); 01563 void cleanup_comm(); 01564 void master_send(); 01565 int start_master_send(); 01566 int start_master_listen(); 01567 int check_filename(); 01568 void master_listen(); 01569 void stop_master_send(); 01570 void stop_master_listen(); 01571 long long start_child_proc(); 01572 int parse_client_line(); 01573 void wait_dist_join(); 01574 void tell_children_begin(); 01575 void start_master_listen_loop(); 01576 void wait_for_master_go(); 01577 void tell_master_ready(); 01578 void stop_master_listen_loop(); 01579 void tell_master_stats(); 01580 void become_client(); 01581 int pick_client(); 01582 long long start_child_proc(); 01583 int start_master_send(); 01584 void child_listen(); 01585 int start_child_listen(); 01586 void stop_master_send(); 01587 void stop_master_listen(); 01588 void stop_child_send(); 01589 void stop_child_listen(); 01590 void master_send(); 01591 void child_send(); 01592 void master_listen(); 01593 int start_master_listen(); 01594 void child_remove_files(); 01595 void terminate_child_async(); 01596 void distribute_stop(); 01597 void send_stop(); 01598 void cleanup_children(); 01599 01600 01601 /****************************************************************/ 01602 /* */ 01603 /* MAIN () */ 01604 /* */ 01605 /****************************************************************/ 01606 01607 int 01608 main(argc,argv) 01609 int argc; 01610 char **argv; 01611 { 01612 01613 long long fileindx,i,tval; 01614 long long ind; 01615 int ret; 01616 FILE *pi; 01617 char reply[IBUFSIZE]; 01618 unsigned char inp_pat; 01619 time_t time_run; 01620 char *port,*m,*subarg; 01621 int num_child1; 01622 int cret; 01623 int anwser,bind_cpu; 01624 char *evalue; 01625 01626 01627 anwser=bind_cpu=0; 01628 /* Used to make fread/fwrite do something better than their defaults */ 01629 setvbuf( stdout, NULL, _IONBF, (size_t) NULL ); 01630 setvbuf( stderr, NULL, _IONBF, (size_t) NULL ); 01631 01632 /* Save the master's name */ 01633 gethostname(controlling_host_name,100); 01634 01635 /* Let user activate mdebug or cdebug via environmental variables */ 01636 evalue = (char *)NULL; 01637 evalue=(char *)getenv("CDEBUG"); 01638 if(evalue) 01639 cdebug=atoi(evalue); 01640 evalue = (char *)NULL; 01641 evalue=(char *)getenv("MDEBUG"); 01642 if(evalue) 01643 mdebug=atoi(evalue); 01644 01645 srand(time(0)); 01646 mygen=rand(); /* Pick a random generation number */ 01647 01648 /* Try to find the actual VM page size, if possible */ 01649 #if defined (solaris) || defined (_HPUX_SOURCE) || defined (linux) || defined(IRIX) || defined (IRIX64) 01650 #ifndef __convex_spp 01651 page_size=getpagesize(); 01652 #endif 01653 #endif 01654 /* Try to find the actual number of ticks per second */ 01655 #ifdef unix 01656 sc_clk_tck = clk_tck(); 01657 #endif 01658 for(ind=0;ind<MAXSTREAMS;ind++) 01659 filearray[ind]=(char *)tfile; 01660 01661 /* base_time=(long)time_so_far(); */ 01662 myid=(long long)getpid(); /* save the master's PID */ 01663 /* get_resolution(); Get clock resolution */ 01664 time_run = time(0); /* Start a timer */ 01665 (void)find_external_mon(imon_start, imon_stop); 01666 01667 /* 01668 * Save the splash screen for later display. When in distributed network 01669 * mode this output does not get displayed on the clients. 01670 */ 01671 sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n"); 01672 sprintf(splash[splash_line++],"\t%s\n\t%s\n", THISVERSION,MODE); 01673 sprintf(splash[splash_line++],"\t\tBuild: %s \n\n",build_name); 01674 sprintf(splash[splash_line++],"\tContributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins\n"); 01675 sprintf(splash[splash_line++],"\t Al Slater, Scott Rhine, Mike Wisner, Ken Goss\n"); 01676 sprintf(splash[splash_line++],"\t Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,\n"); 01677 sprintf(splash[splash_line++],"\t Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,\n"); 01678 sprintf(splash[splash_line++],"\t Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,\n"); 01679 sprintf(splash[splash_line++],"\t Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,\n"); 01680 sprintf(splash[splash_line++],"\t Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer.\n"); 01681 sprintf(splash[splash_line++],"\t Ben England.\n\n"); 01682 sprintf(splash[splash_line++],"\tRun began: %s\n",ctime(&time_run)); 01683 argcsave=argc; 01684 argvsave=argv; 01685 01686 signal(SIGINT, signal_handler); /* handle user interrupt */ 01687 signal(SIGTERM, signal_handler); /* handle kill from shell */ 01688 01689 /********************************************************/ 01690 /* Allocate and align buffer with beginning of the */ 01691 /* on chip data cache. */ 01692 /********************************************************/ 01693 01694 buffer = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0); 01695 if(buffer == 0) { 01696 perror("Memory allocation failed:"); 01697 exit(1); 01698 } 01699 01700 #ifdef _64BIT_ARCH_ 01701 buffer = (char *) ((long long )(buffer + cache_size ) & 01702 ~(cache_size-1)); 01703 #else 01704 buffer = (char *) ((long)(buffer + cache_size ) & 01705 ~((long)cache_size-1)); 01706 #endif 01707 mainbuffer = buffer; 01708 01709 /* de-dup input buf */ 01710 buffer1 = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0); 01711 if(buffer1 == 0) { 01712 perror("Memory allocation failed:"); 01713 exit(1); 01714 } 01715 01716 #ifdef _64BIT_ARCH_ 01717 buffer1 = (char *) ((long long )(buffer1 + cache_size ) & 01718 ~(cache_size-1)); 01719 #else 01720 buffer1 = (char *) ((long)(buffer1 + cache_size ) & 01721 ~((long)cache_size-1)); 01722 #endif 01723 dedup_ibuf = buffer1; 01724 touch_dedup(buffer1, MAXBUFFERSIZE); 01725 01726 #ifdef FOOB 01727 /* de-dup temp buf */ 01728 buffer1 = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0); 01729 if(buffer1 == 0) { 01730 perror("Memory allocation failed:"); 01731 exit(1); 01732 } 01733 01734 #ifdef _64BIT_ARCH_ 01735 buffer1 = (char *) ((long long )(buffer1 + cache_size ) & 01736 ~(cache_size-1)); 01737 #else 01738 buffer1 = (char *) ((long)(buffer1 + cache_size ) & 01739 ~((long)cache_size-1)); 01740 #endif 01741 #endif 01742 dedup_temp = mainbuffer; 01743 01744 fetchon++; /* By default, prefetch the CPU cache lines associated with the buffer */ 01745 strcpy(filename,default_filename); /* Init default filename */ 01746 sprintf(dummyfile[0],"%s.DUMMY",default_filename); 01747 if(argc <=1){ 01748 printf(USAGE); 01749 exit(255); 01750 } 01751 auto_mode = 0; /* Default is to disable auto mode */ 01752 inp_pat = PATTERN; /* Init default pattern for verification */ 01753 /* Fill the entire pattern variable with the same character */ 01754 pattern = ((inp_pat << 24) | (inp_pat << 16) | (inp_pat << 8) | inp_pat); 01755 01756 /* 01757 * Parse all of the options that the user specified. 01758 */ 01759 while((cret = getopt(argc,argv,"ZQNIBDGCTOMREWovAxamwphcezKJ:j:k:V:r:t:s:f:F:d:l:u:U:S:L:H:+:P:i:b:X:Y:g:n:y:q: ")) != EOF){ 01760 switch(cret){ 01761 case 'k': /* Async I/O with no bcopys */ 01762 depth = (long long)(atoi(optarg)); 01763 if(depth <0) 01764 depth=0; 01765 /* 01766 if(depth > 60) 01767 depth=60; 01768 */ 01769 #ifdef NO_PRINT_LLD 01770 sprintf(splash[splash_line++],"\tPOSIX Async I/O (no bcopy). Depth %ld \n",depth); 01771 #else 01772 sprintf(splash[splash_line++],"\tPOSIX Async I/O (no bcopy). Depth %lld \n",depth); 01773 #endif 01774 no_copy_flag=1; 01775 async_flag++; 01776 k_flag++; 01777 break; 01778 case 'T': /* Switch to POSIX thread based */ 01779 #ifndef NO_THREADS 01780 use_thread++; 01781 #else 01782 printf("\tThreads not supported in this version\n"); 01783 exit(2); 01784 #endif 01785 break; 01786 case 'H': /* Use POSIX async_io */ 01787 h_flag++; 01788 depth = (long long)(atoi(optarg)); 01789 if(depth <0) 01790 depth=0; 01791 /* 01792 * Hmmm. many systems fail is strange ways when the maximum 01793 * number of async I/Os per user or proc is exceeded. 01794 */ 01795 /* 01796 if(depth > 60) 01797 depth=60; 01798 */ 01799 #ifdef NO_PRINT_LLD 01800 sprintf(splash[splash_line++],"\tPOSIX async I/O (with bcopy). Depth %ld\n",depth); 01801 #else 01802 sprintf(splash[splash_line++],"\tPOSIX async I/O (with bcopy). Depth %lld\n",depth); 01803 #endif 01804 async_flag++; 01805 break; 01806 case 'I': /* Use VXFS direct advisory or O_DIRECT from Linux or AIX , or O_DIRECTIO for TRU64 or Solaris directio */ 01807 #ifdef VXFS 01808 direct_flag++; 01809 sprintf(splash[splash_line++],"\tVxFS advanced feature SET_CACHE, VX_DIRECT enabled\n"); 01810 break; 01811 #endif 01812 #if ! defined(DONT_HAVE_O_DIRECT) 01813 #if defined(linux) || defined(__AIX__) || defined(IRIX) || defined(IRIX64) || defined(Windows) || defined(__FreeBSD__) || defined(solaris) 01814 direct_flag++; 01815 sprintf(splash[splash_line++],"\tO_DIRECT feature enabled\n"); 01816 break; 01817 #endif 01818 #if defined(TRU64) 01819 direct_flag++; 01820 sprintf(splash[splash_line++],"\tO_DIRECTIO feature enabled\n"); 01821 break; 01822 #endif 01823 #else 01824 break; 01825 #endif 01826 #if defined(Windows) 01827 sprintf(splash[splash_line++],"\tO_DIRECTIO feature not available in Windows version.\n"); 01828 break; 01829 #endif 01830 case 'B': /* Use mmap file for test file */ 01831 sprintf(splash[splash_line++],"\tUsing mmap files\n"); 01832 mmapflag++; 01833 mmapnsflag++; 01834 break; 01835 case 'D': /* Use async msync mmap file */ 01836 sprintf(splash[splash_line++],"\tUsing msync(MS_ASYNC) on mmap files\n"); 01837 mmapflag++; 01838 mmapasflag++; 01839 mmapnsflag=0; 01840 break; 01841 case 'G': /* Use msync sync for mmap file */ 01842 sprintf(splash[splash_line++],"\tUsing msync(MS_SYNC) on mmap files\n"); 01843 mmapssflag++; 01844 mmapnsflag=0; 01845 break; 01846 case 'C': /* show children xfer counts */ 01847 Cflag++; 01848 break; 01849 case 'Q': /* Enable output offset/latency files */ 01850 sprintf(splash[splash_line++],"\tOffset/latency files enabled.\n"); 01851 Q_flag++; 01852 break; 01853 case 'x': /* Disable stone_wall */ 01854 sprintf(splash[splash_line++],"\tStonewall disabled\n"); 01855 xflag++; 01856 break; 01857 01858 case 'a': /* auto mode */ 01859 fetchon=1; 01860 purge=0; 01861 multi_buffer=0; 01862 auto_mode = 1; 01863 aflag++; 01864 sprintf(splash[splash_line++],"\tAuto Mode\n"); 01865 break; 01866 case 'c': /* Include close in timing */ 01867 include_close++; 01868 sprintf(splash[splash_line++],"\tInclude close in write timing\n"); 01869 break; 01870 case 'e': /* Include fsync in timing */ 01871 include_flush++; 01872 sprintf(splash[splash_line++],"\tInclude fsync in write timing\n"); 01873 break; 01874 case 'A': /* auto2 mode. Soon to go away. Please use -az */ 01875 fetchon=1; 01876 purge=0; 01877 multi_buffer=0; 01878 auto_mode = 1; 01879 aflag++; 01880 sprintf(splash[splash_line++],"\tAuto Mode 2. This option is obsolete. Use -az -i0 -i1 \n"); 01881 RWONLYflag++; 01882 NOCROSSflag++; 01883 include_tflag++; /* automatically set WRITER_TEST and READER_TEST */ 01884 include_test[WRITER_TEST]++; 01885 include_test[READER_TEST]++; 01886 break; 01887 case 's': /* Set file size */ 01888 #ifdef NO_PRINT_LLD 01889 sscanf(optarg,"%ld",&kilobytes64); 01890 #else 01891 sscanf(optarg,"%lld",&kilobytes64); 01892 #endif 01893 if(optarg[strlen(optarg)-1]=='k' || 01894 optarg[strlen(optarg)-1]=='K'){ 01895 ; 01896 } 01897 if(optarg[strlen(optarg)-1]=='m' || 01898 optarg[strlen(optarg)-1]=='M'){ 01899 kilobytes64 = kilobytes64 * 1024; 01900 } 01901 if(optarg[strlen(optarg)-1]=='g' || 01902 optarg[strlen(optarg)-1]=='G'){ 01903 kilobytes64 = kilobytes64 *1024 * 1024; 01904 } 01905 if(kilobytes64 <= 0) 01906 kilobytes64=512; 01907 01908 s_range[s_count++]=kilobytes64; 01909 max_file_size = (off64_t)s_range[s_count-1]; /* Make visable globally */ 01910 min_file_size = (off64_t)s_range[0]; /* Make visable globally */ 01911 01912 #ifdef NO_PRINT_LLD 01913 sprintf(splash[splash_line++],"\tFile size set to %ld KB\n",kilobytes64); 01914 #else 01915 sprintf(splash[splash_line++],"\tFile size set to %lld KB\n",kilobytes64); 01916 #endif 01917 sflag++; 01918 break; 01919 case 'l': /* Set lower thread/proc limit */ 01920 mint = (long long)(atoi(optarg)); 01921 if(mint <= 0) 01922 { 01923 mint=1; 01924 num_child=1; 01925 }else 01926 num_child=mint; 01927 if(mint > (unsigned long long)MAXSTREAMS){ 01928 printf("Invalid options: maximum streams for "); 01929 printf("throughput is MAXSTREAMS\n"); 01930 exit(4); 01931 } 01932 lflag++; 01933 trflag++; 01934 if(Uflag) 01935 { 01936 printf("Can not run throughput tests with unmount & remounts.\n"); 01937 exit(5); 01938 } 01939 break; 01940 case 'u': /* Set upper thread/proc limit */ 01941 maxt = (long long)(atoi(optarg)); 01942 if(maxt <= 0) 01943 maxt=1; 01944 if(maxt > MAXSTREAMS){ 01945 printf("Invalid options: maximum streams for "); 01946 printf("throughput is MAXSTREAMS\n"); 01947 exit(6); 01948 } 01949 uflag++; 01950 trflag++; 01951 if(Uflag) 01952 { 01953 printf("Can not run throughput tests with unmount & remounts.\n"); 01954 exit(7); 01955 } 01956 break; 01957 case 'm': /* Use multiple buffers */ 01958 fetchon=0; 01959 multi_buffer=1; 01960 mflag++; 01961 mbuffer = (char *) alloc_mem((long long)MAXBUFFERSIZE,(int)0); 01962 if(mbuffer == 0) { 01963 perror("Memory allocation failed:"); 01964 exit(8); 01965 } 01966 sprintf(splash[splash_line++],"\tMulti_buffer. Work area %d bytes\n", 01967 MAXBUFFERSIZE); 01968 break; 01969 case 'M': /* Report machine name and OS */ 01970 bzero(reply,sizeof(reply)); 01971 pi=popen("uname -a", "r"); 01972 if(pi == (FILE *)0) 01973 { 01974 sprintf(splash[splash_line++],"\n\tError using popen() on uname\n"); 01975 sprintf(splash[splash_line++],"\t-M option suppressed.\n"); 01976 } 01977 else 01978 { 01979 junk=fread(reply,IBUFSIZE-1,1,pi); 01980 pclose(pi); 01981 m=reply; 01982 while(*m) /* Strip new line */ 01983 { 01984 if(*m=='\n') 01985 *m=0; 01986 else 01987 m++; 01988 } 01989 sprintf(splash[splash_line++],"\n\tMachine = %s\n",reply); 01990 } 01991 break; 01992 01993 case 'P': /* Set beginning processor for binding. */ 01994 #ifndef NO_THREADS 01995 #if defined(_HPUX_SOURCE) || defined(linux) 01996 #if defined(_HPUX_SOURCE) 01997 num_processors= pthread_num_processors_np(); 01998 #else 01999 num_processors = sysconf(_SC_NPROCESSORS_ONLN); 02000 #endif 02001 begin_proc = atoi(optarg); 02002 if(begin_proc < 0) 02003 begin_proc=0; 02004 if(begin_proc > num_processors) 02005 begin_proc=0; 02006 sprintf(splash[splash_line++],"\tBinding of processors beginning with %d \n",begin_proc); 02007 ioz_processor_bind++; 02008 #else 02009 sprintf(splash[splash_line++],"\tProcessor binding not available in this version\n"); 02010 #endif 02011 #endif 02012 break; 02013 case 'p': /* purge the processor cache */ 02014 sprintf(splash[splash_line++],"\tPurge Mode On\n"); 02015 fetchon=0; 02016 pflag++; 02017 purge=1; 02018 break; 02019 case 'h': /* show help */ 02020 hflag++; 02021 show_help(); 02022 exit(0); 02023 break; 02024 case 'E': /* Extended testing for pread/pwrite... */ 02025 Eflag++; 02026 break; 02027 case 'R': /* Generate Excel compatible Report */ 02028 Rflag++; 02029 sprintf(splash[splash_line++],"\tExcel chart generation enabled\n"); 02030 break; 02031 case 'o': /* Open OSYNC */ 02032 sprintf(splash[splash_line++],"\tSYNC Mode. \n"); 02033 oflag++; 02034 break; 02035 case 'O': /* Report in Ops/sec instead of KB/sec */ 02036 sprintf(splash[splash_line++],"\tOPS Mode. Output is in operations per second.\n"); 02037 OPS_flag++; 02038 break; 02039 case 'N': /* Report in usec/op */ 02040 sprintf(splash[splash_line++],"\tMicroseconds/op Mode. Output is in microseconds per operation.\n"); 02041 MS_flag++; 02042 break; 02043 case 'V': /* Turn on Verify every byte */ 02044 sverify=0; 02045 inp_pat = (char)(atoi(optarg)); 02046 if(inp_pat == 0) 02047 inp_pat = PATTERN; 02048 pattern = ((inp_pat << 24) | (inp_pat << 16) | (inp_pat << 8) 02049 | inp_pat); 02050 verify=1; 02051 sprintf(splash[splash_line++],"\tVerify Mode. Pattern %x\n",pattern); 02052 sprintf(splash[splash_line++],"\tPerformance measurements are invalid in this mode.\n"); 02053 break; 02054 case 'S': /* Set the processor cache size */ 02055 cache_size = (long)(atoi(optarg)*1024); 02056 if(cache_size == 0) 02057 cache_size = CACHE_SIZE; 02058 break; 02059 case 'L': /* Set processor cache line size */ 02060 cache_line_size = (long)(atoi(optarg)); 02061 if(cache_line_size == 0) 02062 cache_line_size = CACHE_LINE_SIZE; 02063 break; 02064 case 'f': /* Specify the file name */ 02065 if(mfflag) { 02066 printf("invalid options: -f and -F are mutually exclusive\n"); 02067 exit(10); 02068 } 02069 fflag++; 02070 strcpy(filename,optarg); 02071 sprintf(dummyfile[0],"%s.DUMMY",optarg); 02072 break; 02073 case 'b': /* Specify the biff file name */ 02074 Rflag++; 02075 bif_flag++; 02076 strcpy(bif_filename,optarg); 02077 break; 02078 case 'F': /* Specify multiple file names for -t */ 02079 mfflag++; 02080 if(fflag) { 02081 printf("invalid options: -f and -F are mutually exclusive\n"); 02082 exit(11); 02083 } 02084 if(!trflag) { 02085 printf("invalid options: must specify -t N before -F\n"); 02086 exit(12); 02087 } 02088 optind--; 02089 for(fileindx=0;fileindx<maxt;fileindx++) { 02090 filearray[fileindx]=argv[optind++]; 02091 if(optind > argc) { 02092 #ifdef NO_PRINT_LLD 02093 printf("invalid options: not enough filenames for %ld streams\n",num_child); 02094 #else 02095 printf("invalid options: not enough filenames for %lld streams\n",num_child); 02096 #endif 02097 exit(13); 02098 } 02099 } 02100 break; 02101 case 'r': /* Specify the record size to use */ 02102 rflag++; 02103 reclen = ((long long)(atoi(optarg))*1024); 02104 if(optarg[strlen(optarg)-1]=='k' || 02105 optarg[strlen(optarg)-1]=='K'){ 02106 reclen = (long long)(1024 * atoi(optarg)); 02107 } 02108 if(optarg[strlen(optarg)-1]=='m' || 02109 optarg[strlen(optarg)-1]=='M'){ 02110 reclen = (long long)(1024 * 1024 * atoi(optarg)); 02111 } 02112 if(optarg[strlen(optarg)-1]=='g' || 02113 optarg[strlen(optarg)-1]=='G'){ 02114 reclen = (long long)(1024 * 1024 * 1024 *(long long)atoi(optarg)); 02115 } 02116 if(reclen <= 0) 02117 reclen=(long long)4096; 02118 02119 r_range[r_count++]=reclen; 02120 max_rec_size = (off64_t)r_range[r_count-1]; /* Make visable globally */ 02121 min_rec_size = (off64_t)r_range[0]; /* Make visable globally */ 02122 #ifdef NO_PRINT_LLD 02123 sprintf(splash[splash_line++],"\tRecord Size %ld KB\n",reclen/1024); 02124 #else 02125 sprintf(splash[splash_line++],"\tRecord Size %lld KB\n",reclen/1024); 02126 #endif 02127 if(max_rec_size > MAXBUFFERSIZE) { 02128 #ifdef NO_PRINT_LLD 02129 printf("Error: maximum record size %ld KB is greater than maximum buffer size %ld KB\n ", 02130 max_rec_size/1024, MAXBUFFERSIZE/1024); 02131 #else 02132 printf("Error: maximum record size %lld KB is greater than maximum buffer size %lld KB\n ", 02133 (long long)(max_rec_size/1024LL), (long long)MAXBUFFERSIZE/1024LL); 02134 #endif 02135 exit(23); 02136 } 02137 break; 02138 case 'J': /* Specify the compute time in millisecs */ 02139 compute_time = (float)(atoi(optarg)); 02140 compute_time=compute_time/1000; 02141 if(compute_time < (float)0) 02142 compute_time=(float)0; 02143 else 02144 compute_flag=1; 02145 jflag++; 02146 break; 02147 case 'j': /* Specify the stride in records */ 02148 stride = (long long)(atoi(optarg)); 02149 if(stride < 0) 02150 stride=0; 02151 stride_flag=1; 02152 break; 02153 case 't': /* Specify the number of children to run */ 02154 num_child1=(atoi(optarg)); 02155 num_child = (long long)num_child1; 02156 if(num_child > (long long)MAXSTREAMS) { 02157 printf("invalid options: maximum streams for throughput is MAXSTREAMS\n"); 02158 #ifdef NO_PRINT_LLD 02159 printf("Numchild %ld %s\n",num_child,optarg); 02160 #else 02161 printf("Numchild %lld %s\n",num_child,optarg); 02162 #endif 02163 exit(14); 02164 } 02165 if(num_child <= 0) 02166 num_child = 8; 02167 if(num_child == 0) 02168 num_child=1; 02169 t_range[t_count++]=num_child; 02170 maxt = (maxt>num_child?maxt:num_child); 02171 trflag++; 02172 if(Uflag) 02173 { 02174 printf("Can not run throughput tests with unmount & remounts.\n"); 02175 exit(15); 02176 } 02177 break; 02178 case 'd': /* Specify the delay of children to run */ 02179 delay_start = (long long)(atoi(optarg)); 02180 if(delay_start < 0) 02181 delay_start=0; 02182 break; 02183 case 'i': /* Specify specific tests */ 02184 tval=(long long)(atoi(optarg)); 02185 if(tval < 0) tval=0; 02186 #ifndef HAVE_PREAD 02187 if(tval > RANDOM_MIX_TEST) 02188 { 02189 printf("\tPread tests not available on this operating system.\n"); 02190 exit(183); 02191 } 02192 #endif 02193 if(tval > sizeof(func)/sizeof(char *)) 02194 { 02195 tval=0; 02196 sprintf(splash[splash_line++],"\tSelected test not available on the version.\n"); 02197 } 02198 include_test[tval]++; 02199 include_tflag++; 02200 break; 02201 case 'v': /* Show version information */ 02202 for(ind=0; strlen(head1[ind]); ind++) 02203 { 02204 printf("%s\n", head1[ind]); 02205 } 02206 exit(0); 02207 break; 02208 case 'U': /* Specify the dev name for umount/mount*/ 02209 Uflag++; 02210 strcpy(mountname,optarg); 02211 if(trflag) 02212 { 02213 printf("Can not run throughput tests with unmount & remounts.\n"); 02214 exit(16); 02215 } 02216 break; 02217 case 'w': /* Do not unlink files */ 02218 sprintf(splash[splash_line++],"\tSetting no_unlink\n"); 02219 no_unlink = 1; 02220 break; 02221 case 'Z': /* Turn on the mmap and file I/O mixing */ 02222 sprintf(splash[splash_line++],"\tEnable mmap & file I/O mixing.\n"); 02223 mmap_mix = 1; 02224 break; 02225 case 'W': /* Read/Write with file locked */ 02226 file_lock=1; 02227 sprintf(splash[splash_line++],"\tLock file when reading/writing.\n"); 02228 break; 02229 case 'K': /* Cause disrupted read pattern */ 02230 disrupt_flag=1; 02231 sprintf(splash[splash_line++],"\tDisrupted read patterns selected.\n"); 02232 break; 02233 case 'X': /* Open write telemetry file */ 02234 compute_flag=1; 02235 sverify=2; /* touch lightly */ 02236 w_traj_flag=1; 02237 strcpy(write_traj_filename,optarg); 02238 traj_vers(); 02239 w_traj_size(); 02240 sprintf(splash[splash_line++],"\tUsing write telemetry file \"%s\"\n", 02241 write_traj_filename); 02242 w_traj_fd=open_w_traj(); 02243 if(w_traj_fd == (FILE *)0) 02244 exit(200); 02245 break; 02246 case 'Y': /* Open Read telemetry file */ 02247 compute_flag=1; 02248 sverify=2; /* touch lightly */ 02249 r_traj_flag=1; 02250 strcpy(read_traj_filename,optarg); 02251 sprintf(splash[splash_line++],"\tUsing read telemetry file \"%s\"\n", 02252 read_traj_filename); 02253 traj_vers(); 02254 r_traj_size(); 02255 r_traj_fd=open_r_traj(); 02256 if(r_traj_fd == (FILE*) 0) 02257 exit(200); 02258 break; 02259 case 'n': /* Set min file size for auto mode */ 02260 nflag=1; 02261 minimum_file_size = (off64_t)atoi(optarg); 02262 if(optarg[strlen(optarg)-1]=='k' || 02263 optarg[strlen(optarg)-1]=='K'){ 02264 ; 02265 } 02266 if(optarg[strlen(optarg)-1]=='m' || 02267 optarg[strlen(optarg)-1]=='M'){ 02268 minimum_file_size = (long long)(1024 * atoi(optarg)); 02269 } 02270 if(optarg[strlen(optarg)-1]=='g' || 02271 optarg[strlen(optarg)-1]=='G'){ 02272 minimum_file_size = (long long)(1024 * 1024 * (long long)atoi(optarg)); 02273 } 02274 if(minimum_file_size < RECLEN_START/1024) 02275 minimum_file_size=(off64_t)(RECLEN_START/1024); 02276 if(minimum_file_size < page_size/1024) 02277 minimum_file_size=(off64_t)(page_size/1024); 02278 #ifdef NO_PRINT_LLD 02279 sprintf(splash[splash_line++],"\tUsing minimum file size of %ld kilobytes.\n",minimum_file_size); 02280 #else 02281 sprintf(splash[splash_line++],"\tUsing minimum file size of %lld kilobytes.\n",minimum_file_size); 02282 #endif 02283 break; 02284 case 'g': /* Set maximum file size for auto mode */ 02285 gflag=1; 02286 maximum_file_size = (off64_t)atoi(optarg); 02287 if(optarg[strlen(optarg)-1]=='k' || 02288 optarg[strlen(optarg)-1]=='K'){ 02289 ; 02290 } 02291 if(optarg[strlen(optarg)-1]=='m' || 02292 optarg[strlen(optarg)-1]=='M'){ 02293 maximum_file_size = (long long)(1024 * atoi(optarg)); 02294 } 02295 if(optarg[strlen(optarg)-1]=='g' || 02296 optarg[strlen(optarg)-1]=='G'){ 02297 maximum_file_size = (long long)(1024 * 1024 * (long long)atoi(optarg)); 02298 } 02299 if(maximum_file_size < RECLEN_START/1024) 02300 maximum_file_size=(off64_t)(RECLEN_START/1024); 02301 #ifdef NO_PRINT_LLD 02302 sprintf(splash[splash_line++],"\tUsing maximum file size of %ld kilobytes.\n",maximum_file_size); 02303 #else 02304 sprintf(splash[splash_line++],"\tUsing maximum file size of %lld kilobytes.\n",maximum_file_size); 02305 #endif 02306 break; 02307 case 'z': /* Set no cross over */ 02308 sprintf(splash[splash_line++],"\tCross over of record size disabled.\n"); 02309 NOCROSSflag=1; 02310 break; 02311 case 'y': /* Set min record size for auto mode */ 02312 yflag=1; 02313 min_rec_size = ((long long)(atoi(optarg))*1024); 02314 if(optarg[strlen(optarg)-1]=='k' || 02315 optarg[strlen(optarg)-1]=='K'){ 02316 min_rec_size = (long long)(1024 * atoi(optarg)); 02317 } 02318 if(optarg[strlen(optarg)-1]=='m' || 02319 optarg[strlen(optarg)-1]=='M'){ 02320 min_rec_size = (long long)(1024 * 1024 * atoi(optarg)); 02321 } 02322 if(optarg[strlen(optarg)-1]=='g' || 02323 optarg[strlen(optarg)-1]=='G'){ 02324 min_rec_size = (long long)(1024 * 1024 * 1024 *(long long)atoi(optarg)); 02325 } 02326 if(min_rec_size <= 0) 02327 min_rec_size=(long long)RECLEN_START; 02328 #ifdef NO_PRINT_LLD 02329 sprintf(splash[splash_line++],"\tUsing Minimum Record Size %ld KB\n", min_rec_size/1024); 02330 #else 02331 sprintf(splash[splash_line++],"\tUsing Minimum Record Size %lld KB\n", min_rec_size/1024); 02332 #endif 02333 break; 02334 case 'q': /* Set max record size for auto mode */ 02335 qflag=1; 02336 max_rec_size = ((long long)(atoi(optarg))*1024); 02337 if(optarg[strlen(optarg)-1]=='k' || 02338 optarg[strlen(optarg)-1]=='K'){ 02339 max_rec_size = (long long)(1024 * atoi(optarg)); 02340 } 02341 if(optarg[strlen(optarg)-1]=='m' || 02342 optarg[strlen(optarg)-1]=='M'){ 02343 max_rec_size = (long long)(1024 * 1024 * atoi(optarg)); 02344 } 02345 if(optarg[strlen(optarg)-1]=='g' || 02346 optarg[strlen(optarg)-1]=='G'){ 02347 max_rec_size = (long long)(1024 * 1024 * 1024 *(long long)atoi(optarg)); 02348 } 02349 if(max_rec_size <= 0) 02350 min_rec_size=(long long)RECLEN_END; 02351 if(max_rec_size > MAXBUFFERSIZE) { 02352 #ifdef NO_PRINT_LLD 02353 printf("Error: maximum record size %ld KB is greater than maximum buffer size %ld KB\n ", 02354 max_rec_size/1024, MAXBUFFERSIZE/1024); 02355 #else 02356 printf("Error: maximum record size %lld KB is greater than maximum buffer size %lld KB\n ", 02357 (long long)(max_rec_size/1024LL), (long long)MAXBUFFERSIZE/1024LL); 02358 #endif 02359 exit(23); 02360 } 02361 #ifdef NO_PRINT_LLD 02362 sprintf(splash[splash_line++],"\tUsing Maximum Record Size %ld KB\n", max_rec_size/1024); 02363 #else 02364 sprintf(splash[splash_line++],"\tUsing Maximum Record Size %lld KB\n", max_rec_size/1024); 02365 #endif 02366 break; 02367 02368 /* 02369 * The + operator is for the new extended options mechanism 02370 * Syntax is -+ followed by option leter, and if the optino 02371 * takes an operand then it is implemented below. An example 02372 * -+a arg is shown below. This is a sub option with an argument. 02373 * -+b is shown below. This is a sub option with no argument. 02374 */ 02375 case '+': 02376 /* printf("Plus option = >%s<\n",optarg);*/ 02377 switch (*((char *)optarg)) 02378 { 02379 case 'a': /* Example: Has argument */ 02380 subarg=argv[optind++]; 02381 /* if(subarg!=(char *)0) Error checking. */ 02382 /* printf("Plus option argument = >%s<\n",subarg);*/ 02383 break; 02384 case 'b': /* Example: Does not have an argument */ 02385 break; 02386 case 'c': /* Argument is the controlling host name */ 02387 /* I am a client for distributed Iozone */ 02388 subarg=argv[optind++]; 02389 if(subarg==(char *)0) 02390 { 02391 printf("-+c takes an operand !!\n"); 02392 exit(200); 02393 } 02394 strcpy(controlling_host_name,subarg); 02395 distributed=1; 02396 client_iozone=1; 02397 master_iozone=0; 02398 break; 02399 case 'h': /* Argument is the controlling host name */ 02400 subarg=argv[optind++]; 02401 if(subarg==(char *)0) 02402 { 02403 printf("-+h takes an operand !!\n"); 02404 exit(200); 02405 } 02406 strcpy(controlling_host_name,subarg); 02407 sprintf(splash[splash_line++],"\tHostname = %s\n",controlling_host_name); 02408 break; 02409 case 'm': /* I am the controlling process for distributed Iozone */ 02410 /* Does not have an argument */ 02411 subarg=argv[optind++]; 02412 if(subarg==(char *)0) 02413 { 02414 printf("-+m takes an operand. ( filename )\n"); 02415 exit(201); 02416 } 02417 strcpy(client_filename,subarg); 02418 ret=get_client_info(); 02419 if(ret <= 0) 02420 { 02421 printf("Error reading client file\n"); 02422 exit(178); 02423 } 02424 clients_found=ret; 02425 distributed=1; 02426 master_iozone=1; 02427 client_iozone=0; 02428 sprintf(splash[splash_line++],"\tNetwork distribution mode enabled.\n"); 02429 break; 02430 case 'N': /* turn off truncating the file before write test */ 02431 notruncate = 1; 02432 break; 02433 case 'u': /* Set CPU utilization output flag */ 02434 cpuutilflag = 1; /* only used if R(eport) flag is also set */ 02435 get_rusage_resolution(); 02436 sprintf(splash[splash_line++],"\tCPU utilization Resolution = %5.3f seconds.\n",cputime_res); 02437 sprintf(splash[splash_line++],"\tCPU utilization Excel chart enabled\n"); 02438 break; 02439 case 's': /* Clients operate in silent mode. */ 02440 /* Does not have an argument */ 02441 silent=1; 02442 break; 02443 case 'd': /* Diagnostics mode */ 02444 sprintf(splash[splash_line++],"\t>>> I/O Diagnostic mode enabled. <<<\n"); 02445 sprintf(splash[splash_line++],"\tPerformance measurements are invalid in this mode.\n"); 02446 diag_v=1; 02447 sverify=0; 02448 break; 02449 case 'x': /* Argument is the multiplier for rec size and file size */ 02450 subarg=argv[optind++]; 02451 if(subarg==(char *)0) 02452 { 02453 printf("-+c takes an operand !!\n"); 02454 exit(200); 02455 } 02456 multiplier = atoi(subarg); 02457 if(multiplier <=1) 02458 multiplier = 2; 02459 break; 02460 case 'i': /* Argument is the host port */ 02461 subarg=argv[optind++]; 02462 if(subarg==(char *)0) 02463 { 02464 printf("-+i takes an operand !!\n"); 02465 exit(200); 02466 } 02467 controlling_host_port = atoi(subarg); 02468 break; 02469 case 'p': /* Argument is the percentage read */ 02470 subarg=argv[optind++]; 02471 if(subarg==(char *)0) 02472 { 02473 printf("-+p takes an operand !!\n"); 02474 exit(200); 02475 } 02476 pct_read = atoi(subarg); 02477 if(pct_read < 1) 02478 pct_read = 1; 02479 if(pct_read >=100) 02480 pct_read = 100; 02481 sprintf(splash[splash_line++],"\tPercent read in mix test is %d\n",pct_read); 02482 break; 02483 case 't': /* Speed code activated */ 02484 speed_code=1; 02485 break; 02486 #if defined(_HPUX_SOURCE) || defined(linux) || defined(solaris) 02487 case 'r': /* Read sync too */ 02488 read_sync=1; 02489 sprintf(splash[splash_line++],"\tRead & Write sync mode active.\n"); 02490 break; 02491 #endif 02492 #ifndef NO_MADVISE 02493 case 'A': /* Argument is madvise selector */ 02494 subarg=argv[optind++]; 02495 if(subarg==(char *)0) 02496 { 02497 printf("-+A take an operand !!\n"); 02498 exit(200); 02499 } 02500 advise_flag=1; 02501 advise_op=atoi(subarg); 02502 sprintf(splash[splash_line++],"\tMadvise enabled: %d\n",advise_op); 02503 break; 02504 #endif 02505 case 'n': /* Set no-retest */ 02506 noretest = 1; 02507 sprintf(splash[splash_line++],"\tNo retest option selected\n"); 02508 break; 02509 case 'k': /* Constant aggregate data set size */ 02510 aggflag=1; 02511 break; 02512 case 'q': /* Argument is the rest time between tests in seconds */ 02513 subarg=argv[optind++]; 02514 if(subarg==(char *)0) 02515 { 02516 printf("-+q takes an operand !!\n"); 02517 exit(200); 02518 } 02519 rest_val = (long long)atoi(subarg); 02520 if(rest_val <=0) 02521 rest_val = 0; 02522 restf=1; 02523 sprintf(splash[splash_line++],"\tDelay %d seconds between tests enabled.\n",atoi(subarg)); 02524 break; 02525 #if defined(O_DSYNC) 02526 case 'D': /* O_DSYNC mode */ 02527 sprintf(splash[splash_line++],"\t>>> O_DSYNC mode enabled. <<<\n"); 02528 odsync=1; 02529 break; 02530 #endif 02531 case 'l': /* Record locking mode */ 02532 sprintf(splash[splash_line++],"\t>>> Record locking mode enabled. <<<\n"); 02533 rlocking=1; 02534 break; 02535 case 'L': /* Record locking mode shared files*/ 02536 sprintf(splash[splash_line++],"\t>>> Record locking, shared file mode enabled. <<<\n"); 02537 share_file=1; 02538 rlocking=1; 02539 break; 02540 case 'V': /* No Record locking shared files*/ 02541 sprintf(splash[splash_line++],"\t>>> Shared file mode enabled. <<<\n"); 02542 share_file=1; 02543 break; 02544 case 'B': /* Sequential mix */ 02545 sprintf(splash[splash_line++],"\t>>> Sequential Mixed workload. <<<\n"); 02546 seq_mix=1; 02547 break; 02548 /* Use an existing user file, that does 02549 not contain Iozone's pattern. Use file 02550 for testing, but read only, and no 02551 delete at the end of the test. Also, 02552 no pattern verification, but do touch 02553 the pages. */ 02554 case 'E': 02555 sprintf(splash[splash_line++],"\t>>> No Verify mode. <<<\n"); 02556 sverify=2; 02557 no_unlink=1; 02558 no_write=1; 02559 break; 02560 case 'T': /* Time stamps on */ 02561 L_flag=1; 02562 break; 02563 case 'X': /* Short circuit test mode */ 02564 X_flag = 1; 02565 sverify=1; 02566 verify=1; 02567 inp_pat = 0xBB; 02568 pattern = ((inp_pat << 24) | 02569 (inp_pat << 16) | (inp_pat << 8) | 02570 inp_pat); 02571 sprintf(splash[splash_line++],"\tShort circuit mode. For\n"); 02572 sprintf(splash[splash_line++],"\t filesystem development testing ONLY !\n"); 02573 break; 02574 case 'Z': /* Compatibility mode for 0xA5 */ 02575 Z_flag = 1; 02576 sverify=1; 02577 verify=1; 02578 inp_pat = 0xA5; 02579 pattern = ((inp_pat << 24) | 02580 (inp_pat << 16) | (inp_pat << 8) | 02581 inp_pat); 02582 sprintf(splash[splash_line++],"\tUsing old data sets.\n"); 02583 sprintf(splash[splash_line++],"\t Performance measurements may be invalid in this\n"); 02584 sprintf(splash[splash_line++],"\t mode due to published hack.\n"); 02585 break; 02586 #if defined(Windows) 02587 case 'U': /* Windows only Unbufferd I/O */ 02588 unbuffered=1; 02589 sprintf(splash[splash_line++],"\tUnbuffered Windows API usage. >>> Very Experimental <<<\n"); 02590 break; 02591 #endif 02592 case 'K': /* Sony special for manual control of test 8 */ 02593 subarg=argv[optind++]; 02594 if(subarg==(char *)0) 02595 { 02596 printf("-+K takes an operand !!\n"); 02597 exit(204); 02598 } 02599 Kplus_readers = (int)atoi(subarg); 02600 if(Kplus_readers <=0) 02601 Kplus_readers = 1; 02602 Kplus_flag=1; 02603 sprintf(splash[splash_line++],"\tManual control of test 8. >>> Very Experimental. Sony special <<<\n"); 02604 break; 02605 case 'w': /* Argument is the percent of dedup */ 02606 /* Sets size of dedup region across files */ 02607 subarg=argv[optind++]; 02608 if(subarg==(char *)0) 02609 { 02610 printf("-+w takes an operand !!\n"); 02611 exit(200); 02612 } 02613 dedup = atoi(subarg); 02614 if(dedup <=0) 02615 dedup = 0; 02616 if(dedup >100) 02617 dedup = 100; 02618 sprintf(splash[splash_line++],"\tDedup activated %d percent.\n",dedup); 02619 break; 02620 case 'y': /* Argument is the percent of interior dedup */ 02621 /* Sets size of dedup region within and across files */ 02622 subarg=argv[optind++]; 02623 if(subarg==(char *)0) 02624 { 02625 printf("-+y takes an operand !!\n"); 02626 exit(200); 02627 } 02628 dedup_interior = atoi(subarg); 02629 if(dedup_interior <0) 02630 dedup_interior = 0; 02631 if(dedup_interior >100) 02632 dedup_interior = 100; 02633 sprintf(splash[splash_line++],"\tDedupe within & across %d percent.\n",dedup_interior); 02634 break; 02635 case 'C': /* Argument is the percent of dedupe within & !across */ 02636 /* Sets size of dedup region within and !across files */ 02637 subarg=argv[optind++]; 02638 if(subarg==(char *)0) 02639 { 02640 printf("-+C takes an operand !!\n"); 02641 exit(200); 02642 } 02643 dedup_compress = atoi(subarg); 02644 if(dedup_compress <0) 02645 dedup_compress = 0; 02646 if(dedup_compress >100) 02647 dedup_compress = 100; 02648 sprintf(splash[splash_line++],"\tDedupe within %d percent.\n",dedup_compress); 02649 break; 02650 case 'S': /* Argument is the seed for dedup */ 02651 subarg=argv[optind++]; 02652 if(subarg==(char *)0) 02653 { 02654 printf("-+S takes an operand !!\n"); 02655 exit(200); 02656 } 02657 dedup_mseed = atoi(subarg); 02658 if(dedup_mseed ==0) 02659 dedup_mseed = 1; 02660 sprintf(splash[splash_line++],"\tDedup manual seed %d .\n",dedup_mseed); 02661 break; 02662 case 'H': /* Argument is hostname of the PIT */ 02663 subarg=argv[optind++]; 02664 if(subarg==(char *)0) 02665 { 02666 printf("-+H takes operand !!\n"); 02667 exit(200); 02668 } 02669 strcpy(pit_hostname,subarg); 02670 sprintf(splash[splash_line++],"\tPIT_host %s\n",pit_hostname); 02671 02672 break; 02673 case 'P': /* Argument is port of the PIT */ 02674 subarg=argv[optind++]; 02675 if(subarg==(char *)0) 02676 { 02677 printf("-+P takes operand !!\n"); 02678 exit(200); 02679 } 02680 strcpy(pit_service,subarg); 02681 sprintf(splash[splash_line++],"\tPIT_port %s\n",pit_service); 02682 break; 02683 case 'z': /* Enable hist summary*/ 02684 hist_summary=1; 02685 sprintf(splash[splash_line++],"\tHistogram summary enabled.\n"); 02686 break; 02687 case 'O': /* Argument is the Op rate */ 02688 subarg=argv[optind++]; 02689 if(subarg==(char *)0) 02690 { 02691 printf("-+O takes an operand !!\n"); 02692 exit(200); 02693 } 02694 op_rate = atoi(subarg); 02695 if(op_rate <= 0) 02696 op_rate = 1; 02697 op_rate_flag = 1; 02698 sprintf(splash[splash_line++],"\tRate control active %d Ops/sec .\n",op_rate); 02699 break; 02700 default: 02701 printf("Unsupported Plus option -> %s <-\n",optarg); 02702 exit(255); 02703 break; 02704 } 02705 break; 02706 default: 02707 printf("Unsupported option -> %s <-\n",optarg); 02708 exit(255); 02709 } 02710 } 02711 base_time=(long)time_so_far(); 02712 get_resolution(); /* Get clock resolution */ 02713 if(speed_code) 02714 { 02715 do_speed_check(client_iozone); 02716 exit(0); 02717 } 02718 if(r_count > 1) 02719 { 02720 aflag=1; 02721 rflag=0; 02722 NOCROSSflag=1; 02723 } 02724 if(s_count > 1) 02725 { 02726 aflag=1; 02727 sflag=0; 02728 NOCROSSflag=1; 02729 } 02730 /* 02731 * If not in silent mode then display the splash screen. 02732 */ 02733 for(i=0;i<splash_line;i++) 02734 if(!silent) printf("%s",splash[i]); 02735 /* 02736 * Save the command line for later 02737 */ 02738 record_command_line(argcsave, argvsave); 02739 02740 if(pflag) /* Allocate after cache_size is set */ 02741 { 02742 alloc_pbuf(); 02743 } 02744 if(distributed && master_iozone) 02745 { 02746 if(maxt > clients_found) 02747 { 02748 printf("You can not specify more threads/processes than you have in the client file list\n"); 02749 exit(202); 02750 } 02751 } 02752 02753 if(!OPS_flag && !MS_flag) 02754 { 02755 if(!silent) printf("\tOutput is in Kbytes/sec\n"); 02756 } 02757 if (min_rec_size > max_rec_size) { 02758 #ifdef NO_PRINT_LLD 02759 printf("Error: minimum record size %ld KB is greater than maximum record size %ld KB\n ", 02760 min_rec_size/1024, max_rec_size/1024); 02761 #else 02762 printf("Error: minimum record size %lld KB is greater than maximum record size %lld KB\n ", 02763 min_rec_size/1024, max_rec_size/1024); 02764 #endif 02765 exit(23); 02766 } 02767 orig_min_rec_size=min_rec_size; 02768 orig_max_rec_size=max_rec_size; 02769 /* 02770 * No telemetry files... just option selected 02771 */ 02772 if(compute_flag && jflag && !(r_traj_flag || w_traj_flag)) 02773 if(!silent) printf("\tCompute time %f seconds for reads and writes.\n",compute_time); 02774 /* 02775 * Read telemetry file and option selected 02776 */ 02777 if(compute_flag && r_traj_flag && !w_traj_flag) 02778 { 02779 if(r_traj_items==3) 02780 { 02781 if(!silent) printf("\tCompute time from telemetry files for reads.\n"); 02782 } 02783 else 02784 { 02785 if(jflag) 02786 if(!silent) printf("\tCompute time %f seconds for reads.\n",compute_time); 02787 } 02788 if(jflag) 02789 if(!silent) printf("\tCompute time %f seconds for writes.\n",compute_time); 02790 } 02791 /* 02792 * Write telemetry file and option selected 02793 */ 02794 if(compute_flag && !r_traj_flag && w_traj_flag) 02795 { 02796 if(w_traj_items==3) 02797 { 02798 if(!silent) printf("\tCompute time from telemetry files for writes.\n"); 02799 } 02800 else 02801 { 02802 if(jflag) 02803 if(!silent) printf("\tCompute time %f seconds for writes.\n",compute_time); 02804 } 02805 if(jflag) 02806 if(!silent) printf("\tCompute time %f seconds for reads.\n",compute_time); 02807 } 02808 if(compute_flag && r_traj_flag && w_traj_flag && jflag) 02809 { 02810 if(r_traj_items==3) 02811 { 02812 if(!silent) printf("\tCompute time from telemetry files for reads.\n"); 02813 } 02814 else 02815 { 02816 if(!silent) printf("\tCompute time %f seconds for reads.\n",compute_time); 02817 } 02818 if(w_traj_items==3) 02819 { 02820 if(!silent) printf("\tCompute time from telemetry files for writes.\n"); 02821 } 02822 else 02823 { 02824 if(!silent) printf("\tCompute time %f seconds for writes.\n",compute_time); 02825 } 02826 } 02827 if(compute_flag && r_traj_flag && w_traj_flag && !jflag) 02828 { 02829 if(r_traj_items==3) 02830 { 02831 if(!silent) printf("\tCompute time from telemetry files for reads.\n"); 02832 } 02833 else 02834 { 02835 if(!silent) printf("\tNo compute time for reads.\n"); 02836 } 02837 02838 if(w_traj_items==3) 02839 { 02840 if(!silent) printf("\tCompute time from telemetry files for writes.\n"); 02841 } 02842 else 02843 { 02844 if(!silent) printf("\tNo compute time for writes.\n"); 02845 } 02846 } 02847 02848 /* Enforce only write,rewrite,read,reread */ 02849 if(w_traj_flag || r_traj_flag) 02850 { 02851 for(i=2;i<sizeof(func)/sizeof(char *);i++) 02852 { 02853 if(seq_mix && (i==8)) 02854 ; 02855 else 02856 include_test[i] = 0; 02857 } 02858 } 02859 02860 if(r_traj_flag) 02861 { 02862 if(include_test[READER_TEST] == 0) 02863 { 02864 include_test[WRITER_TEST]=1; 02865 include_test[READER_TEST]=1; 02866 include_tflag=1; 02867 } 02868 } 02869 if(w_traj_flag) 02870 { 02871 if(include_test[WRITER_TEST] == 0) 02872 { 02873 include_test[WRITER_TEST]=1; 02874 include_tflag=1; 02875 } 02876 } 02877 if(w_traj_flag && w_traj_fsize != 0) 02878 kilobytes64=w_traj_fsize/1024; 02879 if(r_traj_flag && r_traj_fsize != 0) 02880 kilobytes64=r_traj_fsize/1024; 02881 02882 if( sverify==0 && (w_traj_flag || r_traj_flag)) 02883 { 02884 printf("\n\tFull verification not supported in telemetry mode.\n\n"); 02885 exit(17); 02886 } 02887 ; 02888 if(disrupt_flag &&(w_traj_flag || r_traj_flag) ) 02889 { 02890 printf("\n\tDisrupt not supported in telemetry mode.\n\n"); 02891 exit(17); 02892 } 02893 if(aflag &&(w_traj_flag || r_traj_flag) ) 02894 { 02895 printf("\n\tAuto mode not supported in telemetry mode.\n"); 02896 printf("\tTry: -i 0 -i 1 \n\n"); 02897 exit(17); 02898 } 02899 if(sflag && w_traj_flag ) 02900 { 02901 printf("\n\tSize of file is determined by telemetry file.\n\n"); 02902 exit(17); 02903 } 02904 if(rflag && w_traj_flag ) 02905 { 02906 printf("\n\tRecord size of file is determined by telemetry file.\n\n"); 02907 exit(17); 02908 } 02909 if(stride_flag && (w_traj_flag || r_traj_flag)) 02910 { 02911 printf("\n\tStride size is determined by telemetry file.\n\n"); 02912 exit(17); 02913 } 02914 if(trflag && MS_flag) 02915 { 02916 printf("\n\tMicrosecond mode not supported in throughput mode.\n\n"); 02917 exit(17); 02918 } 02919 if (trflag /* throughput mode, don't allow auto-mode options: */ 02920 && (auto_mode || aflag || yflag || qflag || nflag || gflag)) 02921 { 02922 printf("\n\tCan not mix throughput mode and auto-mode flags.\n\n"); 02923 exit(17); 02924 } 02925 if(fflag && trflag) 02926 { 02927 printf("\n\tYou must use -F when using multiple threads or processes.\n\n"); 02928 exit(17); 02929 } 02930 if(aflag && mfflag) 02931 { 02932 printf("\n\tYou must use -f when using auto mode.\n\n"); 02933 exit(17); 02934 } 02935 if(async_flag && mmapflag) 02936 { 02937 printf("\n\tSorry ... Only mmap or async but not both\n\n"); 02938 exit(18); 02939 } 02940 #ifndef ASYNC_IO 02941 if(async_flag) 02942 { 02943 printf("\n\tSorry ... This version does not support async I/O\n\n"); 02944 exit(19); 02945 } 02946 #endif 02947 if(no_write) 02948 { 02949 if(!include_tflag) 02950 { 02951 printf("You must specify which tests ( -i # ) when using -+E\n"); 02952 exit(19); 02953 } 02954 } 02955 if(include_tflag) 02956 { 02957 for(i=0;i<sizeof(func)/sizeof(char *);i++) 02958 if(include_test[i]) 02959 include_mask|=(long long)(1<<i); 02960 /* printf(">> %llx",include_mask); HERE */ 02961 } 02962 if(no_write) /* Disable if any writer would disturbe existing file */ 02963 { 02964 if(include_test[0] || include_test[4] || 02965 include_test[6] || include_test[8] || include_test[9] || 02966 include_test[11]) 02967 { 02968 printf("You must disable any test that writes when using -+E\n"); 02969 exit(20); 02970 } 02971 } 02972 if(no_write) /* User must specify the existing file name */ 02973 { 02974 if(!(fflag | mfflag)) 02975 { 02976 printf("You must use -f or -F when using -+E\n"); 02977 exit(20); 02978 } 02979 } 02980 if(h_flag && k_flag) 02981 { 02982 printf("\n\tCan not do both -H and -k\n"); 02983 exit(20); 02984 } 02985 if((dedup | dedup_interior) && diag_v) 02986 { 02987 printf("\n\tCan not do both -+d and -+w\n"); 02988 exit(20); 02989 } 02990 02991 if(!aflag && !rflag) 02992 max_rec_size=min_rec_size; 02993 02994 init_record_sizes(min_rec_size,max_rec_size); 02995 if(!silent) printf("\tTime Resolution = %1.6f seconds.\n",time_res); 02996 #ifdef NO_PRINT_LLD 02997 if(!silent) printf("\tProcessor cache size set to %ld Kbytes.\n",cache_size/1024); 02998 if(!silent) printf("\tProcessor cache line size set to %ld bytes.\n",cache_line_size); 02999 if(!silent) printf("\tFile stride size set to %ld * record size.\n",stride); 03000 #else 03001 if(!silent) printf("\tProcessor cache size set to %ld Kbytes.\n",cache_size/1024); 03002 if(!silent) printf("\tProcessor cache line size set to %ld bytes.\n",cache_line_size); 03003 if(!silent) printf("\tFile stride size set to %lld * record size.\n",stride); 03004 #endif 03005 if(!rflag) 03006 reclen=(long long)4096; 03007 03008 if(uflag && !lflag) 03009 num_child=mint = 1; 03010 if(lflag && !uflag) 03011 maxt = mint; 03012 if(use_thread) 03013 port="thread"; 03014 else 03015 port="process"; 03016 if(lflag || uflag){ 03017 #ifdef NO_PRINT_LLD 03018 if(!silent) printf("\tMin %s = %ld \n",port,mint); 03019 if(!silent) printf("\tMax %s = %ld \n",port,maxt); 03020 #else 03021 if(!silent) printf("\tMin %s = %lld \n",port,mint); 03022 if(!silent) printf("\tMax %s = %lld \n",port,maxt); 03023 #endif 03024 } 03025 if(trflag) 03026 { 03027 if(num_child > 1) 03028 { 03029 if(use_thread) 03030 { 03031 port="threads"; 03032 } 03033 else 03034 { 03035 port="processes"; 03036 } 03037 } 03038 03039 #ifdef NO_PRINT_LLD 03040 if(!silent) printf("\tThroughput test with %ld %s\n", num_child,port); 03041 #else 03042 if(!silent) printf("\tThroughput test with %lld %s\n", num_child,port); 03043 #endif 03044 } 03045 numrecs64 = (long long)(kilobytes64*1024)/reclen; 03046 if (reclen > (long long)MAXBUFFERSIZE) { 03047 #ifdef NO_PRINT_LLD 03048 printf("Error: Maximum record length is %ld bytes\n", 03049 MAXBUFFERSIZE); 03050 #else 03051 printf("Error: Maximum record length is %lld bytes\n", 03052 (long long)MAXBUFFERSIZE); 03053 #endif 03054 exit(21); 03055 } 03056 if (reclen < (long long)MINBUFFERSIZE) { 03057 #ifdef NO_PRINT_LLD 03058 printf("Error: Minimum record length is %ld bytes\n", 03059 MINBUFFERSIZE); 03060 #else 03061 printf("Error: Minimum record length is %lld bytes\n", 03062 (long long)MINBUFFERSIZE); 03063 #endif 03064 exit(22); 03065 } 03066 /* Only bzero or fill that which you will use. The buffer is very large */ 03067 if(verify ) 03068 { 03069 fill_buffer((char *)buffer,l_min(reclen,(long long)cache_size),(long long)pattern,(char)sverify,(long long)0); 03070 if(pflag) 03071 fill_buffer((char *)pbuffer,l_min(reclen,(long long)cache_size),(long long)pattern,(char)sverify,(long long)0); 03072 if(mflag) 03073 fill_buffer((char *)mbuffer,l_min(reclen,(long long)cache_size),(long long)pattern,(char)sverify,(long long)0); 03074 } 03075 else 03076 { 03077 bzero(buffer,(size_t)l_min(reclen,(long long)cache_size)); 03078 } 03079 03080 #ifndef NO_THREADS 03081 #if defined( _HPUX_SOURCE ) || defined ( linux ) 03082 if(ioz_processor_bind) 03083 { 03084 bind_cpu=begin_proc; 03085 #if defined( _HPUX_SOURCE ) 03086 pthread_processor_bind_np(PTHREAD_BIND_FORCED_NP, 03087 (pthread_spu_t *)&anwser, (pthread_spu_t)bind_cpu, pthread_self()); 03088 #else 03089 cpu_set_t cpuset; 03090 CPU_ZERO(&cpuset); 03091 CPU_SET(bind_cpu, &cpuset); 03092 03093 pthread_setaffinity_np(pthread_self(), sizeof(cpuset),&cpuset); 03094 #endif 03095 my_nap(40); /* Switch to new cpu */ 03096 } 03097 #endif 03098 #endif 03099 orig_size=kilobytes64; 03100 if(trflag){ 03101 (void)multi_throughput_test(mint,maxt); 03102 goto out; 03103 } 03104 if(trflag && (mint == maxt)){ 03105 auto_mode=0; 03106 throughput_test(); 03107 goto out; 03108 } 03109 if (aflag) { 03110 print_header(); 03111 auto_test(); 03112 goto out; 03113 } 03114 print_header(); 03115 (void) begin(kilobytes64,reclen); 03116 out: 03117 if(r_traj_flag) 03118 fclose(r_traj_fd); 03119 if(w_traj_flag) 03120 fclose(w_traj_fd); 03121 if (!no_unlink) 03122 { 03123 if(check_filename(dummyfile[0])) 03124 unlink(dummyfile[0]); /* delete the file */ 03125 } 03126 if(!silent) printf("\niozone test complete.\n"); 03127 if(res_prob) 03128 { 03129 printf("Timer resolution is poor. Some small transfers may have \n"); 03130 printf("reported inaccurate results. Sizes %ld Kbytes and below.\n", 03131 (long)(rec_prob/(long long)1024)); 03132 } 03133 03134 if(Rflag && !trflag){ 03135 dump_excel(); 03136 } 03137 return(0); 03138 } 03139 03140 #ifdef HAVE_ANSIC_C 03141 void 03142 record_command_line(int argc, char **argv) 03143 #else 03144 void 03145 record_command_line(argc, argv) 03146 int argc; 03147 char **argv; 03148 #endif 03149 { 03150 int ix, len = 0; 03151 03152 /* print and save the entire command line */ 03153 if(!silent) printf("\tCommand line used:"); 03154 for (ix=0; ix < argc; ix++) { 03155 if(!silent) printf(" %s", argv[ix]); 03156 if ((len + strlen(argv[ix])) < sizeof(command_line)) { 03157 strcat (command_line, argv[ix]); 03158 strcat (command_line, " "); 03159 len += strlen(argv[ix]) + 1; 03160 } 03161 else { 03162 printf ("Command line too long to save completely.\n"); 03163 break; 03164 } 03165 } 03166 if(!silent) printf("\n"); 03167 } 03168 03169 /*************************************************************************/ 03170 /* BEGIN() */ 03171 /* This is the main work horse. It is called from main and from */ 03172 /* auto_test. The caller provides the size of file and the record length.*/ 03173 /*************************************************************************/ 03174 #ifdef HAVE_ANSIC_C 03175 void 03176 begin(off64_t kilos64,long long reclength) 03177 #else 03178 void 03179 begin(kilos64,reclength) 03180 off64_t kilos64; 03181 long long reclength; 03182 #endif 03183 { 03184 long long num_tests,test_num,i,j; 03185 long long data1[MAXTESTS], data2[MAXTESTS]; 03186 num_tests = sizeof(func)/sizeof(char *); 03187 #if defined(HAVE_PREAD) 03188 if(!Eflag) 03189 { 03190 #if defined(HAVE_PREAD) && defined(HAVE_PREADV) 03191 num_tests -= 4; 03192 #else 03193 num_tests -= 2; 03194 #endif 03195 if(mmapflag || async_flag) 03196 { 03197 num_tests -= 2; 03198 } 03199 } 03200 else 03201 { 03202 if(mmapflag || async_flag) 03203 #if defined(HAVE_PREAD) && defined(HAVE_PREADV) 03204 num_tests -= 6; 03205 #else 03206 num_tests -= 4; 03207 #endif 03208 } 03209 #else 03210 if(mmapflag || async_flag) 03211 { 03212 num_tests -= 2; 03213 } 03214 #endif 03215 03216 if(RWONLYflag) num_tests = 2; /* kcollins 8-21-96*/ 03217 sync(); /* just in case there were some dirty */ 03218 sync(); 03219 kilobytes64=kilos64; 03220 reclen=reclength; 03221 numrecs64 = (kilobytes64*1024)/reclen; 03222 store_value(kilobytes64); 03223 if(r_traj_flag || w_traj_flag) 03224 store_value((off64_t)0); 03225 else 03226 store_value((off64_t)(reclen/1024)); 03227 03228 #ifdef NO_PRINT_LLD 03229 if(!silent) printf("%16ld",kilobytes64); 03230 if(r_traj_flag || w_traj_flag) 03231 { 03232 if(!silent) printf("%8ld",0); 03233 } 03234 else 03235 { 03236 if(!silent) printf("%8ld",reclen/1024); 03237 } 03238 #else 03239 if(!silent) printf("%16lld",kilobytes64); 03240 if(r_traj_flag || w_traj_flag) 03241 { 03242 if(!silent) printf("%8lld",(long long )0); 03243 } 03244 else 03245 { 03246 if(!silent) printf("%8lld",reclen/1024); 03247 } 03248 #endif 03249 if(include_tflag) 03250 { 03251 for(i=0;i<num_tests;i++) 03252 { 03253 if(include_mask & (long long)(1<<i)) 03254 func[i](kilobytes64,reclen,&data1[i],&data2[i]); 03255 else 03256 { 03257 if(!silent) printf("%s",test_output[i]); 03258 fflush(stdout); 03259 for(j=0;j<test_soutput[i];j++) 03260 store_value((off64_t)0); 03261 } 03262 } 03263 } 03264 else 03265 { 03266 for(test_num=0;test_num < num_tests;test_num++) 03267 { 03268 func[test_num](kilobytes64,reclen,&data1[test_num],&data2[test_num]); 03269 }; 03270 } 03271 if(!silent) printf("\n"); 03272 if(!OPS_flag && !include_tflag){ /* Report in ops/sec ? */ 03273 if(data1[1]!=0 && data2[1] != 0) 03274 { 03275 totaltime = data1[1] + data1[0]; 03276 if (totaltime < TOOFAST) 03277 { 03278 goodkilos = (TOOFAST/totaltime)*2*kilobytes64; 03279 printf("\nThe test completed too quickly to give a good result\n"); 03280 printf("You will get a more precise measure of this machine's\n"); 03281 printf("performance by re-running iozone using the command:\n"); 03282 #ifdef NO_PRINT_LLD 03283 printf("\n\tiozone %ld ", goodkilos); 03284 printf("\t(i.e., file size = %ld kilobytes64)\n", goodkilos); 03285 #else 03286 printf("\n\tiozone %lld ", goodkilos); 03287 printf("\t(i.e., file size = %lld kilobytes64)\n", goodkilos); 03288 #endif 03289 } 03290 } else { 03291 goodrecl = reclen/2; 03292 printf("\nI/O error during read. Try again with the command:\n"); 03293 #ifdef NO_PRINT_LLD 03294 printf("\n\tiozone %ld %ld ", kilobytes64, goodrecl); 03295 printf("\t(i.e. record size = %ld bytes)\n", goodrecl); 03296 #else 03297 printf("\n\tiozone %lld %lld ", kilobytes64, goodrecl); 03298 printf("\t(i.e. record size = %lld bytes)\n", goodrecl); 03299 #endif 03300 } 03301 } 03302 if (!no_unlink) 03303 { 03304 if(check_filename(filename)) 03305 unlink(filename); /* delete the file */ 03306 } 03307 /*stop timer*/ 03308 return ; 03309 } 03310 /****************************************************************** 03311 03312 SHOW_HELP -- show development help of this program 03313 03314 ******************************************************************/ 03315 #ifdef HAVE_ANSIC_C 03316 void show_help(void) 03317 #else 03318 void show_help() 03319 #endif 03320 { 03321 long long i; 03322 if(!silent) printf("iozone: help mode\n\n"); 03323 for(i=0; strlen(help[i]); i++) 03324 { 03325 if(!silent) printf("%s\n", help[i]); 03326 } 03327 } 03328 /****************************************************************** 03329 03330 SIGNAL_HANDLER -- clean up if user interrupts the program 03331 03332 ******************************************************************/ 03333 #ifdef HAVE_ANSIC_C 03334 void signal_handler(void) 03335 #else 03336 void signal_handler() 03337 #endif 03338 { 03339 long long i; 03340 if(distributed) 03341 { 03342 if(master_iozone) 03343 cleanup_children(); 03344 } 03345 if((long long)getpid()==myid) 03346 { 03347 if(!silent) printf("\niozone: interrupted\n\n"); 03348 #ifndef VMS 03349 if (!no_unlink) 03350 { 03351 if(check_filename(filename)) 03352 unlink(filename); /* delete the file */ 03353 } 03354 for(i=1;i<num_child;i++) 03355 { 03356 if(check_filename(dummyfile[i])) 03357 unlink(dummyfile[i]); /* delete the file */ 03358 } 03359 if (!no_unlink) 03360 { 03361 if(check_filename(dummyfile[0])) 03362 unlink(dummyfile[0]); /* delete the file */ 03363 } 03364 03365 #endif 03366 if(Rflag && !trflag){ 03367 dump_excel(); 03368 } 03369 if(Rflag && trflag){ 03370 dump_throughput(); 03371 } 03372 03373 if(!silent) printf("exiting iozone\n\n"); 03374 if(res_prob) 03375 { 03376 printf("Timer resolution is poor. Some small transfers may have \n"); 03377 printf("reported inaccurate results. Sizes %ld Kbytes and below.\n", 03378 (long)rec_prob/1024); 03379 } 03380 if(trflag && !use_thread) 03381 for(i=0;i<num_child;i++) 03382 kill((pid_t)childids[i],SIGTERM); 03383 if(r_traj_flag) 03384 fclose(r_traj_fd); 03385 if(w_traj_flag) 03386 fclose(w_traj_fd); 03387 } 03388 if(sp_msfd) 03389 close(sp_msfd); 03390 if(sp_mrfd) 03391 close(sp_mrfd); 03392 exit(0); 03393 } 03394 03395 /****************************************************************/ 03396 /* */ 03397 /* AUTO_TEST -- perform series of tests and tabulate results */ 03398 /* */ 03399 /****************************************************************/ 03400 #ifdef HAVE_ANSIC_C 03401 void 03402 auto_test(void) 03403 #else 03404 void auto_test() 03405 #endif 03406 { 03407 off64_t kilosi; 03408 long long recszi,count1; 03409 long long mult; 03410 long long xx; 03411 03412 /****************************************************************/ 03413 /* Start with file size of 1 megabyte and repeat the test */ 03414 /* KILOBYTES_ITER_LIMIT */ 03415 /* times. Each time we run, the file size is doubled */ 03416 /****************************************************************/ 03417 /* 03418 if(sflag) { 03419 min_file_size = kilobytes64; 03420 max_file_size = kilobytes64; 03421 } 03422 if(rflag) { 03423 min_rec_size = reclen; 03424 max_rec_size = reclen; 03425 } 03426 */ 03427 if(gflag) 03428 max_file_size = maximum_file_size; 03429 if(nflag) 03430 min_file_size = minimum_file_size; 03431 03432 if (min_rec_size > (long long)(min_file_size*1024)) { 03433 #ifdef NO_PRINT_LLD 03434 printf("Error: record length %ld is greater than filesize %ld KB\n ", 03435 min_rec_size,min_file_size); 03436 #else 03437 printf("Error: record length %lld is greater than filesize %lld KB\n ", 03438 min_rec_size,min_file_size); 03439 #endif 03440 exit(23); 03441 } 03442 03443 if(NOCROSSflag) xover = max_file_size; 03444 03445 init_file_sizes(min_file_size, max_file_size); 03446 del_record_sizes(); 03447 orig_min_rec_size=min_rec_size; 03448 orig_max_rec_size=max_rec_size; 03449 init_record_sizes(min_rec_size, max_rec_size); 03450 03451 for(kilosi=get_next_file_size((off64_t)0); kilosi>0; kilosi=get_next_file_size(kilosi)) 03452 { 03453 /****************************************************************/ 03454 /* Start with record size of min_rec_size bytes and repeat the */ 03455 /* test, multiplying the record size by MULTIPLIER each time, */ 03456 /* until we reach max_rec_size. At the CROSSOVER we stop doing */ 03457 /* small buffers as it takes forever and becomes very */ 03458 /* un-interesting. */ 03459 /****************************************************************/ 03460 if(!rflag && !sflag && !yflag && !qflag) 03461 if(kilosi > xover){ 03462 min_rec_size = LARGE_REC; 03463 mult = orig_min_rec_size/1024; 03464 del_record_sizes(); 03465 init_record_sizes(min_rec_size, max_rec_size); 03466 /************************************/ 03467 /* Generate dummy entries in the */ 03468 /* Excel buffer for skipped */ 03469 /* record sizes */ 03470 /************************************/ 03471 for(count1=min_rec_size; 03472 (count1 != orig_min_rec_size) && ( 03473 mult <= (kilosi*1024)) ; 03474 count1=(count1>>1)) 03475 { 03476 current_x=0; 03477 store_value((off64_t)kilosi); 03478 store_value((off64_t)mult); 03479 for(xx=0;xx<20;xx++) 03480 store_value((off64_t)0); 03481 mult=mult*2; 03482 current_y++; 03483 if(current_y>max_y) 03484 max_y=current_y; 03485 current_x=0; 03486 } 03487 } 03488 03489 for (recszi=get_next_record_size((off64_t)0);recszi!=0;recszi=get_next_record_size(recszi)) 03490 { 03491 if(recszi > (kilosi*1024)) 03492 break; 03493 begin(kilosi, recszi ); 03494 current_x=0; 03495 current_y++; 03496 } 03497 } 03498 } 03499 03500 03501 /****************************************************************/ 03502 /* */ 03503 /* THROUGHPUT_TEST () Multi process throughput test */ 03504 /* */ 03505 /* Note: States for share memory barrier are: */ 03506 /* 0 = Child not running or has finished. */ 03507 /* 1 = Child is ready to begin. */ 03508 /* 2 = Child is told to begin. */ 03509 /****************************************************************/ 03510 /* Data in shared memory format is: */ 03511 /* */ 03512 /* struct child_stats { */ 03513 /* long long flag; Used to barrier */ 03514 /* double walltime; Child's elapsed time */ 03515 /* double cputime; Child's CPU time */ 03516 /* double throughput; Child's throughput */ 03517 /* double actual; Child's actual read/written */ 03518 /* } */ 03519 /* */ 03520 /* There is an array of child_stat structures layed out in */ 03521 /* shared memory. */ 03522 /* */ 03523 /****************************************************************/ 03524 03525 #ifdef HAVE_ANSIC_C 03526 void 03527 throughput_test(void) 03528 #else 03529 void 03530 throughput_test() 03531 #endif 03532 { 03533 char *unit; 03534 double starttime1 = 0; 03535 double jstarttime = 0; 03536 double jtime = 0; 03537 double walltime = 0; 03538 double cputime = 0; 03539 char *port; 03540 char getout; 03541 long long throughsize = KILOBYTES; 03542 long long xx,xy,i; 03543 long long xyz; 03544 double ptotal; 03545 off64_t written_so_far, read_so_far, re_written_so_far,re_read_so_far; 03546 VOLATILE char *temp; 03547 double min_throughput = 0; 03548 double max_throughput = 0; 03549 double avg_throughput = 0; 03550 double min_xfer = 0; 03551 03552 03553 toutputindex=0; 03554 strcpy(&toutput[0][0],throughput_tests[0]); 03555 ptotal=written_so_far=read_so_far=re_written_so_far=re_read_so_far=0 ; 03556 03557 if(OPS_flag) 03558 unit="ops"; 03559 else 03560 unit="KB"; 03561 03562 if(!haveshm) 03563 { 03564 shmaddr=(struct child_stats *)alloc_mem((long long)SHMSIZE,(int)1); 03565 #ifdef _64BIT_ARCH_ 03566 if((long long)shmaddr==(long long)-1) 03567 #else 03568 if((long )shmaddr==(long)-1) 03569 #endif 03570 { 03571 printf("\nShared memory not working\n"); 03572 exit(24); 03573 } 03574 haveshm=(char*)shmaddr; 03575 } 03576 else 03577 shmaddr=(struct child_stats *)haveshm; 03578 03579 if(use_thread) 03580 stop_flag = &stoptime; 03581 else 03582 { 03583 temp = (char *)&shmaddr[0]; 03584 stop_flag = (char *)&temp[(long long)SHMSIZE]-4; 03585 } 03586 for(xyz=0;xyz<num_child;xyz++){ /* all children to state 0 (HOLD) */ 03587 child_stat = (struct child_stats *)&shmaddr[xyz]; 03588 child_stat->flag=CHILD_STATE_HOLD; 03589 child_stat->actual=0; 03590 child_stat->throughput=0; 03591 child_stat->cputime=0; 03592 child_stat->walltime=0; 03593 } 03594 *stop_flag = 0; 03595 if(!sflag) 03596 kilobytes64=throughsize; 03597 if(!rflag) 03598 reclen=(long long)4096; 03599 if(aggflag) 03600 kilobytes64=orig_size/num_child; 03601 numrecs64 = (long long)(kilobytes64*1024)/reclen; 03602 buffer=mainbuffer; 03603 if(use_thread) 03604 port="thread"; 03605 else 03606 port="process"; 03607 if(w_traj_flag) 03608 { 03609 #ifdef NO_PRINT_LLD 03610 if(!silent) printf("\tEach %s writes a %ld Kbyte file in telemetry controlled records\n", 03611 port,kilobytes64); 03612 #else 03613 if(!silent) printf("\tEach %s writes a %lld Kbyte file in telemetry controlled records\n", 03614 port,kilobytes64); 03615 #endif 03616 } 03617 else 03618 { 03619 #ifdef NO_PRINT_LLD 03620 if(!silent) printf("\tEach %s writes a %ld Kbyte file in %ld Kbyte records\n", 03621 port,kilobytes64,reclen/1024); 03622 #else 03623 if(!silent) printf("\tEach %s writes a %lld Kbyte file in %lld Kbyte records\n", 03624 port,kilobytes64,reclen/1024); 03625 #endif 03626 } 03627 03628 if(fflag) /* Each child has a file name to write */ 03629 for(xx=0;xx<num_child;xx++) 03630 filearray[xx] = filename; 03631 myid = (long long)getpid(); 03632 03633 /* rags: skip writer test */ 03634 if(include_tflag) 03635 if(!(include_mask & (long long)WRITER_MASK)) 03636 { 03637 store_dvalue( (double)0); 03638 store_dvalue( (double)0); 03639 toutputindex++; 03640 goto next0; 03641 } 03642 03643 if((!distributed) || (distributed && master_iozone)) 03644 start_monitor("Write"); 03645 /* Hooks to start the distributed Iozone client/server code */ 03646 if(distributed) 03647 { 03648 use_thread=0; /* Turn of any Posix threads */ 03649 if(master_iozone) 03650 master_listen_socket = start_master_listen(); 03651 else 03652 become_client(); 03653 } 03654 if(!use_thread) 03655 { 03656 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 03657 chid=xx; 03658 childids[xx] = start_child_proc(THREAD_WRITE_TEST,numrecs64,reclen); 03659 if(childids[xx]==-1){ 03660 printf("\nFork failed\n"); 03661 for(xy = 0; xy< xx ; xy++){ 03662 if(!use_thread) 03663 kill((pid_t)childids[xy],SIGTERM); 03664 } 03665 exit(25); 03666 } 03667 if(childids[xx]!=0 && debug1) 03668 #ifdef NO_PRINT_LLD 03669 printf("Parent starting slot %ld\n",xx); 03670 #else 03671 printf("Parent starting slot %lld\n",xx); 03672 #endif 03673 if( childids[xx] == 0 ){ 03674 #ifdef _64BIT_ARCH_ 03675 thread_write_test((void *)xx); 03676 #else 03677 thread_write_test((void *)(long)xx); 03678 #endif 03679 }else { 03680 #ifdef NO_PRINT_LLD 03681 sprintf(dummyfile[xx],"%s.DUMMY.%ld",filearray[xx], xx); 03682 #else 03683 sprintf(dummyfile[xx],"%s.DUMMY.%lld",filearray[xx], xx); 03684 #endif 03685 } 03686 } 03687 } 03688 #ifndef NO_THREADS 03689 else 03690 { 03691 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 03692 03693 #ifdef NO_PRINT_LLD 03694 sprintf(dummyfile[xx],"%s.DUMMY.%ld",filearray[xx], xx); 03695 #else 03696 sprintf(dummyfile[xx],"%s.DUMMY.%lld",filearray[xx], xx); 03697 #endif 03698 if(!barray[xx]) 03699 { 03700 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 03701 if(barray[xx] == 0) { 03702 perror("Memory allocation failed:"); 03703 exit(26); 03704 } 03705 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 03706 ~(cache_size-1)); 03707 } 03708 03709 #ifdef _64BIT_ARCH_ 03710 childids[xx] = mythread_create(thread_write_test,(void*)xx); 03711 #else 03712 childids[xx] = mythread_create(thread_write_test,(void*)(long)xx); 03713 #endif 03714 if(childids[xx]==-1){ 03715 printf("Thread create failed\n"); 03716 for(xy = 0; xy< xx ; xy++){ 03717 kill((pid_t)myid,SIGTERM); 03718 } 03719 exit(27); 03720 } 03721 } 03722 } 03723 #endif 03724 if((long long)getpid() == myid) 03725 { 03726 prepage(buffer,reclen); /* Force copy on write */ 03727 /* wait for children to start */ 03728 if(distributed && master_iozone) 03729 { 03730 start_master_listen_loop((int) num_child); 03731 } 03732 for(i=0;i<num_child; i++){ 03733 child_stat = (struct child_stats *)&shmaddr[i]; 03734 while(child_stat->flag==CHILD_STATE_HOLD) 03735 Poll((long long)1); 03736 } 03737 for(i=0;i<num_child; i++) /* Start all children going */ 03738 { 03739 if(delay_start!=0) 03740 Poll((long long)delay_start); 03741 /* State "go" */ 03742 child_stat = (struct child_stats *)&shmaddr[i]; 03743 child_stat->flag=CHILD_STATE_BEGIN; 03744 if(distributed && master_iozone) 03745 tell_children_begin(i); 03746 } 03747 starttime1 = time_so_far(); /* Start parents timer */ 03748 goto waitout; 03749 } 03750 03751 waitout: 03752 getout=0; 03753 if((long long)getpid() == myid) { /* Parent only */ 03754 starttime1 = time_so_far(); /* Wait for all children */ 03755 for( i = 0; i < num_child; i++){ 03756 child_stat = (struct child_stats *) &shmaddr[i]; 03757 if(distributed && master_iozone) 03758 { 03759 printf("\n\tTest running:"); 03760 wait_dist_join(); 03761 break; 03762 } 03763 else 03764 { 03765 if(use_thread) 03766 { 03767 thread_join(childids[i],(void *)&pstatus); 03768 } 03769 else 03770 { 03771 wait(0); 03772 } 03773 } 03774 if(!jstarttime) 03775 jstarttime = time_so_far(); 03776 } 03777 jtime = (time_so_far()-jstarttime)-time_res; 03778 if(jtime < (double).000001) 03779 { 03780 jtime=time_res; 03781 } 03782 } 03783 total_time = (time_so_far() - starttime1)-time_res; /* get parents total time */ 03784 if(total_time < (double).000001) 03785 { 03786 total_time=time_res; 03787 if(rec_prob < reclen) 03788 rec_prob = reclen; 03789 res_prob=1; 03790 } 03791 #ifdef JTIME 03792 total_time=total_time-jtime;/* Remove the join time */ 03793 if(!silent) printf("\nJoin time %10.2f\n",jtime); 03794 #endif 03795 03796 total_kilos=0; 03797 ptotal=0; 03798 walltime = 0.0; 03799 cputime = 0.0; 03800 if(!silent) printf("\n"); 03801 for(xyz=0;xyz<num_child;xyz++){ 03802 child_stat = (struct child_stats *) &shmaddr[xyz]; 03803 total_kilos += child_stat->throughput; /* add up the children */ 03804 ptotal += child_stat->actual; 03805 if(!min_xfer) 03806 min_xfer=child_stat->actual; 03807 if(child_stat->actual < min_xfer) 03808 min_xfer=child_stat->actual; 03809 if(!min_throughput) 03810 min_throughput=child_stat->throughput; 03811 if(child_stat->throughput < min_throughput) 03812 min_throughput=child_stat->throughput; 03813 if(child_stat->throughput > max_throughput) 03814 max_throughput=child_stat->throughput; 03815 /* Add up the cpu times of all children */ 03816 cputime += child_stat->cputime; 03817 03818 /* and find the child with the longest wall time */ 03819 /* Get the earliest start time and latest fini time to calc. elapsed time. */ 03820 if (child_stat->walltime < child_stat->cputime) 03821 child_stat->walltime = child_stat->cputime; 03822 if (child_stat->walltime > walltime) 03823 walltime = child_stat->walltime; 03824 } 03825 avg_throughput=total_kilos/num_child; 03826 if(cpuutilflag) 03827 { 03828 if (cputime < cputime_res) 03829 cputime = 0.0; 03830 } 03831 03832 for(xyz=0;xyz<num_child;xyz++){ 03833 child_stat = (struct child_stats *) &shmaddr[xyz]; 03834 child_stat->flag = CHILD_STATE_HOLD; /* Start children at state 0 (HOLD) */ 03835 } 03836 if(cpuutilflag) 03837 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 03838 store_dvalue(total_kilos); 03839 #ifdef NO_PRINT_LLD 03840 if(!silent) printf("\tChildren see throughput for %2ld initial writers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 03841 if(!silent && !distributed) printf("\tParent sees throughput for %2ld initial writers \t= %10.2f %s/sec\n",num_child,((double)(ptotal)/total_time),unit); 03842 #else 03843 if(!silent) printf("\tChildren see throughput for %2lld initial writers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 03844 if(!silent && !distributed) printf("\tParent sees throughput for %2lld initial writers \t= %10.2f %s/sec\n",num_child,((double)(ptotal)/total_time),unit); 03845 #endif 03846 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 03847 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 03848 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 03849 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 03850 /* CPU% can be > 100.0 for multiple CPUs */ 03851 if(cpuutilflag) 03852 { 03853 if(walltime == 0.0) 03854 { 03855 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 03856 walltime, cputime, 0.0); 03857 } 03858 else 03859 { 03860 if(!silent) printf("\tCPU Utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 03861 walltime, cputime, 100.0 * cputime / walltime); 03862 } 03863 } 03864 if(Cflag) 03865 { 03866 for(xyz=0;xyz<num_child;xyz++) 03867 { 03868 child_stat = (struct child_stats *) &shmaddr[xyz]; 03869 if(cpuutilflag) 03870 { 03871 if(!silent) 03872 printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 03873 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 03874 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 03875 } 03876 else 03877 { 03878 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 03879 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 03880 } 03881 } 03882 } 03883 if((!distributed) || (distributed && master_iozone)) 03884 stop_monitor("Write"); 03885 /**********************************************************/ 03886 /*************** End of intitial writer *******************/ 03887 /**********************************************************/ 03888 sync(); 03889 sleep(2); 03890 if(restf) 03891 sleep((int)rest_val); 03892 *stop_flag=0; 03893 if(distributed && master_iozone) 03894 { 03895 stop_master_listen(master_listen_socket); 03896 cleanup_comm(); 03897 } 03898 03899 /**********************************************************/ 03900 /* Re-write throughput performance test. ******************/ 03901 /**********************************************************/ 03902 walltime = 0.0; 03903 cputime = 0.0; 03904 jstarttime=0; 03905 total_kilos=0; 03906 toutputindex=1; 03907 strcpy(&toutput[1][0],throughput_tests[1]); 03908 if(noretest) 03909 { 03910 store_dvalue( (double)0); 03911 goto next0; 03912 } 03913 if((!distributed) || (distributed && master_iozone)) 03914 start_monitor("Rewrite"); 03915 /* Hooks to start the distributed Iozone client/server code */ 03916 if(distributed) 03917 { 03918 use_thread=0; /* Turn of any Posix threads */ 03919 if(master_iozone) 03920 master_listen_socket = start_master_listen(); 03921 else 03922 become_client(); 03923 } 03924 if(!use_thread) 03925 { 03926 for(xx = 0; xx< num_child ; xx++){ 03927 chid=xx; 03928 childids[xx] = start_child_proc(THREAD_REWRITE_TEST,numrecs64,reclen); 03929 if(childids[xx]==-1){ 03930 printf("\nFork failed\n"); 03931 for(xy = 0; xy< xx ; xy++){ 03932 Kill((long long)childids[xy],(long long)SIGTERM); 03933 } 03934 exit(28); 03935 } 03936 if(childids[xx] == 0){ 03937 #ifdef _64BIT_ARCH_ 03938 thread_rwrite_test((void *)xx); 03939 #else 03940 thread_rwrite_test((void *)((long)xx)); 03941 #endif 03942 } 03943 } 03944 } 03945 #ifndef NO_THREADS 03946 else 03947 { 03948 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 03949 if(!barray[xx]) 03950 { 03951 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 03952 if(barray[xx] == 0) { 03953 perror("Memory allocation failed:"); 03954 exit(26); 03955 } 03956 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 03957 ~(cache_size-1)); 03958 } 03959 #ifdef _64BIT_ARCH_ 03960 childids[xx] = mythread_create( thread_rwrite_test,xx); 03961 #else 03962 childids[xx] = mythread_create( thread_rwrite_test,(void *)(long)xx); 03963 #endif 03964 if(childids[xx]==-1){ 03965 printf("\nThread create failed\n"); 03966 for(xy = 0; xy< xx ; xy++){ 03967 Kill((long long)myid,(long long)SIGTERM); 03968 } 03969 exit(29); 03970 } 03971 } 03972 } 03973 #endif 03974 if((long long)myid == getpid()) 03975 { 03976 if(distributed && master_iozone) 03977 { 03978 start_master_listen_loop((int) num_child); 03979 } 03980 for(i=0;i<num_child; i++){ 03981 child_stat = (struct child_stats *)&shmaddr[i]; 03982 /* wait for children to start */ 03983 while(child_stat->flag==CHILD_STATE_HOLD) 03984 Poll((long long)1); 03985 } 03986 for(i=0;i<num_child; i++) 03987 { 03988 child_stat = (struct child_stats *)&shmaddr[i]; 03989 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 03990 if(delay_start!=0) 03991 Poll((long long)delay_start); 03992 if(distributed && master_iozone) 03993 tell_children_begin(i); 03994 } 03995 starttime1 = time_so_far(); 03996 goto jump3; 03997 } 03998 03999 jump3: 04000 getout=0; 04001 if((long long)myid == getpid()){ /* Parent only here */ 04002 for( i = 0; i < num_child; i++){ 04003 child_stat=(struct child_stats *)&shmaddr[i]; 04004 if(distributed && master_iozone) 04005 { 04006 printf("\n\tTest running:"); 04007 wait_dist_join(); 04008 break; 04009 } 04010 else 04011 { 04012 if(use_thread) 04013 { 04014 thread_join(childids[i],(void *)&pstatus); 04015 } 04016 else 04017 { 04018 wait(0); 04019 } 04020 } 04021 if(!jstarttime) 04022 jstarttime = time_so_far(); 04023 } 04024 jtime = (time_so_far()-jstarttime)-time_res; 04025 if(jtime < (double).000001) 04026 { 04027 jtime=time_res; 04028 } 04029 } 04030 total_time = (time_so_far() - starttime1)-time_res; /* Parents total time */ 04031 if(total_time < (double).000001) 04032 { 04033 total_time=time_res; 04034 if(rec_prob < reclen) 04035 rec_prob = reclen; 04036 res_prob=1; 04037 } 04038 #ifdef JTIME 04039 total_time=total_time-jtime;/* Remove the join time */ 04040 if(!silent) printf("\nJoin time %10.2f\n",jtime); 04041 #endif 04042 04043 04044 total_kilos=0; 04045 ptotal=0; 04046 04047 min_throughput=max_throughput=min_xfer=0; 04048 if(!silent) printf("\n"); 04049 for(xyz=0;xyz<num_child;xyz++){ 04050 child_stat=(struct child_stats *)&shmaddr[xyz]; 04051 total_kilos+=child_stat->throughput; 04052 ptotal+=child_stat->actual; 04053 if(!min_xfer) 04054 min_xfer=child_stat->actual; 04055 if(child_stat->actual < min_xfer) 04056 min_xfer=child_stat->actual; 04057 if(!min_throughput) 04058 min_throughput=child_stat->throughput; 04059 if(child_stat->throughput < min_throughput) 04060 min_throughput=child_stat->throughput; 04061 if(child_stat->throughput > max_throughput) 04062 max_throughput=child_stat->throughput; 04063 cputime += child_stat->cputime; 04064 /* Get the earliest start time and latest fini time to calc. elapsed time. */ 04065 if (child_stat->walltime < child_stat->cputime) 04066 child_stat->walltime = child_stat->cputime; 04067 if (child_stat->walltime > walltime) 04068 walltime = child_stat->walltime; 04069 } 04070 avg_throughput=total_kilos/num_child; 04071 if(cpuutilflag) 04072 { 04073 /* 04074 if (walltime < cputime_res) 04075 walltime = 0.0; 04076 */ 04077 if (cputime < cputime_res) 04078 cputime = 0.0; 04079 } 04080 04081 for(xyz=0;xyz<num_child;xyz++){ /* Reset state to 0 (HOLD) */ 04082 child_stat=(struct child_stats *)&shmaddr[xyz]; 04083 child_stat->flag = CHILD_STATE_HOLD; 04084 } 04085 if(cpuutilflag) 04086 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 04087 store_dvalue(total_kilos); 04088 #ifdef NO_PRINT_LLD 04089 if(!silent) printf("\tChildren see throughput for %2ld rewriters \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 04090 if(!silent && !distributed) printf("\tParent sees throughput for %2ld rewriters \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 04091 #else 04092 if(!silent) printf("\tChildren see throughput for %2lld rewriters \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 04093 if(!silent && !distributed) printf("\tParent sees throughput for %2lld rewriters \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 04094 #endif 04095 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 04096 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 04097 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 04098 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 04099 /* CPU% can be > 100.0 for multiple CPUs */ 04100 if(cpuutilflag) 04101 { 04102 if(walltime == 0.0) 04103 { 04104 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 04105 walltime, cputime, 0.0); 04106 } 04107 else 04108 { 04109 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 04110 walltime, cputime, 100.0 * cputime / walltime); 04111 } 04112 } 04113 if(Cflag) 04114 { 04115 for(xyz=0;xyz<num_child;xyz++) 04116 { 04117 child_stat = (struct child_stats *) &shmaddr[xyz]; 04118 if(cpuutilflag) 04119 { 04120 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 04121 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 04122 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 04123 } 04124 else 04125 { 04126 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 04127 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 04128 } 04129 } 04130 } 04131 *stop_flag=0; 04132 if((!distributed) || (distributed && master_iozone)) 04133 stop_monitor("Rewrite"); 04134 /**********************************************************/ 04135 /*************** End of rewrite throughput ****************/ 04136 /**********************************************************/ 04137 sync(); 04138 sleep(2); 04139 if(restf) 04140 sleep((int)rest_val); 04141 if(distributed && master_iozone) 04142 { 04143 stop_master_listen(master_listen_socket); 04144 cleanup_comm(); 04145 } 04146 next0: 04147 if(include_tflag) 04148 if(!(include_mask & (long long)READER_MASK)) 04149 goto next1; 04150 /**************************************************************/ 04151 /*** Reader throughput tests **********************************/ 04152 /**************************************************************/ 04153 if((!distributed) || (distributed && master_iozone)) 04154 start_monitor("Read"); 04155 toutputindex++; 04156 strcpy(&toutput[toutputindex][0],throughput_tests[2]); 04157 walltime = 0.0; 04158 cputime = 0.0; 04159 jstarttime=0; 04160 total_kilos=0; 04161 if(distributed) 04162 { 04163 use_thread=0; 04164 if(master_iozone) 04165 master_listen_socket=start_master_listen(); 04166 else 04167 become_client(); 04168 } 04169 if(!use_thread) 04170 { 04171 for(xx = 0; xx< num_child ; xx++){ 04172 chid=xx; 04173 childids[xx] = start_child_proc(THREAD_READ_TEST,numrecs64,reclen); 04174 if(childids[xx]==-1){ 04175 printf("\nFork failed\n"); 04176 for(xy = 0; xy< xx ; xy++){ 04177 Kill((long long)childids[xy],(long long)SIGTERM); 04178 } 04179 exit(30); 04180 } 04181 if(childids[xx]==0){ 04182 #ifdef _64BIT_ARCH_ 04183 thread_read_test((void *)xx); 04184 #else 04185 thread_read_test((void *)((long)xx)); 04186 #endif 04187 } 04188 } 04189 } 04190 #ifndef NO_THREADS 04191 else 04192 { 04193 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 04194 if(!barray[xx]) 04195 { 04196 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 04197 if(barray[xx] == 0) { 04198 perror("Memory allocation failed:"); 04199 exit(26); 04200 } 04201 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 04202 ~(cache_size-1)); 04203 } 04204 #ifdef _64BIT_ARCH_ 04205 childids[xx] = mythread_create( thread_read_test,xx); 04206 #else 04207 childids[xx] = mythread_create( thread_read_test,(void *)(long)xx); 04208 #endif 04209 if(childids[xx]==-1){ 04210 printf("\nThread create failed\n"); 04211 for(xy = 0; xy< xx ; xy++){ 04212 kill((pid_t)myid,(int)SIGTERM); 04213 } 04214 exit(31); 04215 } 04216 } 04217 } 04218 #endif 04219 if(myid == (long long)getpid()){ 04220 if(distributed && master_iozone) 04221 { 04222 start_master_listen_loop((int) num_child); 04223 } 04224 for(i=0;i<num_child; i++){ /* wait for children to start */ 04225 child_stat=(struct child_stats *)&shmaddr[i]; 04226 while(child_stat->flag==CHILD_STATE_HOLD) 04227 Poll((long long)1); 04228 } 04229 for(i=0;i<num_child; i++) 04230 { 04231 child_stat=(struct child_stats *)&shmaddr[i]; 04232 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 04233 if(delay_start!=0) 04234 Poll((long long)delay_start); 04235 if(distributed && master_iozone) 04236 tell_children_begin(i); 04237 } 04238 starttime1 = time_so_far(); 04239 goto jumpend4; 04240 } 04241 jumpend4: 04242 getout=0; 04243 if(myid == (long long)getpid()){ /* Parent here */ 04244 for( i = 0; i < num_child; i++){ 04245 child_stat = (struct child_stats *)&shmaddr[i]; 04246 if(distributed && master_iozone) 04247 { 04248 printf("\n\tTest running:"); 04249 wait_dist_join(); 04250 break; 04251 } 04252 else 04253 { 04254 if(use_thread) 04255 { 04256 thread_join(childids[i],(void *)&pstatus); 04257 } 04258 else 04259 { 04260 wait(0); 04261 } 04262 } 04263 if(!jstarttime) 04264 jstarttime = time_so_far(); 04265 } 04266 jtime = (time_so_far()-jstarttime)-time_res; 04267 if(jtime < (double).000001) 04268 { 04269 jtime=time_res; 04270 } 04271 } 04272 total_time = (time_so_far() - starttime1)-time_res; /* Parents time */ 04273 if(total_time < (double).000001) 04274 { 04275 total_time=time_res; 04276 if(rec_prob < reclen) 04277 rec_prob = reclen; 04278 res_prob=1; 04279 } 04280 #ifdef JTIME 04281 total_time=total_time-jtime;/* Remove the join time */ 04282 if(!silent) printf("\nJoin time %10.2f\n",jtime); 04283 #endif 04284 04285 total_kilos=0; 04286 ptotal=0; 04287 min_throughput=max_throughput=min_xfer=0; 04288 if(!silent) printf("\n"); 04289 for(xyz=0;xyz<num_child;xyz++){ 04290 child_stat=(struct child_stats *)&shmaddr[xyz]; 04291 total_kilos+=child_stat->throughput; 04292 ptotal+=child_stat->actual; 04293 if(!min_xfer) 04294 min_xfer=child_stat->actual; 04295 if(child_stat->actual < min_xfer) 04296 min_xfer=child_stat->actual; 04297 if(!min_throughput) 04298 min_throughput=child_stat->throughput; 04299 if(child_stat->throughput < min_throughput) 04300 min_throughput=child_stat->throughput; 04301 if(child_stat->throughput > max_throughput) 04302 max_throughput=child_stat->throughput; 04303 cputime += child_stat->cputime; 04304 /* Get the earliest start time and latest fini time to calc. elapsed time. */ 04305 if (child_stat->walltime < child_stat->cputime) 04306 child_stat->walltime = child_stat->cputime; 04307 if (child_stat->walltime > walltime) 04308 walltime = child_stat->walltime; 04309 } 04310 avg_throughput=total_kilos/num_child; 04311 if(cpuutilflag) 04312 { 04313 if (cputime < cputime_res) 04314 cputime = 0.0; 04315 } 04316 if(cpuutilflag) 04317 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 04318 store_dvalue(total_kilos); 04319 #ifdef NO_PRINT_LLD 04320 if(!silent) printf("\tChildren see throughput for %2ld readers \t\t= %10.2f %s/sec\n", num_child, total_kilos,unit); 04321 if(!silent && !distributed) printf("\tParent sees throughput for %2ld readers \t\t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 04322 #else 04323 if(!silent) printf("\tChildren see throughput for %2lld readers \t\t= %10.2f %s/sec\n", num_child, total_kilos,unit); 04324 if(!silent && !distributed) printf("\tParent sees throughput for %2lld readers \t\t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 04325 #endif 04326 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 04327 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 04328 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 04329 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 04330 /* CPU% can be > 100.0 for multiple CPUs */ 04331 if(cpuutilflag) 04332 { 04333 if(walltime == 0.0) 04334 { 04335 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 04336 walltime, cputime, 0.0); 04337 } 04338 else 04339 { 04340 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 04341 walltime, cputime, 100.0 * cputime / walltime); 04342 } 04343 } 04344 if(Cflag) 04345 { 04346 for(xyz=0;xyz<num_child;xyz++) 04347 { 04348 child_stat = (struct child_stats *) &shmaddr[xyz]; 04349 if(cpuutilflag) 04350 { 04351 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 04352 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 04353 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 04354 } 04355 else 04356 { 04357 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 04358 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 04359 } 04360 } 04361 } 04362 if((!distributed) || (distributed && master_iozone)) 04363 stop_monitor("Read"); 04364 /**********************************************************/ 04365 /*************** End of readers throughput ****************/ 04366 /**********************************************************/ 04367 sync(); 04368 sleep(2); 04369 if(restf) 04370 sleep((int)rest_val); 04371 if(distributed && master_iozone) 04372 { 04373 stop_master_listen(master_listen_socket); 04374 cleanup_comm(); 04375 } 04376 04377 /**************************************************************/ 04378 /*** ReReader throughput tests **********************************/ 04379 /**************************************************************/ 04380 toutputindex++; 04381 strcpy(&toutput[toutputindex][0],throughput_tests[3]); 04382 if(noretest) 04383 { 04384 store_dvalue( (double)0); 04385 goto next1; 04386 } 04387 if((!distributed) || (distributed && master_iozone)) 04388 start_monitor("Reread"); 04389 walltime = 0.0; 04390 cputime = 0.0; 04391 jstarttime=0; 04392 *stop_flag=0; 04393 total_kilos=0; 04394 /* Hooks to start the distributed Iozone client/server code */ 04395 if(distributed) 04396 { 04397 use_thread=0; /* Turn of any Posix threads */ 04398 if(master_iozone) 04399 master_listen_socket = start_master_listen(); 04400 else 04401 become_client(); 04402 } 04403 if(!use_thread) 04404 { 04405 for(xx = 0; xx< num_child ; xx++){ 04406 chid=xx; 04407 childids[xx] = start_child_proc(THREAD_REREAD_TEST, numrecs64,reclen); 04408 if(childids[xx]==-1){ 04409 printf("\nFork failed\n"); 04410 for(xy = 0; xy< xx ; xy++){ 04411 Kill((long long)childids[xy],(long long)SIGTERM); 04412 } 04413 exit(32); 04414 } 04415 if(childids[xx]==0){ 04416 #ifdef _64BIT_ARCH_ 04417 thread_rread_test((void *)xx); 04418 #else 04419 thread_rread_test((void *)((long)xx)); 04420 #endif 04421 } 04422 } 04423 } 04424 #ifndef NO_THREADS 04425 else 04426 { 04427 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 04428 chid=xx; 04429 if(!barray[xx]) 04430 { 04431 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 04432 if(barray[xx] == 0) { 04433 perror("Memory allocation failed:"); 04434 exit(26); 04435 } 04436 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 04437 ~(cache_size-1)); 04438 } 04439 #ifdef _64BIT_ARCH_ 04440 childids[xx] = mythread_create( thread_rread_test,xx); 04441 #else 04442 childids[xx] = mythread_create( thread_rread_test,(void *)(long)xx); 04443 #endif 04444 if(childids[xx]==-1){ 04445 printf("\nThread create failed\n"); 04446 for(xy = 0; xy< xx ; xy++){ 04447 kill((pid_t)myid,(int)SIGTERM); 04448 } 04449 exit(33); 04450 } 04451 } 04452 } 04453 #endif 04454 if(myid == (long long)getpid()){ 04455 if(distributed && master_iozone) 04456 { 04457 start_master_listen_loop((int) num_child); 04458 } 04459 for(i=0;i<num_child; i++){ /* wait for children to start */ 04460 child_stat = (struct child_stats *)&shmaddr[i]; 04461 while(child_stat->flag==CHILD_STATE_HOLD) 04462 Poll((long long)1); 04463 } 04464 for(i=0;i<num_child; i++){ 04465 child_stat = (struct child_stats *)&shmaddr[i]; 04466 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 04467 if(delay_start!=0) 04468 Poll((long long)delay_start); 04469 if(distributed && master_iozone) 04470 tell_children_begin(i); 04471 } 04472 starttime1 = time_so_far(); 04473 goto jumpend2; 04474 } 04475 04476 jumpend2: 04477 getout=0; 04478 if(myid == (long long)getpid()){ /* Parent here */ 04479 for( i = 0; i < num_child; i++){ /* wait for children to stop */ 04480 child_stat = (struct child_stats *)&shmaddr[i]; 04481 if(distributed && master_iozone) 04482 { 04483 printf("\n\tTest running:"); 04484 wait_dist_join(); 04485 break; 04486 } 04487 else 04488 { 04489 if(use_thread) 04490 { 04491 thread_join(childids[i],(void *)&pstatus); 04492 } 04493 else 04494 { 04495 wait(0); 04496 } 04497 } 04498 if(!jstarttime) 04499 jstarttime = time_so_far(); 04500 } 04501 jtime = (time_so_far()-jstarttime)-time_res; 04502 if(jtime < (double).000001) 04503 { 04504 jtime=time_res; 04505 } 04506 } 04507 total_time = (time_so_far() - starttime1)-time_res; /* Parents time */ 04508 if(total_time < (double).000001) 04509 { 04510 total_time=time_res; 04511 if(rec_prob < reclen) 04512 rec_prob = reclen; 04513 res_prob=1; 04514 } 04515 #ifdef JTIME 04516 total_time=total_time-jtime;/* Remove the join time */ 04517 if(!silent) printf("\nJoin time %10.2f\n",jtime); 04518 #endif 04519 min_throughput=max_throughput=min_xfer=0; 04520 total_kilos=0; 04521 ptotal=0; 04522 if(!silent) printf("\n"); 04523 for(xyz=0;xyz<num_child;xyz++){ 04524 child_stat = (struct child_stats *)&shmaddr[xyz]; 04525 total_kilos+=child_stat->throughput; 04526 ptotal+=child_stat->actual; 04527 if(!min_xfer) 04528 min_xfer=child_stat->actual; 04529 if(child_stat->actual < min_xfer) 04530 min_xfer=child_stat->actual; 04531 if(!min_throughput) 04532 min_throughput=child_stat->throughput; 04533 if(child_stat->throughput < min_throughput) 04534 min_throughput=child_stat->throughput; 04535 if(child_stat->throughput > max_throughput) 04536 max_throughput=child_stat->throughput; 04537 cputime += child_stat->cputime; 04538 /* Get the earliest start time and latest fini time to calc. elapsed time. */ 04539 if (child_stat->walltime < child_stat->cputime) 04540 child_stat->walltime = child_stat->cputime; 04541 if (child_stat->walltime > walltime) 04542 walltime = child_stat->walltime; 04543 } 04544 avg_throughput=total_kilos/num_child; 04545 if(cpuutilflag) 04546 { 04547 /* 04548 if (walltime < cputime_res) 04549 walltime = 0.0; 04550 */ 04551 if (cputime < cputime_res) 04552 cputime = 0.0; 04553 } 04554 if(cpuutilflag) 04555 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 04556 store_dvalue(total_kilos); 04557 #ifdef NO_PRINT_LLD 04558 if(!silent) printf("\tChildren see throughput for %ld re-readers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 04559 if(!silent && !distributed) printf("\tParent sees throughput for %ld re-readers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 04560 #else 04561 if(!silent) printf("\tChildren see throughput for %lld re-readers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 04562 if(!silent && !distributed) printf("\tParent sees throughput for %lld re-readers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 04563 #endif 04564 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 04565 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 04566 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 04567 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 04568 /* CPU% can be > 100.0 for multiple CPUs */ 04569 if(cpuutilflag) 04570 { 04571 if(walltime == 0.0) 04572 { 04573 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 04574 walltime, cputime, 0.0); 04575 } 04576 else 04577 { 04578 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 04579 walltime, cputime, 100.0 * cputime / walltime); 04580 } 04581 } 04582 if(Cflag) 04583 { 04584 for(xyz=0;xyz<num_child;xyz++) 04585 { 04586 child_stat = (struct child_stats *) &shmaddr[xyz]; 04587 if(cpuutilflag) 04588 { 04589 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 04590 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 04591 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 04592 } 04593 else 04594 { 04595 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 04596 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 04597 } 04598 } 04599 } 04600 if((!distributed) || (distributed && master_iozone)) 04601 stop_monitor("Reread"); 04602 /**********************************************************/ 04603 /*************** End of re-readers throughput ****************/ 04604 /**********************************************************/ 04605 sync(); 04606 sleep(2); 04607 if(restf) 04608 sleep((int)rest_val); 04609 if(distributed && master_iozone) 04610 { 04611 stop_master_listen(master_listen_socket); 04612 cleanup_comm(); 04613 } 04614 04615 next1: 04616 if(include_tflag) 04617 if(!(include_mask & (long long)REVERSE_MASK)) 04618 goto next2; 04619 sync(); 04620 sleep(2); 04621 04622 /**************************************************************/ 04623 /*** Reverse reader throughput tests **************************/ 04624 /**************************************************************/ 04625 toutputindex++; 04626 strcpy(&toutput[toutputindex][0],throughput_tests[4]); 04627 if((!distributed) || (distributed && master_iozone)) 04628 start_monitor("Revread"); 04629 walltime = 0.0; 04630 cputime = 0.0; 04631 jstarttime=0; 04632 *stop_flag=0; 04633 total_kilos=0; 04634 /* Hooks to start the distributed Iozone client/server code */ 04635 if(distributed) 04636 { 04637 use_thread=0; /* Turn of any Posix threads */ 04638 if(master_iozone) 04639 master_listen_socket = start_master_listen(); 04640 else 04641 become_client(); 04642 } 04643 if(!use_thread) 04644 { 04645 for(xx = 0; xx< num_child ; xx++){ 04646 chid=xx; 04647 childids[xx] = start_child_proc(THREAD_REVERSE_READ_TEST,numrecs64,reclen); 04648 if(childids[xx]==-1){ 04649 printf("\nFork failed\n"); 04650 for(xy = 0; xy< xx ; xy++){ 04651 Kill((long long)childids[xy],(long long)SIGTERM); 04652 } 04653 exit(34); 04654 } 04655 if(childids[xx]==0){ 04656 #ifdef _64BIT_ARCH_ 04657 thread_reverse_read_test((void *)xx); 04658 #else 04659 thread_reverse_read_test((void *)((long)xx)); 04660 #endif 04661 } 04662 } 04663 } 04664 #ifndef NO_THREADS 04665 else 04666 { 04667 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 04668 chid=xx; 04669 if(!barray[xx]) 04670 { 04671 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 04672 if(barray[xx] == 0) { 04673 perror("Memory allocation failed:"); 04674 exit(26); 04675 } 04676 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 04677 ~(cache_size-1)); 04678 } 04679 #ifdef _64BIT_ARCH_ 04680 childids[xx] = mythread_create( thread_reverse_read_test,xx); 04681 #else 04682 childids[xx] = mythread_create( thread_reverse_read_test,(void *)(long)xx); 04683 #endif 04684 if(childids[xx]==-1){ 04685 printf("\nThread create failed\n"); 04686 for(xy = 0; xy< xx ; xy++){ 04687 kill((pid_t)myid,(int)SIGTERM); 04688 } 04689 exit(35); 04690 } 04691 } 04692 } 04693 #endif 04694 if(myid == (long long)getpid()){ 04695 if(distributed && master_iozone) 04696 { 04697 start_master_listen_loop((int) num_child); 04698 } 04699 for(i=0;i<num_child; i++){ /* wait for children to start */ 04700 child_stat = (struct child_stats *)&shmaddr[i]; 04701 while(child_stat->flag==CHILD_STATE_HOLD) 04702 Poll((long long)1); 04703 } 04704 for(i=0;i<num_child; i++){ 04705 child_stat = (struct child_stats *)&shmaddr[i]; 04706 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 04707 if(delay_start!=0) 04708 Poll((long long)delay_start); 04709 if(distributed && master_iozone) 04710 tell_children_begin(i); 04711 } 04712 starttime1 = time_so_far(); 04713 } 04714 04715 getout=0; 04716 if(myid == (long long)getpid()){ /* Parent here */ 04717 for( i = 0; i < num_child; i++){ /* wait for children to stop */ 04718 child_stat = (struct child_stats *)&shmaddr[i]; 04719 if(distributed && master_iozone) 04720 { 04721 printf("\n\tTest running:"); 04722 wait_dist_join(); 04723 break; 04724 } 04725 else 04726 { 04727 if(use_thread) 04728 { 04729 thread_join(childids[i],(void *)&pstatus); 04730 } 04731 else 04732 { 04733 wait(0); 04734 } 04735 } 04736 if(!jstarttime) 04737 jstarttime = time_so_far(); 04738 } 04739 jtime = (time_so_far()-jstarttime)-time_res; 04740 if(jtime < (double).000001) 04741 { 04742 jtime=time_res; 04743 } 04744 } 04745 total_time = (time_so_far() - starttime1)-time_res; /* Parents time */ 04746 if(total_time < (double).000001) 04747 { 04748 total_time=time_res; 04749 if(rec_prob < reclen) 04750 rec_prob = reclen; 04751 res_prob=1; 04752 } 04753 #ifdef JTIME 04754 total_time=total_time-jtime;/* Remove the join time */ 04755 if(!silent) printf("\nJoin time %10.2f\n",jtime); 04756 #endif 04757 total_kilos=0; 04758 ptotal=0; 04759 min_throughput=max_throughput=min_xfer=0; 04760 if(!silent) printf("\n"); 04761 for(xyz=0;xyz<num_child;xyz++){ 04762 child_stat = (struct child_stats *)&shmaddr[xyz]; 04763 total_kilos+=child_stat->throughput; 04764 ptotal+=child_stat->actual; 04765 if(!min_xfer) 04766 min_xfer=child_stat->actual; 04767 if(child_stat->actual < min_xfer) 04768 min_xfer=child_stat->actual; 04769 if(!min_throughput) 04770 min_throughput=child_stat->throughput; 04771 if(child_stat->throughput < min_throughput) 04772 min_throughput=child_stat->throughput; 04773 if(child_stat->throughput > max_throughput) 04774 max_throughput=child_stat->throughput; 04775 /* walltime += child_stat->walltime; */ 04776 cputime += child_stat->cputime; 04777 /* Get the earliest start time and latest fini time to calc. elapsed time. */ 04778 if (child_stat->walltime < child_stat->cputime) 04779 child_stat->walltime = child_stat->cputime; 04780 if (child_stat->walltime > walltime) 04781 walltime = child_stat->walltime; 04782 } 04783 avg_throughput=total_kilos/num_child; 04784 if(cpuutilflag) 04785 { 04786 /* 04787 if (walltime < cputime_res) 04788 walltime = 0.0; 04789 */ 04790 if (cputime < cputime_res) 04791 cputime = 0.0; 04792 } 04793 if(cpuutilflag) 04794 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 04795 store_dvalue(total_kilos); 04796 #ifdef NO_PRINT_LLD 04797 if(!silent) printf("\tChildren see throughput for %ld reverse readers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 04798 if(!silent && !distributed) printf("\tParent sees throughput for %ld reverse readers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 04799 #else 04800 if(!silent) printf("\tChildren see throughput for %lld reverse readers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 04801 if(!silent && !distributed) printf("\tParent sees throughput for %lld reverse readers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 04802 #endif 04803 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 04804 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 04805 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 04806 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 04807 /* CPU% can be > 100.0 for multiple CPUs */ 04808 if(cpuutilflag) 04809 { 04810 if(walltime == 0.0) 04811 { 04812 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 04813 walltime, cputime, 0.0); 04814 } 04815 else 04816 { 04817 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 04818 walltime, cputime, 100.0 * cputime / walltime); 04819 } 04820 } 04821 if(Cflag) 04822 { 04823 for(xyz=0;xyz<num_child;xyz++) 04824 { 04825 child_stat = (struct child_stats *) &shmaddr[xyz]; 04826 if(cpuutilflag) 04827 { 04828 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 04829 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 04830 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 04831 } 04832 else 04833 { 04834 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 04835 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 04836 } 04837 } 04838 } 04839 if((!distributed) || (distributed && master_iozone)) 04840 stop_monitor("Revread"); 04841 sync(); 04842 sleep(2); 04843 if(restf) 04844 sleep((int)rest_val); 04845 if(distributed && master_iozone) 04846 { 04847 stop_master_listen(master_listen_socket); 04848 cleanup_comm(); 04849 } 04850 next2: 04851 if(include_tflag) 04852 if(!(include_mask & (long long)STRIDE_READ_MASK)) 04853 goto next3; 04854 /**************************************************************/ 04855 /*** stride reader throughput tests **************************/ 04856 /**************************************************************/ 04857 toutputindex++; 04858 strcpy(&toutput[toutputindex][0],throughput_tests[5]); 04859 if((!distributed) || (distributed && master_iozone)) 04860 start_monitor("Strideread"); 04861 walltime = 0.0; 04862 cputime = 0.0; 04863 jstarttime=0; 04864 sync(); 04865 sleep(2); 04866 *stop_flag=0; 04867 total_kilos=0; 04868 /* Hooks to start the distributed Iozone client/server code */ 04869 if(distributed) 04870 { 04871 use_thread=0; /* Turn of any Posix threads */ 04872 if(master_iozone) 04873 master_listen_socket = start_master_listen(); 04874 else 04875 become_client(); 04876 } 04877 if(!use_thread) 04878 { 04879 for(xx = 0; xx< num_child ; xx++){ 04880 chid=xx; 04881 childids[xx] = start_child_proc(THREAD_STRIDE_TEST,numrecs64,reclen); 04882 if(childids[xx]==-1){ 04883 printf("\nFork failed\n"); 04884 for(xy = 0; xy< xx ; xy++){ 04885 Kill((long long)childids[xy],(long long)SIGTERM); 04886 } 04887 exit(36); 04888 } 04889 if(childids[xx]==0){ 04890 #ifdef _64BIT_ARCH_ 04891 thread_stride_read_test((void *)xx); 04892 #else 04893 thread_stride_read_test((void *)((long)xx)); 04894 #endif 04895 } 04896 } 04897 } 04898 #ifndef NO_THREADS 04899 else 04900 { 04901 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 04902 chid=xx; 04903 if(!barray[xx]) 04904 { 04905 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 04906 if(barray[xx] == 0) { 04907 perror("Memory allocation failed:"); 04908 exit(26); 04909 } 04910 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 04911 ~(cache_size-1)); 04912 } 04913 #ifdef _64BIT_ARCH_ 04914 childids[xx] = mythread_create( thread_stride_read_test,xx); 04915 #else 04916 childids[xx] = mythread_create( thread_stride_read_test,(void *)(long)xx); 04917 #endif 04918 if(childids[xx]==-1){ 04919 printf("\nThread create failed\n"); 04920 for(xy = 0; xy< xx ; xy++){ 04921 kill((pid_t)myid,(int)SIGTERM); 04922 } 04923 exit(37); 04924 } 04925 } 04926 } 04927 #endif 04928 if(myid == (long long)getpid()){ 04929 if(distributed && master_iozone) 04930 { 04931 start_master_listen_loop((int) num_child); 04932 } 04933 for(i=0;i<num_child; i++){ /* wait for children to start */ 04934 child_stat = (struct child_stats *)&shmaddr[i]; 04935 while(child_stat->flag==CHILD_STATE_HOLD) 04936 Poll((long long)1); 04937 } 04938 for(i=0;i<num_child; i++){ 04939 child_stat = (struct child_stats *)&shmaddr[i]; 04940 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 04941 if(delay_start!=0) 04942 Poll((long long)delay_start); 04943 if(distributed && master_iozone) 04944 tell_children_begin(i); 04945 } 04946 starttime1 = time_so_far(); 04947 } 04948 04949 getout=0; 04950 if(myid == (long long)getpid()){ /* Parent here */ 04951 for( i = 0; i < num_child; i++){ /* wait for children to stop */ 04952 child_stat = (struct child_stats *)&shmaddr[i]; 04953 if(distributed && master_iozone) 04954 { 04955 printf("\n\tTest running:"); 04956 wait_dist_join(); 04957 break; 04958 } 04959 else 04960 { 04961 if(use_thread) 04962 { 04963 thread_join(childids[i],(void *)&pstatus); 04964 } 04965 else 04966 { 04967 wait(0); 04968 } 04969 } 04970 if(!jstarttime) 04971 jstarttime = time_so_far(); 04972 } 04973 jtime = (time_so_far()-jstarttime)-time_res; 04974 if(jtime < (double).000001) 04975 { 04976 jtime=time_res; 04977 } 04978 } 04979 total_time = (time_so_far() - starttime1)-time_res; /* Parents time */ 04980 if(total_time < (double).000001) 04981 { 04982 total_time=time_res; 04983 if(rec_prob < reclen) 04984 rec_prob = reclen; 04985 res_prob=1; 04986 } 04987 #ifdef JTIME 04988 total_time=total_time-jtime;/* Remove the join time */ 04989 if(!silent) printf("\nJoin time %10.2f\n",jtime); 04990 #endif 04991 total_kilos=0; 04992 ptotal=0; 04993 min_throughput=max_throughput=min_xfer=0; 04994 if(!silent) printf("\n"); 04995 for(xyz=0;xyz<num_child;xyz++){ 04996 child_stat = (struct child_stats *)&shmaddr[xyz]; 04997 total_kilos+=child_stat->throughput; 04998 ptotal+=child_stat->actual; 04999 if(!min_xfer) 05000 min_xfer=child_stat->actual; 05001 if(child_stat->actual < min_xfer) 05002 min_xfer=child_stat->actual; 05003 if(!min_throughput) 05004 min_throughput=child_stat->throughput; 05005 if(child_stat->throughput < min_throughput) 05006 min_throughput=child_stat->throughput; 05007 if(child_stat->throughput > max_throughput) 05008 max_throughput=child_stat->throughput; 05009 /* walltime += child_stat->walltime; */ 05010 cputime += child_stat->cputime; 05011 /* Get the biggest walltime */ 05012 if (child_stat->walltime < child_stat->cputime) 05013 child_stat->walltime = child_stat->cputime; 05014 if (child_stat->walltime > walltime) 05015 walltime = child_stat->walltime; 05016 } 05017 avg_throughput=total_kilos/num_child; 05018 if(cpuutilflag) 05019 { 05020 /* 05021 if (walltime < cputime_res) 05022 walltime = 0.0; 05023 */ 05024 if (cputime < cputime_res) 05025 cputime = 0.0; 05026 } 05027 if(cpuutilflag) 05028 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 05029 store_dvalue(total_kilos); 05030 #ifdef NO_PRINT_LLD 05031 if(!silent) printf("\tChildren see throughput for %ld stride readers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05032 if(!silent && !distributed) printf("\tParent sees throughput for %ld stride readers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05033 #else 05034 if(!silent) printf("\tChildren see throughput for %lld stride readers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05035 if(!silent && !distributed) printf("\tParent sees throughput for %lld stride readers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05036 #endif 05037 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 05038 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 05039 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 05040 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 05041 /* CPU% can be > 100.0 for multiple CPUs */ 05042 if(cpuutilflag) 05043 { 05044 if(walltime == 0.0) 05045 { 05046 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 05047 walltime, cputime, 0.0); 05048 } 05049 else 05050 { 05051 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 05052 walltime, cputime, 100.0 * cputime / walltime); 05053 } 05054 } 05055 if(Cflag) 05056 { 05057 for(xyz=0;xyz<num_child;xyz++) 05058 { 05059 child_stat = (struct child_stats *) &shmaddr[xyz]; 05060 if(cpuutilflag) 05061 { 05062 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 05063 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 05064 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 05065 } 05066 else 05067 { 05068 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 05069 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 05070 } 05071 } 05072 } 05073 if((!distributed) || (distributed && master_iozone)) 05074 stop_monitor("Strideread"); 05075 sync(); 05076 sleep(2); 05077 if(restf) 05078 sleep((int)rest_val); 05079 if(distributed && master_iozone) 05080 { 05081 stop_master_listen(master_listen_socket); 05082 cleanup_comm(); 05083 } 05084 /**************************************************************/ 05085 /*** random reader throughput tests ***************************/ 05086 /**************************************************************/ 05087 next3: 05088 if(include_tflag) 05089 if(!(include_mask & (long long)RANDOM_RW_MASK)) 05090 goto next4; 05091 05092 toutputindex++; 05093 strcpy(&toutput[toutputindex][0],throughput_tests[6]); 05094 if((!distributed) || (distributed && master_iozone)) 05095 start_monitor("Randread"); 05096 walltime = 0.0; 05097 cputime = 0.0; 05098 jstarttime=0; 05099 sync(); 05100 sleep(2); 05101 *stop_flag=0; 05102 total_kilos=0; 05103 /* Hooks to start the distributed Iozone client/server code */ 05104 if(distributed) 05105 { 05106 use_thread=0; /* Turn of any Posix threads */ 05107 if(master_iozone) 05108 master_listen_socket = start_master_listen(); 05109 else 05110 become_client(); 05111 } 05112 if(!use_thread) 05113 { 05114 for(xx = 0; xx< num_child ; xx++){ 05115 chid=xx; 05116 childids[xx] = start_child_proc(THREAD_RANDOM_READ_TEST,numrecs64,reclen); 05117 if(childids[xx]==-1){ 05118 printf("\nFork failed\n"); 05119 for(xy = 0; xy< xx ; xy++){ 05120 Kill((long long)childids[xy],(long long)SIGTERM); 05121 } 05122 exit(38); 05123 } 05124 if(childids[xx]==0){ 05125 #ifdef _64BIT_ARCH_ 05126 thread_ranread_test((void *)xx); 05127 #else 05128 thread_ranread_test((void *)((long)xx)); 05129 #endif 05130 } 05131 } 05132 } 05133 #ifndef NO_THREADS 05134 else 05135 { 05136 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 05137 chid=xx; 05138 if(!barray[xx]) 05139 { 05140 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 05141 if(barray[xx] == 0) { 05142 perror("Memory allocation failed:"); 05143 exit(26); 05144 } 05145 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 05146 ~(cache_size-1)); 05147 } 05148 #ifdef _64BIT_ARCH_ 05149 childids[xx] = mythread_create( thread_ranread_test,xx); 05150 #else 05151 childids[xx] = mythread_create( thread_ranread_test,(void *)(long)xx); 05152 #endif 05153 if(childids[xx]==-1){ 05154 printf("\nThread create failed\n"); 05155 for(xy = 0; xy< xx ; xy++){ 05156 kill((pid_t)myid,(int)SIGTERM); 05157 } 05158 exit(39); 05159 } 05160 } 05161 } 05162 #endif 05163 if(myid == (long long)getpid()){ 05164 if(distributed && master_iozone) 05165 { 05166 start_master_listen_loop((int) num_child); 05167 } 05168 for(i=0;i<num_child; i++){ /* wait for children to start */ 05169 child_stat = (struct child_stats *)&shmaddr[i]; 05170 while(child_stat->flag==CHILD_STATE_HOLD) 05171 Poll((long long)1); 05172 } 05173 for(i=0;i<num_child; i++){ 05174 child_stat = (struct child_stats *)&shmaddr[i]; 05175 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 05176 if(delay_start!=0) 05177 Poll((long long)delay_start); 05178 if(distributed && master_iozone) 05179 tell_children_begin(i); 05180 } 05181 starttime1 = time_so_far(); 05182 } 05183 05184 getout=0; 05185 if(myid == (long long)getpid()){ /* Parent here */ 05186 for( i = 0; i < num_child; i++){ /* wait for children to stop */ 05187 child_stat = (struct child_stats *)&shmaddr[i]; 05188 if(distributed && master_iozone) 05189 { 05190 printf("\n\tTest running:"); 05191 wait_dist_join(); 05192 break; 05193 } 05194 else 05195 { 05196 if(use_thread) 05197 { 05198 thread_join(childids[i],(void *)&pstatus); 05199 } 05200 else 05201 { 05202 wait(0); 05203 } 05204 } 05205 if(!jstarttime) 05206 jstarttime = time_so_far(); 05207 } 05208 jtime = (time_so_far()-jstarttime)-time_res; 05209 if(jtime < (double).000001) 05210 { 05211 jtime=time_res; 05212 } 05213 } 05214 total_time = (time_so_far() - starttime1)-time_res; /* Parents time */ 05215 if(total_time < (double).000001) 05216 { 05217 total_time=time_res; 05218 if(rec_prob < reclen) 05219 rec_prob = reclen; 05220 res_prob=1; 05221 } 05222 #ifdef JTIME 05223 total_time=total_time-jtime;/* Remove the join time */ 05224 if(!silent) printf("\nJoin time %10.2f\n",jtime); 05225 #endif 05226 total_kilos=0; 05227 ptotal=0; 05228 min_throughput=max_throughput=min_xfer=0; 05229 if(!silent) printf("\n"); 05230 for(xyz=0;xyz<num_child;xyz++){ 05231 child_stat = (struct child_stats *)&shmaddr[xyz]; 05232 total_kilos+=child_stat->throughput; 05233 ptotal+=child_stat->actual; 05234 if(!min_xfer) 05235 min_xfer=child_stat->actual; 05236 if(child_stat->actual < min_xfer) 05237 min_xfer=child_stat->actual; 05238 if(!min_throughput) 05239 min_throughput=child_stat->throughput; 05240 if(child_stat->throughput < min_throughput) 05241 min_throughput=child_stat->throughput; 05242 if(child_stat->throughput > max_throughput) 05243 max_throughput=child_stat->throughput; 05244 cputime += child_stat->cputime; 05245 /* Get the biggest walltime */ 05246 if (child_stat->walltime < child_stat->cputime) 05247 child_stat->walltime = child_stat->cputime; 05248 if (child_stat->walltime > walltime) 05249 walltime = child_stat->walltime; 05250 } 05251 avg_throughput=total_kilos/num_child; 05252 if(cpuutilflag) 05253 { 05254 if (cputime < cputime_res) 05255 cputime = 0.0; 05256 } 05257 if(cpuutilflag) 05258 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 05259 store_dvalue(total_kilos); 05260 #ifdef NO_PRINT_LLD 05261 if(!silent) printf("\tChildren see throughput for %ld random readers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05262 if(!silent && !distributed) printf("\tParent sees throughput for %ld random readers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05263 #else 05264 if(!silent) printf("\tChildren see throughput for %lld random readers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05265 if(!silent && !distributed) printf("\tParent sees throughput for %lld random readers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05266 #endif 05267 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 05268 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 05269 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 05270 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 05271 /* CPU% can be > 100.0 for multiple CPUs */ 05272 if(cpuutilflag) 05273 { 05274 if(walltime == 0.0) 05275 { 05276 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 05277 walltime, cputime, 0.0); 05278 } 05279 else 05280 { 05281 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 05282 walltime, cputime, 100.0 * cputime / walltime); 05283 } 05284 } 05285 if(Cflag) 05286 { 05287 for(xyz=0;xyz<num_child;xyz++) 05288 { 05289 child_stat = (struct child_stats *) &shmaddr[xyz]; 05290 if(cpuutilflag) 05291 { 05292 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 05293 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 05294 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 05295 } 05296 else 05297 { 05298 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 05299 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 05300 } 05301 } 05302 } 05303 if((!distributed) || (distributed && master_iozone)) 05304 stop_monitor("Randread"); 05305 sync(); 05306 sleep(2); 05307 if(restf) 05308 sleep((int)rest_val); 05309 if(distributed && master_iozone) 05310 { 05311 stop_master_listen(master_listen_socket); 05312 cleanup_comm(); 05313 } 05314 /**************************************************************/ 05315 /*** mixed workload throughput tests ***************************/ 05316 /**************************************************************/ 05317 next4: 05318 if(include_tflag) 05319 if(!(include_mask & (long long)RANDOM_MIX_MASK)) 05320 goto next5; 05321 05322 toutputindex++; 05323 strcpy(&toutput[toutputindex][0],throughput_tests[7]); 05324 if((!distributed) || (distributed && master_iozone)) 05325 start_monitor("Mixed"); 05326 walltime = 0.0; 05327 cputime = 0.0; 05328 jstarttime=0; 05329 sync(); 05330 sleep(2); 05331 *stop_flag=0; 05332 total_kilos=0; 05333 /* Hooks to start the distributed Iozone client/server code */ 05334 if(distributed) 05335 { 05336 use_thread=0; /* Turn of any Posix threads */ 05337 if(master_iozone) 05338 master_listen_socket = start_master_listen(); 05339 else 05340 become_client(); 05341 } 05342 if(!use_thread) 05343 { 05344 for(xx = 0; xx< num_child ; xx++){ 05345 chid=xx; 05346 childids[xx] = start_child_proc(THREAD_RANDOM_MIX_TEST,numrecs64,reclen); 05347 if(childids[xx]==-1){ 05348 printf("\nFork failed\n"); 05349 for(xy = 0; xy< xx ; xy++){ 05350 Kill((long long)childids[xy],(long long)SIGTERM); 05351 } 05352 exit(38); 05353 } 05354 if(childids[xx]==0){ 05355 #ifdef _64BIT_ARCH_ 05356 thread_mix_test((void *)xx); 05357 #else 05358 thread_mix_test((void *)((long)xx)); 05359 #endif 05360 } 05361 } 05362 } 05363 #ifndef NO_THREADS 05364 else 05365 { 05366 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 05367 chid=xx; 05368 if(!barray[xx]) 05369 { 05370 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 05371 if(barray[xx] == 0) { 05372 perror("Memory allocation failed:"); 05373 exit(26); 05374 } 05375 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 05376 ~(cache_size-1)); 05377 } 05378 #ifdef _64BIT_ARCH_ 05379 childids[xx] = mythread_create( thread_mix_test,xx); 05380 #else 05381 childids[xx] = mythread_create( thread_mix_test,(void *)(long)xx); 05382 #endif 05383 if(childids[xx]==-1){ 05384 printf("\nThread create failed\n"); 05385 for(xy = 0; xy< xx ; xy++){ 05386 kill((pid_t)myid,(int)SIGTERM); 05387 } 05388 exit(39); 05389 } 05390 } 05391 } 05392 #endif 05393 if(myid == (long long)getpid()){ 05394 if(distributed && master_iozone) 05395 { 05396 start_master_listen_loop((int) num_child); 05397 } 05398 for(i=0;i<num_child; i++){ /* wait for children to start */ 05399 child_stat = (struct child_stats *)&shmaddr[i]; 05400 while(child_stat->flag==CHILD_STATE_HOLD) 05401 Poll((long long)1); 05402 } 05403 for(i=0;i<num_child; i++){ 05404 child_stat = (struct child_stats *)&shmaddr[i]; 05405 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 05406 if(delay_start!=0) 05407 Poll((long long)delay_start); 05408 if(distributed && master_iozone) 05409 tell_children_begin(i); 05410 } 05411 starttime1 = time_so_far(); 05412 } 05413 05414 getout=0; 05415 if(myid == (long long)getpid()){ /* Parent here */ 05416 for( i = 0; i < num_child; i++){ /* wait for children to stop */ 05417 child_stat = (struct child_stats *)&shmaddr[i]; 05418 if(distributed && master_iozone) 05419 { 05420 printf("\n\tTest running:"); 05421 wait_dist_join(); 05422 break; 05423 } 05424 else 05425 { 05426 if(use_thread) 05427 { 05428 thread_join(childids[i],(void *)&pstatus); 05429 } 05430 else 05431 { 05432 wait(0); 05433 } 05434 } 05435 if(!jstarttime) 05436 jstarttime = time_so_far(); 05437 } 05438 jtime = (time_so_far()-jstarttime)-time_res; 05439 if(jtime < (double).000001) 05440 { 05441 jtime=time_res; 05442 } 05443 } 05444 total_time = (time_so_far() - starttime1)-time_res; /* Parents time */ 05445 if(total_time < (double).000001) 05446 { 05447 total_time=time_res; 05448 if(rec_prob < reclen) 05449 rec_prob = reclen; 05450 res_prob=1; 05451 } 05452 #ifdef JTIME 05453 total_time=total_time-jtime;/* Remove the join time */ 05454 if(!silent) printf("\nJoin time %10.2f\n",jtime); 05455 #endif 05456 total_kilos=0; 05457 ptotal=0; 05458 min_throughput=max_throughput=min_xfer=0; 05459 if(!silent) printf("\n"); 05460 for(xyz=0;xyz<num_child;xyz++){ 05461 child_stat = (struct child_stats *)&shmaddr[xyz]; 05462 total_kilos+=child_stat->throughput; 05463 ptotal+=child_stat->actual; 05464 if(!min_xfer) 05465 min_xfer=child_stat->actual; 05466 if(child_stat->actual < min_xfer) 05467 min_xfer=child_stat->actual; 05468 if(!min_throughput) 05469 min_throughput=child_stat->throughput; 05470 if(child_stat->throughput < min_throughput) 05471 min_throughput=child_stat->throughput; 05472 if(child_stat->throughput > max_throughput) 05473 max_throughput=child_stat->throughput; 05474 cputime += child_stat->cputime; 05475 /* Get the biggest walltime */ 05476 if (child_stat->walltime < child_stat->cputime) 05477 child_stat->walltime = child_stat->cputime; 05478 if (child_stat->walltime > walltime) 05479 walltime = child_stat->walltime; 05480 } 05481 avg_throughput=total_kilos/num_child; 05482 if(cpuutilflag) 05483 { 05484 if (cputime < cputime_res) 05485 cputime = 0.0; 05486 } 05487 if(cpuutilflag) 05488 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 05489 store_dvalue(total_kilos); 05490 #ifdef NO_PRINT_LLD 05491 if(!silent) printf("\tChildren see throughput for %ld mixed workload \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05492 if(!silent && !distributed) printf("\tParent sees throughput for %ld mixed workload \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05493 #else 05494 if(!silent) printf("\tChildren see throughput for %lld mixed workload \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05495 if(!silent && !distributed) printf("\tParent sees throughput for %lld mixed workload \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05496 #endif 05497 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 05498 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 05499 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 05500 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 05501 /* CPU% can be > 100.0 for multiple CPUs */ 05502 if(cpuutilflag) 05503 { 05504 if(walltime == 0.0) 05505 { 05506 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 05507 walltime, cputime, 0.0); 05508 } 05509 else 05510 { 05511 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 05512 walltime, cputime, 100.0 * cputime / walltime); 05513 } 05514 } 05515 if(Cflag) 05516 { 05517 for(xyz=0;xyz<num_child;xyz++) 05518 { 05519 child_stat = (struct child_stats *) &shmaddr[xyz]; 05520 if(cpuutilflag) 05521 { 05522 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 05523 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 05524 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 05525 } 05526 else 05527 { 05528 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 05529 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 05530 } 05531 } 05532 } 05533 if((!distributed) || (distributed && master_iozone)) 05534 stop_monitor("Mixed"); 05535 sync(); 05536 sleep(2); 05537 if(restf) 05538 sleep((int)rest_val); 05539 if(distributed && master_iozone) 05540 { 05541 stop_master_listen(master_listen_socket); 05542 cleanup_comm(); 05543 } 05544 next5: 05545 /**************************************************************/ 05546 /*** random writer throughput tests **************************/ 05547 /**************************************************************/ 05548 if(include_tflag) 05549 if(!(include_mask & (long long)RANDOM_RW_MASK) || no_write) 05550 goto next6; 05551 05552 toutputindex++; 05553 strcpy(&toutput[toutputindex][0],throughput_tests[8]); 05554 if((!distributed) || (distributed && master_iozone)) 05555 start_monitor("Randwrite"); 05556 walltime = 0.0; 05557 cputime = 0.0; 05558 jstarttime=0; 05559 sync(); 05560 sleep(2); 05561 *stop_flag=0; 05562 total_kilos=0; 05563 /* Hooks to start the distributed Iozone client/server code */ 05564 if(distributed) 05565 { 05566 use_thread=0; /* Turn of any Posix threads */ 05567 if(master_iozone) 05568 master_listen_socket = start_master_listen(); 05569 else 05570 become_client(); 05571 } 05572 if(!use_thread) 05573 { 05574 for(xx = 0; xx< num_child ; xx++){ 05575 chid=xx; 05576 childids[xx] = start_child_proc(THREAD_RANDOM_WRITE_TEST,numrecs64,reclen); 05577 if(childids[xx]==-1){ 05578 printf("\nFork failed\n"); 05579 for(xy = 0; xy< xx ; xy++){ 05580 Kill((long long)childids[xy],(long long)SIGTERM); 05581 } 05582 exit(38); 05583 } 05584 if(childids[xx]==0){ 05585 #ifdef _64BIT_ARCH_ 05586 thread_ranwrite_test((void *)xx); 05587 #else 05588 thread_ranwrite_test((void *)((long)xx)); 05589 #endif 05590 } 05591 } 05592 } 05593 #ifndef NO_THREADS 05594 else 05595 { 05596 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 05597 chid=xx; 05598 if(!barray[xx]) 05599 { 05600 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 05601 if(barray[xx] == 0) { 05602 perror("Memory allocation failed:"); 05603 exit(26); 05604 } 05605 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 05606 ~(cache_size-1)); 05607 } 05608 #ifdef _64BIT_ARCH_ 05609 childids[xx] = mythread_create( thread_ranwrite_test,xx); 05610 #else 05611 childids[xx] = mythread_create( thread_ranwrite_test,(void *)(long)xx); 05612 #endif 05613 if(childids[xx]==-1){ 05614 printf("\nThread create failed\n"); 05615 for(xy = 0; xy< xx ; xy++){ 05616 kill((pid_t)myid,(int)SIGTERM); 05617 } 05618 exit(39); 05619 } 05620 } 05621 } 05622 #endif 05623 if(myid == (long long)getpid()){ 05624 if(distributed && master_iozone) 05625 { 05626 start_master_listen_loop((int) num_child); 05627 } 05628 for(i=0;i<num_child; i++){ /* wait for children to start */ 05629 child_stat = (struct child_stats *)&shmaddr[i]; 05630 while(child_stat->flag==CHILD_STATE_HOLD) 05631 Poll((long long)1); 05632 } 05633 for(i=0;i<num_child; i++){ 05634 child_stat = (struct child_stats *)&shmaddr[i]; 05635 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 05636 if(delay_start!=0) 05637 Poll((long long)delay_start); 05638 if(distributed && master_iozone) 05639 tell_children_begin(i); 05640 } 05641 starttime1 = time_so_far(); 05642 } 05643 05644 getout=0; 05645 if(myid == (long long)getpid()){ /* Parent here */ 05646 for( i = 0; i < num_child; i++){ /* wait for children to stop */ 05647 child_stat = (struct child_stats *)&shmaddr[i]; 05648 if(distributed && master_iozone) 05649 { 05650 printf("\n\tTest running:"); 05651 wait_dist_join(); 05652 break; 05653 } 05654 else 05655 { 05656 if(use_thread) 05657 { 05658 thread_join(childids[i],(void *)&pstatus); 05659 } 05660 else 05661 { 05662 wait(0); 05663 } 05664 } 05665 if(!jstarttime) 05666 jstarttime = time_so_far(); 05667 } 05668 jtime = (time_so_far()-jstarttime)-time_res; 05669 if(jtime < (double).000001) 05670 { 05671 jtime=time_res; 05672 } 05673 } 05674 total_time = (time_so_far() - starttime1)-time_res; /* Parents time */ 05675 if(total_time < (double).000001) 05676 { 05677 total_time=time_res; 05678 if(rec_prob < reclen) 05679 rec_prob = reclen; 05680 res_prob=1; 05681 } 05682 #ifdef JTIME 05683 total_time=total_time-jtime;/* Remove the join time */ 05684 if(!silent) printf("\nJoin time %10.2f\n",jtime); 05685 #endif 05686 total_kilos=0; 05687 ptotal=0; 05688 min_throughput=max_throughput=min_xfer=0; 05689 if(!silent) printf("\n"); 05690 for(xyz=0;xyz<num_child;xyz++){ 05691 child_stat = (struct child_stats *)&shmaddr[xyz]; 05692 total_kilos+=child_stat->throughput; 05693 ptotal+=child_stat->actual; 05694 if(!min_xfer) 05695 min_xfer=child_stat->actual; 05696 if(child_stat->actual < min_xfer) 05697 min_xfer=child_stat->actual; 05698 if(!min_throughput) 05699 min_throughput=child_stat->throughput; 05700 if(child_stat->throughput < min_throughput) 05701 min_throughput=child_stat->throughput; 05702 if(child_stat->throughput > max_throughput) 05703 max_throughput=child_stat->throughput; 05704 cputime += child_stat->cputime; 05705 /* Get the biggest walltime */ 05706 if (child_stat->walltime < child_stat->cputime) 05707 child_stat->walltime = child_stat->cputime; 05708 if (child_stat->walltime > walltime) 05709 walltime = child_stat->walltime; 05710 } 05711 avg_throughput=total_kilos/num_child; 05712 if(cpuutilflag) 05713 { 05714 if (cputime < cputime_res) 05715 cputime = 0.0; 05716 } 05717 if(cpuutilflag) 05718 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 05719 store_dvalue(total_kilos); 05720 #ifdef NO_PRINT_LLD 05721 if(!silent) printf("\tChildren see throughput for %ld random writers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05722 if(!silent && !distributed) printf("\tParent sees throughput for %ld random writers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05723 #else 05724 if(!silent) printf("\tChildren see throughput for %lld random writers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05725 if(!silent && !distributed) printf("\tParent sees throughput for %lld random writers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05726 #endif 05727 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 05728 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 05729 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 05730 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 05731 /* CPU% can be > 100.0 for multiple CPUs */ 05732 if(cpuutilflag) 05733 { 05734 if(walltime == 0.0) 05735 { 05736 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 05737 walltime, cputime, 0.0); 05738 } 05739 else 05740 { 05741 if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n", 05742 walltime, cputime, 100.0 * cputime / walltime); 05743 } 05744 } 05745 if(Cflag) 05746 { 05747 for(xyz=0;xyz<num_child;xyz++) 05748 { 05749 child_stat = (struct child_stats *) &shmaddr[xyz]; 05750 if(cpuutilflag) 05751 { 05752 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n", 05753 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime, 05754 child_stat->cputime, cpu_util(child_stat->cputime, child_stat->walltime)); 05755 } 05756 else 05757 { 05758 if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n", 05759 (long)xyz, child_stat->actual, unit, child_stat->throughput, unit); 05760 } 05761 } 05762 } 05763 if((!distributed) || (distributed && master_iozone)) 05764 stop_monitor("Randwrite"); 05765 sync(); 05766 sleep(2); 05767 if(restf) 05768 sleep((int)rest_val); 05769 if(distributed && master_iozone) 05770 { 05771 stop_master_listen(master_listen_socket); 05772 cleanup_comm(); 05773 } 05774 next6: 05775 /**************************************************************/ 05776 /*** Pwrite writer throughput tests **************************/ 05777 /**************************************************************/ 05778 #ifndef HAVE_PREAD 05779 goto next7; 05780 #else 05781 if(include_tflag) 05782 if(!(include_mask & (long long)PWRITER_MASK)) 05783 goto next7; 05784 05785 toutputindex++; 05786 strcpy(&toutput[toutputindex][0],throughput_tests[9]); 05787 if((!distributed) || (distributed && master_iozone)) 05788 start_monitor("Pwrite"); 05789 walltime = 0.0; 05790 cputime = 0.0; 05791 jstarttime=0; 05792 sync(); 05793 sleep(2); 05794 *stop_flag=0; 05795 total_kilos=0; 05796 /* Hooks to start the distributed Iozone client/server code */ 05797 if(distributed) 05798 { 05799 use_thread=0; /* Turn of any Posix threads */ 05800 if(master_iozone) 05801 master_listen_socket = start_master_listen(); 05802 else 05803 become_client(); 05804 } 05805 if(!use_thread) 05806 { 05807 for(xx = 0; xx< num_child ; xx++){ 05808 chid=xx; 05809 childids[xx] = start_child_proc(THREAD_PWRITE_TEST,numrecs64,reclen); 05810 if(childids[xx]==-1){ 05811 printf("\nFork failed\n"); 05812 for(xy = 0; xy< xx ; xy++){ 05813 Kill((long long)childids[xy],(long long)SIGTERM); 05814 } 05815 exit(38); 05816 } 05817 if(childids[xx]==0){ 05818 #ifdef _64BIT_ARCH_ 05819 thread_pwrite_test((void *)xx); 05820 #else 05821 thread_pwrite_test((void *)((long)xx)); 05822 #endif 05823 } 05824 } 05825 } 05826 #ifndef NO_THREADS 05827 else 05828 { 05829 for(xx = 0; xx< num_child ; xx++){ /* Create the children */ 05830 chid=xx; 05831 if(!barray[xx]) 05832 { 05833 barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0); 05834 if(barray[xx] == 0) { 05835 perror("Memory allocation failed:"); 05836 exit(26); 05837 } 05838 barray[xx] =(char *)(((long)barray[xx] + cache_size ) & 05839 ~(cache_size-1)); 05840 } 05841 #ifdef _64BIT_ARCH_ 05842 childids[xx] = mythread_create( thread_pwrite_test,xx); 05843 #else 05844 childids[xx] = mythread_create( thread_pwrite_test,(void *)(long)xx); 05845 #endif 05846 if(childids[xx]==-1){ 05847 printf("\nThread create failed\n"); 05848 for(xy = 0; xy< xx ; xy++){ 05849 kill((pid_t)myid,(int)SIGTERM); 05850 } 05851 exit(39); 05852 } 05853 } 05854 } 05855 #endif 05856 if(myid == (long long)getpid()){ 05857 if(distributed && master_iozone) 05858 { 05859 start_master_listen_loop((int) num_child); 05860 } 05861 for(i=0;i<num_child; i++){ /* wait for children to start */ 05862 child_stat = (struct child_stats *)&shmaddr[i]; 05863 while(child_stat->flag==CHILD_STATE_HOLD) 05864 Poll((long long)1); 05865 } 05866 for(i=0;i<num_child; i++){ 05867 child_stat = (struct child_stats *)&shmaddr[i]; 05868 child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */ 05869 if(delay_start!=0) 05870 Poll((long long)delay_start); 05871 if(distributed && master_iozone) 05872 tell_children_begin(i); 05873 } 05874 starttime1 = time_so_far(); 05875 } 05876 05877 getout=0; 05878 if(myid == (long long)getpid()){ /* Parent here */ 05879 for( i = 0; i < num_child; i++){ /* wait for children to stop */ 05880 child_stat = (struct child_stats *)&shmaddr[i]; 05881 if(distributed && master_iozone) 05882 { 05883 printf("\n\tTest running:"); 05884 wait_dist_join(); 05885 break; 05886 } 05887 else 05888 { 05889 if(use_thread) 05890 { 05891 thread_join(childids[i],(void *)&pstatus); 05892 } 05893 else 05894 { 05895 wait(0); 05896 } 05897 } 05898 if(!jstarttime) 05899 jstarttime = time_so_far(); 05900 } 05901 jtime = (time_so_far()-jstarttime)-time_res; 05902 if(jtime < (double).000001) 05903 { 05904 jtime=time_res; 05905 } 05906 } 05907 total_time = (time_so_far() - starttime1)-time_res; /* Parents time */ 05908 if(total_time < (double).000001) 05909 { 05910 total_time=time_res; 05911 if(rec_prob < reclen) 05912 rec_prob = reclen; 05913 res_prob=1; 05914 } 05915 #ifdef JTIME 05916 total_time=total_time-jtime;/* Remove the join time */ 05917 if(!silent) printf("\nJoin time %10.2f\n",jtime); 05918 #endif 05919 total_kilos=0; 05920 ptotal=0; 05921 min_throughput=max_throughput=min_xfer=0; 05922 if(!silent) printf("\n"); 05923 for(xyz=0;xyz<num_child;xyz++){ 05924 child_stat = (struct child_stats *)&shmaddr[xyz]; 05925 total_kilos+=child_stat->throughput; 05926 ptotal+=child_stat->actual; 05927 if(!min_xfer) 05928 min_xfer=child_stat->actual; 05929 if(child_stat->actual < min_xfer) 05930 min_xfer=child_stat->actual; 05931 if(!min_throughput) 05932 min_throughput=child_stat->throughput; 05933 if(child_stat->throughput < min_throughput) 05934 min_throughput=child_stat->throughput; 05935 if(child_stat->throughput > max_throughput) 05936 max_throughput=child_stat->throughput; 05937 cputime += child_stat->cputime; 05938 /* Get the biggest walltime*/ 05939 if (child_stat->walltime < child_stat->cputime) 05940 child_stat->walltime = child_stat->cputime; 05941 if (child_stat->walltime > walltime) 05942 walltime = child_stat->walltime; 05943 } 05944 avg_throughput=total_kilos/num_child; 05945 if(cpuutilflag) 05946 { 05947 if (cputime < cputime_res) 05948 cputime = 0.0; 05949 } 05950 if(cpuutilflag) 05951 store_times (walltime, cputime); /* Must be Before store_dvalue(). */ 05952 store_dvalue(total_kilos); 05953 #ifdef NO_PRINT_LLD 05954 if(!silent) printf("\tChildren see throughput for %ld pwrite writers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05955 if(!silent && !distributed) printf("\tParent sees throughput for %ld pwrite writers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05956 #else 05957 if(!silent) printf("\tChildren see throughput for %lld pwrite writers \t= %10.2f %s/sec\n", num_child, total_kilos,unit); 05958 if(!silent && !distributed) printf("\tParent sees throughput for %lld pwrite writers \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit); 05959 #endif 05960 if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit); 05961 if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit); 05962 if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit); 05963 if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit); 05964 /* CPU% can be > 100.0 for multiple CPUs */ 05965 if(cpuutilflag) 05966 {