Skip to content

Commit e1e4202

Browse files
committed
Deal with overflow for flops calculation
This wasn't working with larger matrices. Also labeled it GFlops as that is what is being output.
1 parent 27b6f27 commit e1e4202

File tree

1 file changed

+4
-3
lines changed
  • blog/2024-11-25-optimizing-matmul/code/bin/blog/src

1 file changed

+4
-3
lines changed

blog/2024-11-25-optimizing-matmul/code/bin/blog/src/bin.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ fn run_test<T: Display, U: MatrixMultiply<T>>(multiplier: U, size: (u32, u32, u3
158158
// Calculate FLOPS
159159
let flop_span = span!(Level::DEBUG, "calculate_flops");
160160
let _flop_enter = flop_span.enter();
161-
let ops = 2.0 * (m * n * k) as f64;
162-
let flops = ops / compute_time.as_secs_f64() / 1e9;
163-
info!("Flops: {}", flops);
161+
let ops = 2.0 * (m as u64 * n as u64 * k as u64) as f64;
162+
let flops = ops / compute_time.as_secs_f64();
163+
let gflops = flops / 1e9;
164+
info!("GFlops: {}", gflops);
164165
drop(_flop_enter);
165166

166167
// Verification phase

0 commit comments

Comments
 (0)