Skip to content

Commit

Permalink
fix(compiler): add missing args in woppbs simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
youben11 committed Oct 24, 2023
1 parent be8cc50 commit d1226ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ void sim_wop_pbs_crt(
// Additional crypto parameters
uint32_t lwe_small_dim, uint32_t cbs_level_count, uint32_t cbs_base_log,
uint32_t ksk_level_count, uint32_t ksk_base_log, uint32_t bsk_level_count,
uint32_t bsk_base_log, uint32_t polynomial_size, uint32_t glwe_dim);
uint32_t bsk_base_log, uint32_t polynomial_size, uint32_t pksk_base_log,
uint32_t pksk_level_count, uint32_t glwe_dim);

void sim_encode_expand_lut_for_boostrap(
uint64_t *in_allocated, uint64_t *in_aligned, uint64_t in_offset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ struct WopPBSGLWEOpPattern
wopPbs.getLoc(), adaptor.getBsk().getLevels(), 32);
auto bskBaseLogCst = rewriter.create<mlir::arith::ConstantIntOp>(
wopPbs.getLoc(), adaptor.getBsk().getBaseLog(), 32);
auto fpkskLevelCountCst = rewriter.create<mlir::arith::ConstantIntOp>(
wopPbs.getLoc(), adaptor.getPksk().getLevels(), 32);
auto fpkskBaseLogCst = rewriter.create<mlir::arith::ConstantIntOp>(
wopPbs.getLoc(), adaptor.getPksk().getBaseLog(), 32);
auto polySizeCst = rewriter.create<mlir::arith::ConstantIntOp>(
wopPbs.getLoc(), adaptor.getPksk().getOutputPolySize(), 32);
auto glweDimCst = rewriter.create<mlir::arith::ConstantIntOp>(
Expand All @@ -370,6 +374,7 @@ struct WopPBSGLWEOpPattern
rewriter.getIntegerType(32), rewriter.getIntegerType(32),
rewriter.getIntegerType(32), rewriter.getIntegerType(32),
rewriter.getIntegerType(32), rewriter.getIntegerType(32),
rewriter.getIntegerType(32), rewriter.getIntegerType(32),
rewriter.getIntegerType(32), rewriter.getIntegerType(32)},
{}))
.failed()) {
Expand All @@ -382,7 +387,7 @@ struct WopPBSGLWEOpPattern
crtDecompValue, lweDimCst, cbsLevelCountCst,
cbsBaseLogCst, kskLevelCountCst, kskBaseLogCst,
bskLevelCountCst, bskBaseLogCst, polySizeCst,
glweDimCst}));
fpkskLevelCountCst, fpkskBaseLogCst, glweDimCst}));

rewriter.replaceOp(wopPbs, outputBuffer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void sim_wop_pbs_crt(
// Additional crypto parameters
uint32_t lwe_small_dim, uint32_t cbs_level_count, uint32_t cbs_base_log,
uint32_t ksk_level_count, uint32_t ksk_base_log, uint32_t bsk_level_count,
uint32_t bsk_base_log, uint32_t polynomial_size, uint32_t glwe_dim) {
uint32_t bsk_base_log, uint32_t polynomial_size, uint32_t pksk_base_log,
uint32_t pksk_level_count, uint32_t glwe_dim) {

// Check number of blocks
assert(out_size == in_size && out_size == crt_decomp_size);
Expand Down Expand Up @@ -172,8 +173,8 @@ void sim_wop_pbs_crt(
simulation_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_u64(
extract_bits_output_buffer, out_aligned + out_offset, ct_in_count,
ct_out_count, lut_size, lut_count, lut_ct_aligned + lut_ct_offset,
glwe_dim, log_poly_size, lwe_small_dim, cbs_level_count, cbs_base_log, 64,
128);
glwe_dim, log_poly_size, lwe_small_dim, bsk_level_count, bsk_base_log,
cbs_level_count, cbs_base_log, pksk_level_count, pksk_base_log, 64, 128);
}

uint64_t sim_neg_lwe_u64(uint64_t plaintext) { return ~plaintext + 1; }
Expand Down

2 comments on commit d1226ca

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: d1226ca Previous: e5ed6f0 Ratio
v0 PBS table generation 79768916 ns/iter (± 145292) 80136933 ns/iter (± 77281) 1.00
v0 PBS simulate dag table generation 55583972 ns/iter (± 95939) 56003235 ns/iter (± 212405) 0.99
v0 WoP-PBS table generation 132944793 ns/iter (± 69994) 133107361 ns/iter (± 1114657) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: d1226ca Previous: e5ed6f0 Ratio
v0 PBS table generation 94016341 ns/iter (± 1314633) 80136933 ns/iter (± 77281) 1.17
v0 PBS simulate dag table generation 64954747 ns/iter (± 1032602) 56003235 ns/iter (± 212405) 1.16
v0 WoP-PBS table generation 154951682 ns/iter (± 3275574) 133107361 ns/iter (± 1114657) 1.16

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.