feat(compiler/gpu): Integrate gpu crypto optimization

This commit is contained in:
Quentin Bourgerie
2022-10-14 17:48:43 +02:00
committed by Ayoub Benaissa
parent a5047586f4
commit d934553950
4 changed files with 15 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ constexpr uint DEFAULT_SECURITY = 128;
constexpr uint DEFAULT_FALLBACK_LOG_NORM_WOPPBS = 8;
constexpr bool DEFAULT_DISPLAY = false;
constexpr bool DEFAULT_STARTEGY_V0 = false;
constexpr bool DEFAULT_USE_GPU_CONSTRAINTS = false;
struct Config {
double p_error;
@@ -31,11 +32,16 @@ struct Config {
bool strategy_v0;
std::uint64_t security;
double fallback_log_norm_woppbs;
bool use_gpu_constraints;
};
constexpr Config DEFAULT_CONFIG = {
UNSPECIFIED_P_ERROR, NO_GLOBAL_P_ERROR, DEFAULT_DISPLAY,
DEFAULT_STARTEGY_V0, DEFAULT_SECURITY, DEFAULT_FALLBACK_LOG_NORM_WOPPBS};
constexpr Config DEFAULT_CONFIG = {UNSPECIFIED_P_ERROR,
NO_GLOBAL_P_ERROR,
DEFAULT_DISPLAY,
DEFAULT_STARTEGY_V0,
DEFAULT_SECURITY,
DEFAULT_FALLBACK_LOG_NORM_WOPPBS,
DEFAULT_USE_GPU_CONSTRAINTS};
using Dag = rust::Box<concrete_optimizer::OperationDag>;
using Solution = concrete_optimizer::v0::Solution;

View File

@@ -198,6 +198,10 @@ llvm::Error CompilerEngine::determineFHEParameters(CompilationResult &res) {
return llvm::Error::success();
}
CompilationFeedback feedback;
// Make sure to use the gpu constraint of the optimizer if we use gpu
// backend.
compilerOptions.optimizerConfig.use_gpu_constraints =
compilerOptions.emitGPUOps;
auto v0Params = getParameter(descr.get().value(), feedback,
compilerOptions.optimizerConfig);
if (auto err = v0Params.takeError()) {

View File

@@ -28,6 +28,7 @@ concrete_optimizer::Options options_from_config(optimizer::Config config) {
options.security_level = config.security;
options.maximum_acceptable_error_probability = config.p_error;
options.default_log_norm2_woppbs = config.fallback_log_norm_woppbs;
options.use_gpu_constraints = config.use_gpu_constraints;
return options;
}