PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
iozone.c
Go to the documentation of this file.
1 /************************************************************************/
2 /* Original Author: */
3 /* William Norcott (wnorcott@us.oracle.com) */
4 /* 4 Dunlap Drive */
5 /* Nashua, NH 03060 */
6 /* */
7 /************************************************************************/
8 /* Enhancements by: */
9 /* Don Capps (capps@iozone.org) */
10 /* 7417 Crenshaw */
11 /* Plano, TX 75025 */
12 /* */
13 /************************************************************************/
14 /* Copyright 1991, 1992, 1994, 1998, 2000, 2001 William D. Norcott */
15 /************************************************************************/
16 /* */
17 /* Iozone is based on the original work done by William Norrcot. It has */
18 /* been enhanced so that it provides a more complete filesystem */
19 /* characterization. */
20 /* Its purpose is to provide automated filesystem characterization. */
21 /* Enhancements have been made by: */
22 /* */
23 /* Don Capps capps@iozone.org */
24 /* */
25 /* Iozone can perform single stream and multi stream I/O */
26 /* also it now performs read, write, re-read, re-write, */
27 /* read backwards, read/write random, re-read record, */
28 /* pread, re-pread, re-pwrite, preadv, re-preadv, pwritev, */
29 /* stride read, and re-pwritev,mmap, POSIX async I/O, NFS */
30 /* cluster testing and much more. */
31 /* */
32 /* The frontend now uses getopt() and the user can control many more */
33 /* of the actions. */
34 /* */
35 /* */
36 /************************************************************************/
37 /* THIS SOFTWARE IS PROVIDED BY DON CAPPS AND THE IOZONE CREW "AS IS */
38 /* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
39 /* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
40 /* PARTICULAR PURPOSE ARE DISCLAIMED. */
41 /* */
42 /* IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY */
43 /* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL */
44 /* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
45 /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS */
46 /* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER */
47 /* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR */
48 /* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE. */
49 /************************************************************************/
50 
51 /************************************************************************/
52 /* For the beginner... */
53 /* */
54 /* 1. make linux (linux, hpux, convex, hpux_no_ansi) */
55 /* 2. type ./iozone -Ra */
56 /* */
57 /* Hint: Type make (it will give you a list of valid targets) */
58 /* */
59 /************************************************************************/
60 
61 
62 /* The version number */
63 #define THISVERSION " Version $Revision$"
64 
65 #if defined(linux)
66  #define _GNU_SOURCE
67 #endif
68 /* Include for Cygnus development environment for Windows */
69 #if defined (Windows)
70 #include <windows.h>
71 #include <errno.h>
72 #else
73 #if defined(linux) || defined(solaris) || defined(macosx) || defined(__AIX__) || defined(FreeBSD) || defined(_HPUX_SOURCE)
74 #include <errno.h>
75 #else
76 extern int errno; /* imported for errors */
77 extern int h_errno; /* imported for errors */
78 #endif
79 #endif
80 
81 
82 #include <sys/types.h>
83 #include <sys/stat.h>
84 #if defined (__LP64__) || defined(OSF_64) || defined(__alpha__) || defined(__arch64__) || defined(_LP64) || defined(__s390x__) || defined(__AMD64__)
85 #define MODE "\tCompiled for 64 bit mode."
86 #define _64BIT_ARCH_
87 #else
88 #define MODE "\tCompiled for 32 bit mode."
89 #endif
90 
91 #ifndef NO_THREADS
92 #include <pthread.h>
93 #endif
94 
95 #if defined(HAVE_ANSIC_C) && defined(linux)
96 #include <stdlib.h>
97 #include <sys/wait.h>
98 #endif
99 
100 #ifdef HAVE_PROTO
101 #include "proto.h"
102 #else
103 int atoi();
104 int close();
105 int unlink();
106 int main();
107 void record_command_line();
108 #if !defined(linux)
109 int wait();
110 #endif
111 int fsync();
112 void srand48();
113 long lrand48();
114 void create_list();
115 void Poll();
116 void print_header();
117 void Kill();
118 long long l_min();
119 long long l_max();
120 long long mythread_create();
121 int gen_new_buf();
122 void touch_dedup();
123 void init_by_array64(unsigned long long *, unsigned long long );
124 unsigned long long genrand64_int64(void);
125 #endif
126 
127 #include <fcntl.h>
128 
129 char *help[] = {
130 " Usage: iozone [-s filesize_Kb] [-r record_size_Kb] [-f [path]filename] [-h]",
131 " [-i test] [-E] [-p] [-a] [-A] [-z] [-Z] [-m] [-M] [-t children]",
132 " [-l min_number_procs] [-u max_number_procs] [-v] [-R] [-x] [-o]",
133 " [-d microseconds] [-F path1 path2...] [-V pattern] [-j stride]",
134 " [-T] [-C] [-B] [-D] [-G] [-I] [-H depth] [-k depth] [-U mount_point]",
135 " [-S cache_size] [-O] [-L cacheline_size] [-K] [-g maxfilesize_Kb]",
136 " [-n minfilesize_Kb] [-N] [-Q] [-P start_cpu] [-e] [-c] [-b Excel.xls]",
137 " [-J milliseconds] [-X write_telemetry_filename] [-w] [-W]",
138 " [-Y read_telemetry_filename] [-y minrecsize_Kb] [-q maxrecsize_Kb]",
139 " [-+u] [-+m cluster_filename] [-+d] [-+x multiplier] [-+p # ]",
140 " [-+r] [-+t] [-+X] [-+Z] [-+w percent dedupable] [-+y percent_interior_dedup]",
141 " [-+C percent_dedup_within]",
142 " ",
143 " -a Auto mode",
144 " -A Auto2 mode",
145 " -b Filename Create Excel worksheet file",
146 " -B Use mmap() files",
147 " -c Include close in the timing calculations",
148 " -C Show bytes transferred by each child in throughput testing",
149 " -d # Microsecond delay out of barrier",
150 " -D Use msync(MS_ASYNC) on mmap files",
151 " -e Include flush (fsync,fflush) in the timing calculations",
152 " -E Run extension tests",
153 " -f filename to use",
154 " -F filenames for each process/thread in throughput test",
155 " -g # Set maximum file size (in Kbytes) for auto mode (or #m or #g)",
156 " -G Use msync(MS_SYNC) on mmap files",
157 " -h help",
158 " -H # Use POSIX async I/O with # async operations",
159 " -i # Test to run (0=write/rewrite, 1=read/re-read, 2=random-read/write",
160 " 3=Read-backwards, 4=Re-write-record, 5=stride-read, 6=fwrite/re-fwrite",
161 " 7=fread/Re-fread, 8=random_mix, 9=pwrite/Re-pwrite, 10=pread/Re-pread",
162 " 11=pwritev/Re-pwritev, 12=preadv/Re-preadv)",
163 " -I Use VxFS VX_DIRECT, O_DIRECT,or O_DIRECTIO for all file operations",
164 " -j # Set stride of file accesses to (# * record size)",
165 " -J # milliseconds of compute cycle before each I/O operation",
166 " -k # Use POSIX async I/O (no bcopy) with # async operations",
167 " -K Create jitter in the access pattern for readers",
168 " -l # Lower limit on number of processes to run",
169 " -L # Set processor cache line size to value (in bytes)",
170 " -m Use multiple buffers",
171 " -M Report uname -a output",
172 " -n # Set minimum file size (in Kbytes) for auto mode (or #m or #g)",
173 " -N Report results in microseconds per operation",
174 " -o Writes are synch (O_SYNC)",
175 " -O Give results in ops/sec.",
176 " -p Purge on",
177 " -P # Bind processes/threads to processors, starting with this cpu",
178 " -q # Set maximum record size (in Kbytes) for auto mode (or #m or #g)",
179 " -Q Create offset/latency files",
180 " -r # record size in Kb",
181 " or -r #k .. size in Kb",
182 " or -r #m .. size in Mb",
183 " or -r #g .. size in Gb",
184 " -R Generate Excel report",
185 " -s # file size in Kb",
186 " or -s #k .. size in Kb",
187 " or -s #m .. size in Mb",
188 " or -s #g .. size in Gb",
189 " -S # Set processor cache size to value (in Kbytes)",
190 " -t # Number of threads or processes to use in throughput test",
191 " -T Use POSIX pthreads for throughput tests",
192 " -u # Upper limit on number of processes to run",
193 " -U Mount point to remount between tests",
194 " -v version information",
195 " -V # Verify data pattern write/read",
196 " -w Do not unlink temporary file",
197 " -W Lock file when reading or writing",
198 " -x Turn off stone-walling",
199 " -X filename Write telemetry file. Contains lines with (offset reclen compute_time) in ascii",
200 " -y # Set minimum record size (in Kbytes) for auto mode (or #m or #g)",
201 " -Y filename Read telemetry file. Contains lines with (offset reclen compute_time) in ascii",
202 " -z Used in conjunction with -a to test all possible record sizes",
203 " -Z Enable mixing of mmap I/O and file I/O",
204 " -+E Use existing non-Iozone file for read-only testing",
205 " -+K Sony special. Manual control of test 8.",
206 " -+m Cluster_filename Enable Cluster testing",
207 " -+d File I/O diagnostic mode. (To troubleshoot a broken file I/O subsystem)",
208 " -+u Enable CPU utilization output (Experimental)",
209 " -+x # Multiplier to use for incrementing file and record sizes",
210 " -+p # Percentage of mix to be reads",
211 " -+r Enable O_RSYNC|O_SYNC for all testing.",
212 " -+t Enable network performance test. Requires -+m ",
213 " -+n No retests selected.",
214 " -+k Use constant aggregate data set size.",
215 " -+q Delay in seconds between tests.",
216 " -+l Enable record locking mode.",
217 " -+L Enable record locking mode, with shared file.",
218 " -+B Sequential mixed workload.",
219 #if defined(O_DSYNC)
220 " -+D Enable O_DSYNC mode.",
221 #endif
222 #ifndef NO_MADVISE
223 " -+A # Enable madvise. 0 = normal, 1=random, 2=sequential",
224 " 3=dontneed, 4=willneed",
225 #endif
226 " -+N Do not truncate existing files on sequential writes.",
227 " -+S # Dedup-able data is limited to sharing within each numerically",
228 " identified file set",
229 " -+V Enable shared file. No locking.",
230 #if defined(Windows)
231 " -+U Windows Unbufferd I/O API (Very Experimental)",
232 #endif
233 " -+X Enable short circuit mode for filesystem testing ONLY",
234 " ALL Results are NOT valid in this mode.",
235 " -+Z Enable old data set compatibility mode. WARNING.. Published",
236 " hacks may invalidate these results and generate bogus, high",
237 " values for results.",
238 " -+w ## Percent of dedup-able data in buffers.",
239 " -+y ## Percent of dedup-able within & across files in buffers.",
240 " -+C ## Percent of dedup-able within & not across files in buffers.",
241 " -+H Hostname Hostname of the PIT server.",
242 " -+P Service Service of the PIT server.",
243 " -+z Enable latency histogram logging.",
244 "" };
245 
246 char *head1[] = {
247  " 'Iozone' Filesystem Benchmark Program",
248  " ",
250  MODE,
251  " ",
252  " Original Author: William Norcott (wnorcott@us.oracle.com)",
253  " 4 Dunlap Drive",
254  " Nashua, NH 03060",
255  " ",
256  " Enhancements: Don Capps (capps@iozone.org)",
257  " 7417 Crenshaw",
258  " Plano, TX 75025",
259  " ",
260  " Copyright 1991, 1992, 1994, 1998, 1999, 2002 William D. Norcott",
261  " ",
262  " License to freely use and distribute this software is hereby granted ",
263  " by the author, subject to the condition that this copyright notice ",
264  " remains intact. The author retains the exclusive right to publish ",
265  " derivative works based on this work, including, but not limited to, ",
266  " revised versions of this work",
267  " ",
268  " Other contributors:",
269  " ",
270  " Don Capps (Network Appliance) capps@iozone.org",
271  " ",
272  ""};
273 
274 /******************************************************************
275 
276  INCLUDE FILES (system-dependent)
277 
278 ******************************************************************/
279 #include <sys/mman.h>
280 #include <stdio.h>
281 #include <signal.h>
282 #include <unistd.h>
283 
284 #include <fcntl.h>
285 #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__DragonFly__)
286 #include <malloc.h>
287 #endif
288 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__DragonFly__)
289 #include <stdlib.h>
290 #include <string.h>
291 #endif
292 
293 #if defined (__FreeBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__APPLE__) || defined(__DragonFly__)
294 #ifndef O_SYNC
295 #define O_SYNC O_FSYNC
296 #endif
297 #endif
298 
299 #if defined (__FreeBSD__)
300 #ifndef O_RSYNC
301 #define O_RSYNC O_FSYNC
302 #endif
303 #endif
304 
305 #if ((defined(solaris) && defined(__LP64__)) || defined(__s390x__))
306 /* If we are building for 64-bit Solaris, all functions that return pointers
307  * must be declared before they are used; otherwise the compiler will assume
308  * that they return ints and the top 32 bits of the pointer will be lost,
309  * causing segmentation faults. The following includes take care of this.
310  * It should be safe to add these for all other OSs too, but we're only
311  * doing it for Solaris now in case another OS turns out to be a special case.
312  */
313 #include <strings.h>
314 #include <stdlib.h>
315 #include <sys/socket.h>
316 #include <netinet/in.h>
317 #include <arpa/inet.h>
318 
319 #endif
320 #if ( defined(solaris) && defined(studio11) )
321 #include <strings.h>
322 #include <stdlib.h>
323 #endif
324 
325 #if defined(OSFV5) || defined(linux)
326 #include <string.h>
327 #endif
328 
329 #if defined(linux)
330 #include <sys/socket.h>
331 #include <netinet/in.h>
332 #include <arpa/inet.h>
333 #endif
334 
335 #ifndef MAP_FAILED
336 #define MAP_FAILED -1
337 #endif
338 
339 #ifdef generic
340 typedef long long off64_t;
341 #endif
342 
343 #if defined(__DragonFly__)
344 #define __off64_t_defined
345 typedef off_t off64_t;
346 #endif
347 
348 
349 #ifndef solaris
350 #ifndef off64_t
351 #ifndef _OFF64_T
352 #ifndef __AIX__
353 #ifndef __off64_t_defined
354 #ifndef SCO_Unixware_gcc
355 #ifndef UWIN
356 #ifndef __DragonFly__
357 typedef long long off64_t;
358 #endif
359 #endif
360 #endif
361 #endif
362 #endif
363 #endif
364 #endif
365 #endif
366 
367 #ifdef __AIX__
368 #include <fcntl.h>
369 #endif
370 
371 #ifdef VXFS
372 #include <sys/fs/vx_ioctl.h>
373 #endif
374 
375 #ifdef unix
376 #if defined (__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) \
377  || defined(_SUA_)
378 #include <sys/time.h>
379 #endif
380 #include <sys/times.h>
381 #include <sys/file.h>
382 #include <sys/resource.h>
383 #ifndef NULL
384 #define NULL 0
385 #endif
386 
387 #ifndef nolimits
388 #include <limits.h>
389 #endif
390 #endif
391 
392 #ifdef HAVE_ANSIC_C
393 #define VOLATILE volatile
394 #else
395 #define VOLATILE
396 #endif
397 
398 #include <sys/time.h>
399 
400 #ifdef SHARED_MEM
401 #include <sys/shm.h>
402 #endif
403 
404 #if defined(bsd4_2) && !defined(MS_SYNC)
405 #define MS_SYNC 0
406 #define MS_ASYNC 0
407 #endif
408 
409 #if defined(bsd4_4) || defined(__DragonFly__)
410 #define MAP_ANONYMOUS MAP_ANON
411 #endif
412 
413 #if defined(SCO_Unixware_gcc) || defined(solaris) || defined(UWIN) || defined(SCO)
414 #define MAP_FILE (0)
415 #endif
416 
417 #if defined(IRIX) || defined(IRIX64) || defined(Windows) || defined(bsd4_2) || defined(bsd4_4) || defined(SCO) || defined(Solaris) || defined(SCO_Unixware_gcc)
418 long long page_size = 4096;
419 #define GOT_PAGESIZE 1
420 #elif defined(NBPG)
421 long long page_size = NBPG;
422 #define GOT_PAGESIZE 1
423 #elif defined(old_linux)
424 #include <asm/page.h>
425 long long page_size = PAGE_SIZE;
426 #define GOT_PAGESIZE 1
427 #elif !defined(GOT_PAGESIZE)
428 long long page_size = 4096; /* Used when all else fails */
429 #endif
430 
431 #ifdef HAVE_PREAD
432 #ifdef HAVE_PREADV
433 #define PVECMAX 16
434 
435 #ifdef _HPUX_SOURCE
436 #define PER_VECTOR_OFFSET
437 #include <sys/puio.h>
438 struct piovec piov[PVECMAX];
439 #else
440 #include <sys/uio.h>
441 struct iovec piov[PVECMAX];
442 #define piov_base iov_base
443 #define piov_len iov_len
444 #endif
445 
446 #endif
447 #endif
448 
449 #define DEDUPSEED 0x2719362
450 
451 
452 /*
453  * In multi thread/process throughput mode each child keeps track of
454  * statistics and communicates them through various flavors of
455  * shared memory, and via messages.
456  */
457 struct child_stats {
458  long long flag; /* control space */
459  long long flag1; /* pad */
460  float walltime; /* child elapsed time */
461  float cputime; /* child CPU time */
462  float throughput; /* Throughput in either kb/sec or ops/sec */
463  float actual; /* Either actual kb read or # of ops performed */
465 
466 /*
467  * Used for cpu time statistics.
468  */
469 struct runtime {
470  float walltime;
471  float cputime;
472  float cpuutil;
473 };
474 
475 #ifdef __convex_spp
476 #include <sys/cnx_ail.h>
477 #endif
478 
479 #include <sys/socket.h>
480 #include <netinet/in.h>
481 #include <netdb.h>
482 
483 
484 /*
485  * Messages the controlling process sends to children.
486  * Internal representation that is arch specific.
487  * This is used when using the network distributed mode.
488  */
490  char c_host_name[100];
491  char c_pit_hostname[40];
492  char c_pit_service[8];
493  char c_client_name[100];
494  char c_working_dir[200];
495  char c_file_name[200];
496  char c_path_dir[200];
497  char c_execute_name[200];
500  int c_oflag;
501  int c_mfflag;
506  int c_jflag;
508  int c_k_flag;
509  int c_h_flag;
510  int c_mflag;
511  int c_pflag;
513  int c_verify;
515  int c_odsync;
516  int c_diag_v;
517  int c_dedup;
524  int c_Q_flag;
525  int c_L_flag;
536  int c_xflag;
563  int c_restf;
564  int c_mygen;
565  long long c_stride;
566  long long c_rest_val;
567  long long c_delay;
568  long long c_purge;
569  long long c_fetchon;
570  long long c_numrecs64;
571  long long c_reclen;
572  long long c_child_flag;
573  long long c_delay_start;
574  long long c_depth;
576 };
577 
578 /*
579  * All data in this is in string format for portability in a
580  * hetrogeneous environment.
581  *
582  * Messages that the master will send to the clients
583  * over the socket. This provides neutral format
584  * so that heterogeneous clusters will work.
585  * This is used when using the network distributed mode.
586  * WARNING !!! This data structure MUST not be bigger
587  * than 1448 bytes or fragmentation will kick your butt.
588  */
590  char c_host_name[100];
591  char c_pit_hostname[40];
592  char c_pit_service[8];
593  char c_client_name[100];
594  char c_working_dir[200];
595  char c_file_name[200];
596  char c_path_dir[200];
597  char c_execute_name[200];
600  char c_oflag[2];
601  char c_mfflag[2];
602  char c_unbuffered[2];
603  char c_noretest[2];
604  char c_notruncate[2];
605  char c_read_sync[2];
606  char c_jflag[2];
607  char c_async_flag[2];
608  char c_k_flag[2];
609  char c_h_flag[2];
610  char c_mflag[2];
611  char c_pflag[2];
612  char c_stride_flag[2];
613  char c_verify[2];
614  char c_sverify[2];
615  char c_odsync[2];
616  char c_diag_v[2];
617  char c_dedup[4];
620  char c_dedup_mseed[4];
621  char c_hist_summary[4];
622  char c_op_rate[4];
623  char c_op_rate_flag[2];
624  char c_Q_flag[2];
625  char c_L_flag[2];
626  char c_OPS_flag[2];
627  char c_mmapflag[2];
628  char c_mmapasflag[2];
629  char c_mmapnsflag[2];
630  char c_mmapssflag[2];
631  char c_no_copy_flag[2];
634  char c_disrupt_flag[2];
635  char c_compute_flag[2];
636  char c_stop_flag[2];
637  char c_xflag[2];
638  char c_MS_flag[2];
639  char c_mmap_mix[2];
640  char c_Kplus_flag[2];
641  char c_w_traj_flag[2]; /* small int */
642  char c_r_traj_flag[2]; /* small int */
643  char c_direct_flag[2]; /* small int */
644  char c_cpuutilflag[2]; /* small int */
645  char c_seq_mix[2]; /* small int */
646  char c_stride[10]; /* small long long */
647  char c_rest_val[10]; /* small long long */
648  char c_purge[10]; /* very small long long */
649  char c_fetchon[10]; /* very small long long */
650  char c_multiplier[10]; /* small int */
651  char c_share_file[10]; /* small int */
652  char c_file_lock[10]; /* small int */
653  char c_rec_lock[10]; /* small int */
654  char c_Kplus_readers[10]; /* small int */
655  char c_client_number[20]; /* int */
656  char c_command[20]; /* int */
657  char c_testnum[20]; /* int */
658  char c_no_unlink[4]; /* int */
659  char c_no_write[4]; /* int */
660  char c_pattern[20]; /* int */
661  char c_version[20]; /* int */
662  char c_base_time[20]; /* int */
663  char c_num_child[20]; /* int */
664  char c_pct_read[6]; /* small int */
665  char c_advise_op[4]; /* small int */
666  char c_advise_flag[4]; /* small int */
667  char c_restf[4]; /* small int */
668  char c_mygen[20]; /* long */
669  char c_depth[20]; /* small long long */
670  char c_child_flag[40]; /* small long long */
671  char c_delay[80]; /* long long */
672  char c_numrecs64[80]; /* long long */
673  char c_reclen[80]; /* long long */
674  char c_delay_start[80]; /* long long */
675  char c_compute_time[80]; /* float */
676 };
677 
678 /*
679  * Messages the clients will send to the master.
680  * Internal representation on each client and the master.
681  * This is used when using the network distributed mode.
682  */
684  char m_host_name[100];
685  char m_client_name[100];
686  char m_stop_flag;
694  int m_mygen;
696  float m_cputime;
697  float m_walltime;
698  float m_actual;
699  long long m_child_flag;
700 };
701 
702 /*
703  * Messages that the clients will send to the master
704  * over the socket. This provides neutral format
705  * so that heterogeneous clusters will work.
706  * This is used when using the network distributed mode.
707  */
709  char m_host_name[100];
710  char m_client_name[100];
711  char m_client_number[20]; /* int */
712  char m_client_error[20]; /* int */
713  char m_stop_flag[4]; /* char +space */
714  char m_child_port[20]; /* int */
715  char m_child_async_port[20]; /* int */
716  char m_command[20]; /* int */
717  char m_testnum[20]; /* int */
718  char m_version[20]; /* int */
719  char m_mygen[20]; /* int */
720  char m_throughput[80]; /* float */
721  char m_cputime[80]; /* float */
722  char m_walltime[80]; /* float */
723  char m_actual[80]; /* float */
724  char m_child_flag[80]; /* long long */
725 };
726 
727 
728 /*
729  * Possible values for the commands sent to the master
730  */
731 #define R_CHILD_JOIN 1
732 #define R_STAT_DATA 2
733 #define R_FLAG_DATA 3
734 
735 /*
736  * Possible values for the master's commands sent to a client
737  *
738  * The R_FLAG_DATA is also used by the master to tell the
739  * client to update its flags.
740  */
741 #define R_JOIN_ACK 4
742 #define R_STOP_FLAG 5
743 #define R_TERMINATE 6
744 #define R_DEATH 7
745 
746 
747 /* These are the defaults for the processor. They can be
748  * over written by the command line options.
749  */
750 #define CACHE_LINE_SIZE 32
751 #define CACHE_SIZE ( 1024 * 1024 )
752 
753 
754 #define MEG (1024 * 1024)
755 
756 /*
757  * For stride testing use a prime number to avoid stripe
758  * wrap hitting the same spindle.
759  */
760 #define STRIDE 17
761 
762 
763 
764 /************************************************************************/
765 /* */
766 /* DEFINED CONSTANTS */
767 /* */
768 /* Never add a comment to the end of a #define. Some compilers will */
769 /* choke and fail the compile. */
770 /************************************************************************/
771 
772 /*
773  * Size of buffer for capturing the machine's name.
774  */
775 #define IBUFSIZE 100
776 /*
777  * How many I/Os before a non-uniform access.
778  */
779 #define DISRUPT 100
780 
781 /*
782  * Set the crossover size. This is where the small transfers
783  * are skipped to save time. There is an option to
784  * disable the skipping.
785  */
786 #define LARGE_REC 65536
787 
788 /* Default number of kilobytes in file */
789 #define KILOBYTES 512
790 
791 /* Default number of bytes in a record */
792 #define RECLEN 1024
793 
794 /* Default size of file in bytes*/
795 #define FILESIZE (KILOBYTES*1024)
796 
797 /* Default number of records */
798 #define NUMRECS FILESIZE/RECLEN
799 
800 #ifdef __bsdi__
801 /* At 8 Meg switch to large records */
802 #define CROSSOVER (8*1024)
803 /*maximum buffer size*/
804 #define MAXBUFFERSIZE (8*1024*1024)
805 #else
806 /* At 16 Meg switch to large records */
807 #define CROSSOVER (16*1024)
808 /* Maximum buffer size*/
809 #define MAXBUFFERSIZE (16*1024*1024)
810 #endif
811 
812 /* Maximum number of children. Threads/procs/clients */
813 #define MAXSTREAMS 256
814 
815 /* Minimum buffer size */
816 #define MINBUFFERSIZE 128
817 /* If things ran way too fast */
818 #define TOOFAST 10
819 /* Set the maximum number of types of tests */
820 #define MAXTESTS 12
821 /* Default fill pattern for verification */
822 #define PATTERN get_pattern();
823 #define PATTERN1 0xBB
824 /* Used for Excel internal tables */
825 #define MAX_X 100
826 /* Used for Excel internal tables */
827 #define MAX_Y 512
828 
829 #define USAGE "\tUsage: For usage information type iozone -h \n\n"
830 
831 
832 /* Maximum number of characters in filename */
833 #define MAXNAMESIZE 1000
834 
835 /*
836  * Define the typical output that the user will see on their
837  * screen.
838  */
839 #ifdef NO_PRINT_LLD
840 #ifdef HAVE_PREAD
841 #include <sys/times.h>
842 #if defined(HAVE_PREAD) && defined(HAVE_PREADV)
843 #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"
844 #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"
845 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
846 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
847 #else
848 #define CONTROL_STRING1 "%16ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld\n"
849 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s\n"
850 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s\n"
851 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
852 #endif
853 #else
854 #define CONTROL_STRING1 "%16ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld\n"
855 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
856 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
857 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
858 #endif
859 #endif
860 
861 #ifndef NO_PRINT_LLD
862 #ifdef HAVE_PREAD
863 #include <sys/times.h>
864 #if defined(HAVE_PREAD) && defined(HAVE_PREADV)
865 #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"
866 #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"
867 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
868 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
869 #else
870 #define CONTROL_STRING1 "%16lld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld\n"
871 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s\n"
872 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
873 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
874 #endif
875 #else
876 #define CONTROL_STRING1 "%16lld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%8ld%9ld%9ld\n"
877 #define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
878 #define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
879 #define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
880 #endif
881 #endif
882 
883 /*
884  For 'auto mode', these defines determine the number of iterations
885  to perform for both the file size and the record length.
886 */
887 
888 /* Start with 64 kbyte minimum file size by default */
889 #define KILOBYTES_START 64
890 /* Default maximum file size. This is 512 Mbytes */
891 #define KILOBYTES_END (1024*512)
892 /* Default starting record size */
893 #define RECLEN_START 4096
894 /* Default maximum record size */
895 #define RECLEN_END (MAXBUFFERSIZE)
896 /* Multiplier for each itteration on file and record size */
897 #define MULTIPLIER 2
898 
899 /*
900  * Assign numeric values to each of the tests.
901  */
902 #define WRITER_TEST 0
903 #define READER_TEST 1
904 #define RANDOM_RW_TEST 2
905 #define REVERSE_TEST 3
906 #define REWRITE_REC_TEST 4
907 #define STRIDE_READ_TEST 5
908 #define FWRITER_TEST 6
909 #define FREADER_TEST 7
910 #define RANDOM_MIX_TEST 8
911 #ifdef HAVE_PREAD
912 #define PWRITER_TEST 9
913 #define PREADER_TEST 10
914 #endif /* HAVE_PREAD */
915 #ifdef HAVE_PREADV
916 #define PWRITEV_TEST 11
917 #define PREADV_TEST 12
918 #endif /* HAVE_PREADV */
919 
920 #define WRITER_MASK (1 << WRITER_TEST)
921 #define READER_MASK (1 << READER_TEST)
922 #define RANDOM_RW_MASK (1 << RANDOM_RW_TEST)
923 #define RANDOM_MIX_MASK (1 << RANDOM_MIX_TEST)
924 #define REVERSE_MASK (1 << REVERSE_TEST)
925 #define REWRITE_REC_MASK (1 << REWRITE_REC_TEST)
926 #define STRIDE_READ_MASK (1 << STRIDE_READ_TEST)
927 #define FWRITER_MASK (1 << FWRITER_TEST)
928 #define FREADER_MASK (1 << FREADER_TEST)
929 #ifdef HAVE_PREAD
930 #define PWRITER_MASK (1 << PWRITER_TEST)
931 #define PREADER_MASK (1 << PREADER_TEST)
932 #endif /* HAVE_PREAD */
933 #ifdef HAVE_PREADV
934 #define PWRITEV_MASK (1 << PWRITEV_TEST)
935 #define PREADV_MASK (1 << PREADV_TEST)
936 #endif /* HAVE_PREADV */
937 
938 /*
939  * child_stat->flag values and transitions
940  */
941 /* Parent initializes children to HOLD */
942 #define CHILD_STATE_HOLD 0
943 /* Child tells master when it's READY */
944 #define CHILD_STATE_READY 1
945 /* Parent tells child to BEGIN */
946 #define CHILD_STATE_BEGIN 2
947 /* Child tells parent that it's DONE */
948 #define CHILD_STATE_DONE 3
949 
950 #define MERSENNE
951 
952 /******************************************************************/
953 /* */
954 /* FUNCTION DECLARATIONS */
955 /* */
956 /******************************************************************/
957 char *initfile();
958 /*int pit_gettimeofday( struct timeval *, struct timezone *, char *, char *);*/
959 int pit_gettimeofday( );
960 static int openSckt( const char *, const char *, unsigned int );
961 static void pit( int, struct timeval *);
962 void mmap_end();
963 void alloc_pbuf();
964 void auto_test(); /* perform automatic test series */
965 void show_help(); /* show development help */
966 static double time_so_far(); /* time since start of program */
967 #ifdef unix
968 static double utime_so_far(); /* user time */
969 static double stime_so_far(); /* system time */
970 static double clk_tck(); /* Get clocks/tick */
971 static double cputime_so_far();
972 #else
973 #define cputime_so_far() time_so_far()
974 #endif
975 static double time_so_far1(); /* time since start of program */
976 void get_resolution();
977 void get_rusage_resolution();
978 void signal_handler(); /* clean up if user interrupts us */
979 void begin(); /* The main worker in the app */
980 void fetchit(); /* Prime on chip cache */
981 void purgeit(); /* Purge on chip cache */
982 void throughput_test(); /* Multi process throughput */
983 void multi_throughput_test(); /* Multi process throughput */
984 void prepage(); /* Pre-fault user buffer */
985 void get_date();
986 int get_pattern(); /* Set pattern based on version */
987 #ifdef HAVE_ANSIC_C
988 float do_compute(float); /* compute cycle simulation */
989 #else
990 float do_compute(); /* compute cycle simulation */
991 #endif
992 void write_perf_test(); /* write/rewrite test */
993 void fwrite_perf_test(); /* fwrite/refwrite test */
994 void fread_perf_test(); /* fread/refread test */
995 void read_perf_test(); /* read/reread test */
996 void mix_perf_test(); /* read/reread test */
997 void random_perf_test(); /* random read/write test */
998 void reverse_perf_test(); /* reverse read test */
999 void rewriterec_perf_test(); /* rewrite record test */
1000 void read_stride_perf_test(); /* read with stride test */
1001 #ifdef HAVE_PREAD
1002 void pread_perf_test(); /* pread/re-pread test */
1003 void pwrite_perf_test(); /* pwrite/re-pwrite test */
1004 #endif /* HAVE_PREAD */
1005 #ifdef HAVE_PREADV
1006 void preadv_perf_test(); /* preadv/re-preadv test */
1007 void pwritev_perf_test(); /* pwritev/re-pwritev test */
1008 #endif /* HAVE_PREADV */
1009 void store_dvalue(); /* Store doubles array */
1010 void dump_excel();
1011 void dump_throughput();
1012 int sp_start_child_send();
1014 #ifdef HAVE_ANSIC_C
1015 #if defined (HAVE_PREAD) && defined(_LARGEFILE64_SOURCE)
1016 ssize_t pwrite64();
1017 ssize_t pread64();
1018 #endif
1019 #if !defined(linux)
1020 char *getenv();
1021 char *inet_ntoa();
1022 int system();
1023 #endif
1024 void my_nap();
1025 void my_unap();
1026 int thread_exit();
1027 #ifdef ASYNC_IO
1028 size_t async_write();
1029 void async_release();
1030 int async_read();
1031 int async_read_no_copy();
1032 size_t async_write_no_copy();
1033 void end_async();
1034 void async_init();
1035 #else
1036 size_t async_write();
1037 size_t async_write_no_copy();
1038 void async_release();
1039 #endif
1040 void do_float();
1041 int create_xls();
1042 void close_xls();
1043 void do_label();
1044 int mylockf(int, int, int);
1045 int mylockr(int,int, int, off64_t, off64_t);
1046 int rand(void);
1047 void srand(unsigned int);
1048 int get_client_info(void);
1049 void exit(int);
1050 void find_remote_shell(char *);
1051 void find_external_mon(char *,char *);
1052 void start_monitor(char *);
1053 void stop_monitor(char *);
1054 void takeoff_cache();
1055 void del_cache();
1056 void fill_area(long long *, long long *, long long);
1057 void fill_buffer(char *,long long ,long long ,char, long long );
1058 void store_value(off64_t);
1059 void store_times(double, double);
1060 static double cpu_util(double, double);
1061 void dump_cputimes(void);
1062 void purge_buffer_cache(void);
1063 char *alloc_mem(long long,int);
1064 void *(thread_rwrite_test)(void *);
1065 void *(thread_write_test)(void *);
1066 void *(thread_fwrite_test)(void *);
1067 void *(thread_fread_test)(void *);
1068 void *(thread_read_test)(void*);
1069 #ifdef HAVE_PREAD
1070 void *(thread_pread_test)(void*);
1071 void *(thread_pwrite_test)(void*);
1072 #endif
1073 void *(thread_cleanup_test)(void*);
1074 void *(thread_cleanup_quick)(void*);
1075 void *(thread_ranread_test)(void *);
1076 void *(thread_mix_test)(void *);
1077 void *(thread_ranwrite_test)(void *);
1078 void *(thread_rread_test)(void *);
1079 void *(thread_reverse_read_test)(void *);
1080 void *(thread_stride_read_test)(void *);
1081 void *(thread_set_base)(void *);
1082 void *(thread_join)(long long, void *);
1083 void disrupt(int);
1084 #if defined(Windows)
1085 void disruptw(HANDLE);
1086 #endif
1087 long long get_traj(FILE *, long long *, float *, long);
1088 void create_temp(off64_t, long long );
1089 FILE *open_w_traj(void);
1090 FILE *open_r_traj(void);
1091 void traj_vers(void);
1092 void r_traj_size(void);
1093 long long w_traj_size(void);
1094 void init_file_sizes();
1096 void add_file_size(off64_t);
1099 void add_record_size(off64_t);
1101 void del_record_sizes( void );
1102 void hist_insert(double );
1103 void dump_hist(char *,int );
1104 void do_speed_check(int);
1105 #else
1106 void do_speed_check();
1107 #if !defined(linux)
1108 char *getenv();
1109 char *inet_ntoa();
1110 int system();
1111 #endif
1112 void my_nap();
1113 void my_unap();
1114 int thread_exit();
1115 void close_xls();
1116 void do_label();
1117 int create_xls();
1118 void do_float();
1119 #ifdef ASYNC_IO
1120 void async_release();
1121 size_t async_write();
1122 size_t async_write_no_copy();
1123 int async_read();
1124 int async_read_no_copy();
1125 #endif
1126 int mylockf();
1127 int mylockr();
1128 int rand();
1129 void srand();
1130 int get_client_info();
1131 void exit();
1132 void find_remote_shell();
1133 void traj_vers();
1134 void r_traj_size();
1135 long long w_traj_size();
1136 FILE *open_w_traj();
1137 FILE *open_r_traj();
1138 void create_temp();
1139 void fill_buffer();
1140 char *alloc_mem();
1141 void *(thread_rwrite_test)();
1142 void *(thread_write_test)();
1143 void *(thread_fwrite_test)();
1144 void *(thread_fread_test)();
1145 void *(thread_read_test)();
1146 void *(thread_cleanup_test)();
1147 void *(thread_ranread_test)();
1148 void *(thread_mix_test)();
1149 void *(thread_ranwrite_test)();
1150 void *(thread_rread_test)();
1151 void *(thread_reverse_read_test)();
1152 void *(thread_stride_read_test)();
1153 void *(thread_set_base)();
1154 void *(thread_join)();
1155 void disrupt();
1156 long long get_traj();
1157 void init_file_sizes();
1159 void add_file_size();
1160 void init_record_sizes();
1162 void add_record_size();
1163 void dump_cputimes();
1164 static double cpu_util();
1165 void del_record_sizes();
1166 void hist_insert();
1167 void dump_hist();
1168 #endif
1169 
1170 #ifdef _LARGEFILE64_SOURCE
1171 #define I_LSEEK(x,y,z) lseek64(x,(off64_t)(y),z)
1172 #define I_OPEN(x,y,z) open64(x,(int)(y),(int)(z))
1173 #define I_CREAT(x,y) creat64(x,(int)(y))
1174 #define I_FOPEN(x,y) fopen64(x,y)
1175 #define I_STAT(x,y) stat64(x,y)
1176 #ifdef HAVE_PREAD
1177 #define I_PREAD(a,b,c,d) pread64(a,b,(size_t)(c),(off64_t)(d))
1178 #define I_PWRITE(a,b,c,d) pwrite64(a,b,(size_t)(c),(off64_t)(d))
1179 #endif
1180 #define I_MMAP(a,b,c,d,e,f) mmap64((void *)(a),(size_t)(b),(int)(c),(int)(d),(int)(e),(off64_t)(f))
1181 #else
1182 #define I_LSEEK(x,y,z) lseek(x,(off_t)(y),z)
1183 #define I_OPEN(x,y,z) open(x,(int)(y),(int)(z))
1184 #define I_CREAT(x,y) creat(x,(int)(y))
1185 #define I_FOPEN(x,y) fopen(x,y)
1186 #define I_STAT(x,y) stat(x,y)
1187 #ifdef HAVE_PREAD
1188 #define I_PREAD(a,b,c,d) pread(a,b,(size_t)(c),(off_t)(d))
1189 #define I_PWRITE(a,b,c,d) pwrite(a,b,(size_t)(c),(off_t)(d))
1190 #endif
1191 #define I_MMAP(a,b,c,d,e,f) mmap((void *)(a),(size_t)(b),(int)(c),(int)(d),(int)(e),(off_t)(f))
1192 #endif
1193 
1194 
1195 /************************************************************************/
1196 /* The list of tests to be called. */
1197 /************************************************************************/
1198 void (*func[])() = {
1199  write_perf_test,
1207  mix_perf_test
1208 #ifdef HAVE_PREAD
1209  ,
1210  pwrite_perf_test,
1211  pread_perf_test
1212 #ifdef HAVE_PREADV
1213  ,
1214  pwritev_perf_test,
1215  preadv_perf_test
1216 #endif /* HAVE_PREADV */
1217 #endif /* HAVE_PREAD */
1218  };
1219 
1220 /*
1221 char *test_output[] = {" ",
1222  " ",
1223  " ",
1224  " ",
1225  " ",
1226  " ",
1227  " ",
1228  " ",
1229  " ",
1230  " ",
1231  " ",
1232  " \n" };
1233 */
1234 char *test_output[] = {" ",
1235  " ",
1236  " ",
1237  " ",
1238  " ",
1239  " ",
1240  " ",
1241  " ",
1242  "",
1243  " ",
1244  " ",
1245  " ",
1246  " ",
1247  " ",
1248  " ",
1249  " \n" };
1250 long long test_soutput[] = {2,2,2,1,1,1,2,2,2,2,2,2,2,2};
1251 
1252 
1253 /******************************************************************/
1254 /* */
1255 /* GLOBAL VARIABLES */
1256 /* */
1257 /*******************************************************************/
1258 
1259 /*
1260  * Set the size of the shared memory segment for the children
1261  * to put their results.
1262  */
1263 #define SHMSIZE ((( sizeof(struct child_stats) * MAXSTREAMS) )+4096 )
1264 /*
1265  * Pointer to the shared memory segment.
1266  */
1272 long long throughput_array[MAX_X]; /* Filesize & record size are constants */
1274 long long orig_size;
1275 long long max_x, max_y;
1276 unsigned long long goodkilos;
1278 long long goodrecl;
1279 off64_t offset = 0; /*offset for random I/O */
1280 off64_t offset64 = 0; /*offset for random I/O */
1284 int t_range[100];
1285 int t_count = 0;
1288 char *haveshm;
1289 extern int optind;
1291 int fd;
1294 long long res_prob,rec_prob;
1299 int dedup_mseed = 1;
1313 #ifdef Windows
1314 char *build_name = "Windows";
1315 #else
1316 char *build_name = NAME;
1317 #endif
1318 char imon_start[256],imon_stop[256];
1320 char trflag;
1322 char seq_mix;
1324 long long mint, maxt;
1330 struct runtime runtimes [MAX_X] [MAX_Y]; /* in parallel with report_array[][] */
1331 long long include_test[50];
1332 long long include_mask;
1333 char RWONLYflag, NOCROSSflag; /*auto mode 2 - kcollins 8-21-96*/
1334 char mfflag;
1337 #ifndef NO_THREADS
1339 #endif
1343 
1344 extern char *optarg;
1345 #ifndef __AIX__
1346 long long ret;
1347 #else
1348 short ret;
1349 #endif
1350 struct size_entry {
1351  struct size_entry *next;
1353 };
1358 
1359 char bif_filename [MAXNAMESIZE]; /* name of biff file */
1360 char filename [MAXNAMESIZE]; /* name of temporary file */
1361 char mountname [MAXNAMESIZE]; /* name of device */
1362 char dummyfile [MAXSTREAMS][MAXNAMESIZE]; /* name of dummy file */
1363 char dummyfile1 [MAXNAMESIZE]; /* name of dummy file */
1364 char *filearray[MAXSTREAMS]; /* array of file names */
1365 char tfile[] = "iozone";
1369 char *default_filename="iozone.tmp"; /*default name of temporary file*/
1371 char Cflag;
1372 char use_thread = 0;
1373 long long debug1=0;
1374 long long debug=0;
1375 unsigned long cache_size=CACHE_SIZE;
1377 long long *pstatus;
1384 long long xover = CROSSOVER;
1385 char *throughput_tests[] = {"Initial write","Rewrite","Read","Re-read",
1386  "Reverse Read","Stride read","Random read","Mixed workload","Random write","Pwrite","Pread","Fwrite","Fread"};
1387 char command_line[1024] = "\0";
1388 #ifdef unix
1389 double sc_clk_tck;
1390 #endif
1391 
1393 char **argvsave;
1394 char splash[80][80];
1397 char remote_shell[256];
1399 
1400 char pit_hostname[40];
1401 char pit_service[8];
1402 int junk;
1403 
1404 /*
1405  * Host ports used to listen, and handle errors.
1406  */
1407 #define HOST_LIST_PORT 20000
1408 #define HOST_ESEND_PORT (HOST_LIST_PORT+MAXSTREAMS)
1409 #define HOST_ASEND_PORT (HOST_ESEND_PORT+MAXSTREAMS)
1411 
1412 /*
1413  * Childs ports used to listen, and handle errors.
1414  */
1415 #define CHILD_ESEND_PORT (HOST_ASEND_PORT+MAXSTREAMS)
1416 #define CHILD_LIST_PORT (CHILD_ESEND_PORT+MAXSTREAMS)
1417 
1418 /* Childs async message port. Used for stop flag and terminate */
1419 #define CHILD_ALIST_PORT (CHILD_LIST_PORT+MAXSTREAMS)
1420 
1421 /* Ports for the network speed code */
1422 #define SP_CHILD_LISTEN_PORT 31000
1423 #define SP_CHILD_ESEND_PORT (SP_CHILD_LISTEN_PORT+10)
1424 #define SP_MASTER_LISTEN_PORT (SP_CHILD_ESEND_PORT+10)
1425 #define SP_MASTER_ESEND_PORT (SP_MASTER_LISTEN_PORT+10)
1426 #define SP_MASTER_RESULTS_PORT (SP_MASTER_ESEND_PORT+10)
1427 
1428 
1429 #define THREAD_WRITE_TEST 1
1430 #define THREAD_REWRITE_TEST 2
1431 #define THREAD_READ_TEST 3
1432 #define THREAD_REREAD_TEST 4
1433 #define THREAD_STRIDE_TEST 5
1434 #define THREAD_RANDOM_READ_TEST 6
1435 #define THREAD_RANDOM_WRITE_TEST 7
1436 #define THREAD_REVERSE_READ_TEST 8
1437 #define THREAD_RANDOM_MIX_TEST 9
1438 #define THREAD_PWRITE_TEST 10
1439 #define THREAD_PREAD_TEST 11
1440 #define THREAD_FWRITE_TEST 12
1441 #define THREAD_FREAD_TEST 13
1442 #define THREAD_CLEANUP_TEST 14
1443 
1444 /*
1445  * Child states that the master is tracking.
1446  * The master uses these to determine how to shutdown
1447  * the clients when some fool hits control-C.
1448  */
1449 #define C_STATE_ZERO 1
1450 #define C_STATE_WAIT_WHO 2
1451 #define C_STATE_WAIT_BARRIER 3
1452 
1453 
1454 int c_port,a_port; /* port number */
1455 int child_port; /* Virtualized due to fork */
1456 int child_async_port; /* Virtualized due to fork */
1457 int client_listen_pid; /* Virtualized due to fork */
1458 int master_join_count; /* How many children have joined */
1459 int l_sock,l_async_sock; /* Sockets for listening */
1460 char master_rcv_buf[4096]; /* Master's receive buffer */
1461 int master_listen_pid; /* Pid of the master's async listener proc */
1462 char master_send_buf[4096]; /* Master's send buffer */
1463 char child_rcv_buf[4096]; /* Child's receive buffer */
1464 char child_async_rcv_buf[4096]; /* Child's async recieve buffer */
1465 char child_send_buf[4096]; /* Child's send buffer */
1466 int child_send_socket; /* Child's send socket */
1467 int child_listen_socket; /* Child's listener socket */
1468 int child_listen_socket_async; /* Child's async listener socket */
1469 int master_send_socket; /* Needs to be an array. One for each child*/
1470 int master_send_sockets[MAXSTREAMS]; /* Needs to be an array. One for each child*/
1471 int master_send_async_sockets[MAXSTREAMS]; /* Needs to be an array. One for each child*/
1472 int master_listen_port; /* Master's listener port number */
1473 int master_listen_socket; /* Master's listener socket */
1474 int clients_found; /* Number of clients found in the client file */
1475 FILE *newstdin, *newstdout, *newstderr; /* used for debug in cluster mode.*/
1476 char toutput[20][20]; /* Used to help format the output */
1477 int toutputindex; /* Index to the current output line */
1478 int cdebug = 0; /* Use to turn on child/client debugging in cluster mode. */
1479 int mdebug = 0; /* Use to turn on master debug in cluster mode */
1480 int aggflag; /* Used to indicate constant aggregate data set size */
1481 struct sockaddr_in child_sync_sock, child_async_sock;
1482 
1483 /*
1484  * Change this whenever you change the message format of master or client.
1485  */
1486 int proto_version = 25;
1487 
1488 /******************************************************************************/
1489 /* Tele-port zone. These variables are updated on the clients when one is */
1490 /* using cluster mode. (-+m) */
1491 /* Do not touch these unless you have become one with the universe !! */
1492 /******************************************************************************/
1494 struct child_ident {
1495  char child_name[100];
1496  char workdir[200];
1497  char execute_path[200];
1498  char file_name[200];
1499  int state;
1507 char write_traj_filename [MAXNAMESIZE]; /* name of write telemetry file */
1508 char read_traj_filename [MAXNAMESIZE]; /* name of read telemetry file */
1511 char notruncate; /* turn off truncation of files */
1513 char verify = 1;
1514 int restf;
1515 char sverify = 1;
1516 char odsync = 0;
1518 char L_flag=0;
1521 int no_unlink = 0;
1522 int no_write = 0;
1524 int mygen;
1525 char MS_flag;
1529 long long chid;
1531 unsigned int pattern;
1532 long long stride = STRIDE;
1533 long long delay,purge,fetchon;
1535 long long reclen = RECLEN;
1536 long long delay_start,depth;
1537 VOLATILE char *stop_flag; /* Used to stop all children */
1540 long long rest_val;
1541 #if defined(Windows)
1542  HANDLE hand;
1543 #endif
1544 
1545 /******************************************************************************/
1546 /* End of Tele-port zone. */
1547 /******************************************************************************/
1548 
1549 
1550 /*
1551  * Prototypes
1552  * Sort of... Full prototypes break non-ansi C compilers. No protos is
1553  * a bit sloppy, so the compromise is this.
1554  */
1555 void child_send();
1556 int start_child_listen();
1559 void child_listen();
1560 void child_listen_async();
1561 void stop_child_send();
1562 void stop_child_listen();
1563 void cleanup_comm();
1564 void master_send();
1565 int start_master_send();
1566 int start_master_listen();
1567 int check_filename();
1568 void master_listen();
1569 void stop_master_send();
1570 void stop_master_listen();
1571 long long start_child_proc();
1572 int parse_client_line();
1573 void wait_dist_join();
1574 void tell_children_begin();
1576 void wait_for_master_go();
1577 void tell_master_ready();
1579 void tell_master_stats();
1580 void become_client();
1581 int pick_client();
1582 long long start_child_proc();
1583 int start_master_send();
1584 void child_listen();
1585 int start_child_listen();
1586 void stop_master_send();
1587 void stop_master_listen();
1588 void stop_child_send();
1589 void stop_child_listen();
1590 void master_send();
1591 void child_send();
1592 void master_listen();
1593 int start_master_listen();
1594 void child_remove_files();
1595 void terminate_child_async();
1596 void distribute_stop();
1597 void send_stop();
1598 void cleanup_children();
1599 
1600 
1601 /****************************************************************/
1602 /* */
1603 /* MAIN () */
1604 /* */
1605 /****************************************************************/
1606 
1607 int
1608 main(argc,argv)
1610 char **argv;
1612 
1613  long long fileindx,i,tval;
1614  long long ind;
1615  int ret;
1616  FILE *pi;
1618  unsigned char inp_pat;
1619  time_t time_run;
1620  char *port,*m,*subarg;
1622  int cret;
1624  char *evalue;
1625 
1626 
1627  anwser=bind_cpu=0;
1628  /* Used to make fread/fwrite do something better than their defaults */
1629  setvbuf( stdout, NULL, _IONBF, (size_t) NULL );
1630  setvbuf( stderr, NULL, _IONBF, (size_t) NULL );
1631 
1632  /* Save the master's name */
1634 
1635  /* Let user activate mdebug or cdebug via environmental variables */
1636  evalue = (char *)NULL;
1637  evalue=(char *)getenv("CDEBUG");
1638  if(evalue)
1639  cdebug=atoi(evalue);
1640  evalue = (char *)NULL;
1641  evalue=(char *)getenv("MDEBUG");
1642  if(evalue)
1643  mdebug=atoi(evalue);
1644 
1645  srand(time(0));
1646  mygen=rand(); /* Pick a random generation number */
1647 
1648  /* Try to find the actual VM page size, if possible */
1649 #if defined (solaris) || defined (_HPUX_SOURCE) || defined (linux) || defined(IRIX) || defined (IRIX64)
1650 #ifndef __convex_spp
1651  page_size=getpagesize();
1652 #endif
1653 #endif
1654  /* Try to find the actual number of ticks per second */
1655 #ifdef unix
1656  sc_clk_tck = clk_tck();
1657 #endif
1658  for(ind=0;ind<MAXSTREAMS;ind++)
1659  filearray[ind]=(char *)tfile;
1660 
1661  /* base_time=(long)time_so_far(); */
1662  myid=(long long)getpid(); /* save the master's PID */
1663  /* get_resolution(); Get clock resolution */
1664  time_run = time(0); /* Start a timer */
1666 
1667  /*
1668  * Save the splash screen for later display. When in distributed network
1669  * mode this output does not get displayed on the clients.
1670  */
1671  sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n");
1672  sprintf(splash[splash_line++],"\t%s\n\t%s\n", THISVERSION,MODE);
1673  sprintf(splash[splash_line++],"\t\tBuild: %s \n\n",build_name);
1674  sprintf(splash[splash_line++],"\tContributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins\n");
1675  sprintf(splash[splash_line++],"\t Al Slater, Scott Rhine, Mike Wisner, Ken Goss\n");
1676  sprintf(splash[splash_line++],"\t Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,\n");
1677  sprintf(splash[splash_line++],"\t Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,\n");
1678  sprintf(splash[splash_line++],"\t Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,\n");
1679  sprintf(splash[splash_line++],"\t Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,\n");
1680  sprintf(splash[splash_line++],"\t Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer.\n");
1681  sprintf(splash[splash_line++],"\t Ben England.\n\n");
1682  sprintf(splash[splash_line++],"\tRun began: %s\n",ctime(&time_run));
1683  argcsave=argc;
1684  argvsave=argv;
1685 
1686  signal(SIGINT, signal_handler); /* handle user interrupt */
1687  signal(SIGTERM, signal_handler); /* handle kill from shell */
1688 
1689  /********************************************************/
1690  /* Allocate and align buffer with beginning of the */
1691  /* on chip data cache. */
1692  /********************************************************/
1693 
1694  buffer = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0);
1695  if(buffer == 0) {
1696  perror("Memory allocation failed:");
1697  exit(1);
1698  }
1699 
1700 #ifdef _64BIT_ARCH_
1701  buffer = (char *) ((long long )(buffer + cache_size ) &
1702  ~(cache_size-1));
1703 #else
1704  buffer = (char *) ((long)(buffer + cache_size ) &
1705  ~((long)cache_size-1));
1706 #endif
1707  mainbuffer = buffer;
1708 
1709  /* de-dup input buf */
1710  buffer1 = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0);
1711  if(buffer1 == 0) {
1712  perror("Memory allocation failed:");
1713  exit(1);
1714  }
1715 
1716 #ifdef _64BIT_ARCH_
1717  buffer1 = (char *) ((long long )(buffer1 + cache_size ) &
1718  ~(cache_size-1));
1719 #else
1720  buffer1 = (char *) ((long)(buffer1 + cache_size ) &
1721  ~((long)cache_size-1));
1722 #endif
1723  dedup_ibuf = buffer1;
1725 
1726 #ifdef FOOB
1727  /* de-dup temp buf */
1728  buffer1 = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0);
1729  if(buffer1 == 0) {
1730  perror("Memory allocation failed:");
1731  exit(1);
1732  }
1733 
1734 #ifdef _64BIT_ARCH_
1735  buffer1 = (char *) ((long long )(buffer1 + cache_size ) &
1736  ~(cache_size-1));
1737 #else
1738  buffer1 = (char *) ((long)(buffer1 + cache_size ) &
1739  ~((long)cache_size-1));
1740 #endif
1741 #endif
1743 
1744  fetchon++; /* By default, prefetch the CPU cache lines associated with the buffer */
1745  strcpy(filename,default_filename); /* Init default filename */
1746  sprintf(dummyfile[0],"%s.DUMMY",default_filename);
1747  if(argc <=1){
1748  printf(USAGE);
1749  exit(255);
1750  }
1751  auto_mode = 0; /* Default is to disable auto mode */
1752  inp_pat = PATTERN; /* Init default pattern for verification */
1753  /* Fill the entire pattern variable with the same character */
1754  pattern = ((inp_pat << 24) | (inp_pat << 16) | (inp_pat << 8) | inp_pat);
1755 
1756  /*
1757  * Parse all of the options that the user specified.
1758  */
1759  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){
1760  switch(cret){
1761  case 'k': /* Async I/O with no bcopys */
1762  depth = (long long)(atoi(optarg));
1763  if(depth <0)
1764  depth=0;
1765  /*
1766  if(depth > 60)
1767  depth=60;
1768  */
1769 #ifdef NO_PRINT_LLD
1770  sprintf(splash[splash_line++],"\tPOSIX Async I/O (no bcopy). Depth %ld \n",depth);
1771 #else
1772  sprintf(splash[splash_line++],"\tPOSIX Async I/O (no bcopy). Depth %lld \n",depth);
1773 #endif
1774  no_copy_flag=1;
1775  async_flag++;
1776  k_flag++;
1777  break;
1778  case 'T': /* Switch to POSIX thread based */
1779 #ifndef NO_THREADS
1780  use_thread++;
1781 #else
1782  printf("\tThreads not supported in this version\n");
1783  exit(2);
1784 #endif
1785  break;
1786  case 'H': /* Use POSIX async_io */
1787  h_flag++;
1788  depth = (long long)(atoi(optarg));
1789  if(depth <0)
1790  depth=0;
1791  /*
1792  * Hmmm. many systems fail is strange ways when the maximum
1793  * number of async I/Os per user or proc is exceeded.
1794  */
1795  /*
1796  if(depth > 60)
1797  depth=60;
1798  */
1799 #ifdef NO_PRINT_LLD
1800  sprintf(splash[splash_line++],"\tPOSIX async I/O (with bcopy). Depth %ld\n",depth);
1801 #else
1802  sprintf(splash[splash_line++],"\tPOSIX async I/O (with bcopy). Depth %lld\n",depth);
1803 #endif
1804  async_flag++;
1805  break;
1806  case 'I': /* Use VXFS direct advisory or O_DIRECT from Linux or AIX , or O_DIRECTIO for TRU64 or Solaris directio */
1807 #ifdef VXFS
1808  direct_flag++;
1809  sprintf(splash[splash_line++],"\tVxFS advanced feature SET_CACHE, VX_DIRECT enabled\n");
1810  break;
1811 #endif
1812 #if ! defined(DONT_HAVE_O_DIRECT)
1813 #if defined(linux) || defined(__AIX__) || defined(IRIX) || defined(IRIX64) || defined(Windows) || defined(__FreeBSD__) || defined(solaris)
1814  direct_flag++;
1815  sprintf(splash[splash_line++],"\tO_DIRECT feature enabled\n");
1816  break;
1817 #endif
1818 #if defined(TRU64)
1819  direct_flag++;
1820  sprintf(splash[splash_line++],"\tO_DIRECTIO feature enabled\n");
1821  break;
1822 #endif
1823 #else
1824  break;
1825 #endif
1826 #if defined(Windows)
1827  sprintf(splash[splash_line++],"\tO_DIRECTIO feature not available in Windows version.\n");
1828  break;
1829 #endif
1830  case 'B': /* Use mmap file for test file */
1831  sprintf(splash[splash_line++],"\tUsing mmap files\n");
1832  mmapflag++;
1833  mmapnsflag++;
1834  break;
1835  case 'D': /* Use async msync mmap file */
1836  sprintf(splash[splash_line++],"\tUsing msync(MS_ASYNC) on mmap files\n");
1837  mmapflag++;
1838  mmapasflag++;
1839  mmapnsflag=0;
1840  break;
1841  case 'G': /* Use msync sync for mmap file */
1842  sprintf(splash[splash_line++],"\tUsing msync(MS_SYNC) on mmap files\n");
1843  mmapssflag++;
1844  mmapnsflag=0;
1845  break;
1846  case 'C': /* show children xfer counts */
1847  Cflag++;
1848  break;
1849  case 'Q': /* Enable output offset/latency files */
1850  sprintf(splash[splash_line++],"\tOffset/latency files enabled.\n");
1851  Q_flag++;
1852  break;
1853  case 'x': /* Disable stone_wall */
1854  sprintf(splash[splash_line++],"\tStonewall disabled\n");
1855  xflag++;
1856  break;
1857 
1858  case 'a': /* auto mode */
1859  fetchon=1;
1860  purge=0;
1861  multi_buffer=0;
1862  auto_mode = 1;
1863  aflag++;
1864  sprintf(splash[splash_line++],"\tAuto Mode\n");
1865  break;
1866  case 'c': /* Include close in timing */
1867  include_close++;
1868  sprintf(splash[splash_line++],"\tInclude close in write timing\n");
1869  break;
1870  case 'e': /* Include fsync in timing */
1871  include_flush++;
1872  sprintf(splash[splash_line++],"\tInclude fsync in write timing\n");
1873  break;
1874  case 'A': /* auto2 mode. Soon to go away. Please use -az */
1875  fetchon=1;
1876  purge=0;
1877  multi_buffer=0;
1878  auto_mode = 1;
1879  aflag++;
1880  sprintf(splash[splash_line++],"\tAuto Mode 2. This option is obsolete. Use -az -i0 -i1 \n");
1881  RWONLYflag++;
1882  NOCROSSflag++;
1883  include_tflag++; /* automatically set WRITER_TEST and READER_TEST */
1886  break;
1887  case 's': /* Set file size */
1888 #ifdef NO_PRINT_LLD
1889  sscanf(optarg,"%ld",&kilobytes64);
1890 #else
1891  sscanf(optarg,"%lld",&kilobytes64);
1892 #endif
1893  if(optarg[strlen(optarg)-1]=='k' ||
1894  optarg[strlen(optarg)-1]=='K'){
1895  ;
1896  }
1897  if(optarg[strlen(optarg)-1]=='m' ||
1898  optarg[strlen(optarg)-1]=='M'){
1899  kilobytes64 = kilobytes64 * 1024;
1900  }
1901  if(optarg[strlen(optarg)-1]=='g' ||
1902  optarg[strlen(optarg)-1]=='G'){
1903  kilobytes64 = kilobytes64 *1024 * 1024;
1904  }
1905  if(kilobytes64 <= 0)
1906  kilobytes64=512;
1907 
1909  max_file_size = (off64_t)s_range[s_count-1]; /* Make visable globally */
1910  min_file_size = (off64_t)s_range[0]; /* Make visable globally */
1911 
1912 #ifdef NO_PRINT_LLD
1913  sprintf(splash[splash_line++],"\tFile size set to %ld KB\n",kilobytes64);
1914 #else
1915  sprintf(splash[splash_line++],"\tFile size set to %lld KB\n",kilobytes64);
1916 #endif
1917  sflag++;
1918  break;
1919  case 'l': /* Set lower thread/proc limit */
1920  mint = (long long)(atoi(optarg));
1921  if(mint <= 0)
1922  {
1923  mint=1;
1924  num_child=1;
1925  }else
1926  num_child=mint;
1927  if(mint > (unsigned long long)MAXSTREAMS){
1928  printf("Invalid options: maximum streams for ");
1929  printf("throughput is MAXSTREAMS\n");
1930  exit(4);
1931  }
1932  lflag++;
1933  trflag++;
1934  if(Uflag)
1935  {
1936  printf("Can not run throughput tests with unmount & remounts.\n");
1937  exit(5);
1938  }
1939  break;
1940  case 'u': /* Set upper thread/proc limit */
1941  maxt = (long long)(atoi(optarg));
1942  if(maxt <= 0)
1943  maxt=1;
1944  if(maxt > MAXSTREAMS){
1945  printf("Invalid options: maximum streams for ");
1946  printf("throughput is MAXSTREAMS\n");
1947  exit(6);
1948  }
1949  uflag++;
1950  trflag++;
1951  if(Uflag)
1952  {
1953  printf("Can not run throughput tests with unmount & remounts.\n");
1954  exit(7);
1955  }
1956  break;
1957  case 'm': /* Use multiple buffers */
1958  fetchon=0;
1959  multi_buffer=1;
1960  mflag++;
1961  mbuffer = (char *) alloc_mem((long long)MAXBUFFERSIZE,(int)0);
1962  if(mbuffer == 0) {
1963  perror("Memory allocation failed:");
1964  exit(8);
1965  }
1966  sprintf(splash[splash_line++],"\tMulti_buffer. Work area %d bytes\n",
1967  MAXBUFFERSIZE);
1968  break;
1969  case 'M': /* Report machine name and OS */
1970  bzero(reply,sizeof(reply));
1971  pi=popen("uname -a", "r");
1972  if(pi == (FILE *)0)
1973  {
1974  sprintf(splash[splash_line++],"\n\tError using popen() on uname\n");
1975  sprintf(splash[splash_line++],"\t-M option suppressed.\n");
1976  }
1977  else
1978  {
1979  junk=fread(reply,IBUFSIZE-1,1,pi);
1980  pclose(pi);
1981  m=reply;
1982  while(*m) /* Strip new line */
1983  {
1984  if(*m=='\n')
1985  *m=0;
1986  else
1987  m++;
1988  }
1989  sprintf(splash[splash_line++],"\n\tMachine = %s\n",reply);
1990  }
1991  break;
1992 
1993  case 'P': /* Set beginning processor for binding. */
1994 #ifndef NO_THREADS
1995 #if defined(_HPUX_SOURCE) || defined(linux)
1996 #if defined(_HPUX_SOURCE)
1997  num_processors= pthread_num_processors_np();
1998 #else
1999  num_processors = sysconf(_SC_NPROCESSORS_ONLN);
2000 #endif
2001  begin_proc = atoi(optarg);
2002  if(begin_proc < 0)
2003  begin_proc=0;
2005  begin_proc=0;
2006  sprintf(splash[splash_line++],"\tBinding of processors beginning with %d \n",begin_proc);
2008 #else
2009  sprintf(splash[splash_line++],"\tProcessor binding not available in this version\n");
2010 #endif
2011 #endif
2012  break;
2013  case 'p': /* purge the processor cache */
2014  sprintf(splash[splash_line++],"\tPurge Mode On\n");
2015  fetchon=0;
2016  pflag++;
2017  purge=1;
2018  break;
2019  case 'h': /* show help */
2020  hflag++;
2021  show_help();
2022  exit(0);
2023  break;
2024  case 'E': /* Extended testing for pread/pwrite... */
2025  Eflag++;
2026  break;
2027  case 'R': /* Generate Excel compatible Report */
2028  Rflag++;
2029  sprintf(splash[splash_line++],"\tExcel chart generation enabled\n");
2030  break;
2031  case 'o': /* Open OSYNC */
2032  sprintf(splash[splash_line++],"\tSYNC Mode. \n");
2033  oflag++;
2034  break;
2035  case 'O': /* Report in Ops/sec instead of KB/sec */
2036  sprintf(splash[splash_line++],"\tOPS Mode. Output is in operations per second.\n");
2037  OPS_flag++;
2038  break;
2039  case 'N': /* Report in usec/op */
2040  sprintf(splash[splash_line++],"\tMicroseconds/op Mode. Output is in microseconds per operation.\n");
2041  MS_flag++;
2042  break;
2043  case 'V': /* Turn on Verify every byte */
2044  sverify=0;
2045  inp_pat = (char)(atoi(optarg));
2046  if(inp_pat == 0)
2047  inp_pat = PATTERN;
2048  pattern = ((inp_pat << 24) | (inp_pat << 16) | (inp_pat << 8)
2049  | inp_pat);
2050  verify=1;
2051  sprintf(splash[splash_line++],"\tVerify Mode. Pattern %x\n",pattern);
2052  sprintf(splash[splash_line++],"\tPerformance measurements are invalid in this mode.\n");
2053  break;
2054  case 'S': /* Set the processor cache size */
2055  cache_size = (long)(atoi(optarg)*1024);
2056  if(cache_size == 0)
2058  break;
2059  case 'L': /* Set processor cache line size */
2061  if(cache_line_size == 0)
2063  break;
2064  case 'f': /* Specify the file name */
2065  if(mfflag) {
2066  printf("invalid options: -f and -F are mutually exclusive\n");
2067  exit(10);
2068  }
2069  fflag++;
2071  sprintf(dummyfile[0],"%s.DUMMY",optarg);
2072  break;
2073  case 'b': /* Specify the biff file name */
2074  Rflag++;
2075  bif_flag++;
2077  break;
2078  case 'F': /* Specify multiple file names for -t */
2079  mfflag++;
2080  if(fflag) {
2081  printf("invalid options: -f and -F are mutually exclusive\n");
2082  exit(11);
2083  }
2084  if(!trflag) {
2085  printf("invalid options: must specify -t N before -F\n");
2086  exit(12);
2087  }
2088  optind--;
2089  for(fileindx=0;fileindx<maxt;fileindx++) {
2090  filearray[fileindx]=argv[optind++];
2091  if(optind > argc) {
2092 #ifdef NO_PRINT_LLD
2093  printf("invalid options: not enough filenames for %ld streams\n",num_child);
2094 #else
2095  printf("invalid options: not enough filenames for %lld streams\n",num_child);
2096 #endif
2097  exit(13);
2098  }
2099  }
2100  break;
2101  case 'r': /* Specify the record size to use */
2102  rflag++;
2103  reclen = ((long long)(atoi(optarg))*1024);
2104  if(optarg[strlen(optarg)-1]=='k' ||
2105  optarg[strlen(optarg)-1]=='K'){
2106  reclen = (long long)(1024 * atoi(optarg));
2107  }
2108  if(optarg[strlen(optarg)-1]=='m' ||
2109  optarg[strlen(optarg)-1]=='M'){
2110  reclen = (long long)(1024 * 1024 * atoi(optarg));
2111  }
2112  if(optarg[strlen(optarg)-1]=='g' ||
2113  optarg[strlen(optarg)-1]=='G'){
2114  reclen = (long long)(1024 * 1024 * 1024 *(long long)atoi(optarg));
2115  }
2116  if(reclen <= 0)
2117  reclen=(long long)4096;
2118 
2119  r_range[r_count++]=reclen;
2120  max_rec_size = (off64_t)r_range[r_count-1]; /* Make visable globally */
2121  min_rec_size = (off64_t)r_range[0]; /* Make visable globally */
2122 #ifdef NO_PRINT_LLD
2123  sprintf(splash[splash_line++],"\tRecord Size %ld KB\n",reclen/1024);
2124 #else
2125  sprintf(splash[splash_line++],"\tRecord Size %lld KB\n",reclen/1024);
2126 #endif
2127  if(max_rec_size > MAXBUFFERSIZE) {
2128 #ifdef NO_PRINT_LLD
2129  printf("Error: maximum record size %ld KB is greater than maximum buffer size %ld KB\n ",
2130  max_rec_size/1024, MAXBUFFERSIZE/1024);
2131 #else
2132  printf("Error: maximum record size %lld KB is greater than maximum buffer size %lld KB\n ",
2133  (long long)(max_rec_size/1024LL), (long long)MAXBUFFERSIZE/1024LL);
2134 #endif
2135  exit(23);
2136  }
2137  break;
2138  case 'J': /* Specify the compute time in millisecs */
2139  compute_time = (float)(atoi(optarg));
2140  compute_time=compute_time/1000;
2141  if(compute_time < (float)0)
2142  compute_time=(float)0;
2143  else
2144  compute_flag=1;
2145  jflag++;
2146  break;
2147  case 'j': /* Specify the stride in records */
2148  stride = (long long)(atoi(optarg));
2149  if(stride < 0)
2150  stride=0;
2151  stride_flag=1;
2152  break;
2153  case 't': /* Specify the number of children to run */
2154  num_child1=(atoi(optarg));
2155  num_child = (long long)num_child1;
2156  if(num_child > (long long)MAXSTREAMS) {
2157  printf("invalid options: maximum streams for throughput is MAXSTREAMS\n");
2158 #ifdef NO_PRINT_LLD
2159  printf("Numchild %ld %s\n",num_child,optarg);
2160 #else
2161  printf("Numchild %lld %s\n",num_child,optarg);
2162 #endif
2163  exit(14);
2164  }
2165  if(num_child <= 0)
2166  num_child = 8;
2167  if(num_child == 0)
2168  num_child=1;
2170  maxt = (maxt>num_child?maxt:num_child);
2171  trflag++;
2172  if(Uflag)
2173  {
2174  printf("Can not run throughput tests with unmount & remounts.\n");
2175  exit(15);
2176  }
2177  break;
2178  case 'd': /* Specify the delay of children to run */
2179  delay_start = (long long)(atoi(optarg));
2180  if(delay_start < 0)
2181  delay_start=0;
2182  break;
2183  case 'i': /* Specify specific tests */
2184  tval=(long long)(atoi(optarg));
2185  if(tval < 0) tval=0;
2186 #ifndef HAVE_PREAD
2187  if(tval > RANDOM_MIX_TEST)
2188  {
2189  printf("\tPread tests not available on this operating system.\n");
2190  exit(183);
2191  }
2192 #endif
2193  if(tval > sizeof(func)/sizeof(char *))
2194  {
2195  tval=0;
2196  sprintf(splash[splash_line++],"\tSelected test not available on the version.\n");
2197  }
2198  include_test[tval]++;
2199  include_tflag++;
2200  break;
2201  case 'v': /* Show version information */
2202  for(ind=0; strlen(head1[ind]); ind++)
2203  {
2204  printf("%s\n", head1[ind]);
2205  }
2206  exit(0);
2207  break;
2208  case 'U': /* Specify the dev name for umount/mount*/
2209  Uflag++;
2211  if(trflag)
2212  {
2213  printf("Can not run throughput tests with unmount & remounts.\n");
2214  exit(16);
2215  }
2216  break;
2217  case 'w': /* Do not unlink files */
2218  sprintf(splash[splash_line++],"\tSetting no_unlink\n");
2219  no_unlink = 1;
2220  break;
2221  case 'Z': /* Turn on the mmap and file I/O mixing */
2222  sprintf(splash[splash_line++],"\tEnable mmap & file I/O mixing.\n");
2223  mmap_mix = 1;
2224  break;
2225  case 'W': /* Read/Write with file locked */
2226  file_lock=1;
2227  sprintf(splash[splash_line++],"\tLock file when reading/writing.\n");
2228  break;
2229  case 'K': /* Cause disrupted read pattern */
2230  disrupt_flag=1;
2231  sprintf(splash[splash_line++],"\tDisrupted read patterns selected.\n");
2232  break;
2233  case 'X': /* Open write telemetry file */
2234  compute_flag=1;
2235  sverify=2; /* touch lightly */
2236  w_traj_flag=1;
2238  traj_vers();
2239  w_traj_size();
2240  sprintf(splash[splash_line++],"\tUsing write telemetry file \"%s\"\n",
2243  if(w_traj_fd == (FILE *)0)
2244  exit(200);
2245  break;
2246  case 'Y': /* Open Read telemetry file */
2247  compute_flag=1;
2248  sverify=2; /* touch lightly */
2249  r_traj_flag=1;
2251  sprintf(splash[splash_line++],"\tUsing read telemetry file \"%s\"\n",
2253  traj_vers();
2254  r_traj_size();
2256  if(r_traj_fd == (FILE*) 0)
2257  exit(200);
2258  break;
2259  case 'n': /* Set min file size for auto mode */
2260  nflag=1;
2262  if(optarg[strlen(optarg)-1]=='k' ||
2263  optarg[strlen(optarg)-1]=='K'){
2264  ;
2265  }
2266  if(optarg[strlen(optarg)-1]=='m' ||
2267  optarg[strlen(optarg)-1]=='M'){
2268  minimum_file_size = (long long)(1024 * atoi(optarg));
2269  }
2270  if(optarg[strlen(optarg)-1]=='g' ||
2271  optarg[strlen(optarg)-1]=='G'){
2272  minimum_file_size = (long long)(1024 * 1024 * (long long)atoi(optarg));
2273  }
2274  if(minimum_file_size < RECLEN_START/1024)
2276  if(minimum_file_size < page_size/1024)
2278 #ifdef NO_PRINT_LLD
2279  sprintf(splash[splash_line++],"\tUsing minimum file size of %ld kilobytes.\n",minimum_file_size);
2280 #else
2281  sprintf(splash[splash_line++],"\tUsing minimum file size of %lld kilobytes.\n",minimum_file_size);
2282 #endif
2283  break;
2284  case 'g': /* Set maximum file size for auto mode */
2285  gflag=1;
2287  if(optarg[strlen(optarg)-1]=='k' ||
2288  optarg[strlen(optarg)-1]=='K'){
2289  ;
2290  }
2291  if(optarg[strlen(optarg)-1]=='m' ||
2292  optarg[strlen(optarg)-1]=='M'){
2293  maximum_file_size = (long long)(1024 * atoi(optarg));
2294  }
2295  if(optarg[strlen(optarg)-1]=='g' ||
2296  optarg[strlen(optarg)-1]=='G'){
2297  maximum_file_size = (long long)(1024 * 1024 * (long long)atoi(optarg));
2298  }
2299  if(maximum_file_size < RECLEN_START/1024)
2301 #ifdef NO_PRINT_LLD
2302  sprintf(splash[splash_line++],"\tUsing maximum file size of %ld kilobytes.\n",maximum_file_size);
2303 #else
2304  sprintf(splash[splash_line++],"\tUsing maximum file size of %lld kilobytes.\n",maximum_file_size);
2305 #endif
2306  break;
2307  case 'z': /* Set no cross over */
2308  sprintf(splash[splash_line++],"\tCross over of record size disabled.\n");
2309  NOCROSSflag=1;
2310  break;
2311  case 'y': /* Set min record size for auto mode */
2312  yflag=1;
2313  min_rec_size = ((long long)(atoi(optarg))*1024);
2314  if(optarg[strlen(optarg)-1]=='k' ||
2315  optarg[strlen(optarg)-1]=='K'){
2316  min_rec_size = (long long)(1024 * atoi(optarg));
2317  }
2318  if(optarg[strlen(optarg)-1]=='m' ||
2319  optarg[strlen(optarg)-1]=='M'){
2320  min_rec_size = (long long)(1024 * 1024 * atoi(optarg));
2321  }
2322  if(optarg[strlen(optarg)-1]=='g' ||
2323  optarg[strlen(optarg)-1]=='G'){
2324  min_rec_size = (long long)(1024 * 1024 * 1024 *(long long)atoi(optarg));
2325  }
2326  if(min_rec_size <= 0)
2328 #ifdef NO_PRINT_LLD
2329  sprintf(splash[splash_line++],"\tUsing Minimum Record Size %ld KB\n", min_rec_size/1024);
2330 #else
2331  sprintf(splash[splash_line++],"\tUsing Minimum Record Size %lld KB\n", min_rec_size/1024);
2332 #endif
2333  break;
2334  case 'q': /* Set max record size for auto mode */
2335  qflag=1;
2336  max_rec_size = ((long long)(atoi(optarg))*1024);
2337  if(optarg[strlen(optarg)-1]=='k' ||
2338  optarg[strlen(optarg)-1]=='K'){
2339  max_rec_size = (long long)(1024 * atoi(optarg));
2340  }
2341  if(optarg[strlen(optarg)-1]=='m' ||
2342  optarg[strlen(optarg)-1]=='M'){
2343  max_rec_size = (long long)(1024 * 1024 * atoi(optarg));
2344  }
2345  if(optarg[strlen(optarg)-1]=='g' ||
2346  optarg[strlen(optarg)-1]=='G'){
2347  max_rec_size = (long long)(1024 * 1024 * 1024 *(long long)atoi(optarg));
2348  }
2349  if(max_rec_size <= 0)
2351  if(max_rec_size > MAXBUFFERSIZE) {
2352 #ifdef NO_PRINT_LLD
2353  printf("Error: maximum record size %ld KB is greater than maximum buffer size %ld KB\n ",
2354  max_rec_size/1024, MAXBUFFERSIZE/1024);
2355 #else
2356  printf("Error: maximum record size %lld KB is greater than maximum buffer size %lld KB\n ",
2357  (long long)(max_rec_size/1024LL), (long long)MAXBUFFERSIZE/1024LL);
2358 #endif
2359  exit(23);
2360  }
2361 #ifdef NO_PRINT_LLD
2362  sprintf(splash[splash_line++],"\tUsing Maximum Record Size %ld KB\n", max_rec_size/1024);
2363 #else
2364  sprintf(splash[splash_line++],"\tUsing Maximum Record Size %lld KB\n", max_rec_size/1024);
2365 #endif
2366  break;
2367 
2368  /*
2369  * The + operator is for the new extended options mechanism
2370  * Syntax is -+ followed by option leter, and if the optino
2371  * takes an operand then it is implemented below. An example
2372  * -+a arg is shown below. This is a sub option with an argument.
2373  * -+b is shown below. This is a sub option with no argument.
2374  */
2375  case '+':
2376  /* printf("Plus option = >%s<\n",optarg);*/
2377  switch (*((char *)optarg))
2378  {
2379  case 'a': /* Example: Has argument */
2380  subarg=argv[optind++];
2381  /* if(subarg!=(char *)0) Error checking. */
2382  /* printf("Plus option argument = >%s<\n",subarg);*/
2383  break;
2384  case 'b': /* Example: Does not have an argument */
2385  break;
2386  case 'c': /* Argument is the controlling host name */
2387  /* I am a client for distributed Iozone */
2388  subarg=argv[optind++];
2389  if(subarg==(char *)0)
2390  {
2391  printf("-+c takes an operand !!\n");
2392  exit(200);
2393  }
2394  strcpy(controlling_host_name,subarg);
2395  distributed=1;
2396  client_iozone=1;
2397  master_iozone=0;
2398  break;
2399  case 'h': /* Argument is the controlling host name */
2400  subarg=argv[optind++];
2401  if(subarg==(char *)0)
2402  {
2403  printf("-+h takes an operand !!\n");
2404  exit(200);
2405  }
2406  strcpy(controlling_host_name,subarg);
2407  sprintf(splash[splash_line++],"\tHostname = %s\n",controlling_host_name);
2408  break;
2409  case 'm': /* I am the controlling process for distributed Iozone */
2410  /* Does not have an argument */
2411  subarg=argv[optind++];
2412  if(subarg==(char *)0)
2413  {
2414  printf("-+m takes an operand. ( filename )\n");
2415  exit(201);
2416  }
2417  strcpy(client_filename,subarg);
2418  ret=get_client_info();
2419  if(ret <= 0)
2420  {
2421  printf("Error reading client file\n");
2422  exit(178);
2423  }
2425  distributed=1;
2426  master_iozone=1;
2427  client_iozone=0;
2428  sprintf(splash[splash_line++],"\tNetwork distribution mode enabled.\n");
2429  break;
2430  case 'N': /* turn off truncating the file before write test */
2431  notruncate = 1;
2432  break;
2433  case 'u': /* Set CPU utilization output flag */
2434  cpuutilflag = 1; /* only used if R(eport) flag is also set */
2436  sprintf(splash[splash_line++],"\tCPU utilization Resolution = %5.3f seconds.\n",cputime_res);
2437  sprintf(splash[splash_line++],"\tCPU utilization Excel chart enabled\n");
2438  break;
2439  case 's': /* Clients operate in silent mode. */
2440  /* Does not have an argument */
2441  silent=1;
2442  break;
2443  case 'd': /* Diagnostics mode */
2444  sprintf(splash[splash_line++],"\t>>> I/O Diagnostic mode enabled. <<<\n");
2445  sprintf(splash[splash_line++],"\tPerformance measurements are invalid in this mode.\n");
2446  diag_v=1;
2447  sverify=0;
2448  break;
2449  case 'x': /* Argument is the multiplier for rec size and file size */
2450  subarg=argv[optind++];
2451  if(subarg==(char *)0)
2452  {
2453  printf("-+c takes an operand !!\n");
2454  exit(200);
2455  }
2456  multiplier = atoi(subarg);
2457  if(multiplier <=1)
2458  multiplier = 2;
2459  break;
2460  case 'i': /* Argument is the host port */
2461  subarg=argv[optind++];
2462  if(subarg==(char *)0)
2463  {
2464  printf("-+i takes an operand !!\n");
2465  exit(200);
2466  }
2467  controlling_host_port = atoi(subarg);
2468  break;
2469  case 'p': /* Argument is the percentage read */
2470  subarg=argv[optind++];
2471  if(subarg==(char *)0)
2472  {
2473  printf("-+p takes an operand !!\n");
2474  exit(200);
2475  }
2476  pct_read = atoi(subarg);
2477  if(pct_read < 1)
2478  pct_read = 1;
2479  if(pct_read >=100)
2480  pct_read = 100;
2481  sprintf(splash[splash_line++],"\tPercent read in mix test is %d\n",pct_read);
2482  break;
2483  case 't': /* Speed code activated */
2484  speed_code=1;
2485  break;
2486 #if defined(_HPUX_SOURCE) || defined(linux) || defined(solaris)
2487  case 'r': /* Read sync too */
2488  read_sync=1;
2489  sprintf(splash[splash_line++],"\tRead & Write sync mode active.\n");
2490  break;
2491 #endif
2492 #ifndef NO_MADVISE
2493  case 'A': /* Argument is madvise selector */
2494  subarg=argv[optind++];
2495  if(subarg==(char *)0)
2496  {
2497  printf("-+A take an operand !!\n");
2498  exit(200);
2499  }
2500  advise_flag=1;
2501  advise_op=atoi(subarg);
2502  sprintf(splash[splash_line++],"\tMadvise enabled: %d\n",advise_op);
2503  break;
2504 #endif
2505  case 'n': /* Set no-retest */
2506  noretest = 1;
2507  sprintf(splash[splash_line++],"\tNo retest option selected\n");
2508  break;
2509  case 'k': /* Constant aggregate data set size */
2510  aggflag=1;
2511  break;
2512  case 'q': /* Argument is the rest time between tests in seconds */
2513  subarg=argv[optind++];
2514  if(subarg==(char *)0)
2515  {
2516  printf("-+q takes an operand !!\n");
2517  exit(200);
2518  }
2519  rest_val = (long long)atoi(subarg);
2520  if(rest_val <=0)
2521  rest_val = 0;
2522  restf=1;
2523  sprintf(splash[splash_line++],"\tDelay %d seconds between tests enabled.\n",atoi(subarg));
2524  break;
2525 #if defined(O_DSYNC)
2526  case 'D': /* O_DSYNC mode */
2527  sprintf(splash[splash_line++],"\t>>> O_DSYNC mode enabled. <<<\n");
2528  odsync=1;
2529  break;
2530 #endif
2531  case 'l': /* Record locking mode */
2532  sprintf(splash[splash_line++],"\t>>> Record locking mode enabled. <<<\n");
2533  rlocking=1;
2534  break;
2535  case 'L': /* Record locking mode shared files*/
2536  sprintf(splash[splash_line++],"\t>>> Record locking, shared file mode enabled. <<<\n");
2537  share_file=1;
2538  rlocking=1;
2539  break;
2540  case 'V': /* No Record locking shared files*/
2541  sprintf(splash[splash_line++],"\t>>> Shared file mode enabled. <<<\n");
2542  share_file=1;
2543  break;
2544  case 'B': /* Sequential mix */
2545  sprintf(splash[splash_line++],"\t>>> Sequential Mixed workload. <<<\n");
2546  seq_mix=1;
2547  break;
2548  /* Use an existing user file, that does
2549  not contain Iozone's pattern. Use file
2550  for testing, but read only, and no
2551  delete at the end of the test. Also,
2552  no pattern verification, but do touch
2553  the pages. */
2554  case 'E':
2555  sprintf(splash[splash_line++],"\t>>> No Verify mode. <<<\n");
2556  sverify=2;
2557  no_unlink=1;
2558  no_write=1;
2559  break;
2560  case 'T': /* Time stamps on */
2561  L_flag=1;
2562  break;
2563  case 'X': /* Short circuit test mode */
2564  X_flag = 1;
2565  sverify=1;
2566  verify=1;
2567  inp_pat = 0xBB;
2568  pattern = ((inp_pat << 24) |
2569  (inp_pat << 16) | (inp_pat << 8) |
2570  inp_pat);
2571  sprintf(splash[splash_line++],"\tShort circuit mode. For\n");
2572  sprintf(splash[splash_line++],"\t filesystem development testing ONLY !\n");
2573  break;
2574  case 'Z': /* Compatibility mode for 0xA5 */
2575  Z_flag = 1;
2576  sverify=1;
2577  verify=1;
2578  inp_pat = 0xA5;
2579  pattern = ((inp_pat << 24) |
2580  (inp_pat << 16) | (inp_pat << 8) |
2581  inp_pat);
2582  sprintf(splash[splash_line++],"\tUsing old data sets.\n");
2583  sprintf(splash[splash_line++],"\t Performance measurements may be invalid in this\n");
2584  sprintf(splash[splash_line++],"\t mode due to published hack.\n");
2585  break;
2586 #if defined(Windows)
2587  case 'U': /* Windows only Unbufferd I/O */
2588  unbuffered=1;
2589  sprintf(splash[splash_line++],"\tUnbuffered Windows API usage. >>> Very Experimental <<<\n");
2590  break;
2591 #endif
2592  case 'K': /* Sony special for manual control of test 8 */
2593  subarg=argv[optind++];
2594  if(subarg==(char *)0)
2595  {
2596  printf("-+K takes an operand !!\n");
2597  exit(204);
2598  }
2599  Kplus_readers = (int)atoi(subarg);
2600  if(Kplus_readers <=0)
2601  Kplus_readers = 1;
2602  Kplus_flag=1;
2603  sprintf(splash[splash_line++],"\tManual control of test 8. >>> Very Experimental. Sony special <<<\n");
2604  break;
2605  case 'w': /* Argument is the percent of dedup */
2606  /* Sets size of dedup region across files */
2607  subarg=argv[optind++];
2608  if(subarg==(char *)0)
2609  {
2610  printf("-+w takes an operand !!\n");
2611  exit(200);
2612  }
2613  dedup = atoi(subarg);
2614  if(dedup <=0)
2615  dedup = 0;
2616  if(dedup >100)
2617  dedup = 100;
2618  sprintf(splash[splash_line++],"\tDedup activated %d percent.\n",dedup);
2619  break;
2620  case 'y': /* Argument is the percent of interior dedup */
2621  /* Sets size of dedup region within and across files */
2622  subarg=argv[optind++];
2623  if(subarg==(char *)0)
2624  {
2625  printf("-+y takes an operand !!\n");
2626  exit(200);
2627  }
2628  dedup_interior = atoi(subarg);
2629  if(dedup_interior <0)
2630  dedup_interior = 0;
2631  if(dedup_interior >100)
2632  dedup_interior = 100;
2633  sprintf(splash[splash_line++],"\tDedupe within & across %d percent.\n",dedup_interior);
2634  break;
2635  case 'C': /* Argument is the percent of dedupe within & !across */
2636  /* Sets size of dedup region within and !across files */
2637  subarg=argv[optind++];
2638  if(subarg==(char *)0)
2639  {
2640  printf("-+C takes an operand !!\n");
2641  exit(200);
2642  }
2643  dedup_compress = atoi(subarg);
2644  if(dedup_compress <0)
2645  dedup_compress = 0;
2646  if(dedup_compress >100)
2647  dedup_compress = 100;
2648  sprintf(splash[splash_line++],"\tDedupe within %d percent.\n",dedup_compress);
2649  break;
2650  case 'S': /* Argument is the seed for dedup */
2651  subarg=argv[optind++];
2652  if(subarg==(char *)0)
2653  {
2654  printf("-+S takes an operand !!\n");
2655  exit(200);
2656  }
2657  dedup_mseed = atoi(subarg);
2658  if(dedup_mseed ==0)
2659  dedup_mseed = 1;
2660  sprintf(splash[splash_line++],"\tDedup manual seed %d .\n",dedup_mseed);
2661  break;
2662  case 'H': /* Argument is hostname of the PIT */
2663  subarg=argv[optind++];
2664  if(subarg==(char *)0)
2665  {
2666  printf("-+H takes operand !!\n");
2667  exit(200);
2668  }
2669  strcpy(pit_hostname,subarg);
2670  sprintf(splash[splash_line++],"\tPIT_host %s\n",pit_hostname);
2671 
2672  break;
2673  case 'P': /* Argument is port of the PIT */
2674  subarg=argv[optind++];
2675  if(subarg==(char *)0)
2676  {
2677  printf("-+P takes operand !!\n");
2678  exit(200);
2679  }
2680  strcpy(pit_service,subarg);
2681  sprintf(splash[splash_line++],"\tPIT_port %s\n",pit_service);
2682  break;
2683  case 'z': /* Enable hist summary*/
2684  hist_summary=1;
2685  sprintf(splash[splash_line++],"\tHistogram summary enabled.\n");
2686  break;
2687  case 'O': /* Argument is the Op rate */
2688  subarg=argv[optind++];
2689  if(subarg==(char *)0)
2690  {
2691  printf("-+O takes an operand !!\n");
2692  exit(200);
2693  }
2694  op_rate = atoi(subarg);
2695  if(op_rate <= 0)
2696  op_rate = 1;
2697  op_rate_flag = 1;
2698  sprintf(splash[splash_line++],"\tRate control active %d Ops/sec .\n",op_rate);
2699  break;
2700  default:
2701  printf("Unsupported Plus option -> %s <-\n",optarg);
2702  exit(255);
2703  break;
2704  }
2705  break;
2706  default:
2707  printf("Unsupported option -> %s <-\n",optarg);
2708  exit(255);
2709  }
2710  }
2712  get_resolution(); /* Get clock resolution */
2714  {
2716  exit(0);
2717  }
2718  if(r_count > 1)
2719  {
2720  aflag=1;
2721  rflag=0;
2722  NOCROSSflag=1;
2723  }
2724  if(s_count > 1)
2725  {
2726  aflag=1;
2727  sflag=0;
2728  NOCROSSflag=1;
2729  }
2730  /*
2731  * If not in silent mode then display the splash screen.
2732  */
2733  for(i=0;i<splash_line;i++)
2734  if(!silent) printf("%s",splash[i]);
2735  /*
2736  * Save the command line for later
2737  */
2739 
2740  if(pflag) /* Allocate after cache_size is set */
2741  {
2742  alloc_pbuf();
2743  }
2745  {
2746  if(maxt > clients_found)
2747  {
2748  printf("You can not specify more threads/processes than you have in the client file list\n");
2749  exit(202);
2750  }
2751  }
2752 
2754  {
2755  if(!silent) printf("\tOutput is in Kbytes/sec\n");
2756  }
2758 #ifdef NO_PRINT_LLD
2759  printf("Error: minimum record size %ld KB is greater than maximum record size %ld KB\n ",
2760  min_rec_size/1024, max_rec_size/1024);
2761 #else
2762  printf("Error: minimum record size %lld KB is greater than maximum record size %lld KB\n ",
2763  min_rec_size/1024, max_rec_size/1024);
2764 #endif
2765  exit(23);
2766  }
2769  /*
2770  * No telemetry files... just option selected
2771  */
2772  if(compute_flag && jflag && !(r_traj_flag || w_traj_flag))
2773  if(!silent) printf("\tCompute time %f seconds for reads and writes.\n",compute_time);
2774  /*
2775  * Read telemetry file and option selected
2776  */
2778  {
2779  if(r_traj_items==3)
2780  {
2781  if(!silent) printf("\tCompute time from telemetry files for reads.\n");
2782  }
2783  else
2784  {
2785  if(jflag)
2786  if(!silent) printf("\tCompute time %f seconds for reads.\n",compute_time);
2787  }
2788  if(jflag)
2789  if(!silent) printf("\tCompute time %f seconds for writes.\n",compute_time);
2790  }
2791  /*
2792  * Write telemetry file and option selected
2793  */
2795  {
2796  if(w_traj_items==3)
2797  {
2798  if(!silent) printf("\tCompute time from telemetry files for writes.\n");
2799  }
2800  else
2801  {
2802  if(jflag)
2803  if(!silent) printf("\tCompute time %f seconds for writes.\n",compute_time);
2804  }
2805  if(jflag)
2806  if(!silent) printf("\tCompute time %f seconds for reads.\n",compute_time);
2807  }
2809  {
2810  if(r_traj_items==3)
2811  {
2812  if(!silent) printf("\tCompute time from telemetry files for reads.\n");
2813  }
2814  else
2815  {
2816  if(!silent) printf("\tCompute time %f seconds for reads.\n",compute_time);
2817  }
2818  if(w_traj_items==3)
2819  {
2820  if(!silent) printf("\tCompute time from telemetry files for writes.\n");
2821  }
2822  else
2823  {
2824  if(!silent) printf("\tCompute time %f seconds for writes.\n",compute_time);
2825  }
2826  }
2828  {
2829  if(r_traj_items==3)
2830  {
2831  if(!silent) printf("\tCompute time from telemetry files for reads.\n");
2832  }
2833  else
2834  {
2835  if(!silent) printf("\tNo compute time for reads.\n");
2836  }
2837 
2838  if(w_traj_items==3)
2839  {
2840  if(!silent) printf("\tCompute time from telemetry files for writes.\n");
2841  }
2842  else
2843  {
2844  if(!silent) printf("\tNo compute time for writes.\n");
2845  }
2846  }
2847 
2848  /* Enforce only write,rewrite,read,reread */
2850  {
2851  for(i=2;i<sizeof(func)/sizeof(char *);i++)
2852  {
2853  if(seq_mix && (i==8))
2854  ;
2855  else
2856  include_test[i] = 0;
2857  }
2858  }
2859 
2861  {
2862  if(include_test[READER_TEST] == 0)
2863  {
2866  include_tflag=1;
2867  }
2868  }
2870  {
2871  if(include_test[WRITER_TEST] == 0)
2872  {
2874  include_tflag=1;
2875  }
2876  }
2877  if(w_traj_flag && w_traj_fsize != 0)
2879  if(r_traj_flag && r_traj_fsize != 0)
2881 
2882  if( sverify==0 && (w_traj_flag || r_traj_flag))
2883  {
2884  printf("\n\tFull verification not supported in telemetry mode.\n\n");
2885  exit(17);
2886  }
2887  ;
2889  {
2890  printf("\n\tDisrupt not supported in telemetry mode.\n\n");
2891  exit(17);
2892  }
2893  if(aflag &&(w_traj_flag || r_traj_flag) )
2894  {
2895  printf("\n\tAuto mode not supported in telemetry mode.\n");
2896  printf("\tTry: -i 0 -i 1 \n\n");
2897  exit(17);
2898  }
2900  {
2901  printf("\n\tSize of file is determined by telemetry file.\n\n");
2902  exit(17);
2903  }
2905  {
2906  printf("\n\tRecord size of file is determined by telemetry file.\n\n");
2907  exit(17);
2908  }
2909  if(stride_flag && (w_traj_flag || r_traj_flag))
2910  {
2911  printf("\n\tStride size is determined by telemetry file.\n\n");
2912  exit(17);
2913  }
2915  {
2916  printf("\n\tMicrosecond mode not supported in throughput mode.\n\n");
2917  exit(17);
2918  }
2919  if (trflag /* throughput mode, don't allow auto-mode options: */
2920  && (auto_mode || aflag || yflag || qflag || nflag || gflag))
2921  {
2922  printf("\n\tCan not mix throughput mode and auto-mode flags.\n\n");
2923  exit(17);
2924  }
2925  if(fflag && trflag)
2926  {
2927  printf("\n\tYou must use -F when using multiple threads or processes.\n\n");
2928  exit(17);
2929  }
2930  if(aflag && mfflag)
2931  {
2932  printf("\n\tYou must use -f when using auto mode.\n\n");
2933  exit(17);
2934  }
2936  {
2937  printf("\n\tSorry ... Only mmap or async but not both\n\n");
2938  exit(18);
2939  }
2940 #ifndef ASYNC_IO
2942  {
2943  printf("\n\tSorry ... This version does not support async I/O\n\n");
2944  exit(19);
2945  }
2946 #endif
2948  {
2949  if(!include_tflag)
2950  {
2951  printf("You must specify which tests ( -i # ) when using -+E\n");
2952  exit(19);
2953  }
2954  }
2956  {
2957  for(i=0;i<sizeof(func)/sizeof(char *);i++)
2958  if(include_test[i])
2959  include_mask|=(long long)(1<<i);
2960  /* printf(">> %llx",include_mask); HERE */
2961  }
2962  if(no_write) /* Disable if any writer would disturbe existing file */
2963  {
2964  if(include_test[0] || include_test[4] ||
2965  include_test[6] || include_test[8] || include_test[9] ||
2966  include_test[11])
2967  {
2968  printf("You must disable any test that writes when using -+E\n");
2969  exit(20);
2970  }
2971  }
2972  if(no_write) /* User must specify the existing file name */
2973  {
2974  if(!(fflag | mfflag))
2975  {
2976  printf("You must use -f or -F when using -+E\n");
2977  exit(20);
2978  }
2979  }
2981  {
2982  printf("\n\tCan not do both -H and -k\n");
2983  exit(20);
2984  }
2985  if((dedup | dedup_interior) && diag_v)
2986  {
2987  printf("\n\tCan not do both -+d and -+w\n");
2988  exit(20);
2989  }
2990 
2991  if(!aflag && !rflag)
2993 
2995  if(!silent) printf("\tTime Resolution = %1.6f seconds.\n",time_res);
2996 #ifdef NO_PRINT_LLD
2997  if(!silent) printf("\tProcessor cache size set to %ld Kbytes.\n",cache_size/1024);
2998  if(!silent) printf("\tProcessor cache line size set to %ld bytes.\n",cache_line_size);
2999  if(!silent) printf("\tFile stride size set to %ld * record size.\n",stride);
3000 #else
3001  if(!silent) printf("\tProcessor cache size set to %ld Kbytes.\n",cache_size/1024);
3002  if(!silent) printf("\tProcessor cache line size set to %ld bytes.\n",cache_line_size);
3003  if(!silent) printf("\tFile stride size set to %lld * record size.\n",stride);
3004 #endif
3005  if(!rflag)
3006  reclen=(long long)4096;
3007 
3008  if(uflag && !lflag)
3009  num_child=mint = 1;
3010  if(lflag && !uflag)
3011  maxt = mint;
3012  if(use_thread)
3013  port="thread";
3014  else
3015  port="process";
3016  if(lflag || uflag){
3017 #ifdef NO_PRINT_LLD
3018  if(!silent) printf("\tMin %s = %ld \n",port,mint);
3019  if(!silent) printf("\tMax %s = %ld \n",port,maxt);
3020 #else
3021  if(!silent) printf("\tMin %s = %lld \n",port,mint);
3022  if(!silent) printf("\tMax %s = %lld \n",port,maxt);
3023 #endif
3024  }
3025  if(trflag)
3026  {
3027  if(num_child > 1)
3028  {
3029  if(use_thread)
3030  {
3031  port="threads";
3032  }
3033  else
3034  {
3035  port="processes";
3036  }
3037  }
3038 
3039 #ifdef NO_PRINT_LLD
3040  if(!silent) printf("\tThroughput test with %ld %s\n", num_child,port);
3041 #else
3042  if(!silent) printf("\tThroughput test with %lld %s\n", num_child,port);
3043 #endif
3044  }
3045  numrecs64 = (long long)(kilobytes64*1024)/reclen;
3046  if (reclen > (long long)MAXBUFFERSIZE) {
3047 #ifdef NO_PRINT_LLD
3048  printf("Error: Maximum record length is %ld bytes\n",
3049  MAXBUFFERSIZE);
3050 #else
3051  printf("Error: Maximum record length is %lld bytes\n",
3052  (long long)MAXBUFFERSIZE);
3053 #endif
3054  exit(21);
3055  }
3056  if (reclen < (long long)MINBUFFERSIZE) {
3057 #ifdef NO_PRINT_LLD
3058  printf("Error: Minimum record length is %ld bytes\n",
3059  MINBUFFERSIZE);
3060 #else
3061  printf("Error: Minimum record length is %lld bytes\n",
3062  (long long)MINBUFFERSIZE);
3063 #endif
3064  exit(22);
3065  }
3066  /* Only bzero or fill that which you will use. The buffer is very large */
3067  if(verify )
3068  {
3069  fill_buffer((char *)buffer,l_min(reclen,(long long)cache_size),(long long)pattern,(char)sverify,(long long)0);
3070  if(pflag)
3071  fill_buffer((char *)pbuffer,l_min(reclen,(long long)cache_size),(long long)pattern,(char)sverify,(long long)0);
3072  if(mflag)
3073  fill_buffer((char *)mbuffer,l_min(reclen,(long long)cache_size),(long long)pattern,(char)sverify,(long long)0);
3074  }
3075  else
3076  {
3077  bzero(buffer,(size_t)l_min(reclen,(long long)cache_size));
3078  }
3079 
3080 #ifndef NO_THREADS
3081 #if defined( _HPUX_SOURCE ) || defined ( linux )
3082  if(ioz_processor_bind)
3083  {
3084  bind_cpu=begin_proc;
3085 #if defined( _HPUX_SOURCE )
3086  pthread_processor_bind_np(PTHREAD_BIND_FORCED_NP,
3087  (pthread_spu_t *)&anwser, (pthread_spu_t)bind_cpu, pthread_self());
3088 #else
3089  cpu_set_t cpuset;
3090  CPU_ZERO(&cpuset);
3091  CPU_SET(bind_cpu, &cpuset);
3092 
3093  pthread_setaffinity_np(pthread_self(), sizeof(cpuset),&cpuset);
3094 #endif
3095  my_nap(40); /* Switch to new cpu */
3096  }
3097 #endif
3098 #endif
3100  if(trflag){
3102  goto out;
3103  }
3104  if(trflag && (mint == maxt)){
3105  auto_mode=0;
3106  throughput_test();
3107  goto out;
3108  }
3109  if (aflag) {
3110  print_header();
3111  auto_test();
3112  goto out;
3113  }
3114  print_header();
3116 out:
3117  if(r_traj_flag)
3118  fclose(r_traj_fd);
3119  if(w_traj_flag)
3120  fclose(w_traj_fd);
3121  if (!no_unlink)
3122  {
3123  if(check_filename(dummyfile[0]))
3124  unlink(dummyfile[0]); /* delete the file */
3125  }
3126  if(!silent) printf("\niozone test complete.\n");
3127  if(res_prob)
3128  {
3129  printf("Timer resolution is poor. Some small transfers may have \n");
3130  printf("reported inaccurate results. Sizes %ld Kbytes and below.\n",
3131  (long)(rec_prob/(long long)1024));
3132  }
3133 
3134  if(Rflag && !trflag){
3135  dump_excel();
3136  }
3137  return(0);
3138 }
3139 
3140 #ifdef HAVE_ANSIC_C
3141 void
3142 record_command_line(int argc, char **argv)
3143 #else
3144 void
3145 record_command_line(argc, argv)
3146 int argc;
3147 char **argv;
3148 #endif
3149 {
3150  int ix, len = 0;
3151 
3152  /* print and save the entire command line */
3153  if(!silent) printf("\tCommand line used:");
3154  for (ix=0; ix < argc; ix++) {
3155  if(!silent) printf(" %s", argv[ix]);
3156  if ((len + strlen(argv[ix])) < sizeof(command_line)) {
3157  strcat (command_line, argv[ix]);
3158  strcat (command_line, " ");
3159  len += strlen(argv[ix]) + 1;
3160  }
3161  else {
3162  printf ("Command line too long to save completely.\n");
3163  break;
3164  }
3165  }
3166  if(!silent) printf("\n");
3167 }
3168 
3169 /*************************************************************************/
3170 /* BEGIN() */
3171 /* This is the main work horse. It is called from main and from */
3172 /* auto_test. The caller provides the size of file and the record length.*/
3173 /*************************************************************************/
3174 #ifdef HAVE_ANSIC_C
3175 void
3176 begin(off64_t kilos64,long long reclength)
3177 #else
3178 void
3179 begin(kilos64,reclength)
3180 off64_t kilos64;
3181 long long reclength;
3182 #endif
3183 {
3184  long long num_tests,test_num,i,j;
3185  long long data1[MAXTESTS], data2[MAXTESTS];
3186  num_tests = sizeof(func)/sizeof(char *);
3187 #if defined(HAVE_PREAD)
3188  if(!Eflag)
3189  {
3190 #if defined(HAVE_PREAD) && defined(HAVE_PREADV)
3191  num_tests -= 4;
3192 #else
3193  num_tests -= 2;
3194 #endif
3195  if(mmapflag || async_flag)
3196  {
3197  num_tests -= 2;
3198  }
3199  }
3200  else
3201  {
3202  if(mmapflag || async_flag)
3203 #if defined(HAVE_PREAD) && defined(HAVE_PREADV)
3204  num_tests -= 6;
3205 #else
3206  num_tests -= 4;
3207 #endif
3208  }
3209 #else
3210  if(mmapflag || async_flag)
3211  {
3212  num_tests -= 2;
3213  }
3214 #endif
3215 
3216  if(RWONLYflag) num_tests = 2; /* kcollins 8-21-96*/
3217  sync(); /* just in case there were some dirty */
3218  sync();
3219  kilobytes64=kilos64;
3220  reclen=reclength;
3221  numrecs64 = (kilobytes64*1024)/reclen;
3222  store_value(kilobytes64);
3223  if(r_traj_flag || w_traj_flag)
3224  store_value((off64_t)0);
3225  else
3226  store_value((off64_t)(reclen/1024));
3227 
3228 #ifdef NO_PRINT_LLD
3229  if(!silent) printf("%16ld",kilobytes64);
3230  if(r_traj_flag || w_traj_flag)
3231  {
3232  if(!silent) printf("%8ld",0);
3233  }
3234  else
3235  {
3236  if(!silent) printf("%8ld",reclen/1024);
3237  }
3238 #else
3239  if(!silent) printf("%16lld",kilobytes64);
3240  if(r_traj_flag || w_traj_flag)
3241  {
3242  if(!silent) printf("%8lld",(long long )0);
3243  }
3244  else
3245  {
3246  if(!silent) printf("%8lld",reclen/1024);
3247  }
3248 #endif
3249  if(include_tflag)
3250  {
3251  for(i=0;i<num_tests;i++)
3252  {
3253  if(include_mask & (long long)(1<<i))
3254  func[i](kilobytes64,reclen,&data1[i],&data2[i]);
3255  else
3256  {
3257  if(!silent) printf("%s",test_output[i]);
3258  fflush(stdout);
3259  for(j=0;j<test_soutput[i];j++)
3260  store_value((off64_t)0);
3261  }
3262  }
3263  }
3264  else
3265  {
3266  for(test_num=0;test_num < num_tests;test_num++)
3267  {
3268  func[test_num](kilobytes64,reclen,&data1[test_num],&data2[test_num]);
3269  };
3270  }
3271  if(!silent) printf("\n");
3272  if(!OPS_flag && !include_tflag){ /* Report in ops/sec ? */
3273  if(data1[1]!=0 && data2[1] != 0)
3274  {
3275  totaltime = data1[1] + data1[0];
3276  if (totaltime < TOOFAST)
3277  {
3278  goodkilos = (TOOFAST/totaltime)*2*kilobytes64;
3279  printf("\nThe test completed too quickly to give a good result\n");
3280  printf("You will get a more precise measure of this machine's\n");
3281  printf("performance by re-running iozone using the command:\n");
3282 #ifdef NO_PRINT_LLD
3283  printf("\n\tiozone %ld ", goodkilos);
3284  printf("\t(i.e., file size = %ld kilobytes64)\n", goodkilos);
3285 #else
3286  printf("\n\tiozone %lld ", goodkilos);
3287  printf("\t(i.e., file size = %lld kilobytes64)\n", goodkilos);
3288 #endif
3289  }
3290  } else {
3291  goodrecl = reclen/2;
3292  printf("\nI/O error during read. Try again with the command:\n");
3293 #ifdef NO_PRINT_LLD
3294  printf("\n\tiozone %ld %ld ", kilobytes64, goodrecl);
3295  printf("\t(i.e. record size = %ld bytes)\n", goodrecl);
3296 #else
3297  printf("\n\tiozone %lld %lld ", kilobytes64, goodrecl);
3298  printf("\t(i.e. record size = %lld bytes)\n", goodrecl);
3299 #endif
3300  }
3301  }
3302  if (!no_unlink)
3303  {
3305  unlink(filename); /* delete the file */
3306  }
3307  /*stop timer*/
3308  return ;
3309 }
3310 /******************************************************************
3311 
3312  SHOW_HELP -- show development help of this program
3313 
3314 ******************************************************************/
3315 #ifdef HAVE_ANSIC_C
3316 void show_help(void)
3317 #else
3318 void show_help()
3319 #endif
3320 {
3321  long long i;
3322  if(!silent) printf("iozone: help mode\n\n");
3323  for(i=0; strlen(help[i]); i++)
3324  {
3325  if(!silent) printf("%s\n", help[i]);
3326  }
3327 }
3328 /******************************************************************
3329 
3330  SIGNAL_HANDLER -- clean up if user interrupts the program
3331 
3332 ******************************************************************/
3333 #ifdef HAVE_ANSIC_C
3334 void signal_handler(void)
3335 #else
3336 void signal_handler()
3337 #endif
3338 {
3339  long long i;
3340  if(distributed)
3341  {
3342  if(master_iozone)
3343  cleanup_children();
3344  }
3345  if((long long)getpid()==myid)
3346  {
3347  if(!silent) printf("\niozone: interrupted\n\n");
3348 #ifndef VMS
3349  if (!no_unlink)
3350  {
3352  unlink(filename); /* delete the file */
3353  }
3354  for(i=1;i<num_child;i++)
3355  {
3356  if(check_filename(dummyfile[i]))
3357  unlink(dummyfile[i]); /* delete the file */
3358  }
3359  if (!no_unlink)
3360  {
3361  if(check_filename(dummyfile[0]))
3362  unlink(dummyfile[0]); /* delete the file */
3363  }
3364 
3365 #endif
3366  if(Rflag && !trflag){
3367  dump_excel();
3368  }
3369  if(Rflag && trflag){
3370  dump_throughput();
3371  }
3372 
3373  if(!silent) printf("exiting iozone\n\n");
3374  if(res_prob)
3375  {
3376  printf("Timer resolution is poor. Some small transfers may have \n");
3377  printf("reported inaccurate results. Sizes %ld Kbytes and below.\n",
3378  (long)rec_prob/1024);
3379  }
3380  if(trflag && !use_thread)
3381  for(i=0;i<num_child;i++)
3382  kill((pid_t)childids[i],SIGTERM);
3383  if(r_traj_flag)
3384  fclose(r_traj_fd);
3385  if(w_traj_flag)
3386  fclose(w_traj_fd);
3387  }
3388  if(sp_msfd)
3389  close(sp_msfd);
3390  if(sp_mrfd)
3391  close(sp_mrfd);
3392  exit(0);
3393 }
3394 
3395 /****************************************************************/
3396 /* */
3397 /* AUTO_TEST -- perform series of tests and tabulate results */
3398 /* */
3399 /****************************************************************/
3400 #ifdef HAVE_ANSIC_C
3401 void
3402 auto_test(void)
3403 #else
3404 void auto_test()
3405 #endif
3406 {
3407  off64_t kilosi;
3408  long long recszi,count1;
3409  long long mult;
3410  long long xx;
3411 
3412  /****************************************************************/
3413  /* Start with file size of 1 megabyte and repeat the test */
3414  /* KILOBYTES_ITER_LIMIT */
3415  /* times. Each time we run, the file size is doubled */
3416  /****************************************************************/
3417 /*
3418  if(sflag) {
3419  min_file_size = kilobytes64;
3420  max_file_size = kilobytes64;
3421  }
3422  if(rflag) {
3423  min_rec_size = reclen;
3424  max_rec_size = reclen;
3425  }
3426 */
3427  if(gflag)
3429  if(nflag)
3431 
3432  if (min_rec_size > (long long)(min_file_size*1024)) {
3433 #ifdef NO_PRINT_LLD
3434  printf("Error: record length %ld is greater than filesize %ld KB\n ",
3436 #else
3437  printf("Error: record length %lld is greater than filesize %lld KB\n ",
3439 #endif
3440  exit(23);
3441  }
3442 
3444 
3446  del_record_sizes();
3450 
3451  for(kilosi=get_next_file_size((off64_t)0); kilosi>0; kilosi=get_next_file_size(kilosi))
3452  {
3453  /****************************************************************/
3454  /* Start with record size of min_rec_size bytes and repeat the */
3455  /* test, multiplying the record size by MULTIPLIER each time, */
3456  /* until we reach max_rec_size. At the CROSSOVER we stop doing */
3457  /* small buffers as it takes forever and becomes very */
3458  /* un-interesting. */
3459  /****************************************************************/
3460  if(!rflag && !sflag && !yflag && !qflag)
3461  if(kilosi > xover){
3463  mult = orig_min_rec_size/1024;
3464  del_record_sizes();
3466  /************************************/
3467  /* Generate dummy entries in the */
3468  /* Excel buffer for skipped */
3469  /* record sizes */
3470  /************************************/
3471  for(count1=min_rec_size;
3472  (count1 != orig_min_rec_size) && (
3473  mult <= (kilosi*1024)) ;
3474  count1=(count1>>1))
3475  {
3476  current_x=0;
3477  store_value((off64_t)kilosi);
3478  store_value((off64_t)mult);
3479  for(xx=0;xx<20;xx++)
3480  store_value((off64_t)0);
3481  mult=mult*2;
3482  current_y++;
3483  if(current_y>max_y)
3484  max_y=current_y;
3485  current_x=0;
3486  }
3487  }
3488 
3489  for (recszi=get_next_record_size((off64_t)0);recszi!=0;recszi=get_next_record_size(recszi))
3490  {
3491  if(recszi > (kilosi*1024))
3492  break;
3493  begin(kilosi, recszi );
3494  current_x=0;
3495  current_y++;
3496  }
3497  }
3498 }
3499 
3500 
3501 /****************************************************************/
3502 /* */
3503 /* THROUGHPUT_TEST () Multi process throughput test */
3504 /* */
3505 /* Note: States for share memory barrier are: */
3506 /* 0 = Child not running or has finished. */
3507 /* 1 = Child is ready to begin. */
3508 /* 2 = Child is told to begin. */
3509 /****************************************************************/
3510 /* Data in shared memory format is: */
3511 /* */
3512 /* struct child_stats { */
3513 /* long long flag; Used to barrier */
3514 /* double walltime; Child's elapsed time */
3515 /* double cputime; Child's CPU time */
3516 /* double throughput; Child's throughput */
3517 /* double actual; Child's actual read/written */
3518 /* } */
3519 /* */
3520 /* There is an array of child_stat structures layed out in */
3521 /* shared memory. */
3522 /* */
3523 /****************************************************************/
3524 
3525 #ifdef HAVE_ANSIC_C
3526 void
3527 throughput_test(void)
3528 #else
3529 void
3531 #endif
3532 {
3533  char *unit;
3534  double starttime1 = 0;
3535  double jstarttime = 0;
3536  double jtime = 0;
3537  double walltime = 0;
3538  double cputime = 0;
3539  char *port;
3540  char getout;
3541  long long throughsize = KILOBYTES;
3542  long long xx,xy,i;
3543  long long xyz;
3544  double ptotal;
3546  VOLATILE char *temp;
3547  double min_throughput = 0;
3548  double max_throughput = 0;
3549  double avg_throughput = 0;
3550  double min_xfer = 0;
3551 
3552 
3553  toutputindex=0;
3554  strcpy(&toutput[0][0],throughput_tests[0]);
3555  ptotal=written_so_far=read_so_far=re_written_so_far=re_read_so_far=0 ;
3556 
3557  if(OPS_flag)
3558  unit="ops";
3559  else
3560  unit="KB";
3561 
3562  if(!haveshm)
3563  {
3564  shmaddr=(struct child_stats *)alloc_mem((long long)SHMSIZE,(int)1);
3565 #ifdef _64BIT_ARCH_
3566  if((long long)shmaddr==(long long)-1)
3567 #else
3568  if((long )shmaddr==(long)-1)
3569 #endif
3570  {
3571  printf("\nShared memory not working\n");
3572  exit(24);
3573  }
3574  haveshm=(char*)shmaddr;
3575  }
3576  else
3577  shmaddr=(struct child_stats *)haveshm;
3578 
3579  if(use_thread)
3580  stop_flag = &stoptime;
3581  else
3582  {
3583  temp = (char *)&shmaddr[0];
3584  stop_flag = (char *)&temp[(long long)SHMSIZE]-4;
3585  }
3586  for(xyz=0;xyz<num_child;xyz++){ /* all children to state 0 (HOLD) */
3587  child_stat = (struct child_stats *)&shmaddr[xyz];
3589  child_stat->actual=0;
3591  child_stat->cputime=0;
3592  child_stat->walltime=0;
3593  }
3594  *stop_flag = 0;
3595  if(!sflag)
3596  kilobytes64=throughsize;
3597  if(!rflag)
3598  reclen=(long long)4096;
3599  if(aggflag)
3600  kilobytes64=orig_size/num_child;
3601  numrecs64 = (long long)(kilobytes64*1024)/reclen;
3603  if(use_thread)
3604  port="thread";
3605  else
3606  port="process";
3607  if(w_traj_flag)
3608  {
3609 #ifdef NO_PRINT_LLD
3610  if(!silent) printf("\tEach %s writes a %ld Kbyte file in telemetry controlled records\n",
3611  port,kilobytes64);
3612 #else
3613  if(!silent) printf("\tEach %s writes a %lld Kbyte file in telemetry controlled records\n",
3614  port,kilobytes64);
3615 #endif
3616  }
3617  else
3618  {
3619 #ifdef NO_PRINT_LLD
3620  if(!silent) printf("\tEach %s writes a %ld Kbyte file in %ld Kbyte records\n",
3621  port,kilobytes64,reclen/1024);
3622 #else
3623  if(!silent) printf("\tEach %s writes a %lld Kbyte file in %lld Kbyte records\n",
3624  port,kilobytes64,reclen/1024);
3625 #endif
3626  }
3627 
3628  if(fflag) /* Each child has a file name to write */
3629  for(xx=0;xx<num_child;xx++)
3630  filearray[xx] = filename;
3631  myid = (long long)getpid();
3632 
3633  /* rags: skip writer test */
3634  if(include_tflag)
3635  if(!(include_mask & (long long)WRITER_MASK))
3636  {
3637  store_dvalue( (double)0);
3638  store_dvalue( (double)0);
3639  toutputindex++;
3640  goto next0;
3641  }
3642 
3643  if((!distributed) || (distributed && master_iozone))
3644  start_monitor("Write");
3645  /* Hooks to start the distributed Iozone client/server code */
3646  if(distributed)
3647  {
3648  use_thread=0; /* Turn of any Posix threads */
3649  if(master_iozone)
3651  else
3652  become_client();
3653  }
3654  if(!use_thread)
3655  {
3656  for(xx = 0; xx< num_child ; xx++){ /* Create the children */
3657  chid=xx;
3659  if(childids[xx]==-1){
3660  printf("\nFork failed\n");
3661  for(xy = 0; xy< xx ; xy++){
3662  if(!use_thread)
3663  kill((pid_t)childids[xy],SIGTERM);
3664  }
3665  exit(25);
3666  }
3667  if(childids[xx]!=0 && debug1)
3668 #ifdef NO_PRINT_LLD
3669  printf("Parent starting slot %ld\n",xx);
3670 #else
3671  printf("Parent starting slot %lld\n",xx);
3672 #endif
3673  if( childids[xx] == 0 ){
3674 #ifdef _64BIT_ARCH_
3675  thread_write_test((void *)xx);
3676 #else
3677  thread_write_test((void *)(long)xx);
3678 #endif
3679  }else {
3680 #ifdef NO_PRINT_LLD
3681  sprintf(dummyfile[xx],"%s.DUMMY.%ld",filearray[xx], xx);
3682 #else
3683  sprintf(dummyfile[xx],"%s.DUMMY.%lld",filearray[xx], xx);
3684 #endif
3685  }
3686  }
3687  }
3688 #ifndef NO_THREADS
3689  else
3690  {
3691  for(xx = 0; xx< num_child ; xx++){ /* Create the children */
3692 
3693 #ifdef NO_PRINT_LLD
3694  sprintf(dummyfile[xx],"%s.DUMMY.%ld",filearray[xx], xx);
3695 #else
3696  sprintf(dummyfile[xx],"%s.DUMMY.%lld",filearray[xx], xx);
3697 #endif
3698  if(!barray[xx])
3699  {
3700  barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0);
3701  if(barray[xx] == 0) {
3702  perror("Memory allocation failed:");
3703  exit(26);
3704  }
3705  barray[xx] =(char *)(((long)barray[xx] + cache_size ) &
3706  ~(cache_size-1));
3707  }
3708 
3709 #ifdef _64BIT_ARCH_
3711 #else
3712  childids[xx] = mythread_create(thread_write_test,(void*)(long)xx);
3713 #endif
3714  if(childids[xx]==-1){
3715  printf("Thread create failed\n");
3716  for(xy = 0; xy< xx ; xy++){
3717  kill((pid_t)myid,SIGTERM);
3718  }
3719  exit(27);
3720  }
3721  }
3722  }
3723 #endif
3724  if((long long)getpid() == myid)
3725  {
3726  prepage(buffer,reclen); /* Force copy on write */
3727  /* wait for children to start */
3728  if(distributed && master_iozone)
3729  {
3730  start_master_listen_loop((int) num_child);
3731  }
3732  for(i=0;i<num_child; i++){
3733  child_stat = (struct child_stats *)&shmaddr[i];
3735  Poll((long long)1);
3736  }
3737  for(i=0;i<num_child; i++) /* Start all children going */
3738  {
3739  if(delay_start!=0)
3740  Poll((long long)delay_start);
3741  /* State "go" */
3742  child_stat = (struct child_stats *)&shmaddr[i];
3744  if(distributed && master_iozone)
3746  }
3747  starttime1 = time_so_far(); /* Start parents timer */
3748  goto waitout;
3749  }
3750 
3751 waitout:
3752  getout=0;
3753  if((long long)getpid() == myid) { /* Parent only */
3754  starttime1 = time_so_far(); /* Wait for all children */
3755  for( i = 0; i < num_child; i++){
3756  child_stat = (struct child_stats *) &shmaddr[i];
3757  if(distributed && master_iozone)
3758  {
3759  printf("\n\tTest running:");
3760  wait_dist_join();
3761  break;
3762  }
3763  else
3764  {
3765  if(use_thread)
3766  {
3767  thread_join(childids[i],(void *)&pstatus);
3768  }
3769  else
3770  {
3771  wait(0);
3772  }
3773  }
3774  if(!jstarttime)
3775  jstarttime = time_so_far();
3776  }
3777  jtime = (time_so_far()-jstarttime)-time_res;
3778  if(jtime < (double).000001)
3779  {
3780  jtime=time_res;
3781  }
3782  }
3783  total_time = (time_so_far() - starttime1)-time_res; /* get parents total time */
3784  if(total_time < (double).000001)
3785  {
3787  if(rec_prob < reclen)
3788  rec_prob = reclen;
3789  res_prob=1;
3790  }
3791 #ifdef JTIME
3792  total_time=total_time-jtime;/* Remove the join time */
3793  if(!silent) printf("\nJoin time %10.2f\n",jtime);
3794 #endif
3795 
3796  total_kilos=0;
3797  ptotal=0;
3798  walltime = 0.0;
3799  cputime = 0.0;
3800  if(!silent) printf("\n");
3801  for(xyz=0;xyz<num_child;xyz++){
3802  child_stat = (struct child_stats *) &shmaddr[xyz];
3803  total_kilos += child_stat->throughput; /* add up the children */
3804  ptotal += child_stat->actual;
3805  if(!min_xfer)
3806  min_xfer=child_stat->actual;
3807  if(child_stat->actual < min_xfer)
3808  min_xfer=child_stat->actual;
3809  if(!min_throughput)
3810  min_throughput=child_stat->throughput;
3811  if(child_stat->throughput < min_throughput)
3812  min_throughput=child_stat->throughput;
3813  if(child_stat->throughput > max_throughput)
3814  max_throughput=child_stat->throughput;
3815  /* Add up the cpu times of all children */
3816  cputime += child_stat->cputime;
3817 
3818  /* and find the child with the longest wall time */
3819  /* Get the earliest start time and latest fini time to calc. elapsed time. */
3822  if (child_stat->walltime > walltime)
3823  walltime = child_stat->walltime;
3824  }
3825  avg_throughput=total_kilos/num_child;
3826  if(cpuutilflag)
3827  {
3828  if (cputime < cputime_res)
3829  cputime = 0.0;
3830  }
3831 
3832  for(xyz=0;xyz<num_child;xyz++){
3833  child_stat = (struct child_stats *) &shmaddr[xyz];
3834  child_stat->flag = CHILD_STATE_HOLD; /* Start children at state 0 (HOLD) */
3835  }
3836  if(cpuutilflag)
3837  store_times (walltime, cputime); /* Must be Before store_dvalue(). */
3839 #ifdef NO_PRINT_LLD
3840  if(!silent) printf("\tChildren see throughput for %2ld initial writers \t= %10.2f %s/sec\n", num_child, total_kilos,unit);
3841  if(!silent && !distributed) printf("\tParent sees throughput for %2ld initial writers \t= %10.2f %s/sec\n",num_child,((double)(ptotal)/total_time),unit);
3842 #else
3843  if(!silent) printf("\tChildren see throughput for %2lld initial writers \t= %10.2f %s/sec\n", num_child, total_kilos,unit);
3844  if(!silent && !distributed) printf("\tParent sees throughput for %2lld initial writers \t= %10.2f %s/sec\n",num_child,((double)(ptotal)/total_time),unit);
3845 #endif
3846  if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit);
3847  if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit);
3848  if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit);
3849  if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit);
3850  /* CPU% can be > 100.0 for multiple CPUs */
3851  if(cpuutilflag)
3852  {
3853  if(walltime == 0.0)
3854  {
3855  if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n",
3856  walltime, cputime, 0.0);
3857  }
3858  else
3859  {
3860  if(!silent) printf("\tCPU Utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n",
3861  walltime, cputime, 100.0 * cputime / walltime);
3862  }
3863  }
3864  if(Cflag)
3865  {
3866  for(xyz=0;xyz<num_child;xyz++)
3867  {
3868  child_stat = (struct child_stats *) &shmaddr[xyz];
3869  if(cpuutilflag)
3870  {
3871  if(!silent)
3872  printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n",
3873  (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime,
3875  }
3876  else
3877  {
3878  if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n",
3879  (long)xyz, child_stat->actual, unit, child_stat->throughput, unit);
3880  }
3881  }
3882  }
3883  if((!distributed) || (distributed && master_iozone))
3884  stop_monitor("Write");
3885  /**********************************************************/
3886  /*************** End of intitial writer *******************/
3887  /**********************************************************/
3888  sync();
3889  sleep(2);
3890  if(restf)
3891  sleep((int)rest_val);
3892  *stop_flag=0;
3893  if(distributed && master_iozone)
3894  {
3896  cleanup_comm();
3897  }
3898 
3899  /**********************************************************/
3900  /* Re-write throughput performance test. ******************/
3901  /**********************************************************/
3902  walltime = 0.0;
3903  cputime = 0.0;
3904  jstarttime=0;
3905  total_kilos=0;
3906  toutputindex=1;
3907  strcpy(&toutput[1][0],throughput_tests[1]);
3908  if(noretest)
3909  {
3910  store_dvalue( (double)0);
3911  goto next0;
3912  }
3913  if((!distributed) || (distributed && master_iozone))
3914  start_monitor("Rewrite");
3915  /* Hooks to start the distributed Iozone client/server code */
3916  if(distributed)
3917  {
3918  use_thread=0; /* Turn of any Posix threads */
3919  if(master_iozone)
3921  else
3922  become_client();
3923  }
3924  if(!use_thread)
3925  {
3926  for(xx = 0; xx< num_child ; xx++){
3927  chid=xx;
3929  if(childids[xx]==-1){
3930  printf("\nFork failed\n");
3931  for(xy = 0; xy< xx ; xy++){
3932  Kill((long long)childids[xy],(long long)SIGTERM);
3933  }
3934  exit(28);
3935  }
3936  if(childids[xx] == 0){
3937 #ifdef _64BIT_ARCH_
3938  thread_rwrite_test((void *)xx);
3939 #else
3940  thread_rwrite_test((void *)((long)xx));
3941 #endif
3942  }
3943  }
3944  }
3945 #ifndef NO_THREADS
3946  else
3947  {
3948  for(xx = 0; xx< num_child ; xx++){ /* Create the children */
3949  if(!barray[xx])
3950  {
3951  barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0);
3952  if(barray[xx] == 0) {
3953  perror("Memory allocation failed:");
3954  exit(26);
3955  }
3956  barray[xx] =(char *)(((long)barray[xx] + cache_size ) &
3957  ~(cache_size-1));
3958  }
3959 #ifdef _64BIT_ARCH_
3961 #else
3962  childids[xx] = mythread_create( thread_rwrite_test,(void *)(long)xx);
3963 #endif
3964  if(childids[xx]==-1){
3965  printf("\nThread create failed\n");
3966  for(xy = 0; xy< xx ; xy++){
3967  Kill((long long)myid,(long long)SIGTERM);
3968  }
3969  exit(29);
3970  }
3971  }
3972  }
3973 #endif
3974  if((long long)myid == getpid())
3975  {
3976  if(distributed && master_iozone)
3977  {
3978  start_master_listen_loop((int) num_child);
3979  }
3980  for(i=0;i<num_child; i++){
3981  child_stat = (struct child_stats *)&shmaddr[i];
3982  /* wait for children to start */
3983  while(child_stat->flag==CHILD_STATE_HOLD)
3984  Poll((long long)1);
3985  }
3986  for(i=0;i<num_child; i++)
3987  {
3988  child_stat = (struct child_stats *)&shmaddr[i];
3989  child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */
3990  if(delay_start!=0)
3991  Poll((long long)delay_start);
3992  if(distributed && master_iozone)
3994  }
3995  starttime1 = time_so_far();
3996  goto jump3;
3997  }
3998 
3999 jump3:
4000  getout=0;
4001  if((long long)myid == getpid()){ /* Parent only here */
4002  for( i = 0; i < num_child; i++){
4003  child_stat=(struct child_stats *)&shmaddr[i];
4004  if(distributed && master_iozone)
4005  {
4006  printf("\n\tTest running:");
4007  wait_dist_join();
4008  break;
4009  }
4010  else
4011  {
4012  if(use_thread)
4013  {
4014  thread_join(childids[i],(void *)&pstatus);
4015  }
4016  else
4017  {
4018  wait(0);
4019  }
4020  }
4021  if(!jstarttime)
4022  jstarttime = time_so_far();
4023  }
4024  jtime = (time_so_far()-jstarttime)-time_res;
4025  if(jtime < (double).000001)
4026  {
4027  jtime=time_res;
4028  }
4029  }
4030  total_time = (time_so_far() - starttime1)-time_res; /* Parents total time */
4031  if(total_time < (double).000001)
4032  {
4034  if(rec_prob < reclen)
4035  rec_prob = reclen;
4036  res_prob=1;
4037  }
4038 #ifdef JTIME
4039  total_time=total_time-jtime;/* Remove the join time */
4040  if(!silent) printf("\nJoin time %10.2f\n",jtime);
4041 #endif
4042 
4043 
4044  total_kilos=0;
4045  ptotal=0;
4046 
4047  min_throughput=max_throughput=min_xfer=0;
4048  if(!silent) printf("\n");
4049  for(xyz=0;xyz<num_child;xyz++){
4050  child_stat=(struct child_stats *)&shmaddr[xyz];
4052  ptotal+=child_stat->actual;
4053  if(!min_xfer)
4054  min_xfer=child_stat->actual;
4055  if(child_stat->actual < min_xfer)
4056  min_xfer=child_stat->actual;
4057  if(!min_throughput)
4058  min_throughput=child_stat->throughput;
4059  if(child_stat->throughput < min_throughput)
4060  min_throughput=child_stat->throughput;
4061  if(child_stat->throughput > max_throughput)
4062  max_throughput=child_stat->throughput;
4063  cputime += child_stat->cputime;
4064  /* Get the earliest start time and latest fini time to calc. elapsed time. */
4067  if (child_stat->walltime > walltime)
4068  walltime = child_stat->walltime;
4069  }
4070  avg_throughput=total_kilos/num_child;
4071  if(cpuutilflag)
4072  {
4073 /*
4074  if (walltime < cputime_res)
4075  walltime = 0.0;
4076 */
4077  if (cputime < cputime_res)
4078  cputime = 0.0;
4079  }
4080 
4081  for(xyz=0;xyz<num_child;xyz++){ /* Reset state to 0 (HOLD) */
4082  child_stat=(struct child_stats *)&shmaddr[xyz];
4084  }
4085  if(cpuutilflag)
4086  store_times (walltime, cputime); /* Must be Before store_dvalue(). */
4088 #ifdef NO_PRINT_LLD
4089  if(!silent) printf("\tChildren see throughput for %2ld rewriters \t= %10.2f %s/sec\n", num_child, total_kilos,unit);
4090  if(!silent && !distributed) printf("\tParent sees throughput for %2ld rewriters \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit);
4091 #else
4092  if(!silent) printf("\tChildren see throughput for %2lld rewriters \t= %10.2f %s/sec\n", num_child, total_kilos,unit);
4093  if(!silent && !distributed) printf("\tParent sees throughput for %2lld rewriters \t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit);
4094 #endif
4095  if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit);
4096  if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit);
4097  if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit);
4098  if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit);
4099  /* CPU% can be > 100.0 for multiple CPUs */
4100  if(cpuutilflag)
4101  {
4102  if(walltime == 0.0)
4103  {
4104  if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n",
4105  walltime, cputime, 0.0);
4106  }
4107  else
4108  {
4109  if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n",
4110  walltime, cputime, 100.0 * cputime / walltime);
4111  }
4112  }
4113  if(Cflag)
4114  {
4115  for(xyz=0;xyz<num_child;xyz++)
4116  {
4117  child_stat = (struct child_stats *) &shmaddr[xyz];
4118  if(cpuutilflag)
4119  {
4120  if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n",
4121  (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime,
4123  }
4124  else
4125  {
4126  if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n",
4127  (long)xyz, child_stat->actual, unit, child_stat->throughput, unit);
4128  }
4129  }
4130  }
4131  *stop_flag=0;
4132  if((!distributed) || (distributed && master_iozone))
4133  stop_monitor("Rewrite");
4134  /**********************************************************/
4135  /*************** End of rewrite throughput ****************/
4136  /**********************************************************/
4137  sync();
4138  sleep(2);
4139  if(restf)
4140  sleep((int)rest_val);
4141  if(distributed && master_iozone)
4142  {
4144  cleanup_comm();
4145  }
4146 next0:
4147  if(include_tflag)
4148  if(!(include_mask & (long long)READER_MASK))
4149  goto next1;
4150  /**************************************************************/
4151  /*** Reader throughput tests **********************************/
4152  /**************************************************************/
4153  if((!distributed) || (distributed && master_iozone))
4154  start_monitor("Read");
4155  toutputindex++;
4157  walltime = 0.0;
4158  cputime = 0.0;
4159  jstarttime=0;
4160  total_kilos=0;
4161  if(distributed)
4162  {
4163  use_thread=0;
4164  if(master_iozone)
4166  else
4167  become_client();
4168  }
4169  if(!use_thread)
4170  {
4171  for(xx = 0; xx< num_child ; xx++){
4172  chid=xx;
4174  if(childids[xx]==-1){
4175  printf("\nFork failed\n");
4176  for(xy = 0; xy< xx ; xy++){
4177  Kill((long long)childids[xy],(long long)SIGTERM);
4178  }
4179  exit(30);
4180  }
4181  if(childids[xx]==0){
4182 #ifdef _64BIT_ARCH_
4183  thread_read_test((void *)xx);
4184 #else
4185  thread_read_test((void *)((long)xx));
4186 #endif
4187  }
4188  }
4189  }
4190 #ifndef NO_THREADS
4191  else
4192  {
4193  for(xx = 0; xx< num_child ; xx++){ /* Create the children */
4194  if(!barray[xx])
4195  {
4196  barray[xx]=(char *) alloc_mem((long long)(MAXBUFFERSIZE+cache_size),(int)0);
4197  if(barray[xx] == 0) {
4198  perror("Memory allocation failed:");
4199  exit(26);
4200  }
4201  barray[xx] =(char *)(((long)barray[xx] + cache_size ) &
4202  ~(cache_size-1));
4203  }
4204 #ifdef _64BIT_ARCH_
4206 #else
4207  childids[xx] = mythread_create( thread_read_test,(void *)(long)xx);
4208 #endif
4209  if(childids[xx]==-1){
4210  printf("\nThread create failed\n");
4211  for(xy = 0; xy< xx ; xy++){
4212  kill((pid_t)myid,(int)SIGTERM);
4213  }
4214  exit(31);
4215  }
4216  }
4217  }
4218 #endif
4219  if(myid == (long long)getpid()){
4220  if(distributed && master_iozone)
4221  {
4222  start_master_listen_loop((int) num_child);
4223  }
4224  for(i=0;i<num_child; i++){ /* wait for children to start */
4225  child_stat=(struct child_stats *)&shmaddr[i];
4227  Poll((long long)1);
4228  }
4229  for(i=0;i<num_child; i++)
4230  {
4231  child_stat=(struct child_stats *)&shmaddr[i];
4232  child_stat->flag = CHILD_STATE_BEGIN; /* tell children to go */
4233  if(delay_start!=0)
4234  Poll((long long)delay_start);
4235  if(distributed && master_iozone)
4237  }
4238  starttime1 = time_so_far();
4239  goto jumpend4;
4240  }
4241 jumpend4:
4242  getout=0;
4243  if(myid == (long long)getpid()){ /* Parent here */
4244  for( i = 0; i < num_child; i++){
4245  child_stat = (struct child_stats *)&shmaddr[i];
4246  if(distributed && master_iozone)
4247  {
4248  printf("\n\tTest running:");
4249  wait_dist_join();
4250  break;
4251  }
4252  else
4253  {
4254  if(use_thread)
4255  {
4256  thread_join(childids[i],(void *)&pstatus);
4257  }
4258  else
4259  {
4260  wait(0);
4261  }
4262  }
4263  if(!jstarttime)
4264  jstarttime = time_so_far();
4265  }
4266  jtime = (time_so_far()-jstarttime)-time_res;
4267  if(jtime < (double).000001)
4268  {
4269  jtime=time_res;
4270  }
4271  }
4272  total_time = (time_so_far() - starttime1)-time_res; /* Parents time */
4273  if(total_time < (double).000001)
4274  {
4276  if(rec_prob < reclen)
4277  rec_prob = reclen;
4278  res_prob=1;
4279  }
4280 #ifdef JTIME
4281  total_time=total_time-jtime;/* Remove the join time */
4282  if(!silent) printf("\nJoin time %10.2f\n",jtime);
4283 #endif
4284 
4285  total_kilos=0;
4286  ptotal=0;
4287  min_throughput=max_throughput=min_xfer=0;
4288  if(!silent) printf("\n");
4289  for(xyz=0;xyz<num_child;xyz++){
4290  child_stat=(struct child_stats *)&shmaddr[xyz];
4292  ptotal+=child_stat->actual;
4293  if(!min_xfer)
4294  min_xfer=child_stat->actual;
4295  if(child_stat->actual < min_xfer)
4296  min_xfer=child_stat->actual;
4297  if(!min_throughput)
4298  min_throughput=child_stat->throughput;
4299  if(child_stat->throughput < min_throughput)
4300  min_throughput=child_stat->throughput;
4301  if(child_stat->throughput > max_throughput)
4302  max_throughput=child_stat->throughput;
4303  cputime += child_stat->cputime;
4304  /* Get the earliest start time and latest fini time to calc. elapsed time. */
4307  if (child_stat->walltime > walltime)
4308  walltime = child_stat->walltime;
4309  }
4310  avg_throughput=total_kilos/num_child;
4311  if(cpuutilflag)
4312  {
4313  if (cputime < cputime_res)
4314  cputime = 0.0;
4315  }
4316  if(cpuutilflag)
4317  store_times (walltime, cputime); /* Must be Before store_dvalue(). */
4319 #ifdef NO_PRINT_LLD
4320  if(!silent) printf("\tChildren see throughput for %2ld readers \t\t= %10.2f %s/sec\n", num_child, total_kilos,unit);
4321  if(!silent && !distributed) printf("\tParent sees throughput for %2ld readers \t\t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit);
4322 #else
4323  if(!silent) printf("\tChildren see throughput for %2lld readers \t\t= %10.2f %s/sec\n", num_child, total_kilos,unit);
4324  if(!silent && !distributed) printf("\tParent sees throughput for %2lld readers \t\t= %10.2f %s/sec\n", num_child, (double)(ptotal)/total_time,unit);
4325 #endif
4326  if(!silent) printf("\tMin throughput per %s \t\t\t= %10.2f %s/sec \n", port,min_throughput,unit);
4327  if(!silent) printf("\tMax throughput per %s \t\t\t= %10.2f %s/sec\n", port,max_throughput,unit);
4328  if(!silent) printf("\tAvg throughput per %s \t\t\t= %10.2f %s/sec\n", port,avg_throughput,unit);
4329  if(!silent) printf("\tMin xfer \t\t\t\t\t= %10.2f %s\n", min_xfer,unit);
4330  /* CPU% can be > 100.0 for multiple CPUs */
4331  if(cpuutilflag)
4332  {
4333  if(walltime == 0.0)
4334  {
4335  if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n",
4336  walltime, cputime, 0.0);
4337  }
4338  else
4339  {
4340  if(!silent) printf("\tCPU utilization: Wall time %8.3f CPU time %8.3f CPU utilization %6.2f %%\n\n",
4341  walltime, cputime, 100.0 * cputime / walltime);
4342  }
4343  }
4344  if(Cflag)
4345  {
4346  for(xyz=0;xyz<num_child;xyz++)
4347  {
4348  child_stat = (struct child_stats *) &shmaddr[xyz];
4349  if(cpuutilflag)
4350  {
4351  if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec, wall=%6.3f, cpu=%6.3f, %%=%6.2f\n",
4352  (long)xyz, child_stat->actual, unit, child_stat->throughput, unit, child_stat->walltime,
4354  }
4355  else
4356  {
4357  if(!silent) printf("\tChild[%ld] xfer count = %10.2f %s, Throughput = %10.2f %s/sec\n",
4358  (long)xyz, child_stat->actual, unit, child_stat->throughput, unit);
4359  }
4360  }
4361  }
4362  if((!distributed) || (distributed && master_iozone))
4363  stop_monitor("Read");
4364  /**********************************************************/
4365  /*************** End of readers throughput ****************/
4366  /**********************************************************/
4367  sync();
4368  sleep(2);
4369  if(restf)
4370  sleep((int)rest_val);
4371  if(distributed && master_iozone)
4372  {
4374  cleanup_comm();
4375  }
4376 
4377  /**************************************************************/
4378  /*** ReReader throughput tests **********************************/
4379  /**************************************************************/
4380  toutputindex++;
4382  if(noretest)
4383  {
4384  store_dvalue( (double)0);
4385  goto next1;
4386  }
4387  if((!distributed) || (distributed && master_iozone))
4388  start_monitor("Reread");
4389  walltime = 0.0;
4390  cputime = 0.0;
4391  jstarttime=0;
4392  *stop_flag=0;
4393  total_kilos=0;
4394  /* Hooks to start the distributed Iozone client/server code */
4395  if(distributed)
4396  {
4397  use_thread=0; /* Turn of any Posix threads */
4398  if(master_iozone)
4400  else
4401  become_client();
4402  }
4403  if(!use_thread)
4404  {
4405  for(xx = 0; xx< num_child ; xx++){
4406  chid=xx;
4408  if(childids[xx]==-1){
4409  printf("\nFork failed\n");
4410  for(xy = 0; xy< xx ; xy++){
4411  Kill((long long)childids[xy],(long long)SIGTERM);
4412  }
4413  exit(32);
4414  }
4415  if(childids[xx]==0){
4416 #ifdef _64BIT_ARCH_
4417  thread_rread_test((void *)xx);
4418 #else
4419