mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-09 14:47:56 -05:00
chore(bench): run groups of benchmarks using env variable
This commit is contained in:
10
Makefile
10
Makefile
@@ -14,6 +14,7 @@ BIG_TESTS_INSTANCE?=FALSE
|
||||
GEN_KEY_CACHE_MULTI_BIT_ONLY?=FALSE
|
||||
PARSE_INTEGER_BENCH_CSV_FILE?=tfhe_rs_integer_benches.csv
|
||||
FAST_TESTS?=FALSE
|
||||
BENCH_OP_FLAVOR?=DEFAULT
|
||||
# This is done to avoid forgetting it, we still precise the RUSTFLAGS in the commands to be able to
|
||||
# copy paste the command in the terminal and change them if required without forgetting the flags
|
||||
export RUSTFLAGS?=-C target-cpu=native
|
||||
@@ -407,19 +408,22 @@ no_dbg_log:
|
||||
|
||||
.PHONY: bench_integer # Run benchmarks for integer
|
||||
bench_integer: install_rs_check_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
|
||||
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_OP_FLAVOR=$(BENCH_OP_FLAVOR) \
|
||||
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
|
||||
--bench integer-bench \
|
||||
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,$(AVX512_FEATURE) -p tfhe --
|
||||
|
||||
.PHONY: bench_integer_multi_bit # Run benchmarks for integer using multi-bit parameters
|
||||
bench_integer_multi_bit: install_rs_check_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_TYPE=MULTI_BIT cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
|
||||
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_TYPE=MULTI_BIT __TFHE_RS_BENCH_OP_FLAVOR=$(BENCH_OP_FLAVOR) \
|
||||
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
|
||||
--bench integer-bench \
|
||||
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,$(AVX512_FEATURE) -p tfhe --
|
||||
|
||||
.PHONY: bench_shortint # Run benchmarks for shortint
|
||||
bench_shortint: install_rs_check_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
|
||||
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_OP_FLAVOR=$(BENCH_OP_FLAVOR) \
|
||||
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
|
||||
--bench shortint-bench \
|
||||
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache,$(AVX512_FEATURE) -p tfhe
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ mod utilities;
|
||||
use crate::utilities::{write_to_json, OperatorType};
|
||||
use std::env;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use criterion::{criterion_group, Criterion};
|
||||
use itertools::iproduct;
|
||||
use rand::Rng;
|
||||
use std::vec::IntoIter;
|
||||
@@ -739,7 +739,7 @@ define_server_key_bench_default_fn!(
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
smart_arithmetic_operation,
|
||||
smart_ops,
|
||||
smart_neg,
|
||||
smart_add,
|
||||
smart_mul,
|
||||
@@ -756,7 +756,7 @@ criterion_group!(
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
smart_arithmetic_parallelized_operation,
|
||||
smart_parallelized_ops,
|
||||
smart_add_parallelized,
|
||||
smart_sub_parallelized,
|
||||
smart_mul_parallelized,
|
||||
@@ -773,10 +773,11 @@ criterion_group!(
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
arithmetic_parallelized_operation,
|
||||
default_parallelized_ops,
|
||||
add_parallelized,
|
||||
sub_parallelized,
|
||||
mul_parallelized,
|
||||
neg_parallelized,
|
||||
bitand_parallelized,
|
||||
bitnot_parallelized,
|
||||
bitor_parallelized,
|
||||
@@ -784,37 +785,50 @@ criterion_group!(
|
||||
max_parallelized,
|
||||
min_parallelized,
|
||||
eq_parallelized,
|
||||
ne_parallelized,
|
||||
lt_parallelized,
|
||||
le_parallelized,
|
||||
gt_parallelized,
|
||||
ge_parallelized,
|
||||
left_shift_parallelized,
|
||||
right_shift_parallelized,
|
||||
rotate_left_parallelized,
|
||||
rotate_right_parallelized,
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
smart_scalar_arithmetic_operation,
|
||||
smart_scalar_ops,
|
||||
smart_scalar_add,
|
||||
smart_scalar_sub,
|
||||
smart_scalar_mul,
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
smart_scalar_arithmetic_parallel_operation,
|
||||
smart_scalar_parallelized_ops,
|
||||
smart_scalar_add_parallelized,
|
||||
smart_scalar_sub_parallelized,
|
||||
smart_scalar_mul_parallelized,
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
scalar_arithmetic_parallel_operation,
|
||||
default_scalar_parallelized_ops,
|
||||
scalar_add_parallelized,
|
||||
scalar_sub_parallelized,
|
||||
scalar_mul_parallelized,
|
||||
scalar_left_shift_parallelized,
|
||||
scalar_right_shift_parallelized,
|
||||
scalar_eq_parallelized,
|
||||
scalar_ne_parallelized,
|
||||
scalar_lt_parallelized,
|
||||
scalar_le_parallelized,
|
||||
scalar_gt_parallelized,
|
||||
scalar_ge_parallelized,
|
||||
scalar_min_parallelized,
|
||||
scalar_max_parallelized,
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
unchecked_arithmetic_operation,
|
||||
unchecked_ops,
|
||||
unchecked_add,
|
||||
unchecked_sub,
|
||||
unchecked_mul,
|
||||
@@ -831,7 +845,7 @@ criterion_group!(
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
unchecked_scalar_arithmetic_operation,
|
||||
unchecked_scalar_ops,
|
||||
unchecked_scalar_add,
|
||||
unchecked_scalar_sub,
|
||||
unchecked_small_scalar_mul,
|
||||
@@ -849,52 +863,27 @@ criterion_group!(
|
||||
|
||||
criterion_group!(misc, full_propagate, full_propagate_parallelized);
|
||||
|
||||
// User-oriented benchmark group.
|
||||
// This gather all the operations that a high-level user could use.
|
||||
criterion_group!(
|
||||
fast_integer_benchmarks,
|
||||
bitand_parallelized,
|
||||
bitnot_parallelized,
|
||||
bitor_parallelized,
|
||||
bitxor_parallelized,
|
||||
add_parallelized,
|
||||
sub_parallelized,
|
||||
mul_parallelized,
|
||||
neg_parallelized,
|
||||
min_parallelized,
|
||||
max_parallelized,
|
||||
eq_parallelized,
|
||||
ne_parallelized,
|
||||
lt_parallelized,
|
||||
le_parallelized,
|
||||
gt_parallelized,
|
||||
ge_parallelized,
|
||||
left_shift_parallelized,
|
||||
right_shift_parallelized,
|
||||
rotate_left_parallelized,
|
||||
rotate_right_parallelized,
|
||||
scalar_add_parallelized,
|
||||
scalar_sub_parallelized,
|
||||
scalar_mul_parallelized,
|
||||
scalar_left_shift_parallelized,
|
||||
scalar_right_shift_parallelized,
|
||||
scalar_eq_parallelized,
|
||||
scalar_ne_parallelized,
|
||||
scalar_lt_parallelized,
|
||||
scalar_le_parallelized,
|
||||
scalar_gt_parallelized,
|
||||
scalar_ge_parallelized,
|
||||
scalar_min_parallelized,
|
||||
scalar_max_parallelized,
|
||||
);
|
||||
fn main() {
|
||||
match env::var("__TFHE_RS_BENCH_OP_FLAVOR") {
|
||||
Ok(val) => {
|
||||
match val.to_lowercase().as_str() {
|
||||
"default" => default_parallelized_ops(),
|
||||
"default_scalar" => default_scalar_parallelized_ops(),
|
||||
"smart" => smart_ops(),
|
||||
"smart_scalar" => smart_scalar_ops(),
|
||||
"smart_parallelized" => smart_parallelized_ops(),
|
||||
"smart_scalar_parallelized" => smart_scalar_parallelized_ops(),
|
||||
"unchecked" => unchecked_ops(),
|
||||
"unchecked_scalar" => unchecked_scalar_ops(),
|
||||
"misc" => misc(),
|
||||
_ => panic!("unknown benchmark operations flavor"),
|
||||
};
|
||||
}
|
||||
Err(_) => {
|
||||
default_parallelized_ops();
|
||||
default_scalar_parallelized_ops()
|
||||
}
|
||||
};
|
||||
|
||||
criterion_main!(
|
||||
fast_integer_benchmarks,
|
||||
// smart_arithmetic_operation,
|
||||
// smart_arithmetic_parallelized_operation,
|
||||
// smart_scalar_arithmetic_operation,
|
||||
// smart_scalar_arithmetic_parallel_operation,
|
||||
// unchecked_arithmetic_operation,
|
||||
// unchecked_scalar_arithmetic_operation,
|
||||
// misc,
|
||||
);
|
||||
Criterion::default().configure_from_args().final_summary();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#[path = "../utilities.rs"]
|
||||
mod utilities;
|
||||
use crate::utilities::{write_to_json, OperatorType};
|
||||
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use crate::utilities::{write_to_json, OperatorType};
|
||||
use std::env;
|
||||
|
||||
use criterion::{criterion_group, Criterion};
|
||||
use tfhe::shortint::keycache::NamedParam;
|
||||
use tfhe::shortint::parameters::*;
|
||||
use tfhe::shortint::{Ciphertext, ClassicPBSParameters, ServerKey, ShortintParameterSet};
|
||||
@@ -638,33 +640,32 @@ define_server_key_scalar_div_bench_fn!(
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
arithmetic_operation,
|
||||
unchecked_neg,
|
||||
unchecked_add,
|
||||
unchecked_sub,
|
||||
unchecked_mul_lsb,
|
||||
unchecked_mul_msb,
|
||||
unchecked_div,
|
||||
smart_ops,
|
||||
smart_bitand,
|
||||
smart_bitor,
|
||||
smart_bitxor,
|
||||
smart_add,
|
||||
smart_sub,
|
||||
smart_mul_lsb,
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
unchecked_ops,
|
||||
unchecked_neg,
|
||||
unchecked_add,
|
||||
unchecked_sub,
|
||||
unchecked_mul_lsb,
|
||||
unchecked_mul_msb,
|
||||
unchecked_div,
|
||||
unchecked_greater,
|
||||
unchecked_less,
|
||||
unchecked_equal,
|
||||
carry_extract,
|
||||
// programmable_bootstrapping,
|
||||
// multivalue_programmable_bootstrapping
|
||||
//bench_two_block_pbs
|
||||
//wopbs_v0_norm2_2,
|
||||
//bench_wopbs_param_message_8_norm2_5,
|
||||
programmable_bootstrapping
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
arithmetic_scalar_operation,
|
||||
unchecked_scalar_ops,
|
||||
unchecked_scalar_add,
|
||||
unchecked_scalar_mul,
|
||||
unchecked_scalar_sub,
|
||||
@@ -717,10 +718,27 @@ criterion_group!(
|
||||
casting::cast
|
||||
);
|
||||
|
||||
criterion_main!(
|
||||
// arithmetic_operation,
|
||||
// arithmetic_scalar_operation,
|
||||
casting,
|
||||
default_ops,
|
||||
default_scalar_ops,
|
||||
);
|
||||
fn main() {
|
||||
fn default_bench() {
|
||||
casting();
|
||||
default_ops();
|
||||
default_scalar_ops();
|
||||
}
|
||||
|
||||
match env::var("__TFHE_RS_BENCH_OP_FLAVOR") {
|
||||
Ok(val) => {
|
||||
match val.to_lowercase().as_str() {
|
||||
"default" => default_bench(),
|
||||
"smart" => smart_ops(),
|
||||
"unchecked" => {
|
||||
unchecked_ops();
|
||||
unchecked_scalar_ops();
|
||||
}
|
||||
_ => panic!("unknown benchmark operations flavor"),
|
||||
};
|
||||
}
|
||||
Err(_) => default_bench(),
|
||||
};
|
||||
|
||||
Criterion::default().configure_from_args().final_summary();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user