1 /*****************************************************************************
2 * *
3 * Copyright (c) 2003-2006 Intel Corporation. *
4 * All rights reserved. *
5 * *
6 *****************************************************************************
7
8 This code is covered by the Community Source License (CPL), version
9 1.0 as published by IBM and reproduced in the file "license.txt" in the
10 "license" subdirectory. Redistribution in source and binary form, with
11 or without modification, is permitted ONLY within the regulations
12 contained in above mentioned license.
13
14 Use of the name and trademark "Intel(R) MPI Benchmarks" is allowed ONLY
15 within the regulations of the "License for Use of "Intel(R) MPI
16 Benchmarks" Name and Trademark" as reproduced in the file
17 "use-of-trademark-license.txt" in the "license" subdirectory.
18
19 THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
20 CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
21 LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
22 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
23 solely responsible for determining the appropriateness of using and
24 distributing the Program and assumes all risks associated with its
25 exercise of rights under this Agreement, including but not limited to
26 the risks and costs of program errors, compliance with applicable
27 laws, damage to or loss of data, programs or equipment, and
28 unavailability or interruption of operations.
29
30 EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
31 ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
32 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
33 WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
34 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
36 DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
37 HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
38
39 EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
40 YOUR JURISDICTION. It is licensee's responsibility to comply with any
41 export regulations applicable in licensee's jurisdiction. Under
42 CURRENT U.S. export regulations this software is eligible for export
43 from the U.S. and can be downloaded by or otherwise exported or
44 reexported worldwide EXCEPT to U.S. embargoed destinations which
45 include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
46 Afghanistan and any other country to which the U.S. has embargoed
47 goods and services.
48
49 ***************************************************************************
50
51 For more documentation than found here, see
52
53 [1] doc/ReadMe_IMB.txt
54
55 [2] Intel (R) MPI Benchmarks
56 Users Guide and Methodology Description
57 In
58 doc/IMB_ug.pdf
59
60 File: IMB_benchlist.c
61
62 Implemented functions:
63
64 IMB_list_names;
65 IMB_get_def_index;
66 IMB_construct_blist;
67 IMB_destruct_blist;
68 IMB_print_blist;
69
70 ***************************************************************************/
71
72
73
74
75
76 #include <stdio.h>
77
78 #include "IMB_declare.h"
79
80 #include "IMB_benchmark.h"
81
82 #include "IMB_prototypes.h"
83
84
85 char * NIL_COMMENT[] ={NULL};
86
87
88
89
IMB_list_names(char * Bname,int ** List)90 void IMB_list_names(char* Bname, int** List)
91 /*
92
93
94
95 Input variables:
96
97 -Bname (type char*)
98 Input benchmark name (or "all" for all available benchmarks)
99
100
101
102 In/out variables:
103
104 -List (type int**)
105 Auxiliary list of internal numbering for input benchmark(s)
106
107
108
109 */
110 {
111 char** def_cases, **General_cmt;
112
113 IMB_get_def_cases(&def_cases,&General_cmt);
114
115 if( !strcmp(Bname,"all") )
116 {
117 int Ndeflt=-1, n;
118 while ( def_cases[++Ndeflt] );
119
120 IMB_i_alloc(List, Ndeflt+1,"List_Names");
121 for ( n=0; n<Ndeflt; n++ )
122 (*List)[n] = n;
123 /* IMB_3.0
124 (*List)[Ndeflt] = -1;
125 */
126 (*List)[Ndeflt] = LIST_END;
127 }
128
129 else
130 {
131 IMB_i_alloc(List, 2, "List_Names");
132 IMB_get_def_index(*List, Bname);
133 /* IMB_3.0
134 (*List)[1]=-1;
135 */
136 (*List)[1]=LIST_END;
137 }
138
139 }
140
141
IMB_get_def_index(int * index,char * name)142 void IMB_get_def_index(int* index, char* name)
143 /*
144
145
146
147 Input variables:
148
149 -name (type char*)
150 Input benchmark name
151
152
153
154 In/out variables:
155
156 -index (type int*)
157 Internal number of benchmark
158
159
160
161 */
162 {
163 char** def_cases, **General_cmt;
164 *index = 0;
165
166 IMB_get_def_cases(&def_cases,&General_cmt);
167
168 while( def_cases[*index] )
169 {
170 char* TMP1 = IMB_str(def_cases[*index]), *TMP2 = IMB_str(name);
171 IMB_lwr(TMP1); IMB_lwr(TMP2);
172 if(!strcmp(TMP1,TMP2))
173 {free(TMP1); free(TMP2); break;}
174 (*index)++;
175 free(TMP1); free(TMP2);
176 }
177
178 /* IMB_3.0
179 if( ! def_cases[*index] ) *index=-1;
180 */
181 if( ! def_cases[*index] ) *index=LIST_INVALID;
182 }
183
184
185
IMB_construct_blist(struct Bench ** P_BList,int n_args,char * name)186 void IMB_construct_blist(struct Bench** P_BList, int n_args, char* name)
187 /*
188
189
190 Sets up the list of requested benchmarks
191 (represented as list of struct Bench structures).
192 In one call, 1 benchmark is included.
193
194
195
196 Input variables:
197
198 -n_args (type int)
199 Overall number of benchmarks to be run (0 means "all")
200
201
202 -name (type char*)
203 Name of benchmark to be included in list
204
205
206
207 Output variables:
208
209 -P_BList (type struct Bench**)
210 (For explanation of struct Bench type:
211 describes all aspects of modes of a benchmark;
212 see [1] for more information)
213
214 Updated benchmark list
215
216
217
218 */
219 {
220
221 static int Ndeflt = -1 ;
222 static int n_cases;
223
224 struct Bench* Bmark;
225 char* Bname;
226
227 char** def_cases, **General_cmt;
228
229 int* List;
230 int plc;
231
232 IMB_get_def_cases(&def_cases, &General_cmt);
233
234 if( Ndeflt < 0 )
235 {
236 Ndeflt=-1;
237 while( def_cases[++Ndeflt] ) ;
238
239 *P_BList = (struct Bench*)IMB_v_alloc((1+n_args+Ndeflt)*sizeof(struct Bench), "Construct_Blist 1");
240
241 n_cases=0;
242 }
243
244 Bname = IMB_str(name);
245 IMB_lwr(Bname);
246
247 IMB_list_names(Bname, &List);
248
249 /* IMB_3.0
250 for( plc=0; List[plc]>=0 ; plc++ )
251 */
252 for( plc=0; List[plc]!=LIST_END ; plc++ )
253 {
254 Bmark = (*P_BList)+n_cases;
255
256 /* IMB_3.0 */
257 if ( List[plc]>=0 ) {
258 Bmark->name = IMB_str(def_cases[List[plc]]);
259 }
260 else {
261 Bmark->name = IMB_str(Bname);
262 }
263 IMB_lwr(Bmark->name);
264
265 Bmark->bench_comments = &NIL_COMMENT[0];
266 Bmark->scale_time = 1.0;
267 Bmark->scale_bw = 1.0;
268 Bmark->success = 1;
269
270 IMB_set_bmark(Bmark);
271
272 /* IMB_3.0
273 if( Bmark->RUN_MODES[0].type == BTYPE_INVALID ) strcpy(Bmark->name,name);
274 */
275 n_cases++;
276
277 }
278 (*P_BList)[n_cases].name=NULL;
279
280 free(Bname);
281 free (List);
282
283 }
284
285
286
287
IMB_destruct_blist(struct Bench ** P_BList)288 void IMB_destruct_blist(struct Bench ** P_BList)
289 /*
290
291
292 Completely destructs benchmark list
293
294
295
296 In/out variables:
297
298 -P_BList (type struct Bench **)
299 (For explanation of struct Bench type:
300 describes all aspects of modes of a benchmark;
301 see [1] for more information)
302
303 All substructures plus list itself are free-d
304 and NULL initialized
305
306
307
308 */
309 {
310 /****************************************************************
311 Freeing of the Benchmark list
312 *****************************************************************/
313 /* IMB_3.0: take care of empty BList */
314 if( *P_BList != (struct Bench*)NULL ){
315 int i;
316 i=0;
317 while( (*P_BList)[i].name )
318 {
319 free ((*P_BList)[i++].name);
320 }
321 free(*P_BList);
322 }
323 }
324
325
326
327
IMB_print_blist(struct comm_info * c_info,struct Bench * BList)328 void IMB_print_blist(struct comm_info * c_info, struct Bench *BList)
329 /*
330
331
332 Displays requested benchmark scenario on stdout
333
334
335
336 Input variables:
337
338 -c_info (type struct comm_info *)
339 Collection of all base data for MPI;
340 see [1] for more information
341
342
343 -BList (type struct Bench *)
344 (For explanation of struct Bench type:
345 describes all aspects of modes of a benchmark;
346 see [1] for more information)
347
348
349
350 */
351 {
352 int j, ninvalid;
353 char*nn,*cmt;
354 char** def_cases, **General_cmt;
355
356 IMB_get_def_cases(&def_cases, &General_cmt);
357
358 if( General_cmt[0] != NULL )
359 {
360 fprintf(unit,"# Remarks on the current Version:\n\n");
361 j=0;
362 while ( (nn=General_cmt[j++]) )
363 fprintf(unit,"# %s\n",nn);
364 }
365
366 j=0; ninvalid=0;
367
368 while( BList[j].name )
369 {
370 if( BList[j].RUN_MODES[0].type == BTYPE_INVALID )
371 {
372 ninvalid++;
373 if( ninvalid==1 )
374 fprintf(unit,"\n# Attention, invalid benchmark name(s):\n");
375
376 fprintf(unit,"# %s\n",BList[j].name);
377 free (BList[j].name);
378 BList[j].name = IMB_str("");
379 }
380 j++;
381 }
382
383 /* IMB_3.0 */
384 if( ninvalid>0 )
385 {
386 fprintf(unit,"\n# List of valid benchmarks:\n#\n");
387 int i=0;
388 while( def_cases[i] ){fprintf(unit,"# %s\n",def_cases[i++]);}
389 }
390
391 if( ninvalid < j)
392 {
393
394 fprintf(unit,"\n# List of Benchmarks to run:\n\n");
395
396 j=0;
397 while((nn=BList[j].name))
398 {
399 if( BList[j].RUN_MODES[0].type != BTYPE_INVALID )
400 {
401 if( c_info->group_mode >= 0 )
402 fprintf(unit,"# (Multi-)%s\n",nn);
403 else
404 fprintf(unit,"# %s\n",nn);
405
406 if ( *(BList[j].bench_comments) )
407 fprintf(unit,"# Comments on this Benchmark:\n");
408 while ( (cmt = *(BList[j].bench_comments++)) )
409 fprintf(unit,"# %s\n",cmt);
410
411 }
412 j++;
413 }
414 }
415
416 }
417