Skip to content

Commit 74bf275

Browse files
committed
[update] benchmarks
1 parent aba39c9 commit 74bf275

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ int main() {
6767
## Benchmarks
6868
We tested the performance of HEhub compiled with Clang-12.0.5 and run on an Intel i7-9750H @ 2.60GHz. _Note: The code for benchmark is still incomplete since our effort is limited currently. We will list more benchmark results later._
6969

70-
| parameter set | NTT | INTT |
71-
| ------------- | --- | ---- |
72-
| N = 1024 | 7 us | 9 us |
73-
| N = 2048 | 15 us | 19 us |
74-
| N = 4096 | 31 us | 42 us |
75-
| N = 8192 | 69 us | 97 us |
76-
| N = 16384 | 144 us| 196 us |
77-
| N = 32768 | 313 us| 470 us |
70+
| parameter set | NTT | INTT | CKKS<br>encode |
71+
| ------------- | --- | ---- | -------------- |
72+
| N = 1024 | 7 us | 9 us | |
73+
| N = 2048 | 14 us | 19 us | |
74+
| N = 4096 | 30 us | 37 us | 138 us |
75+
| N = 8192 | 68 us | 85 us | 309 us |
76+
| N = 16384 | 142 us| 195 us | 838 us |
77+
| N = 32768 | 330 us| 406 us | 3952 us |
7878

7979
## How to contribute
8080
If you want to contribute to this project, feel free to create an issue at our [Issue](https://github.com/primihub/primihub/issues) page (e.g., documentation, new idea and proposal).

bench/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_executable(benchmarks benchmarks.cpp mod_arith_bm.cpp ntt_bm.cpp)
1+
add_executable(benchmarks benchmarks.cpp mod_arith_bm.cpp ntt_bm.cpp ckks_bm.cpp)
22
add_definitions(-DCATCH_CONFIG_ENABLE_BENCHMARKING)
33
target_link_libraries(benchmarks PUBLIC hehub)
44
target_include_directories(benchmarks PUBLIC ${PROJECT_SOURCE_DIR}/src)

bench/ckks_bm.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "catch2/catch.hpp"
2+
#include "ckks/ckks.h"
3+
#include "common/ntt.h"
4+
5+
using namespace hehub;
6+
using namespace std;
7+
8+
TEST_CASE("benchmark ckks") {
9+
for (auto [LOGN, scaling_bits] :
10+
{pair{12, 36}, pair{13, 43}, pair{14, 48}, pair{15, 55}}) {
11+
u64 N = 1 << LOGN;
12+
auto params = ckks::create_params(N, scaling_bits);
13+
cache_ntt_factors_strict(LOGN, params.moduli);
14+
15+
std::vector<cc_double> data(N / 2);
16+
BENCHMARK(string("CKKS encode / N=") + to_string(N) +
17+
string(" / scaling=2^") + to_string(scaling_bits)) {
18+
return ckks::simd_encode(data, params);
19+
};
20+
}
21+
}

0 commit comments

Comments
 (0)