fix(build): refactor DFRuntime build and link in ConcretelangRuntime instead.

This commit is contained in:
Antoniu Pop
2022-04-01 01:35:01 +01:00
committed by Antoniu Pop
parent 0b14f4c7c5
commit 51d4d044cb
6 changed files with 53 additions and 158 deletions

View File

@@ -1,34 +1,31 @@
add_library(ConcretelangRuntime SHARED
context.cpp
wrappers.cpp
dfr_terminate.cpp
context.cpp
wrappers.cpp
DFRuntime.cpp
)
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
link_libraries(-Wl,--no-as-needed omp)
endif()
if(CONCRETELANG_PARALLEL_EXECUTION_ENABLED)
add_library(DFRuntime SHARED DFRuntime.cpp)
target_link_libraries(DFRuntime PUBLIC pthread m dl HPX::hpx HPX::iostreams_component -rdynamic)
install(TARGETS DFRuntime EXPORT DFRuntime)
install(EXPORT DFRuntime DESTINATION "./")
target_link_libraries(ConcretelangRuntime
Concrete
pthread
m
dl
$<TARGET_OBJECTS:mlir_c_runner_utils>
-Wl,--no-as-needed
DFRuntime
omp
)
else()
target_link_libraries(ConcretelangRuntime Concrete pthread m dl $<TARGET_OBJECTS:mlir_c_runner_utils> omp)
target_link_libraries(
ConcretelangRuntime
PRIVATE
HPX::hpx HPX::iostreams_component
)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(ConcretelangRuntime PUBLIC omp)
else()
target_link_libraries(ConcretelangRuntime PUBLIC -Wl,--no-as-needed omp)
endif()
target_link_libraries(
ConcretelangRuntime
PUBLIC
Concrete
pthread m dl
$<TARGET_OBJECTS:mlir_c_runner_utils>
)
install(TARGETS ConcretelangRuntime omp EXPORT ConcretelangRuntime)
install(EXPORT ConcretelangRuntime DESTINATION "./")

View File

