diff --git a/include/mulfft.hpp b/include/mulfft.hpp index d43ef75..ccd7f40 100644 --- a/include/mulfft.hpp +++ b/include/mulfft.hpp @@ -155,20 +155,20 @@ template inline void FMAInFD(std::array &res, const std::array &a, const std::array &b) { - // for (int i = 0; i < N / 2; i++) { - // res[i] = std::fma(a[i], b[i], res[i]); - // res[i + N / 2] = std::fma(a[i + N / 2], b[i], res[i + N / 2]); - // } - // for (int i = 0; i < N / 2; i++) { - // res[i + N / 2] = std::fma(a[i], b[i + N / 2], res[i + N / 2]); - // res[i] -= a[i + N / 2] * b[i + N / 2]; - // } for (int i = 0; i < N / 2; i++) { - res[i] = std::fma(a[i + N / 2], b[i + N / 2], -res[i]); - res[i] = std::fma(a[i], b[i], -res[i]); - res[i + N / 2] = std::fma(a[i], b[i + N / 2], res[i + N / 2]); + res[i] = std::fma(a[i], b[i], res[i]); res[i + N / 2] = std::fma(a[i + N / 2], b[i], res[i + N / 2]); } + for (int i = 0; i < N / 2; i++) { + res[i + N / 2] = std::fma(a[i], b[i + N / 2], res[i + N / 2]); + res[i] -= a[i + N / 2] * b[i + N / 2]; + } + // for (int i = 0; i < N / 2; i++) { + // res[i] = std::fma(a[i + N / 2], b[i + N / 2], -res[i]); + // res[i] = std::fma(a[i], b[i], -res[i]); + // res[i + N / 2] = std::fma(a[i], b[i + N / 2], res[i + N / 2]); + // res[i + N / 2] = std::fma(a[i + N / 2], b[i], res[i + N / 2]); + // } } template diff --git a/include/params.hpp b/include/params.hpp index 0fe21cd..d4d19a1 100644 --- a/include/params.hpp +++ b/include/params.hpp @@ -133,7 +133,7 @@ using BootstrappingKey = std::array, P::domainP::k * P::domainP::n>; template using BootstrappingKeyFFT = - std::array, + alignas(16) std::array, P::domainP::k * P::domainP::n / P::Addends>; template using BootstrappingKeyNTT = @@ -143,7 +143,7 @@ using BootstrappingKeyRAINTT = std::array, P::domainP::k * P::domainP::n>; template -using KeySwitchingKey = std::array< +using KeySwitchingKey = alignas(16) std::array< std::array, (1 << P::basebit) - 1>, P::t>, P::domainP::k * P::domainP::n>; diff --git a/test/gatebootstrapping.cpp b/test/gatebootstrapping.cpp index 3693024..53f9b02 100644 --- a/test/gatebootstrapping.cpp +++ b/test/gatebootstrapping.cpp @@ -1,3 +1,7 @@ +#ifdef USE_PERF +#include +#endif + #include #include #include @@ -6,7 +10,7 @@ int main() { - constexpr uint32_t num_test = 10; + constexpr uint32_t num_test = 1000; std::random_device seed_gen; std::default_random_engine engine(seed_gen()); std::uniform_int_distribution binary(0, 1); @@ -28,11 +32,16 @@ int main() std::chrono::system_clock::time_point start, end; start = std::chrono::system_clock::now(); - +#ifdef USE_PERF + ProfilerStart("gb.prof"); +#endif for (int test = 0; test < num_test; test++) { TFHEpp::GateBootstrapping(bootedtlwe[test], tlwe[test], ek); } +#ifdef USE_PERF + ProfilerStop(); +#endif end = std::chrono::system_clock::now(); double elapsed =