chore(ffi): update to concrete-ffi without fftw

This commit is contained in:
Samuel Tap
2022-10-07 10:34:14 +02:00
committed by mayeul-zama
parent 77729514e0
commit 8a231974f7
7 changed files with 45 additions and 45 deletions

View File

@@ -21,7 +21,7 @@ HPX_TARBALL=$(shell pwd)/hpx-$(HPX_VERSION).tar.gz
HPX_LOCAL_DIR=$(shell pwd)/hpx-$(HPX_VERSION)
HPX_INSTALL_DIR?=$(HPX_LOCAL_DIR)/build
CONCRETE_CORE_FFI_VERSION?=0.2.0-rc.5
CONCRETE_CORE_FFI_VERSION?=0.2.0
ifeq ($(shell uname), Linux)
CONCRETE_CORE_FFI_TARBALL=concrete-core-ffi_$(CONCRETE_CORE_FFI_VERSION)_linux_amd64.tar.gz
else

View File

@@ -37,26 +37,26 @@ typedef struct RuntimeContext {
~RuntimeContext() {
CAPI_ASSERT_ERROR(destroy_default_engine(default_engine));
for (const auto &key : fftw_engines) {
CAPI_ASSERT_ERROR(destroy_fftw_engine(key.second));
for (const auto &key : fft_engines) {
CAPI_ASSERT_ERROR(destroy_fft_engine(key.second));
}
if (fbsk != nullptr) {
CAPI_ASSERT_ERROR(destroy_fftw_fourier_lwe_bootstrap_key_u64(fbsk));
CAPI_ASSERT_ERROR(destroy_fft_fourier_lwe_bootstrap_key_u64(fbsk));
}
}
FftwEngine *get_fftw_engine() {
FftEngine *get_fft_engine() {
pthread_t threadId = pthread_self();
std::lock_guard<std::mutex> guard(engines_map_guard);
auto engineIt = fftw_engines.find(threadId);
if (engineIt == fftw_engines.end()) {
FftwEngine *fftw_engine = nullptr;
auto engineIt = fft_engines.find(threadId);
if (engineIt == fft_engines.end()) {
FftEngine *fft_engine = nullptr;
CAPI_ASSERT_ERROR(new_fftw_engine(&fftw_engine));
CAPI_ASSERT_ERROR(new_fft_engine(&fft_engine));
engineIt =
fftw_engines
.insert(std::pair<pthread_t, FftwEngine *>(threadId, fftw_engine))
fft_engines
.insert(std::pair<pthread_t, FftEngine *>(threadId, fft_engine))
.first;
}
assert(engineIt->second && "No engine available in context");
@@ -65,7 +65,7 @@ typedef struct RuntimeContext {
DefaultEngine *get_default_engine() { return default_engine; }
FftwFourierLweBootstrapKey64 *get_fftw_fourier_bsk() {
FftFourierLweBootstrapKey64 *get_fft_fourier_bsk() {
if (fbsk != nullptr) {
return fbsk;
@@ -74,8 +74,8 @@ typedef struct RuntimeContext {
const std::lock_guard<std::mutex> guard(fbskMutex);
if (fbsk == nullptr) {
CAPI_ASSERT_ERROR(
fftw_engine_convert_lwe_bootstrap_key_to_fftw_fourier_lwe_bootstrap_key_u64(
get_fftw_engine(), evaluationKeys.getBsk(), &fbsk));
fft_engine_convert_lwe_bootstrap_key_to_fft_fourier_lwe_bootstrap_key_u64(
get_fft_engine(), evaluationKeys.getBsk(), &fbsk));
}
return fbsk;
}
@@ -97,9 +97,9 @@ typedef struct RuntimeContext {
private:
std::mutex fbskMutex;
FftwFourierLweBootstrapKey64 *fbsk = nullptr;
FftFourierLweBootstrapKey64 *fbsk = nullptr;
DefaultEngine *default_engine;
std::map<pthread_t, FftwEngine *> fftw_engines;
std::map<pthread_t, FftEngine *> fft_engines;
std::mutex engines_map_guard;
} RuntimeContext;
@@ -111,14 +111,14 @@ extern "C" {
LweKeyswitchKey64 *
get_keyswitch_key_u64(mlir::concretelang::RuntimeContext *context);
FftwFourierLweBootstrapKey64 *
get_fftw_fourier_bootstrap_key_u64(mlir::concretelang::RuntimeContext *context);
FftFourierLweBootstrapKey64 *
get_fft_fourier_bootstrap_key_u64(mlir::concretelang::RuntimeContext *context);
LweBootstrapKey64 *
get_bootstrap_key_u64(mlir::concretelang::RuntimeContext *context);
DefaultEngine *get_engine(mlir::concretelang::RuntimeContext *context);
FftwEngine *get_fftw_engine(mlir::concretelang::RuntimeContext *context);
FftEngine *get_fft_engine(mlir::concretelang::RuntimeContext *context);
}
#endif

View File

@@ -79,16 +79,16 @@ std::ostream &operator<<(std::ostream &ostream, const LweBootstrapKey64 *key) {
}
std::ostream &operator<<(std::ostream &ostream,
const FftwFourierLweBootstrapKey64 *key) {
FftwSerializationEngine *engine;
const FftFourierLweBootstrapKey64 *key) {
FftSerializationEngine *engine;
// No Freeing as it doesn't allocate anything.
CAPI_ASSERT_ERROR(new_fftw_serialization_engine(&engine));
CAPI_ASSERT_ERROR(new_fft_serialization_engine(&engine));
Buffer b;
CAPI_ASSERT_ERROR(
fftw_serialization_engine_serialize_fftw_fourier_lwe_bootstrap_key_u64(
fft_serialization_engine_serialize_fft_fourier_lwe_bootstrap_key_u64(
engine, key, &b))
writeBufferLike(ostream, b);
@@ -122,15 +122,15 @@ std::istream &operator>>(std::istream &istream, LweBootstrapKey64 *&key) {
}
std::istream &operator>>(std::istream &istream,
FftwFourierLweBootstrapKey64 *&key) {
FftwSerializationEngine *engine;
FftFourierLweBootstrapKey64 *&key) {
FftSerializationEngine *engine;
// No Freeing as it doesn't allocate anything.
CAPI_ASSERT_ERROR(new_fftw_serialization_engine(&engine));
CAPI_ASSERT_ERROR(new_fft_serialization_engine(&engine));
key = read_deser(
istream,
fftw_serialization_engine_deserialize_fftw_fourier_lwe_bootstrap_key_u64,
fft_serialization_engine_deserialize_fft_fourier_lwe_bootstrap_key_u64,
engine);
return istream;
}

View File

@@ -66,9 +66,9 @@ void async_bootstrap(
expanded_tabulated_function_array.data(), poly_size));
CAPI_ASSERT_ERROR(
fftw_engine_lwe_ciphertext_discarding_bootstrap_u64_raw_ptr_buffers(
get_fftw_engine(context), get_engine(context),
get_fftw_fourier_bootstrap_key_u64(context), out_aligned + out_offset,
fft_engine_lwe_ciphertext_discarding_bootstrap_u64_raw_ptr_buffers(
get_fft_engine(context), get_engine(context),
get_fft_fourier_bootstrap_key_u64(context), out_aligned + out_offset,
ct0_aligned + ct0_offset, glwe_ct));
promise.set_value(concretelang::clientlib::MemRefDescriptor<1>{
out_allocated, out_aligned, out_offset, {out_size}, {out_stride}});

View File

@@ -19,15 +19,15 @@ get_bootstrap_key_u64(mlir::concretelang::RuntimeContext *context) {
return context->get_bsk();
}
FftwFourierLweBootstrapKey64 *get_fftw_fourier_bootstrap_key_u64(
mlir::concretelang::RuntimeContext *context) {
return context->get_fftw_fourier_bsk();
FftFourierLweBootstrapKey64 *
get_fft_fourier_bootstrap_key_u64(mlir::concretelang::RuntimeContext *context) {
return context->get_fft_fourier_bsk();
}
DefaultEngine *get_engine(mlir::concretelang::RuntimeContext *context) {
return context->get_default_engine();
}
FftwEngine *get_fftw_engine(mlir::concretelang::RuntimeContext *context) {
return context->get_fftw_engine();
FftEngine *get_fft_engine(mlir::concretelang::RuntimeContext *context) {
return context->get_fft_engine();
}

View File

@@ -360,9 +360,9 @@ void memref_bootstrap_lwe_u64(
expanded_tabulated_function_array.data(), poly_size));
CAPI_ASSERT_ERROR(
fftw_engine_lwe_ciphertext_discarding_bootstrap_u64_raw_ptr_buffers(
get_fftw_engine(context), get_engine(context),
get_fftw_fourier_bootstrap_key_u64(context), out_aligned + out_offset,
fft_engine_lwe_ciphertext_discarding_bootstrap_u64_raw_ptr_buffers(
get_fft_engine(context), get_engine(context),
get_fft_fourier_bootstrap_key_u64(context), out_aligned + out_offset,
ct0_aligned + ct0_offset, glwe_ct));
free(glwe_ct);
}
@@ -476,9 +476,9 @@ void memref_wop_pbs_crt_buffer(
(uint64_t(1) << (uint64_t(64) - nb_bits_to_extract - 5));
in_block[lwe_big_size - 1] -= sub;
CAPI_ASSERT_ERROR(
fftw_engine_lwe_ciphertext_discarding_bit_extraction_unchecked_u64_raw_ptr_buffers(
context->get_fftw_engine(), context->get_default_engine(),
context->get_fftw_fourier_bsk(), context->get_ksk(),
fft_engine_lwe_ciphertext_discarding_bit_extraction_unchecked_u64_raw_ptr_buffers(
context->get_fft_engine(), context->get_default_engine(),
context->get_fft_fourier_bsk(), context->get_ksk(),
&extract_bits_output_buffer[lwe_small_size *
extract_bits_output_offset],
in_block, nb_bits_to_extract, delta_log));
@@ -493,9 +493,9 @@ void memref_wop_pbs_crt_buffer(
// Vertical packing
CAPI_ASSERT_ERROR(
fftw_engine_lwe_ciphertext_vector_discarding_circuit_bootstrap_boolean_vertical_packing_u64_raw_ptr_buffers(
context->get_fftw_engine(), context->get_default_engine(),
context->get_fftw_fourier_bsk(), out_aligned, lwe_big_size,
fft_engine_lwe_ciphertext_vector_discarding_circuit_bootstrap_boolean_vertical_packing_u64_raw_ptr_buffers(
context->get_fft_engine(), context->get_default_engine(),
context->get_fft_fourier_bsk(), out_aligned, lwe_big_size,
crt_decomp_size, extract_bits_output_buffer, lwe_small_size,
total_number_of_bits_per_block, luts_crt, luts_crt_size,
cbs_level_count, cbs_base_log, context->get_fpksk()));