From 51d4d044cbbf9f95a813d649435a734f783d06ad Mon Sep 17 00:00:00 2001 From: Antoniu Pop Date: Fri, 1 Apr 2022 01:35:01 +0100 Subject: [PATCH] fix(build): refactor DFRuntime build and link in ConcretelangRuntime instead. --- compiler/lib/Runtime/CMakeLists.txt | 49 ++++++++------- compiler/lib/Runtime/DFRuntime.cpp | 9 +++ compiler/lib/Runtime/dfr_terminate.cpp | 11 ---- compiler/src/CMakeLists.txt | 56 +++++------------- compiler/tests/TestLib/CMakeLists.txt | 4 +- compiler/tests/unittest/CMakeLists.txt | 82 ++------------------------ 6 files changed, 53 insertions(+), 158 deletions(-) delete mode 100644 compiler/lib/Runtime/dfr_terminate.cpp diff --git a/compiler/lib/Runtime/CMakeLists.txt b/compiler/lib/Runtime/CMakeLists.txt index 286677bce..74b173b12 100644 --- a/compiler/lib/Runtime/CMakeLists.txt +++ b/compiler/lib/Runtime/CMakeLists.txt @@ -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 - $ - -Wl,--no-as-needed - DFRuntime - omp - ) -else() - target_link_libraries(ConcretelangRuntime Concrete pthread m dl $ 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 + $ +) + install(TARGETS ConcretelangRuntime omp EXPORT ConcretelangRuntime) install(EXPORT ConcretelangRuntime DESTINATION "./") + diff --git a/compiler/lib/Runtime/DFRuntime.cpp b/compiler/lib/Runtime/DFRuntime.cpp index 607c77816..4f45926bd 100644 --- a/compiler/lib/Runtime/DFRuntime.cpp +++ b/compiler/lib/Runtime/DFRuntime.cpp @@ -12,6 +12,8 @@ framework currently used, from the code generation side. */ +#ifdef CONCRETELANG_PARALLEL_EXECUTION_ENABLED + #include #include #include @@ -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 + +void _dfr_terminate() {} +#endif diff --git a/compiler/lib/Runtime/dfr_terminate.cpp b/compiler/lib/Runtime/dfr_terminate.cpp deleted file mode 100644 index 9ecf182db..000000000 --- a/compiler/lib/Runtime/dfr_terminate.cpp +++ /dev/null @@ -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 -void _dfr_terminate() {} - -#endif diff --git a/compiler/src/CMakeLists.txt b/compiler/src/CMakeLists.txt index 73bda1b45..adbf6871d 100644 --- a/compiler/src/CMakeLists.txt +++ b/compiler/src/CMakeLists.txt @@ -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) diff --git a/compiler/tests/TestLib/CMakeLists.txt b/compiler/tests/TestLib/CMakeLists.txt index bf0141967..fab708bd0 100644 --- a/compiler/tests/TestLib/CMakeLists.txt +++ b/compiler/tests/TestLib/CMakeLists.txt @@ -15,10 +15,8 @@ set_source_files_properties( target_link_libraries( testlib_unit_test - ConcretelangRuntime - ConcretelangSupport - DFRuntime gtest_main + ConcretelangSupport ) include(GoogleTest) diff --git a/compiler/tests/unittest/CMakeLists.txt b/compiler/tests/unittest/CMakeLists.txt index f2976ac67..67aafed65 100644 --- a/compiler/tests/unittest/CMakeLists.txt +++ b/compiler/tests/unittest/CMakeLists.txt @@ -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()