@@ -68,41 +68,63 @@ void delete_file(char* file_name) {
68
68
69
69
int main (int argc , char * * argv ) {
70
70
if (argc < 2 ) {
71
- fprintf (stderr , "usage: ./benchmark_read [file_name.h5] [optional: "
72
- "compression_level]\n" );
71
+ fprintf (stderr ,
72
+ "usage: ./benchmark_read [file_name.h5] [scratch_space] [optional: "
73
+ "compression_level]\n" );
73
74
return 1 ;
74
75
}
75
76
76
77
char * file_name = argv [1 ];
78
+ char * scratch_space = argv [2 ];
77
79
78
80
int compression_level = 0 ;
79
81
80
- if (argc >= 3 ) {
81
- compression_level = atoi (argv [2 ]);
82
+ if (argc >= 4 ) {
83
+ compression_level = atoi (argv [3 ]);
82
84
}
83
85
84
86
printf ("Opening %s\n" , file_name );
85
87
86
- const int num_trials = 10 ;
88
+ const int num_trials = 1 ;
87
89
88
90
double durations [num_trials ];
89
91
90
92
bsp_matrix_t mat = bsp_read_matrix (file_name , NULL );
91
93
size_t nbytes = bsp_matrix_nbytes (mat );
92
94
93
95
char output_filename [2048 ];
94
- strncpy (output_filename , "benchmark_write_file_n.h5" , 2047 );
96
+ strncpy (output_filename , scratch_space , 2047 );
97
+ strncpy (output_filename + strlen (scratch_space ), "/benchmark_write_file_n.h5" ,
98
+ 2047 - strlen (scratch_space ));
99
+
100
+ // Current output name logic does not do much.
101
+ assert (num_trials <= 10 );
102
+
103
+ // To flush the filesystem cache before each trial, change to `true`.
104
+ bool cold_cache = false;
105
+
106
+ // To flush each write to the filesystem and include this in the timing,
107
+ // change to `true`.
108
+ bool flush_each_write = true;
95
109
96
110
for (size_t i = 0 ; i < num_trials ; i ++ ) {
97
- flush_cache ();
98
- output_filename [21 ] = '0' + i ;
111
+ if (cold_cache ) {
112
+ flush_cache ();
113
+ }
114
+
115
+ output_filename [strlen (scratch_space ) + 21 ] = '0' + i ;
99
116
printf ("Writing to file %s\n" , output_filename );
100
117
101
118
double begin = gettime ();
102
119
bsp_write_matrix (output_filename , mat , NULL , NULL , compression_level );
103
- flush_writes ();
120
+
121
+ if (flush_each_write ) {
122
+ flush_writes ();
123
+ }
124
+
104
125
double end = gettime ();
105
126
durations [i ] = end - begin ;
127
+
106
128
delete_file (output_filename );
107
129
}
108
130
@@ -119,13 +141,17 @@ int main(int argc, char** argv) {
119
141
120
142
double variance = compute_variance (durations , num_trials );
121
143
122
- printf ( "Wrote file in %lf seconds\n" , durations [num_trials / 2 ]) ;
144
+ double median_time = durations [num_trials / 2 ];
123
145
124
- printf ("Variance is %lf seconds, standard devication is %lf seconds\n" ,
125
- variance , sqrt (variance ));
146
+ printf ("Wrote file in %lf seconds\n" , median_time );
147
+
148
+ if (num_trials > 1 ) {
149
+ printf ("Variance is %lf seconds, standard devication is %lf seconds\n" ,
150
+ variance , sqrt (variance ));
151
+ }
126
152
127
153
double gbytes = ((double ) nbytes ) / 1024 / 1024 / 1024 ;
128
- double gbytes_s = gbytes / durations [ num_trials / 2 ] ;
154
+ double gbytes_s = gbytes / median_time ;
129
155
130
156
printf ("Achieved %lf GiB/s\n" , gbytes_s );
131
157
@@ -138,5 +164,7 @@ int main(int argc, char** argv) {
138
164
}
139
165
printf ("]\n" );
140
166
167
+ printf ("FORPARSER: %s,%lf,%lf\n" , file_name , median_time , gbytes_s );
168
+
141
169
return 0 ;
142
170
}
0 commit comments