From 73b53196dce3d7ac9527183bb3f6134c3cb5f30e Mon Sep 17 00:00:00 2001 From: Ryan Kim Date: Thu, 31 Oct 2024 13:42:30 +0900 Subject: [PATCH] perf(crypto): optimize `TwoAdicFri::CreateOpeningProof()` - parallelize copy. - merge `ReverseMatrixIndexBits()` into one single parallel loop. --- tachyon/crypto/commitments/fri/two_adic_fri.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tachyon/crypto/commitments/fri/two_adic_fri.h b/tachyon/crypto/commitments/fri/two_adic_fri.h index 0bfbd6ab6..96fb7721d 100644 --- a/tachyon/crypto/commitments/fri/two_adic_fri.h +++ b/tachyon/crypto/commitments/fri/two_adic_fri.h @@ -148,9 +148,13 @@ class TwoAdicFRI { reduced_openings[log_num_rows]; CHECK_EQ(reduced_opening_for_log_num_rows.size(), num_rows); - math::RowMajorMatrix block = - mat.topRows(num_rows >> config_.log_blowup); - ReverseMatrixIndexBits(block); + math::RowMajorMatrix block; + block.resize(num_rows >> config_.log_blowup, mat.cols()); + OMP_PARALLEL_FOR(size_t row = 0; row < num_rows >> config_.log_blowup; + ++row) { + block.row(row) = mat.row(base::bits::ReverseBitsLen( + row, log_num_rows - config_.log_blowup)); + } std::vector reduced_rows = DotExtPowers(mat, alpha); // TODO(ashjeong): Determine if using a matrix is a better fit.