forked from edf-hpc/verrou
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvr_clo.c
274 lines (231 loc) · 9.3 KB
/
vr_clo.c
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
/*--------------------------------------------------------------------*/
/*--- Verrou: a FPU instrumentation tool. ---*/
/*--- This file contains code related command-line options. ---*/
/*--- vr_clo.c ---*/
/*--------------------------------------------------------------------*/
/*
This file is part of Verrou, a FPU instrumentation tool.
Copyright (C) 2014-2021 EDF
F. Févotte <[email protected]>
B. Lathuilière <[email protected]>
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., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA.
The GNU General Public License is contained in the file COPYING.
*/
#include "vr_main.h"
//#include "backend_verrou/vr_rand.h"
#include "backend_verrou/interflop_verrou.h"
#include "backend_mcaquad/interflop_mcaquad.h"
void vr_env_clo (const HChar* env, const HChar *clo) {
HChar* val = VG_(getenv)(env);
if (val) {
HChar tmp[256];
VG_(snprintf)(tmp, 255, "%s=%s", clo, val);
if (!vr_process_clo(tmp)) {
VG_(umsg)("WARNING: unknown command-line option `%s'\n", tmp);
}
}
}
void vr_clo_defaults (void) {
vr.backend = vr_verrou;
vr.roundingMode = VR_NEAREST;
vr.count = True;
vr.instr_scalar = False;
vr.instrument = VR_INSTR_ON;
vr.verbose = False;
vr.unsafe_llo_optim = False;
vr.genExclude = False;
vr.exclude = NULL;
// vr.genAbove = NULL;
vr.genIncludeSource = False;
vr.includeSource = NULL;
vr.sourceActivated= False;
vr.genTrace=False;
vr.includeTrace = NULL;
vr.outputTraceRep = NULL;
int opIt;
for(opIt=0 ; opIt<VR_OP ; opIt++){
vr.instr_op[opIt]=False;
}
vr.firstSeed=(unsigned int)(-1);
vr.mca_precision_double=53;
vr.mca_precision_float=24;
vr.mca_mode=MCAMODE_MCA;
vr.checknan=True;
vr.checkCancellation=False;
vr.cc_threshold_float=18;
vr.cc_threshold_double=40;
vr.dumpCancellation=False;
vr.cancellationSource=NULL;
vr.checkDenorm=False;
vr.ftz=False;
vr.dumpDenorm=False;
vr.cancellationSource=NULL;
}
Bool vr_process_clo (const HChar *arg) {
Bool bool_val;
const HChar * str;
//Option --backend=
if (VG_XACT_CLOM (cloPD, arg, "--backend=verrou",
vr.backend, vr_verrou)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--backend=mcaquad",
vr.backend, vr_mcaquad)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--backend=checkdenorm",
vr.backend, vr_checkdenorm)) {}
//Option --rounding-mode=
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=random",
vr.roundingMode, VR_RANDOM)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=average",
vr.roundingMode, VR_AVERAGE)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=nearest",
vr.roundingMode, VR_NEAREST)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=upward",
vr.roundingMode, VR_UPWARD)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=downward",
vr.roundingMode, VR_DOWNWARD)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=toward_zero",
vr.roundingMode, VR_ZERO)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=farthest",
vr.roundingMode, VR_FARTHEST)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=float",
vr.roundingMode, VR_FLOAT)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=native",
vr.roundingMode, VR_NATIVE)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--rounding-mode=ftz",
vr.roundingMode, VR_FTZ)) {}
//Option mcaquad
else if (VG_INT_CLOM (cloPD, arg, "--mca-precision-double",
vr.mca_precision_double)){}
else if (VG_INT_CLOM (cloPD, arg, "--mca-precision-float",
vr.mca_precision_float)){}
else if (VG_XACT_CLOM (cloPD, arg, "--mca-mode=rr",
vr.mca_mode, MCAMODE_RR)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--mca-mode=pb",
vr.mca_mode, MCAMODE_PB)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--mca-mode=mca",
vr.mca_mode, MCAMODE_MCA)) {}
else if (VG_XACT_CLOM (cloPD, arg, "--mca-mode=ieee",
vr.mca_mode, MCAMODE_IEEE)) {}
//Option checkdenorm
else if (VG_BOOL_CLO (arg, "--check-denorm", bool_val)) {
vr.checkDenorm= bool_val;
}
//Options to choose op to instrument
else if (VG_XACT_CLO (arg, "--vr-instr=add",
vr.instr_op[VR_OP_ADD] , True)) {}
else if (VG_XACT_CLO (arg, "--vr-instr=sub",
vr.instr_op[VR_OP_SUB] , True)) {}
else if (VG_XACT_CLO (arg, "--vr-instr=mul",
vr.instr_op[VR_OP_MUL] , True)) {}
else if (VG_XACT_CLO (arg, "--vr-instr=div",
vr.instr_op[VR_OP_DIV] , True)) {}
else if (VG_XACT_CLO (arg, "--vr-instr=mAdd",
vr.instr_op[VR_OP_MADD] , True)) {}
else if (VG_XACT_CLO (arg, "--vr-instr=mSub",
vr.instr_op[VR_OP_MSUB] , True)) {}
else if (VG_XACT_CLO (arg, "--vr-instr=conv",
vr.instr_op[VR_OP_CONV] , True)) {}
//Option to enable check-cancellation backend
else if (VG_BOOL_CLO (arg, "--check-cancellation", bool_val)) {
vr.checkCancellation= bool_val;
}
else if (VG_INT_CLO (arg, "--cc-threshold-double",
vr.cc_threshold_double)){}
else if (VG_INT_CLO (arg, "--cc-threshold-float",
vr.cc_threshold_float)){}
else if (VG_BOOL_CLO (arg, "--check-nan", bool_val)) {
vr.checknan= bool_val;
}
//Options to choose op to instrument
else if (VG_BOOL_CLO (arg, "--vr-instr-scalar", bool_val)) {
vr.instr_scalar= bool_val;
}
//Option --vr-verbose (to avoid verbose of valgrind)
else if (VG_BOOL_CLO (arg, "--vr-verbose", bool_val)) {
vr.verbose = bool_val;
}
//Option --vr-unsafe-llo-optim (performance optimization)
else if (VG_BOOL_CLO (arg, "--vr-unsafe-llo-optim", bool_val)) {
vr.unsafe_llo_optim = bool_val;
}
//Option --count-op
else if (VG_BOOL_CLO (arg, "--count-op", bool_val)) {
vr.count = bool_val;
}
// Instrumentation at start
else if (VG_BOOL_CLOM (cloPD, arg, "--instr-atstart", bool_val)) {
vr.instrument = bool_val ? VR_INSTR_ON : VR_INSTR_OFF;
}
// Exclusion of specified symbols
else if (VG_STR_CLOM (cloPD, arg, "--gen-exclude", str)) {
//vr.excludeFile = VG_(strdup)("vr.process_clo.gen-exclude", str);
vr.excludeFile = VG_(expand_file_name)("vr.process_clo.gen-exclude", str);
vr.genExclude = True;
}
/* else if (VG_STR_CLOM (cloPD, arg, "--gen-above", str)) { */
/* vr.genAbove = VG_(strdup)("vr.process_clo.gen-above", str); */
/* } */
else if (VG_STR_CLOM (cloPD, arg, "--exclude", str)) {
vr.exclude = vr_loadExcludeList(vr.exclude, str);
}
else if (VG_XACT_CLOM (cloPD, arg, "--gen-trace",
vr.genTrace, True)) {}
else if (VG_STR_CLOM (cloPD, arg, "--trace", str)) {
vr.includeTrace = vr_loadIncludeTraceList(vr.includeTrace, str);
vr.genTrace = True;
}
else if (VG_STR_CLOM (cloPD, arg, "--output-trace-rep", str)) {
//vr.includeSourceFile = VG_(strdup)("vr.process_clo.gen-source", str);
vr.outputTraceRep = VG_(expand_file_name)("vr.process_clo.trace-rep", str);
}
// Instrumentation of only specified source lines
else if (VG_STR_CLOM (cloPD, arg, "--gen-source", str)) {
//vr.includeSourceFile = VG_(strdup)("vr.process_clo.gen-source", str);
vr.includeSourceFile = VG_(expand_file_name)("vr.process_clo.gen-source", str);
vr.genIncludeSource = True;
}
else if (VG_STR_CLOM (cloPD, arg, "--source", str)) {
vr.includeSource = vr_loadIncludeSourceList(vr.includeSource, str);
vr.sourceActivated = True;
}
else if (VG_STR_CLOM (cloPD, arg, "--cc-gen-file", str)) {
vr.cancellationDumpFile = VG_(expand_file_name)("vr.process_clo.cc-file", str);
vr.dumpCancellation = True;
}
else if (VG_STR_CLOM (cloPD, arg, "--cd-gen-file", str)) {
vr.denormDumpFile = VG_(expand_file_name)("vr.process_clo.cd-file", str);
vr.dumpDenorm = True;
}
// Set the pseudo-Random Number Generator
else if (VG_STR_CLOM (cloPD, arg, "--vr-seed", str)) {
//vr_rand_setSeed (&vr_rand, VG_(strtoull10)(str, NULL));
vr.firstSeed=VG_(strtoull10)(str, NULL);
if(vr.firstSeed==(unsigned int)(-1)){
VG_(tool_panic) ( "--vr-seed=-1 no taken into account\n");
}
}
// Unknown option
else {
return False;
}
return True;
}
void vr_print_usage (void) {
VG_(printf)
(
#include "vr_clo.txt"
);
}
void vr_print_debug_usage (void) {
vr_print_usage();
}