Skip to content

Commit ef07963

Browse files
committed
chore(bench): print bench id before running the benchmark
Done to circumvent criterion limitation regarding automatic truncation of long benchmark ID. Using a println() call we ensure the complete name is displayed before benchmark execution to ease manual parsing and debugging.
1 parent 6d2de33 commit ef07963

23 files changed

+200
-16
lines changed

tfhe-benchmark/benches/boolean/bench.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,37 @@ fn benches(c: &mut Criterion, params: BooleanParameters, parameter_name: &str) {
5151
let ct3 = cks.encrypt(true);
5252

5353
let id = format!("AND::{parameter_name}");
54+
println!("{id}");
5455
bench_group.bench_function(&id, |b| b.iter(|| black_box(sks.and(&ct1, &ct2))));
5556
write_to_json_boolean(&id, params, parameter_name, "and");
5657

5758
let id = format!("NAND::{parameter_name}");
59+
println!("{id}");
5860
bench_group.bench_function(&id, |b| b.iter(|| black_box(sks.nand(&ct1, &ct2))));
5961
write_to_json_boolean(&id, params, parameter_name, "nand");
6062

6163
let id = format!("OR::{parameter_name}");
64+
println!("{id}");
6265
bench_group.bench_function(&id, |b| b.iter(|| black_box(sks.or(&ct1, &ct2))));
6366
write_to_json_boolean(&id, params, parameter_name, "or");
6467

6568
let id = format!("XOR::{parameter_name}");
69+
println!("{id}");
6670
bench_group.bench_function(&id, |b| b.iter(|| black_box(sks.xor(&ct1, &ct2))));
6771
write_to_json_boolean(&id, params, parameter_name, "xor");
6872

6973
let id = format!("XNOR::{parameter_name}");
74+
println!("{id}");
7075
bench_group.bench_function(&id, |b| b.iter(|| black_box(sks.xnor(&ct1, &ct2))));
7176
write_to_json_boolean(&id, params, parameter_name, "xnor");
7277

7378
let id = format!("NOT::{parameter_name}");
79+
println!("{id}");
7480
bench_group.bench_function(&id, |b| b.iter(|| black_box(sks.not(&ct1))));
7581
write_to_json_boolean(&id, params, parameter_name, "not");
7682

7783
let id = format!("MUX::{parameter_name}");
84+
println!("{id}");
7885
bench_group.bench_function(&id, |b| b.iter(|| black_box(sks.mux(&ct1, &ct2, &ct3))));
7986
write_to_json_boolean(&id, params, parameter_name, "mux");
8087
}

tfhe-benchmark/benches/core_crypto/ks_bench.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ fn keyswitch<Scalar: UnsignedTorus + CastInto<usize> + Serialize>(
7373
);
7474

