mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
fix(keysetcache): use a portable hash function
will help to make macos faster on the ci
This commit is contained in:
4
.github/workflows/continuous-integration.yml
vendored
4
.github/workflows/continuous-integration.yml
vendored
@@ -136,7 +136,7 @@ jobs:
|
||||
if: ${{ matrix.compiler == 'gcc7' && github.ref == 'refs/heads/master' }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: KeySetCache
|
||||
name: KeySetCacheV1
|
||||
path: KeySetCache
|
||||
retention-days: 90
|
||||
|
||||
@@ -144,7 +144,7 @@ jobs:
|
||||
uses: Remagpie/gha-remove-artifact@v1
|
||||
if: ${{ matrix.compiler == 'gcc7' && github.ref == 'refs/heads/master' }}
|
||||
with:
|
||||
only-name: KeySetCache
|
||||
only-name: KeySetCacheV1
|
||||
max-count: 1
|
||||
|
||||
- name: Build compiler
|
||||
|
||||
@@ -10,6 +10,7 @@ CONCRETE_OPTIMIZER_BRANCH ?= master
|
||||
|
||||
KEYSETCACHEDEV=/tmp/KeySetCache
|
||||
KEYSETCACHECI ?= ../KeySetCache
|
||||
KEYSETCACHENAME ?= KeySetCacheV1
|
||||
|
||||
export PATH := $(BUILD_DIR)/bin:$(PATH)
|
||||
|
||||
@@ -115,7 +116,7 @@ test-dataflow: test-end-to-end-jit-dfr test-end-to-end-jit-auto-parallelization
|
||||
GITHUB_URL=https://api.github.com/repos/zama-ai/concrete-compiler-internal
|
||||
GITHUB_URL_LIST_ARTIFACTS="${GITHUB_URL}/actions/artifacts"
|
||||
CURL=curl -H"Accept: application/vnd.github.v3+json" -H"authorization: Bearer ${GITHUB_TOKEN}"
|
||||
keysetcache.zip: REDIRECT_URL = $(shell ${CURL} -s ${GITHUB_URL_LIST_ARTIFACTS} | grep -A 10 KeySetCache | grep archive_download_url | head -n 1 | grep -o 'http[^"]\+')
|
||||
keysetcache.zip: REDIRECT_URL = $(shell ${CURL} -s ${GITHUB_URL_LIST_ARTIFACTS} | grep -A 10 ${KEYSETCACHENAME} | grep archive_download_url | head -n 1 | grep -o 'http[^"]\+')
|
||||
keysetcache.zip:
|
||||
${CURL} --location -o keysetcache.zip ${REDIRECT_URL}
|
||||
du -h keysetcache.zip
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "boost/outcome.h"
|
||||
#include "llvm/ADT/Hashing.h"
|
||||
|
||||
#include "concretelang/ClientLib/ClientParameters.h"
|
||||
|
||||
@@ -20,20 +21,22 @@ template <typename T, typename... Rest>
|
||||
static inline void hash_(std::size_t &seed, const T &v, Rest... rest) {
|
||||
// See https://softwareengineering.stackexchange.com/a/402543
|
||||
const auto GOLDEN_RATIO = 0x9e3779b97f4a7c15; // pseudo random bits
|
||||
const std::hash<T> hasher;
|
||||
seed ^= hasher(v) + GOLDEN_RATIO + (seed << 6) + (seed >> 2);
|
||||
seed ^= llvm::hash_value(v) + GOLDEN_RATIO + (seed << 6) + (seed >> 2);
|
||||
hash_(seed, rest...);
|
||||
}
|
||||
|
||||
static long double_to_bits(double &v) { return *reinterpret_cast<long *>(&v); }
|
||||
|
||||
void LweSecretKeyParam::hash(size_t &seed) { hash_(seed, dimension); }
|
||||
|
||||
void BootstrapKeyParam::hash(size_t &seed) {
|
||||
hash_(seed, inputSecretKeyID, outputSecretKeyID, level, baseLog,
|
||||
glweDimension, variance);
|
||||
glweDimension, double_to_bits(variance));
|
||||
}
|
||||
|
||||
void KeyswitchKeyParam::hash(size_t &seed) {
|
||||
hash_(seed, inputSecretKeyID, outputSecretKeyID, level, baseLog, variance);
|
||||
hash_(seed, inputSecretKeyID, outputSecretKeyID, level, baseLog,
|
||||
double_to_bits(variance));
|
||||
}
|
||||
|
||||
std::size_t ClientParameters::hash() {
|
||||
|
||||
@@ -235,7 +235,8 @@ KeySetCache::loadOrGenerateSave(ClientParameters ¶ms, uint64_t seed_msb,
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << "KeySetCache: miss, regenerating\n";
|
||||
std::cerr << "KeySetCache: miss, regenerating " << std::string(folderPath)
|
||||
<< "\n";
|
||||
OUTCOME_TRY(auto key_set, KeySet::generate(params, seed_msb, seed_lsb));
|
||||
|
||||
OUTCOME_TRYV(saveKeys(*key_set, folderPath));
|
||||
|
||||
Reference in New Issue
Block a user