diff --git a/include/mulfft.hpp b/include/mulfft.hpp
index 2ded7e8..d43ef75 100644
--- a/include/mulfft.hpp
+++ b/include/mulfft.hpp
@@ -87,10 +87,14 @@ inline void TwistFFT(Polynomial
&res, const PolynomialInFD
&a)
template
inline void TwistFFTrescale(Polynomial &res, const PolynomialInFD
&a)
{
- if constexpr (std::is_same_v)
- fftplvl1.execute_direct_torus32_rescale(res.data(), a.data(), P::Δ);
- // else if constexpr (std::is_same_v)
- // fftplvl2.execute_direct_torus64_rescale(res.data(), a.data());
+ if constexpr (std::is_same_v){
+ if constexpr(std::is_same_v)
+ fftplvl1.execute_direct_torus32_rescale(res.data(), a.data(), P::Δ);
+ else if constexpr(std::is_same_v)
+ fftplvl1.execute_direct_torus64_rescale(res.data(), a.data(), P::Δ);
+ }
+ else if constexpr (std::is_same_v)
+ fftplvl2.execute_direct_torus64_rescale(res.data(), a.data(), P::Δ);
else
static_assert(false_v, "Undefined TwistFFT!");
}
@@ -179,7 +183,7 @@ inline void PolyMul(Polynomial &res, const Polynomial
&a,
MulInFD(ffta, ffta, fftb);
TwistFFT(res, ffta);
}
- else if constexpr (std::is_same_v
) {
+ else if constexpr (std::is_same_v) {
// Naieve
// for (int i = 0; i < P::n; i++) {
// typename P::T ri = 0;
@@ -227,15 +231,15 @@ inline void PolyMulRescaleUnsigned(Polynomial &res,
const UnsignedPolynomial
&a,
const UnsignedPolynomial
&b)
{
- if constexpr (std::is_same_v) {
+ // if constexpr (std::is_same_v) {
PolynomialInFD ffta, fftb;
TwistIFFT
(ffta, a);
TwistIFFT
(fftb, b);
MulInFD(ffta, ffta, fftb);
TwistFFTrescale(res, ffta);
- }
- else
- static_assert(false_v, "Undefined PolyMul!");
+ // }
+ // else
+ // static_assert(false_v, "Undefined PolyMul!");
}
template
diff --git a/include/params/tfhe-rs.hpp b/include/params/tfhe-rs.hpp
index ca46e06..000af1f 100644
--- a/include/params/tfhe-rs.hpp
+++ b/include/params/tfhe-rs.hpp
@@ -12,14 +12,14 @@ struct lvl0param {
static constexpr int32_t key_value_max = 1;
static constexpr int32_t key_value_min = 0;
static constexpr int32_t key_value_diff = key_value_max - key_value_min;
- static constexpr std::uint32_t n = 776; // dimension
+ static constexpr std::uint32_t n = 636; // dimension
static constexpr std::uint32_t k = 1;
static constexpr ErrorDistribution errordist =
ErrorDistribution::ModularGaussian;
static constexpr double α =
- 5.033523219195911e-06; // fresh noise, 2^{-17.6}
+ 3.2192861177056265e-06; // fresh noise, 2^{-17.6}
using T = uint32_t; // Torus representation
- static constexpr T μ = 1U << (std::numeric_limits::digits - 3);
+ static constexpr std::make_signed_t μ = 1U << (std::numeric_limits::digits - 3);
static constexpr uint32_t plain_modulus = 2;
static constexpr double Δ =
static_cast(1ULL << std::numeric_limits::digits) /
@@ -37,7 +37,7 @@ struct lvlhalfparam {
ErrorDistribution::ModularGaussian;
static const inline double α = std::pow(2.0, -17); // fresh noise
using T = uint32_t; // Torus representation
- static constexpr T μ = 1U << (std::numeric_limits::digits - 3);
+ static constexpr std::make_signed_t μ = 1U << (std::numeric_limits::digits - 3);
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ =
static_cast(1ULL << std::numeric_limits::digits) /
@@ -58,9 +58,9 @@ struct lvl1param {
static constexpr ErrorDistribution errordist =
ErrorDistribution::ModularGaussian;
static const inline double α =
- 0.0000000000034525330484572114; // fresh noise, 2^{-24.8...}
+ 3.966608917163306e-12; // fresh noise, 2^{-24.8...}
using T = uint64_t; // Torus representation
- static constexpr T μ = 1ULL << 61;
+ static constexpr std::make_signed_t μ = 1ULL << 61;
static constexpr uint32_t plain_modulus = 2;
static constexpr double Δ =
2 * static_cast(1ULL << (std::numeric_limits::digits - 1)) /
@@ -81,7 +81,7 @@ struct lvl2param {
ErrorDistribution::ModularGaussian;
static const inline double α = std::pow(2.0, -44); // fresh noise
using T = uint64_t; // Torus representation
- static constexpr T μ = 1ULL << 61;
+ static constexpr std::make_signed_t μ = 1ULL << 61;
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ = μ;
};
diff --git a/include/trgsw.hpp b/include/trgsw.hpp
index 537b94c..46e890f 100644
--- a/include/trgsw.hpp
+++ b/include/trgsw.hpp
@@ -106,13 +106,13 @@ void trgswfftExternalProduct(TRLWE &res, const TRLWE
&trlwe,
DecomposedPolynomial
decpoly;
Decomposition
(decpoly, trlwe[0]);
PolynomialInFD
decpolyfft;
- __builtin_prefetch(trgswfft[0].data());
+ // __builtin_prefetch(trgswfft[0].data());
TwistIFFT
(decpolyfft, decpoly[0]);
TRLWEInFD
restrlwefft;
for (int m = 0; m < P::k + 1; m++)
MulInFD(restrlwefft[m], decpolyfft, trgswfft[0][m]);
for (int i = 1; i < P::l; i++) {
- __builtin_prefetch(trgswfft[i].data());
+ // __builtin_prefetch(trgswfft[i].data());
TwistIFFT(decpolyfft, decpoly[i]);
for (int m = 0; m < P::k + 1; m++)
FMAInFD(restrlwefft[m], decpolyfft, trgswfft[i][m]);
@@ -120,7 +120,7 @@ void trgswfftExternalProduct(TRLWE &res, const TRLWE
&trlwe,
for (int k = 1; k < P::k + 1; k++) {
Decomposition
(decpoly, trlwe[k]);
for (int i = 0; i < P::l; i++) {
- __builtin_prefetch(trgswfft[i + k * P::l].data());
+ // __builtin_prefetch(trgswfft[i + k * P::l].data());
TwistIFFT
(decpolyfft, decpoly[i]);
for (int m = 0; m < P::k + 1; m++)
FMAInFD(restrlwefft[m], decpolyfft,
diff --git a/thirdparties/spqlios/fft_processor_spqlios.cpp b/thirdparties/spqlios/fft_processor_spqlios.cpp
index 00b5bd2..34c29fe 100644
--- a/thirdparties/spqlios/fft_processor_spqlios.cpp
+++ b/thirdparties/spqlios/fft_processor_spqlios.cpp
@@ -238,6 +238,35 @@ void FFT_Processor_Spqlios::execute_direct_torus64(uint64_t* res, const double*
#endif
}
+void FFT_Processor_Spqlios::execute_direct_torus64_rescale(uint64_t* res, const double* a, const double Δ) {
+ static const double _2sN = double(2)/double(N);
+ //static const double _2p64 = pow(2.,64);
+ //for (int i=0; i