From 6f02d1248d76ee604698b58f22ce4f5e0774bfa7 Mon Sep 17 00:00:00 2001 From: rudy Date: Wed, 4 May 2022 15:49:22 +0200 Subject: [PATCH] feat(optimizer): update to use the new cpp brige --- compiler/.gitignore | 1 + compiler/CMakeLists.txt | 10 ++-------- compiler/Makefile | 20 ++++++++++---------- compiler/lib/Support/CMakeLists.txt | 6 +++--- compiler/lib/Support/V0Parameters.cpp | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/compiler/.gitignore b/compiler/.gitignore index afc75ca76..6f75ce9e8 100644 --- a/compiler/.gitignore +++ b/compiler/.gitignore @@ -1,3 +1,4 @@ +.dependencies/ build/ *.mlir.script *.lit_test_times.txt \ No newline at end of file diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt index 3b54015fb..01be1b557 100644 --- a/compiler/CMakeLists.txt +++ b/compiler/CMakeLists.txt @@ -117,14 +117,6 @@ endif() option(CONCRETELANG_UNIT_TESTS "Enables the build of unittests" ON) -#------------------------------------------------------------------------------- -# Adding rust dependencies, already compiled -#------------------------------------------------------------------------------- - -link_directories(${CONCRETE_OPTIMIZER_DIR}/target) -include_directories(${CONCRETE_OPTIMIZER_DIR}/target/include) - - #------------------------------------------------------------------------------- # Handling sub dirs #------------------------------------------------------------------------------- @@ -133,3 +125,5 @@ add_subdirectory(include) add_subdirectory(lib) add_subdirectory(src) add_subdirectory(tests) + +add_subdirectory(${CONCRETE_OPTIMIZER_DIR}/concrete-optimizer-cpp/cmake-utils) diff --git a/compiler/Makefile b/compiler/Makefile index c9db529c3..e366128d1 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -5,7 +5,7 @@ PARALLEL_EXECUTION_ENABLED=OFF CC_COMPILER= CXX_COMPILER= -CONCRETE_OPTIMIZER_DIR ?= .dependencies/concrete-optimizer +CONCRETE_OPTIMIZER_DIR ?= $(shell pwd)/.dependencies/concrete-optimizer CONCRETE_OPTIMIZER_BRANCH ?= master KEYSETCACHEDEV=/tmp/KeySetCache @@ -68,21 +68,20 @@ $(BUILD_DIR)/configured.stamp: build-initialized: concrete-optimizer-lib $(BUILD_DIR)/configured.stamp +CONCRETE_OPTIMIZER_SRC = $(shell find $(CONCRETE_OPTIMIZER_DIR)/* -not -path '$(CONCRETE_OPTIMIZER_DIR)/target*') + +LIB_CONCRETE_OPTIMIZER_CPP = $(CONCRETE_OPTIMIZER_DIR)/target/libconcrete_optimizer_cpp.a # Fetch concrete-optimizer $(CONCRETE_OPTIMIZER_DIR): export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=accept-new" # for CI - # change to master on merge mkdir -p $(shell dirname ${CONCRETE_OPTIMIZER_DIR}) git clone --branch $(CONCRETE_OPTIMIZER_BRANCH) git@github.com:zama-ai/concrete-optimizer.git $@ -CONCRETE_OPTIMIZER_SRC := $(shell find $(CONCRETE_OPTIMIZER_DIR) -not -path '$(CONCRETE_OPTIMIZER_DIR)/target*') +# we need CONCRETE_OPTIMIZER_DIR here to ensure it is present before computing CONCRETE_OPTIMIZER_SRC +$(LIB_CONCRETE_OPTIMIZER_CPP): $(CONCRETE_OPTIMIZER_DIR) $(CONCRETE_OPTIMIZER_SRC) + make -C $(CONCRETE_OPTIMIZER_DIR)/concrete-optimizer-cpp $@ -# Build concrete-optimizer -$(CONCRETE_OPTIMIZER_DIR)/target/libconcrete_optimizer.a: $(CONCRETE_OPTIMIZER_DIR) $(CONCRETE_OPTIMIZER_SRC) - cd $(CONCRETE_OPTIMIZER_DIR)/concrete-optimizer && cargo build --release - cp $(CONCRETE_OPTIMIZER_DIR)/target/release/$(shell basename $@) $@ - -concrete-optimizer-lib: $(CONCRETE_OPTIMIZER_DIR)/target/libconcrete_optimizer.a +concrete-optimizer-lib: $(LIB_CONCRETE_OPTIMIZER_CPP) doc: build-initialized cmake --build $(BUILD_DIR) --target mlir-doc @@ -294,4 +293,5 @@ python_lint: generate_conv_op \ python_lint \ python_format \ - check_python_format + check_python_format \ + concrete-optimizer-lib diff --git a/compiler/lib/Support/CMakeLists.txt b/compiler/lib/Support/CMakeLists.txt index 1cc2d5205..c3f315af9 100644 --- a/compiler/lib/Support/CMakeLists.txt +++ b/compiler/lib/Support/CMakeLists.txt @@ -1,6 +1,5 @@ -link_directories(${CONCRETE_OPTIMIZER_DIR}/target) -include_directories(${CONCRETE_OPTIMIZER_DIR}/target/include) -link_libraries(concrete_optimizer.a) +# not working in ADDITIONAL_HEADER_DIRS +include_directories(${CONCRETE_OPTIMIZER_DIR}/concrete-optimizer-cpp/src/cpp) add_mlir_library(ConcretelangSupport Pipeline.cpp @@ -30,6 +29,7 @@ add_mlir_library(ConcretelangSupport FHEDialectAnalysis RTDialectAnalysis ConcretelangTransforms + concrete_optimizer MLIRExecutionEngine ${LLVM_PTHREAD_LIB} diff --git a/compiler/lib/Support/V0Parameters.cpp b/compiler/lib/Support/V0Parameters.cpp index 31f1d431f..80efae91b 100644 --- a/compiler/lib/Support/V0Parameters.cpp +++ b/compiler/lib/Support/V0Parameters.cpp @@ -15,7 +15,7 @@ #include "llvm/Support/raw_ostream.h" -#include "concrete-optimizer.h" +#include "concrete-optimizer.hpp" #include "concretelang/Support/V0Parameters.h" namespace mlir {