@@ -34,6 +34,7 @@ struct FormatSpec {
3434}
3535
3636const FORMATS : & [ FormatSpec ] = & [
37+ FormatSpec { name : "f32" , exp_bits : 8 , mantissa_bits : 23 , phi_distance : 0.000 } ,
3738 FormatSpec { name : "GF8" , exp_bits : 3 , mantissa_bits : 4 , phi_distance : 0.132 } ,
3839 FormatSpec { name : "GF16" , exp_bits : 6 , mantissa_bits : 9 , phi_distance : 0.049 } ,
3940 FormatSpec { name : "GF32" , exp_bits : 13 , mantissa_bits : 18 , phi_distance : 0.340 } ,
@@ -123,6 +124,7 @@ fn run_benchmark(spec: &FormatSpec, values: &[f64], range_label: &'static str) -
123124
124125 for & v in values {
125126 let quantized = match spec. name {
127+ "f32" => v,
126128 "fp16" => ieee_fp16_quantize ( v) ,
127129 "bf16" => bf16_quantize ( v) ,
128130 _ => phi_quantize ( v, spec. exp_bits , spec. mantissa_bits ) ,
@@ -172,8 +174,45 @@ fn phi_spaced(start: f64, end: f64, n: usize) -> Vec<f64> {
172174// ── Main ────────────────────────────────────────────────────────────────────
173175
174176fn main ( ) {
177+ let args: Vec < String > = std:: env:: args ( ) . collect ( ) ;
178+ let format_filter: Option < Vec < & str > > = if args. len ( ) > 1 {
179+ let mut found = false ;
180+ for arg in & args[ 1 ..] {
181+ if arg. starts_with ( "--formats=" ) {
182+ found = true ;
183+ break ;
184+ }
185+ }
186+ if found {
187+ let formats_arg = args. iter ( ) . find ( |a| a. starts_with ( "--formats=" ) ) . unwrap ( ) ;
188+ let formats_str = & formats_arg[ "--formats=" . len ( ) ..] ;
189+ Some ( formats_str. split ( ',' ) . map ( |s| s. trim ( ) ) . collect ( ) )
190+ } else {
191+ None
192+ }
193+ } else {
194+ None
195+ } ;
196+
197+ let active_formats: Vec < & FormatSpec > = if let Some ( ref filter) = format_filter {
198+ FORMATS . iter ( ) . filter ( |f| filter. contains ( & f. name ) ) . collect ( )
199+ } else {
200+ FORMATS . iter ( ) . collect ( )
201+ } ;
202+
203+ if active_formats. is_empty ( ) {
204+ eprintln ! ( "No matching formats. Available: f32, fp16, gf8, GF8, GF16, GF32, GF64, bf16, GFTernary" ) ;
205+ eprintln ! ( "Usage: {} [--formats=f32,fp16,gf8,gf16]" , args[ 0 ] ) ;
206+ std:: process:: exit ( 1 ) ;
207+ }
208+
175209 println ! ( "BENCH-007b: φ-Distance Extended Range Benchmark" ) ;
176210 println ! ( "================================================" ) ;
211+ if let Some ( ref filter) = format_filter {
212+ println ! ( "Formats filter: {}" , filter. join( "," ) ) ;
213+ } else {
214+ println ! ( "Formats: all" ) ;
215+ }
177216 println ! ( "Cross-reference: whitepaper.md §9.5, issue #12" ) ;
178217 println ! ( ) ;
179218
@@ -202,7 +241,7 @@ fn main() {
202241 "Format" , "MSE" , "MAE" , "MaxAbsErr" , "φ-dist" , "InRange" ) ;
203242 println ! ( "{:-<70}" , "" ) ;
204243
205- let mut range_results: Vec < BenchResult > = FORMATS . iter ( )
244+ let mut range_results: Vec < BenchResult > = active_formats . iter ( )
206245 . map ( |spec| run_benchmark ( spec, & values, label) )
207246 . collect ( ) ;
208247
0 commit comments