|
| 1 | +# Include FetchContent module |
| 2 | +include(FetchContent) |
| 3 | + |
| 4 | +# Add OpenFHE via FetchContent |
| 5 | +FetchContent_Declare( |
| 6 | + OpenFHE |
| 7 | + GIT_REPOSITORY https://github.com/AlexanderViand/openfhe-development.git |
| 8 | + GIT_TAG 274e470b99495d571a1f6008578601b99e569d84 # head of `tracing` branch (2025-07-28) |
| 9 | +) |
| 10 | + |
| 11 | +# Set OpenFHE build options before making it available |
| 12 | +set(BUILD_UNITTESTS OFF CACHE BOOL "" FORCE) |
| 13 | +set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) |
| 14 | +set(BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE) |
| 15 | +set(ENABLE_TRACER ON CACHE BOOL "" FORCE) |
| 16 | + |
| 17 | +message(STATUS "Fetching OpenFHE, this may take a while...") |
| 18 | +FetchContent_MakeAvailable(OpenFHE) |
| 19 | +message(STATUS "Finished configuring OpenFHE") |
| 20 | + |
| 21 | +FetchContent_GetProperties(openfhe) |
| 22 | + |
| 23 | +# Create executable from simple_tracing.cpp |
| 24 | +add_executable(simple_tracing simple_tracing.cpp heraclestracer.h) |
| 25 | +# Set C++ standard |
| 26 | +target_compile_features(simple_tracing PRIVATE cxx_std_17) |
| 27 | +# Link with OpenFHE libraries |
| 28 | +target_link_libraries(simple_tracing PRIVATE HERACLES_DATA_FORMATS::heracles_data_formats OPENFHEcore OPENFHEpke OPENFHEbinfhe) |
| 29 | + |
| 30 | +target_include_directories(simple_tracing PRIVATE |
| 31 | + # Third Party Includes |
| 32 | + $<BUILD_INTERFACE:${openfhe_SOURCE_DIR}/third-party/include> |
| 33 | + $<BUILD_INTERFACE:${openfhe_SOURCE_DIR}/third-party/cereal/include> |
| 34 | + $<BUILD_INTERFACE:${openfhe_SOURCE_DIR}/third-party/google-test/googletest> |
| 35 | + $<BUILD_INTERFACE:${openfhe_SOURCE_DIR}/third-party/google-test/googletest/include> |
| 36 | + # public headers that sit in the repo |
| 37 | + $<BUILD_INTERFACE:${openfhe_SOURCE_DIR}/src/core/include> |
| 38 | + $<BUILD_INTERFACE:${openfhe_SOURCE_DIR}/src/pke/include> |
| 39 | + $<BUILD_INTERFACE:${openfhe_SOURCE_DIR}/src/binfhe/include> |
| 40 | + # generated header (configure_file → config_core.h) |
| 41 | + $<BUILD_INTERFACE:${openfhe_BINARY_DIR}/src/core>) |
| 42 | + |
| 43 | + |
| 44 | +# Set compiler flags for optimization and debug info |
| 45 | +target_compile_options(simple_tracing PRIVATE |
| 46 | + $<$<CONFIG:Release>:-O3> |
| 47 | + $<$<CONFIG:Debug>:-g -O0> |
| 48 | +) |
| 49 | + |
| 50 | + |
| 51 | +# define a custom target that runs tracing, then submits the trace to the program mapper, finally sending the pisa and mem file to the functional modeler |
| 52 | +add_custom_target( |
| 53 | + run_simple_tracing |
| 54 | + # Run the actual example, which will generate the traces as end-to-end-test/simple_tracing.bin and end-to-end-test/simple_tracing_data.bin |
| 55 | + COMMAND simple_tracing |
| 56 | + # Run the program mapper on the instruction trace, generating end-to-end-test/simple_tracing.bin.csv |
| 57 | + COMMAND env VIRTUAL_ENV=${VENV_PATH} PATH=${VENV_PATH}/bin:$ENV{PATH} PYTHONPATH=${VENV_SITE_PACKAGES}:$ENV{PYTHONPATH} $<TARGET_FILE:program_mapper> ${CMAKE_BINARY_DIR}/end-to-end-test/simple_tracing.bin ${CMAKE_SOURCE_DIR}/kerngen/kerngen.py |
| 58 | + COMMAND $<TARGET_FILE:functional_modeler> ${CMAKE_BINARY_DIR}/end-to-end-test/simple_tracing_pisa.csv --verbose --hec_dataformats_mode --hec_dataformats_poly_program_location ${CMAKE_BINARY_DIR}/end-to-end-test/simple_tracing.bin --hec_dataformats_data ${CMAKE_BINARY_DIR}/end-to-end-test/simple_tracing_data.bin |
| 59 | + # TODO: Next step: assemble the *.pisa.csv and the *tw.mem using the assembler from https://github.com/IntelLabs/HERACLES-HGCF |
| 60 | + # TODO: Then it's a dead end :( as we don't have any tooling that can support non-toy sized workloads |
| 61 | + DEPENDS simple_tracing program_mapper functional_modeler create-end-to-end-test-dir |
| 62 | + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/end-to-end-test |
| 63 | +) |
| 64 | + |
| 65 | +add_custom_target(create-end-to-end-test-dir |
| 66 | + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/end-to-end-test |
| 67 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/end-to-end-test |
| 68 | +) |
0 commit comments