-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbots_common.cilk
337 lines (316 loc) · 11.4 KB
/
bots_common.cilk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/**********************************************************************************************/
/* This program is part of the Barcelona OpenMP Tasks Suite */
/* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */
/* Copyright (C) 2009 Universitat Politecnica de Catalunya */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
/**********************************************************************************************/
#include <cilk.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <sys/utsname.h>
#include <sys/resource.h>
#include "bots_common.h"
#include "bots_main.h"
#include "bots.h"
void
bots_error(int error, char *message)
{
if (message == NULL)
{
switch(error)
{
case BOTS_ERROR:
fprintf(stderr, "Error (%d): %s\n",error,"Unspecified error.");
break;
case BOTS_ERROR_NOT_ENOUGH_MEMORY:
fprintf(stderr, "Error (%d): %s\n",error,"Not enough memory.");
break;
case BOTS_ERROR_UNRECOGNIZED_PARAMETER:
fprintf(stderr, "Error (%d): %s\n",error,"Unrecognized parameter.");
bots_print_usage();
break;
default:
fprintf(stderr, "Error (%d): %s\n",error,"Invalid error code.");
break;
}
}
else fprintf(stderr, "Error (%d): %s\n",error,message);
exit(100+error);
}
void
bots_warning(int warning, char *message)
{
if (message == NULL)
{
switch(warning)
{
case BOTS_WARNING:
fprintf(stderr, "Warning (%d): %s\n",warning,"Unspecified warning.");
break;
default:
fprintf(stderr, "Warning (%d): %s\n",warning,"Invalid warning code.");
break;
}
}
else fprintf(stderr, "Warning (%d): %s\n",warning,message);
}
long bots_usecs (void)
{
struct timeval t;
gettimeofday(&t,NULL);
return t.tv_sec*1000000+t.tv_usec;
}
void
bots_get_date(char *str)
{
time_t now;
time(&now);
strftime(str, 32, "%Y/%m/%d;%H:%M", gmtime(&now));
}
#if defined (__linux)
/* ****************************************************************** */
void bots_get_architecture(char *str)
{
int ncpus = sysconf(_SC_NPROCESSORS_CONF);
struct utsname architecture;
uname(&architecture);
sprintf(str, "%s-%s;%d" ,architecture.sysname, architecture.machine, ncpus);
}
void bots_get_load_average(char *str)
{
double loadavg[3];
getloadavg (loadavg, 3);
sprintf(str, "%.2f;%.2f;%.2f",loadavg[0],loadavg[1],loadavg[2]);
}
#else
/* ****************************************************************** */
int bots_get_max_cpus(void) { return 0; }
void bots_get_architecture(char *str) { sprintf(str,";"); }
void bots_get_load_average(char *str) { sprintf(str,";;"); }
#endif
void bots_print_results()
{
char str_name[128];
char str_parameters[128];
char str_model[128];
char str_resources[128];
char str_result[15];
char str_time_program[15];
char str_time_sequential[15];
char str_speed_up[15];
char str_number_of_tasks[15];
char str_number_of_tasks_per_second[15];
char str_exec_date[128];
char str_exec_message[128];
char str_architecture[128];
char str_load_avg[128];
char str_comp_date[128];
char str_comp_message[128];
char str_cc[128];
char str_cflags[128];
char str_ld[128];
char str_ldflags[128];
char str_cutoff[128];
/* compute output strings */
sprintf(str_name, "%s", bots_name);
sprintf(str_parameters, "%s", bots_parameters);
sprintf(str_model, "%s", "cilk");
sprintf(str_cutoff, "%s", bots_cutoff);
sprintf(str_resources, "%s", bots_resources);
switch(bots_result)
{
case BOTS_RESULT_NA:
sprintf(str_result, "n/a");
break;
case BOTS_RESULT_SUCCESSFUL:
sprintf(str_result, "successful");
break;
case BOTS_RESULT_UNSUCCESSFUL:
sprintf(str_result, "UNSUCCESSFUL");
break;
case BOTS_RESULT_NOT_REQUESTED:
sprintf(str_result, "Not requested");
break;
default:
sprintf(str_result, "error");
break;
}
sprintf(str_time_program, "%f", bots_time_program);
if (bots_sequential_flag) sprintf(str_time_sequential, "%f", bots_time_sequential);
else sprintf(str_time_sequential, "n/a");
if (bots_sequential_flag)
sprintf(str_speed_up, "%3.2f", bots_time_sequential/bots_time_program);
else sprintf(str_speed_up, "n/a");
sprintf(str_number_of_tasks, "%3.2f", (float) bots_number_of_tasks);
sprintf(str_number_of_tasks_per_second, "%3.2f", (float) bots_number_of_tasks/bots_time_program);
sprintf(str_exec_date, "%s", bots_exec_date);
sprintf(str_exec_message, "%s", bots_exec_message);
bots_get_architecture(str_architecture);
bots_get_load_average(str_load_avg);
sprintf(str_comp_date, "%s", bots_comp_date);
sprintf(str_comp_message, "%s", bots_comp_message);
sprintf(str_cc, "%s", bots_cc);
sprintf(str_cflags, "%s", bots_cflags);
sprintf(str_ld, "%s", bots_ld);
sprintf(str_ldflags, "%s", bots_ldflags);
if(bots_print_header)
{
switch(bots_output_format)
{
case 0:
break;
case 1:
break;
case 2:
fprintf(stdout,
"Benchmark;Parameters;Model;Cutoff;Resources;Result;\
Time;Sequential;Speed-up;\
Nodes;Nodes/Sec;\
Exec Date;Exec Time;Exec Message;\
Architecture;Processors;Load Avg-1;Load Avg-5;Load Avg-15;\
Comp Date;Comp Time;Comp Message;CC;CFLAGS;LD;LDFLAGS\n");
break;
case 3:
break;
case 4:
fprintf(stdout,
"Benchmark;Parameters;Model;Cutoff;Resources;Result;\
Time;Sequential;Speed-up;\
Nodes;Nodes/Sec;\n");
break;
default:
break;
}
}
/* print results */
switch(bots_output_format)
{
case 0:
break;
case 1:
fprintf(stdout, "\n");
fprintf(stdout, "Program = %s\n", str_name); /*fix*/
fprintf(stdout, "Parameters = %s\n", str_parameters); /*fix*/
fprintf(stdout, "Model = %s\n", str_model);
fprintf(stdout, "Embedded cut-off = %s\n", str_cutoff);
fprintf(stdout, "# of Threads = %s\n", str_resources);
fprintf(stdout, "Verification = %s\n", str_result);
fprintf(stdout, "Time Program = %s seconds\n", str_time_program);
if (bots_sequential_flag) {
fprintf(stdout, "Time Sequential = %s seconds\n", str_time_sequential);
fprintf(stdout, "Speed-up = %s\n", str_speed_up);
}
if ( bots_number_of_tasks > 0 ) {
fprintf(stdout, "Nodes = %s\n", str_number_of_tasks);
fprintf(stdout, "Nodes/Sec = %s\n", str_number_of_tasks_per_second);
}
fprintf(stdout, "Execution Date = %s\n", str_exec_date);
fprintf(stdout, "Execution Message = %s\n", str_exec_message);
fprintf(stdout, "Architecture = %s\n", str_architecture);
fprintf(stdout, "Load Avg [1:5:15] = %s\n", str_load_avg);
fprintf(stdout, "Compilation Date = %s\n", str_comp_date);
fprintf(stdout, "Compilation Message = %s\n", str_comp_message);
fprintf(stdout, "Compiler = %s\n", str_cc);
fprintf(stdout, "Compiler Flags = %s\n", str_cflags);
fprintf(stdout, "Linker = %s\n", str_ld);
fprintf(stdout, "Linker Flags = %s\n", str_ldflags);
fflush(stdout);
break;
case 2:
fprintf(stdout,"%s;%s;%s;%s;%s;%s;",
str_name,
str_parameters,
str_model,
str_cutoff,
str_resources,
str_result
);
fprintf(stdout,"%s;%s;%s;",
str_time_program,
str_time_sequential,
str_speed_up
);
fprintf(stdout,"%s;%s;",
str_number_of_tasks,
str_number_of_tasks_per_second
);
fprintf(stdout,"%s;%s;",
str_exec_date,
str_exec_message
);
fprintf(stdout,"%s;%s;",
str_architecture,
str_load_avg
);
fprintf(stdout,"%s;%s;",
str_comp_date,
str_comp_message
);
fprintf(stdout,"%s;%s;%s;%s;",
str_cc,
str_cflags,
str_ld,
str_ldflags
);
fprintf(stdout,"\n");
break;
case 3:
fprintf(stdout, "\n");
fprintf(stdout, "Program = %s\n", str_name); /*fix*/
fprintf(stdout, "Parameters = %s\n", str_parameters); /*fix*/
fprintf(stdout, "Model = %s\n", str_model);
fprintf(stdout, "Embedded cut-off = %s\n", str_cutoff);
fprintf(stdout, "# of Threads = %s\n", str_resources);
fprintf(stdout, "Verification = %s\n", str_result);
fprintf(stdout, "Time Program = %s seconds\n", str_time_program);
if (bots_sequential_flag) {
fprintf(stdout, "Time Sequential = %s seconds\n", str_time_sequential);
fprintf(stdout, "Speed-up = %s\n", str_speed_up);
}
if ( bots_number_of_tasks > 0 ) {
fprintf(stdout, "Nodes = %s\n", str_number_of_tasks);
fprintf(stdout, "Nodes/Sec = %s\n", str_number_of_tasks_per_second);
}
break;
case 4:
fprintf(stdout,"%s;%s;%s;%s;%s;%s;",
str_name,
str_parameters,
str_model,
str_cutoff,
str_resources,
str_result
);
fprintf(stdout,"%s;%s;%s;",
str_time_program,
str_time_sequential,
str_speed_up
);
fprintf(stdout,"%s;%s;",
str_number_of_tasks,
str_number_of_tasks_per_second
);
fprintf(stdout,"\n");
break;
default:
bots_error(BOTS_ERROR,"No valid output format\n");
break;
}
}