2 atlc - arbitrary transmission line calculator, for the analysis of
3 transmission lines are directional couplers.
5 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either package_version 2
10 of the License, or (at your option) any later package_version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 Dr. David Kirkby, e-mail drkirkby@ntlworld.com
25 /* Times two commands entered on the command line, to make
26 sure the second takes less time than the first. */
38 #ifdef HAVE_SYS_TYPES_H
39 #include <sys/types.h>
51 #include <unistd.h> /* sleep on Solaris needs this */
57 int main(int argc, char **argv)
59 time_t start1, finished1;
60 struct computer_data data;
65 #ifdef ENABLE_POSIX_THREADS
66 time_t start2, finished2;
67 strcpy((char *) data.eff,"unknown");
69 strcpy((char *) data.eff,"N/A");
70 #endif /* ENABLE_POSIX_THREADS */
72 strcpy((char *) data.mhz,"unknown");
73 strcpy((char *) data.cpu_type,"unknown");
74 strcpy((char *) data.fpu_type,"unknown");
75 strcpy((char *) data.max_cpus,"unknown");
76 strcpy((char *) data.cpus,"unknown");
77 strcpy((char *) data.sysname,"unknown");
78 strcpy((char *) data.nodename,"unknown");
79 strcpy((char *) data.release,"unknown");
80 strcpy((char *) data.version,"unknown");
81 strcpy((char *) data.machine,"unknown");
82 strcpy((char *) data.hw_provider,"unknown");
83 strcpy((char *) data.hw_platform,"unknown");
84 strcpy((char *) data.speedup,"N/A ");
85 strcpy((char *) data.t2,"N/A ");
86 strcpy((char *) data.L1data,"unknown");
87 strcpy((char *) data.L1instruction,"unknown");
88 strcpy((char *) data.L2,"unknown");
90 /* Trying to get information about the hardware is likely to break
91 on some platforms, as it is very platform specific. If the option
92 --disble-hardware-info is given, the software will not try to obtain
95 The information is useful, for benchmarking purposes and to
96 obtain the efficiency of a multi-processor machine if the number
97 of CPUs can be found. */
99 #ifdef TRY_TO_GET_HARDWARE_INFO
100 try_portable(&data); /* Use uname, which is platform independant */
102 try_aix(&data); /* Try to find if the system is AIX and if so get data */
113 /* Whatever happens (single-threaded or multi-theraded, we will check that all the
114 files (the executable atlc and bitmap are both present). */
117 fprintf(stderr,"Usage: path_to_atlc path_to_bitmap\n");
120 if( (str=malloc(2000)) == NULL)
122 fprintf(stderr,"Memory allocation failure in benchmark.c\n");
125 if ((fp=fopen(argv[1],"rb")) == NULL)
127 fprintf(stderr,"Can't open the binary file %s for reading\n",argv[1]);
130 if ((fp=fopen(argv[2],"rb")) == NULL)
132 fprintf(stderr,"Can't open the bitmap %s for reading\n",argv[2]);
135 /* Assuming we have not exited due to a lack of suitable files present,
136 run the benchmark at least once - but possibly twice if code is
139 sprintf(str,"%s -s -S -t0 %s > /dev/null 2> /dev/null \n", argv[1], argv[2]);
141 pclose(popen(str, "w"));
143 sprintf(data.t1,"%d",(int) (finished1-start1));
145 /* If the code is multi-threaded, run the benchmark for a second time. We can
146 always calculate a speedup in these circumstances */
148 #ifdef ENABLE_POSIX_THREADS
149 sprintf(str,"%s -s -S %s > /dev/null\n", argv[1], argv[2]);
151 pclose(popen(str, "w"));
153 sprintf(data.t2,"%d",(int) (finished2-start2));
154 sprintf(data.speedup,"%.3f\n",atof(data.t1)/atof(data.t2)); /* other N/A */
156 /* Whether or not we can calculate the efficency depends on whether we have managed
157 to obtain the number of processors present in the system. If the number of procesors
158 found is zero (i.e. we have been unable to determine them, due to a lack of
159 processor_information, or that not working properly, then we can't compute the efficiency,
160 so will leave it at the default value of "unknown". */
162 if(atoi(data.cpus) != 0)
163 sprintf(data.eff,"%.3f",atof(data.speedup)/atoi(data.cpus)); /* otherwise unknown */
165 printf("0 %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n",data.t1, data.t2, data.speedup, data.cpus, data.mhz, data.eff, data.cpu_type,data.fpu_type,data.max_cpus,data.sysname,data.nodename,data.release,data.version,data.machine,data.hw_provider, data.hw_platform, data.L1data, data.L1instruction, data.L2);