mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
fix: display compilation error in benchmark
the checking of llvm expected was not correct
This commit is contained in:
@@ -16,9 +16,10 @@ namespace mlir {
|
||||
namespace concretelang {
|
||||
|
||||
namespace optimizer {
|
||||
constexpr double DEFAULT_P_ERROR = 1.0 / 100000.0;
|
||||
constexpr double UNSPECIFIED_P_ERROR = NAN; // will use the default p error
|
||||
constexpr double NO_GLOBAL_P_ERROR = NAN; // will fallback on p error
|
||||
constexpr double DEFAULT_GLOBAL_P_ERROR = 1.0 / 100000.0;
|
||||
constexpr double UNSPECIFIED_P_ERROR = NAN; // will use DEFAULT_GLOBAL_P_ERROR
|
||||
constexpr double UNSPECIFIED_GLOBAL_P_ERROR =
|
||||
NAN; // will use DEFAULT_GLOBAL_P_ERROR
|
||||
constexpr uint DEFAULT_SECURITY = 128;
|
||||
constexpr uint DEFAULT_FALLBACK_LOG_NORM_WOPPBS = 8;
|
||||
constexpr bool DEFAULT_DISPLAY = false;
|
||||
@@ -42,7 +43,7 @@ struct Config {
|
||||
|
||||
constexpr Config DEFAULT_CONFIG = {
|
||||
UNSPECIFIED_P_ERROR,
|
||||
NO_GLOBAL_P_ERROR,
|
||||
UNSPECIFIED_GLOBAL_P_ERROR,
|
||||
DEFAULT_DISPLAY,
|
||||
DEFAULT_STRATEGY_V0,
|
||||
DEFAULT_SECURITY,
|
||||
|
||||
@@ -176,7 +176,7 @@ llvm::Expected<V0Parameter> getParameter(optimizer::Description &descr,
|
||||
std::isnan(config.p_error) && std::isnan(config.global_p_error);
|
||||
|
||||
if (naive_user) {
|
||||
config.global_p_error = optimizer::DEFAULT_P_ERROR;
|
||||
config.global_p_error = optimizer::DEFAULT_GLOBAL_P_ERROR;
|
||||
}
|
||||
if (std::isnan(config.p_error)) {
|
||||
// We always need a valid p-error
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
#include "tests_tools/StackSize.h"
|
||||
#include "tests_tools/keySetCache.h"
|
||||
|
||||
#define check(expr) \
|
||||
if (auto E = expr.takeError()) { \
|
||||
std::cerr << "Error: " << llvm::toString(std::move(E)) << "\n"; \
|
||||
assert(false && "See error above"); \
|
||||
}
|
||||
|
||||
/// Benchmark time of the compilation
|
||||
template <typename LambdaSupport>
|
||||
static void BM_Compile(benchmark::State &state, EndToEndDesc description,
|
||||
@@ -25,13 +31,13 @@ static void BM_KeyGen(benchmark::State &state, EndToEndDesc description,
|
||||
LambdaSupport support,
|
||||
mlir::concretelang::CompilationOptions options) {
|
||||
auto compilationResult = support.compile(description.program, options);
|
||||
assert(compilationResult);
|
||||
check(compilationResult);
|
||||
|
||||
auto clientParameters = support.loadClientParameters(**compilationResult);
|
||||
assert(clientParameters);
|
||||
check(clientParameters);
|
||||
|
||||
for (auto _ : state) {
|
||||
assert(support.keySet(*clientParameters, llvm::None));
|
||||
check(support.keySet(*clientParameters, llvm::None));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,13 +47,13 @@ static void BM_ExportArguments(benchmark::State &state,
|
||||
EndToEndDesc description, LambdaSupport support,
|
||||
mlir::concretelang::CompilationOptions options) {
|
||||
auto compilationResult = support.compile(description.program, options);
|
||||
assert(compilationResult);
|
||||
check(compilationResult);
|
||||
|
||||
auto clientParameters = support.loadClientParameters(**compilationResult);
|
||||
assert(clientParameters);
|
||||
check(clientParameters);
|
||||
|
||||
auto keySet = support.keySet(*clientParameters, getTestKeySetCache());
|
||||
assert(keySet);
|
||||
check(keySet);
|
||||
|
||||
assert(description.tests.size() > 0);
|
||||
auto test = description.tests[0];
|
||||
@@ -58,8 +64,7 @@ static void BM_ExportArguments(benchmark::State &state,
|
||||
}
|
||||
|
||||
for (auto _ : state) {
|
||||
assert(
|
||||
support.exportArguments(*clientParameters, **keySet, inputArguments));
|
||||
check(support.exportArguments(*clientParameters, **keySet, inputArguments));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,15 +73,13 @@ template <typename LambdaSupport>
|
||||
static void BM_Evaluate(benchmark::State &state, EndToEndDesc description,
|
||||
LambdaSupport support,
|
||||
mlir::concretelang::CompilationOptions options) {
|
||||
options.optimizerConfig.display = true;
|
||||
auto compilationResult = support.compile(description.program, options);
|
||||
assert(compilationResult);
|
||||
|
||||
check(compilationResult);
|
||||
auto clientParameters = support.loadClientParameters(**compilationResult);
|
||||
assert(clientParameters);
|
||||
|
||||
check(clientParameters);
|
||||
auto keySet = support.keySet(*clientParameters, getTestKeySetCache());
|
||||
assert(keySet);
|
||||
|
||||
check(keySet);
|
||||
assert(description.tests.size() > 0);
|
||||
auto test = description.tests[0];
|
||||
std::vector<const mlir::concretelang::LambdaArgument *> inputArguments;
|
||||
@@ -84,21 +87,19 @@ static void BM_Evaluate(benchmark::State &state, EndToEndDesc description,
|
||||
for (auto input : test.inputs) {
|
||||
inputArguments.push_back(&input.getValue());
|
||||
}
|
||||
|
||||
auto publicArguments =
|
||||
support.exportArguments(*clientParameters, **keySet, inputArguments);
|
||||
assert(publicArguments);
|
||||
check(publicArguments);
|
||||
|
||||
auto serverLambda = support.loadServerLambda(**compilationResult);
|
||||
assert(serverLambda);
|
||||
check(serverLambda);
|
||||
auto evaluationKeys = (*keySet)->evaluationKeys();
|
||||
|
||||
// Warmup
|
||||
assert(support.serverCall(*serverLambda, **publicArguments, evaluationKeys));
|
||||
|
||||
for (auto _ : state) {
|
||||
assert(
|
||||
support.serverCall(*serverLambda, **publicArguments, evaluationKeys));
|
||||
check(support.serverCall(*serverLambda, **publicArguments, evaluationKeys));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user