@@ -12,6 +12,8 @@
framework currently used, from the code generation side.
*/
#ifdef CONCRETELANG_PARALLEL_EXECUTION_ENABLED
#include <hpx/future.hpp>
#include <hpx/hpx_start.hpp>
#include <hpx/hpx_suspend.hpp>
@@ -364,3 +366,10 @@ void _dfr_debug_print_task(const char *name, int inputs, int outputs) {
void _dfr_print_debug(size_t val) {
hpx::cout << "_dfr_print_debug : " << val << "\n" << std::flush;
}
#else // CONCRETELANG_PARALLEL_EXECUTION_ENABLED
#include <concretelang/Runtime/runtime_api.h>
void _dfr_terminate() {}
#endif

View File

@@ -1,11 +0,0 @@
// Part of the Concrete Compiler Project, under the BSD3 License with Zama
// Exceptions. See
// https://github.com/zama-ai/concrete-compiler-internal/blob/master/LICENSE.txt
// for license information.
#ifndef CONCRETELANG_PARALLEL_EXECUTION_ENABLED
#include <concretelang/Runtime/runtime_api.h>
void _dfr_terminate() {}
#endif

View File

@@ -7,49 +7,23 @@ get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
add_dependencies(concretecompiler mlir-headers)
if(CONCRETELANG_PARALLEL_EXECUTION_ENABLED)
target_link_libraries(concretecompiler
PRIVATE
${dialect_libs}
${conversion_libs}
target_link_libraries(concretecompiler
PRIVATE
${dialect_libs}
${conversion_libs}
MLIRTransforms
BConcreteDialect
ConcreteDialect
TFHEDialect
FHEDialect
MLIRTransforms
BConcreteDialect
ConcreteDialect
TFHEDialect
FHEDialect
MLIRIR
MLIRLLVMIR
MLIRLLVMToLLVMIRTranslation
RTDialect
MLIRIR
MLIRLLVMIR
MLIRLLVMToLLVMIRTranslation
RTDialect
ConcretelangSupport
-Wl,-rpath,${CMAKE_BINARY_DIR}/lib/Runtime
-Wl,-rpath,${HPX_DIR}/../../
-Wl,--no-as-needed
DFRuntime
omp
)
else()
target_link_libraries(concretecompiler
PRIVATE
${dialect_libs}
${conversion_libs}
MLIRTransforms
BConcreteDialect
ConcreteDialect
TFHEDialect
FHEDialect
MLIRIR
MLIRLLVMIR
MLIRLLVMToLLVMIRTranslation
ConcretelangSupport
)
endif()
ConcretelangSupport
)
mlir_check_all_link_libraries(concretecompiler)

View File

@@ -15,10 +15,8 @@ set_source_files_properties(
target_link_libraries(
testlib_unit_test
ConcretelangRuntime
ConcretelangSupport
DFRuntime
gtest_main
ConcretelangSupport
)
include(GoogleTest)

View File

@@ -3,31 +3,16 @@ enable_testing()
include_directories(${PROJECT_SOURCE_DIR}/include)
if(CONCRETELANG_PARALLEL_EXECUTION_ENABLED)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY, ${CMAKE_BINARY_DIR}/lib/)
set (CMAKE_SHARED_LINKER_FLAGS)
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/lib/gtest_main_shared_src/TestMain.cpp.o"
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/lib/gtest_main_shared_src
COMMAND ${CMAKE_C_COMPILER_AR} -x ${CMAKE_BINARY_DIR}/lib/libgtest_main.a --output ${CMAKE_BINARY_DIR}/lib/gtest_main_shared_src
DEPENDS gtest_main
)
add_library(gtest_main_shared SHARED
"${CMAKE_BINARY_DIR}/lib/gtest_main_shared_src/TestMain.cpp.o"
)
set_target_properties(gtest_main_shared PROPERTIES LINKER_LANGUAGE C)
add_compile_options(
-DCONCRETELANG_PARALLEL_TESTING_ENABLED
)
link_libraries(
-Wl,-rpath,${CMAKE_BINARY_DIR}/lib/
-Wl,-rpath,${HPX_DIR}/../../
-Wl,--no-as-needed
DFRuntime
gtest_main_shared
omp
)
endif()
link_libraries(
gtest_main
ConcretelangSupport
)
add_executable(
end_to_end_jit_test
end_to_end_jit_test.cc
@@ -77,43 +62,6 @@ set_source_files_properties(
PROPERTIES COMPILE_FLAGS "-fno-rtti"
)
target_link_libraries(
end_to_end_jit_test
gtest_main
ConcretelangSupport
)
target_link_libraries(
end_to_end_jit_clear_tensor
gtest_main
ConcretelangSupport
)
target_link_libraries(
end_to_end_jit_encrypted_tensor
gtest_main
ConcretelangSupport
)
target_link_libraries(
end_to_end_jit_fhe
gtest_main
ConcretelangSupport
)
target_link_libraries(
end_to_end_jit_fhelinalg
gtest_main
ConcretelangSupport
)
target_link_libraries(
end_to_end_jit_lambda
gtest_main
ConcretelangSupport
)
include(GoogleTest)
gtest_discover_tests(end_to_end_jit_test)
gtest_discover_tests(end_to_end_jit_clear_tensor)
@@ -138,26 +86,6 @@ if(CONCRETELANG_PARALLEL_EXECUTION_ENABLED)
end_to_end_jit_auto_parallelization.cc
PROPERTIES COMPILE_FLAGS "-fno-rtti"
)
target_link_libraries(
end_to_end_jit_dfr
gtest_main
ConcretelangSupport
-Wl,-rpath,${CMAKE_BINARY_DIR}/lib/
-Wl,-rpath,${HPX_DIR}/../../
-Wl,--no-as-needed
DFRuntime
)
target_link_libraries(
end_to_end_jit_auto_parallelization
gtest_main
ConcretelangSupport
-Wl,-rpath,${CMAKE_BINARY_DIR}/lib/
-Wl,-rpath,${HPX_DIR}/../../
-Wl,--no-as-needed
DFRuntime
)
gtest_discover_tests(end_to_end_jit_dfr)
gtest_discover_tests(end_to_end_jit_auto_parallelization)
endif()