7575
bench_id = format!("{bench_name}::{name}");
76+
println!("{bench_id}");
7677
{
7778
bench_group.bench_function(&bench_id, |b| {
7879
b.iter(|| {
@@ -84,6 +85,7 @@ fn keyswitch<Scalar: UnsignedTorus + CastInto<usize> + Serialize>(
8485
}
8586
BenchmarkType::Throughput => {
8687
bench_id = format!("{bench_name}::throughput::{name}");
88+
println!("{bench_id}");
8789
let blocks: usize = 1;
8890
let elements = throughput_num_threads(blocks, 1); // FIXME This number of element do not staturate the target machine
8991
bench_group.throughput(Throughput::Elements(elements));
@@ -231,6 +233,7 @@ fn packing_keyswitch<Scalar, F>(
231233
);
232234

233235
bench_id = format!("{bench_name}::{name}");
236+
println!("{bench_id}");
234237
{
235238
bench_group.bench_function(&bench_id, |b| {
236239
b.iter(|| {
@@ -242,6 +245,7 @@ fn packing_keyswitch<Scalar, F>(
242245
}
243246
BenchmarkType::Throughput => {
244247
bench_id = format!("{bench_name}::throughput::{name}");
248+
println!("{bench_id}");
245249
let blocks: usize = 1;
246250
let elements = throughput_num_threads(blocks, 1);
247251
bench_group.throughput(Throughput::Elements(elements));
@@ -414,6 +418,7 @@ mod cuda {
414418
let cuda_indexes = CudaIndexes::new(&h_indexes, &streams, 0);
415419

416420
bench_id = format!("{bench_name}::{name}");
421+
println!("{bench_id}");
417422
{
418423
bench_group.bench_function(&bench_id, |b| {
419424
b.iter(|| {
@@ -435,6 +440,7 @@ mod cuda {
435440
let gpu_count = get_number_of_gpus() as usize;
436441

437442
bench_id = format!("{bench_name}::throughput::{name}");
443+
println!("{bench_id}");
438444
let blocks: usize = 1;
439445
let elements = throughput_num_threads(blocks, 1);
440446
let elements_per_stream = elements as usize / gpu_count;
@@ -644,6 +650,7 @@ mod cuda {
644650
streams.synchronize();
645651

646652
bench_id = format!("{bench_name}::{name}");
653+
println!("{bench_id}");
647654
{
648655
bench_group.bench_function(&bench_id, |b| {
649656
b.iter(|| {
@@ -663,6 +670,7 @@ mod cuda {
663670
let gpu_count = get_number_of_gpus() as usize;
664671

665672
bench_id = format!("{bench_name}::throughput::{name}");
673+
println!("{bench_id}");
666674

667675
let mem_size = get_packing_keyswitch_list_64_size_on_gpu(
668676
&CudaStreams::new_single_gpu(GpuIndex::new(0)),

tfhe-benchmark/benches/core_crypto/ks_pbs_bench.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ fn ks_pbs<Scalar: UnsignedTorus + CastInto<usize> + Serialize>(
111111
);
112112

113113
bench_id = format!("{bench_name}::{name}");
114+
println!("{bench_id}");
114115
{
115116
bench_group.bench_function(&bench_id, |b| {
116117
b.iter(|| {
@@ -134,6 +135,7 @@ fn ks_pbs<Scalar: UnsignedTorus + CastInto<usize> + Serialize>(
134135
}
135136
BenchmarkType::Throughput => {
136137
bench_id = format!("{bench_name}::throughput::{name}");
138+
println!("{bench_id}");
137139
let blocks: usize = 1;
138140
let elements = throughput_num_threads(blocks, 1);
139141
println!("Number of elements: {elements}"); // DEBUG
@@ -370,6 +372,7 @@ fn multi_bit_ks_pbs<
370372
);
371373

372374
bench_id = format!("{bench_name}::{name}::parallelized");
375+
println!("{bench_id}");
373376
bench_group.bench_function(&bench_id, |b| {
374377
b.iter(|| {
375378
keyswitch_lwe_ciphertext(
@@ -391,6 +394,7 @@ fn multi_bit_ks_pbs<
391394
}
392395
BenchmarkType::Throughput => {
393396
bench_id = format!("{bench_name}::throughput::{name}");
397+
println!("{bench_id}");
394398
let blocks: usize = 1;
395399
let elements = throughput_num_threads(blocks, 1);
396400
println!("Number of elements: {elements}"); // DEBUG
@@ -621,6 +625,7 @@ mod cuda {
621625
let cuda_indexes = CudaIndexes::new(&h_indexes, &streams, 0);
622626

623627
bench_id = format!("{bench_name}::{name}");
628+
println!("{bench_id}");
624629
{
625630
bench_group.bench_function(&bench_id, |b| {
626631
b.iter(|| {
@@ -652,6 +657,7 @@ mod cuda {
652657
let gpu_count = get_number_of_gpus() as usize;
653658

654659
bench_id = format!("{bench_name}::throughput::{name}");
660+
println!("{bench_id}");
655661
let blocks: usize = 1;
656662
let elements = throughput_num_threads(blocks, 1);
657663
let elements_per_stream = elements as usize / gpu_count;
@@ -929,6 +935,7 @@ mod cuda {
929935
let cuda_indexes = CudaIndexes::new(&h_indexes, &streams, 0);
930936

931937
bench_id = format!("{bench_name}::{name}");
938+
println!("{bench_id}");
932939
bench_group.bench_function(&bench_id, |b| {
933940
b.iter(|| {
934941
cuda_keyswitch_lwe_ciphertext(
@@ -958,6 +965,7 @@ mod cuda {
958965
let gpu_count = get_number_of_gpus() as usize;
959966

960967
bench_id = format!("{bench_name}::throughput::{name}");
968+
println!("{bench_id}");
961969
let blocks: usize = 1;
962970
let elements = throughput_num_threads(blocks, 1);
963971
let elements_per_stream = elements as usize / gpu_count;

tfhe-benchmark/benches/core_crypto/modulus_switch_noise_reduction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn modulus_switch_noise_reduction(c: &mut Criterion) {
6262
.measurement_time(std::time::Duration::from_secs(5));
6363

6464
let bench_name = format!("modulus_switch_noise_reduction_{count}");
65+
println!("{bench_name}");
6566

6667
bench_group.bench_function(&bench_name, |b| {
6768
b.iter(|| {

tfhe-benchmark/benches/core_crypto/pbs128_bench.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ mod cuda {
296296
CudaLweCiphertextList::from_lwe_ciphertext(&out_pbs_ct, &streams);
297297

298298
bench_id = format!("{bench_name}::{params_name}");
299+
println!("{bench_id}");
299300
{
300301
bench_group.bench_function(&bench_id, |b| {
301302
b.iter(|| {
@@ -317,6 +318,7 @@ mod cuda {
317318
let gpu_count = get_number_of_gpus() as usize;
318319

319320
bench_id = format!("{bench_name}::throughput::{params_name}");
321+
println!("{bench_id}");
320322
let blocks: usize = 1;
321323
let elements = throughput_num_threads(blocks, 1);
322324
let elements_per_stream = elements as usize / gpu_count;
@@ -541,6 +543,7 @@ mod cuda {
541543
let cuda_indexes = CudaIndexes::new(&h_indexes, &streams, 0);
542544

543545
bench_id = format!("{bench_name}::{params_name}");
546+
println!("{bench_id}");
544547
{
545548
bench_group.bench_function(&bench_id, |b| {
546549
b.iter(|| {
@@ -564,6 +567,7 @@ mod cuda {
564567
let gpu_count = get_number_of_gpus() as usize;
565568

566569
bench_id = format!("{bench_name}::throughput::{params_name}");
570+
println!("{bench_id}");
567571
let blocks: usize = 1;
568572
let elements = throughput_num_threads(blocks, 1);
569573
let elements_per_stream = elements as usize / gpu_count;

tfhe-benchmark/benches/core_crypto/pbs_bench.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ fn mem_optimized_pbs<Scalar: UnsignedTorus + CastInto<usize> + Serialize>(
9797
);
9898

9999
bench_id = format!("{bench_name}::{name}");
100+
println!("{bench_id}");
100101

101102
bench_group.bench_function(&bench_id, |b| {
102103
b.iter(|| {
@@ -114,6 +115,7 @@ fn mem_optimized_pbs<Scalar: UnsignedTorus + CastInto<usize> + Serialize>(
114115
}
115116
BenchmarkType::Throughput => {
116117
bench_id = format!("{bench_name}::throughput::{name}");
118+
println!("{bench_id}");
117119
let blocks: usize = 1;
118120
let elements = throughput_num_threads(blocks, 1);
119121
bench_group.throughput(Throughput::Elements(elements));
@@ -326,6 +328,7 @@ fn mem_optimized_batched_pbs<Scalar: UnsignedTorus + CastInto<usize> + Serialize
326328
);
327329

328330
bench_id = format!("{bench_name}::{name}");
331+
println!("{bench_id}");
329332
bench_group.bench_function(&bench_id, |b| {
330333
b.iter(|| {
331334
batch_programmable_bootstrap_lwe_ciphertext_mem_optimized(
@@ -342,6 +345,7 @@ fn mem_optimized_batched_pbs<Scalar: UnsignedTorus + CastInto<usize> + Serialize
342345
}
343346
BenchmarkType::Throughput => {
344347
bench_id = format!("{bench_name}::throughput::{name}");
348+
println!("{bench_id}");
345349
let blocks: usize = 1;
346350
let elements = throughput_num_threads(blocks, 1);
347351
bench_group.throughput(Throughput::Elements(elements));
@@ -552,6 +556,7 @@ fn multi_bit_pbs<
552556
);
553557

554558
bench_id = format!("{bench_name}::{name}::parallelized");
559+
println!("{bench_id}");
555560
bench_group.bench_function(&bench_id, |b| {
556561
b.iter(|| {
557562
multi_bit_programmable_bootstrap_lwe_ciphertext(
@@ -568,6 +573,7 @@ fn multi_bit_pbs<
568573
}
569574
BenchmarkType::Throughput => {
570575
bench_id = format!("{bench_name}::throughput::{name}");
576+
println!("{bench_id}");
571577
let blocks: usize = 1;
572578
let elements = throughput_num_threads(blocks, 1);
573579
bench_group.throughput(Throughput::Elements(elements));
@@ -779,6 +785,7 @@ fn mem_optimized_pbs_ntt(c: &mut Criterion) {
779785
buffers.resize(stack_size);
780786

781787
bench_id = format!("{bench_name}::{name}");
788+
println!("{bench_id}");
782789
bench_group.bench_function(&bench_id, |b| {
783790
b.iter(|| {
784791
programmable_bootstrap_ntt64_lwe_ciphertext_mem_optimized(
@@ -795,6 +802,7 @@ fn mem_optimized_pbs_ntt(c: &mut Criterion) {
795802
}
796803
BenchmarkType::Throughput => {
797804
bench_id = format!("{bench_name}::throughput::{name}");
805+
println!("{bench_id}");
798806
let blocks: usize = 1;
799807
let elements = throughput_num_threads(blocks, 1);
800808
bench_group.throughput(Throughput::Elements(elements));
@@ -1020,6 +1028,7 @@ mod cuda {
10201028
let cuda_indexes = CudaIndexes::new(&h_indexes, &streams, 0);
10211029

10221030
bench_id = format!("{bench_name}::{name}");
1031+
println!("{bench_id}");
10231032
{
10241033
bench_group.bench_function(&bench_id, |b| {
10251034
b.iter(|| {
@@ -1043,6 +1052,7 @@ mod cuda {
10431052
let gpu_count = get_number_of_gpus() as usize;
10441053

10451054
bench_id = format!("{bench_name}::throughput::{name}");
1055+
println!("{bench_id}");
10461056
let blocks: usize = 1;
10471057
let elements = throughput_num_threads(blocks, 1);
10481058
let elements_per_stream = elements as usize / gpu_count;
@@ -1280,6 +1290,7 @@ mod cuda {
12801290
let cuda_indexes = CudaIndexes::new(&h_indexes, &streams, 0);
12811291

12821292
bench_id = format!("{bench_name}::{name}");
1293+
println!("{bench_id}");
12831294
bench_group.bench_function(&bench_id, |b| {
12841295
b.iter(|| {
12851296
cuda_multi_bit_programmable_bootstrap_lwe_ciphertext(
@@ -1301,6 +1312,7 @@ mod cuda {
13011312
let gpu_count = get_number_of_gpus() as usize;
13021313

13031314
bench_id = format!("{bench_name}::throughput::{name}");
1315+
println!("{bench_id}");
13041316
let blocks: usize = 1;
13051317
let elements = throughput_num_threads(blocks, 1);
13061318
let elements_per_stream = elements as usize / gpu_count;

0 commit comments

Comments
 (0)