Files
concrete/compiler/tests/unit_tests/concretelang/ClientLib/CRT.cpp
Quentin Bourgerie 8cd3a3a599 feat(compiler): First draft to support FHE.eint up to 16bits
For now what it works are only levelled ops with user parameters. (take a look to the tests)

Done:
- Add parameters to the fhe parameters to support CRT-based large integers
- Add command line options and tests options to allows the user to give those new parameters
- Update the dialects and pipeline to handle new fhe parameters for CRT-based large integers
- Update the client parameters and the client library to handle the CRT-based large integers

Todo:
- Plug the optimizer to compute the CRT-based large interger parameters
- Plug the pbs for the CRT-based large integer
2022-08-12 16:35:11 +02:00

51 lines
1.5 KiB
C++

#include <gtest/gtest.h>
#include "concretelang/ClientLib/CRT.h"
#include "tests_tools/assert.h"
namespace {
namespace crt = concretelang::clientlib::crt;
typedef std::vector<int64_t> CRTModuli;
// Define a fixture for instantiate test with client parameters
class CRTTest : public ::testing::TestWithParam<CRTModuli> {};
TEST_P(CRTTest, crt_iCrt) {
auto moduli = GetParam();
// Max representable value from moduli
uint64_t maxValue = 1;
for (auto modulus : moduli)
maxValue *= modulus;
maxValue = maxValue - 1;
std::vector<uint64_t> valuesToTest{0, maxValue / 2, maxValue};
for (auto a : valuesToTest) {
auto remainders = crt::crt(moduli, a);
auto b = crt::iCrt(moduli, remainders);
ASSERT_EQ(a, b);
}
}
std::vector<CRTModuli> generateAllParameters() {
return {
// This is our default moduli for the 16 bits
{7, 8, 9, 11, 13},
};
}
INSTANTIATE_TEST_SUITE_P(CRTSuite, CRTTest,
::testing::ValuesIn(generateAllParameters()),
[](const testing::TestParamInfo<CRTModuli> info) {
auto moduli = info.param;
std::string desc("mod");
if (!moduli.empty()) {
for (auto b : moduli) {
desc = desc + "_" + std::to_string(b);
}
}
return desc;
});
} // namespace