From 5370fb3cf9a78b84c2eaeea9d147a18fc54df36b Mon Sep 17 00:00:00 2001 From: Bourgerie Quentin Date: Wed, 13 Mar 2024 15:15:50 +0100 Subject: [PATCH] fix(compiler): Do not reinstantiate csprng each time in the simulation backend --- .../concrete-compiler/compiler/lib/Runtime/simulation.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compilers/concrete-compiler/compiler/lib/Runtime/simulation.cpp b/compilers/concrete-compiler/compiler/lib/Runtime/simulation.cpp index 0d3c06e19..f36a36ed6 100644 --- a/compilers/concrete-compiler/compiler/lib/Runtime/simulation.cpp +++ b/compilers/concrete-compiler/compiler/lib/Runtime/simulation.cpp @@ -16,6 +16,8 @@ using concretelang::csprng::SoftCSPRNG; +thread_local auto csprng = SoftCSPRNG(0); + inline concrete::SecurityCurve *security_curve() { return concrete::getSecurityCurve(128, concrete::BINARY); } @@ -29,7 +31,7 @@ uint64_t from_torus(double torus) { // single one? uint64_t gaussian_noise(double mean, double variance) { uint64_t random_gaussian_buff[2]; - auto csprng = SoftCSPRNG(0); + concrete_cpu_fill_with_random_gaussian(random_gaussian_buff, 2, variance, csprng.ptr); return random_gaussian_buff[0];