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.memory,"unknown");
78 strcpy((char *) data.sysname,"unknown");
79 strcpy((char *) data.nodename,"unknown");
80 strcpy((char *) data.release,"unknown");
81 strcpy((char *) data.version,"unknown");
82 strcpy((char *) data.machine,"unknown");
83 strcpy((char *) data.hw_provider,"unknown");
84 strcpy((char *) data.hw_platform,"unknown");
85 strcpy((char *) data.speedup,"N/A ");
86 strcpy((char *) data.t2,"N/A ");
87 strcpy((char *) data.L1data,"unknown");
88 strcpy((char *) data.L1instruction,"unknown");
89 strcpy((char *) data.L2,"unknown");
91 /* Trying to get information about the hardware is likely to break
92 on some platforms, as it is very platform specific. If the option
93 --disble-hardware-info is given, the software will not try to obtain
96 The information is useful, for benchmarking purposes and to
97 obtain the efficiency of a multi-processor machine if the number
98 of CPUs can be found. */
100 #ifdef TRY_TO_GET_HARDWARE_INFO
101 try_portable(&data); /* Use uname, which is platform independant */
103 try_aix(&data); /* Try to find if the system is AIX and if so get data */
114 /* Whatever happens (single-threaded or multi-theraded, we will check that all the
115 files (the executable atlc and bitmap are both present). */
118 fprintf(stderr,"Usage: path_to_atlc path_to_bitmap\n");
121 if( (str=malloc(2000)) == NULL)
123 fprintf(stderr,"Memory allocation failure in benchmark.c\n");
126 if ((fp=fopen(argv[1],"rb")) == NULL)
128 fprintf(stderr,"Can't open the binary file %s for reading\n",argv[1]);
131 if ((fp=fopen(argv[2],"rb")) == NULL)
133 fprintf(stderr,"Can't open the bitmap %s for reading\n",argv[2]);
136 /* Assuming we have not exited due to a lack of suitable files present,
137 run the benchmark at least once - but possibly twice if code is
140 sprintf(str,"%s -s -S -t0 %s > /dev/null 2> /dev/null \n", argv[1], argv[2]);
142 pclose(popen(str, "w"));
144 sprintf(data.t1,"%d",(int) (finished1-start1));
146 /* If the code is multi-threaded, run the benchmark for a second time. We can
147 always calculate a speedup in these circumstances */
149 #ifdef ENABLE_POSIX_THREADS
150 sprintf(str,"%s -s -S %s > /dev/null\n", argv[1], argv[2]);
152 pclose(popen(str, "w"));
154 sprintf(data.t2,"%d",(int) (finished2-start2));
155 sprintf(data.speedup,"%.3f\n",atof(data.t1)/atof(data.t2)); /* other N/A */
157 /* Whether or not we can calculate the efficency depends on whether we have managed
158 to obtain the number of processors present in the system. If the number of procesors
159 found is zero (i.e. we have been unable to determine them, due to a lack of
160 processor_information, or that not working properly, then we can't compute the efficiency,
161 so will leave it at the default value of "unknown". */
163 if(atoi(data.cpus) != 0)
164 sprintf(data.eff,"%.3f",atof(data.speedup)/atoi(data.cpus)); /* otherwise unknown */
166 printf("0 %s %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.memory,data.sysname,data.nodename,data.release,data.version,data.machine,data.hw_provider, data.hw_platform, data.L1data, data.L1instruction, data.L2);