-
Notifications
You must be signed in to change notification settings - Fork 0
/
parfu_bench_test_002.c
203 lines (184 loc) · 7.68 KB
/
parfu_bench_test_002.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
////////////////////////////////////////////////////////////////////////////////
//
// University of Illinois/NCSA Open Source License
// http://otm.illinois.edu/disclose-protect/illinois-open-source-license
//
// Parfu is copyright © 2017, The Trustees of the University of Illinois.
// All rights reserved.
//
// Parfu was developed by:
// The University of Illinois
// The National Center For Supercomputing Applications (NCSA)
// Blue Waters Science and Engineering Applications Support Team (SEAS)
// Craig P Steffen <[email protected]>
//
// https://github.com/ncsa/parfu_archive_tool
// http://www.ncsa.illinois.edu/People/csteffen/parfu/
//
// For full licnse text see the LICENSE file provided with the source
// distribution.
//
////////////////////////////////////////////////////////////////////////////////
#include <parfu_primary.h>
void parfu_usage(void);
int main(int argc, char *argv[]){
// char mode='Z'; // 'Z' is the "unset" value. Valid modes are 'C' and 'X'
// int i;
parfu_behavior_control_t *marching_orders=NULL;
// int opt_integer;
int total_runs;
int ind_E;
int ind_B;
int ind_N;
int ind_arc;
int target_for_data;
FILE *data_file=NULL;
if(argc<2){
fprintf(stderr,"You didn't enter any command-line flags or arguments\n");
fprintf(stderr," Printing usage explanation:\n");
parfu_usage();
exit(2);
}
if((marching_orders=parfu_parse_arguments(argc,argv))==NULL){
fprintf(stderr,"There was an error parsing the command line. Exiting!\n");
exit(2);
}
// Sanity check; tell the user what we understood them to tell us to do
fprintf(stderr,"Finished parsing command line.\n\n");
switch(marching_orders->mode){
case 'X':
fprintf(stderr,"We e(X)tracting an archive.\n");
break;
case 'C':
fprintf(stderr,"We are (C)reating an archive.\n");
break;
default:
fprintf(stderr,"You must specify mode \"-C\" (create) or \"-X\" (extract)!\n");
fprintf(stderr," We don't know what to do; aborting.\n");
exit(2);
break;
}
// count the runs and confirm to the user what we're going to do
total_runs=1;
// count the number of archive files
if( marching_orders->n_archive_files < 1){
fprintf(stderr,"You must specify at least one archive file!\n");
fprintf(stderr," Exiting.\n");
exit(3);
}
if( marching_orders->mode=='X' &&
marching_orders->n_archive_files > 1 ){
fprintf(stderr,"In extract mode, you must ONLY specify one archive file!\n");
fprintf(stderr," You specified %d files. Aborting.\n",
marching_orders->n_archive_files);
exit(4);
}
fprintf(stderr,"You specified %d archive files.\n",
marching_orders->n_archive_files);
total_runs *= marching_orders->n_archive_files;
// count the number of specified min block size exponents
if(marching_orders->n_min_block_exponent_values){
fprintf(stderr,"You specified %d values of min block size exponent.\n",
marching_orders->n_min_block_exponent_values);
}
else{
marching_orders->n_min_block_exponent_values=1;
marching_orders->min_block_exponent_values[0]=
PARFU_DEFAULT_MIN_BLOCK_SIZE_EXPONENT;
fprintf(stderr,"No values of min block size exponent specified, so we will\n");
fprintf(stderr," be using the default, %d.\n",
marching_orders->min_block_exponent_values[0]);
}
total_runs *= marching_orders->n_min_block_exponent_values;
// count the number of specified blocks-per-fragment values
if(marching_orders->n_blocks_per_fragment_values){
fprintf(stderr,"You specified %d values of blocks per fragment.\n",
marching_orders->n_blocks_per_fragment_values);
}
else{
marching_orders->n_blocks_per_fragment_values=1;
marching_orders->blocks_per_fragment_values[0]=
PARFU_DEFAULT_BLOCKS_PER_FRAGMENT;
fprintf(stderr,"No values of blocks per fragment specified, so we will\n");
fprintf(stderr," be using the default, %d.\n",
marching_orders->blocks_per_fragment_values[0]);
}
total_runs *= marching_orders->n_blocks_per_fragment_values;
// finally count the number of iterations per above combination of parameters
if(marching_orders->yn_iterations_argument){
fprintf(stderr,"You specified %d iterations per parameter combination.\n",
marching_orders->n_iterations);
}
else{
fprintf(stderr,"No # of iterations specified, so 1 run\n");
fprintf(stderr," per combination of parameters specified.\n");
marching_orders->yn_iterations_argument=1;
marching_orders->n_iterations=1;
}
fprintf(stderr,"\n");
fprintf(stderr,"So we'll being running a total of %d times.\n\n",total_runs);
total_runs *= marching_orders->n_iterations;
target_for_data=0;
if(marching_orders->yn_data_to_stdout){
fprintf(stderr,"Timing data will be written to STDOUT.\n");
target_for_data=1;
}
if(marching_orders->data_output_file){
if((data_file=fopen(marching_orders->data_output_file,"a"))==NULL){
fprintf(stderr,"Could not open file >%s< for appending data!\n",
marching_orders->data_output_file);
exit(3);
}
fprintf(stderr,"Timing data will be written to file >%s<\n",
marching_orders->data_output_file);
target_for_data=1;
}
if(!target_for_data){
fprintf(stderr,"WARNING! You have not specified a destination for\n");
fprintf(stderr,"timing data. None will be written.\n");
}
fprintf(stderr,"\nNow looping through trials.\n");
for(ind_arc=0;ind_arc<marching_orders->n_archive_files;ind_arc++){
fprintf(stderr," Using archive file: %s\n",
marching_orders->archive_files[ind_arc]);
for(ind_E=0;ind_E<marching_orders->n_min_block_exponent_values;ind_E++){
for(ind_B=0;ind_B<marching_orders->n_blocks_per_fragment_values;ind_B++){
for(ind_N=0;ind_N<marching_orders->n_iterations;ind_N++){
fprintf(stderr," Using E=%2d, B=%4d, trial #=%3d\n",
marching_orders->min_block_exponent_values[ind_E],
marching_orders->blocks_per_fragment_values[ind_B],
ind_N);
}
}
}
}
fprintf(stderr,"\n\n");
// now actually do stuff
exit(0);
}
void parfu_usage(void){
fprintf(stderr,"\nparfu_bench_test_002 usage:\n\n");
fprintf(stderr," Flags for this version are Gnu-style:\n");
fprintf(stderr," -A sets \"A\" to true\n");
fprintf(stderr," OR\n");
fprintf(stderr," -A xxx gives \"A\" the value \"xxx\"\n");
fprintf(stderr,"Allowed arguments:\n");
fprintf(stderr," -C to Create an archive\n");
fprintf(stderr," -X to eXtract an archive\n");
fprintf(stderr," (only ONE of -C or -X may be specified\n");
fprintf(stderr," -d (Creating: target directory to create an archive of,\n");
fprintf(stderr," eXtracting: directory to extract into) (only one -d value allowed.)\n\n");
fprintf(stderr," -f my_arc_file.pfu (File to archive into. For Create\n");
fprintf(stderr," mode, may specify more than one to test different\n");
fprintf(stderr," target directory characteristics, like stripe counts.\n");
fprintf(stderr," In eXtract mode, only one is allowed.)\n\n");
fprintf(stderr," -e EE Min Block Size Exponent value \"EE\" to test.\n");
fprintf(stderr," my specify any number of values. If nome specified, uses internal default.\n\n");
fprintf(stderr," -B BB Blocks Per Fragment value \"BB\" to test.\n");
fprintf(stderr," Specify any number of values. If none specified,\n");
fprintf(stderr," uses one value, the internal default.\n\n");
fprintf(stderr," -N NN Number of trials per parameter setup to run.\n");
fprintf(stderr," Default is 1.\n\n");
fprintf(stderr," -S Outputs timing results to STDOUT.\n\n");
fprintf(stderr," -L logfile.out Outputs timing results to specified file\n\n");
}