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 authored and rudy-6-4 committed Nov 6, 2023
1 parent c0411d9 commit 58d122d
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

1 comment on commit 58d122d

@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: 58d122d Previous: 5d3bee7 Ratio
v0 PBS table generation 88694510 ns/iter (± 641855) 108643488 ns/iter (± 2493251) 0.82
v0 PBS simulate dag table generation 56855583 ns/iter (± 146040) 67926768 ns/iter (± 977573) 0.84
v0 WoP-PBS table generation 114217728 ns/iter (± 96931) 134978311 ns/iter (± 582159) 0.85

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

Please sign in to comment.