Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions gpu_prover/benches/hypercube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
};

const LOG_ROWS: u32 = 24;
const COLS: usize = 10;

struct HypercubeBitrevBenchCase {
rows: usize,
Expand All @@ -26,28 +27,34 @@
fn new(stream: &CudaStream) -> CudaResult<Self> {
let rows = 1usize << LOG_ROWS;

let mut d_src = DeviceAllocation::alloc(rows)?;
let d_dst = DeviceAllocation::alloc(rows)?;
let mut d_src = DeviceAllocation::alloc(rows * COLS)?;
let d_dst = DeviceAllocation::alloc(rows * COLS)?;

// Fill once to avoid benchmarking uninitialized memory reads.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Believe me, you can get into benchmarking allocator here - as it's zeroed memory and it may be allocated lazily

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good point that i should ensure all first touch overhead happens before benchmarking iterations, but this particular spot allocates gpu memory which doesn't have the same lazy first touch behavior as cpu ram.

Anyway, RobertGPT fixed the whole issue a different way here, so my patch is no longer needed.

let h_src = vec![BF::ZERO; rows];
let h_src = vec![BF::ZERO; rows * COLS];
memory_copy_async(&mut d_src, &h_src, stream)?;
stream.synchronize()?;

Ok(Self { rows, d_src, d_dst })
}

Check warning on line 39 in gpu_prover/benches/hypercube.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/zksync-airbender/zksync-airbender/gpu_prover/benches/hypercube.rs

fn run_out_of_place(&mut self, stream: &CudaStream) -> CudaResult<()> {
hypercube_evals_into_coeffs_bitrev_bf(&self.d_src, &mut self.d_dst, stream)
for (src, dst) in self.d_src.chunks(self.rows).zip(self.d_dst.chunks_mut(self.rows)) {
hypercube_evals_into_coeffs_bitrev_bf(src, dst, stream)?;
}
Ok(())
}

fn run_in_place(&mut self, stream: &CudaStream) -> CudaResult<()> {
hypercube_evals_into_coeffs_bitrev_bf_in_place(&mut self.d_src, stream)
for src in self.d_src.chunks_mut(self.rows) {
hypercube_evals_into_coeffs_bitrev_bf_in_place(src, stream)?;
}
Ok(())
}

fn bytes_per_transform(&self) -> u64 {
// Approximate traffic: read + write per launch, with exactly 3 launches.
(self.rows as u64) * (std::mem::size_of::<BF>() as u64) * 2 * 3
((self.rows * COLS) as u64) * (std::mem::size_of::<BF>() as u64) * 2 * 3
}
}

Expand Down
Loading