From 43b7c8206ffa8a88b7f6b11309b46c6393c5abb8 Mon Sep 17 00:00:00 2001 From: Lennart Braun Date: Fri, 12 Oct 2018 13:54:20 +0200 Subject: [PATCH] add compile time option for matrix output The parameter `-DABY_ENABLE_MATRIX=On` to cmake now enables output for the MATRIX framework. Also, the `write_log` method is not called automatically anymore after the last task. --- CMakeLists.txt | 1 + MATRIX/build.sh | 2 +- README.md | 3 +++ src/abycore/MATRIX/MatrixMeasurement.h | 6 ------ src/examples/innerproduct/CMakeLists.txt | 3 +++ src/examples/innerproduct/common/innerproduct.cpp | 4 ++++ 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a03b222e..eab3b031 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.10) project(ABY LANGUAGES CXX) option(ABY_BUILD_EXE "Build executables" OFF) +option(ABY_ENABLE_MATRIX "Enable logging for the MATRIX framework in examples applications" OFF) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") diff --git a/MATRIX/build.sh b/MATRIX/build.sh index 16c0ebc3..9481ea90 100644 --- a/MATRIX/build.sh +++ b/MATRIX/build.sh @@ -5,5 +5,5 @@ export PATH="$HOME/prefix/bin:$PATH" cd .. mkdir -p build && cd build -cmake .. -DABY_BUILD_EXE=On +cmake .. -DABY_BUILD_EXE=On -DABY_ENABLE_MATRIX=On make -j`nproc` diff --git a/README.md b/README.md index 76922336..34475eff 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,9 @@ applications, you use the `ABY_BUILD_EXE` option: cmake .. -DABY_BUILD_EXE=On ``` +If also `-DABY_ENABLE_MATRIX=On` is given, then the examples output data for +the [MATRIX framework](https://github.com/cryptobiu/MATRIX) (if available). + ###### Build Options You can choose the build type, e.g. `Release` or `Debug` using diff --git a/src/abycore/MATRIX/MatrixMeasurement.h b/src/abycore/MATRIX/MatrixMeasurement.h index 260096bc..1c8cab93 100644 --- a/src/abycore/MATRIX/MatrixMeasurement.h +++ b/src/abycore/MATRIX/MatrixMeasurement.h @@ -75,12 +75,6 @@ class MatrixMeasurement { auto taskIdx = getTaskIdx(taskName); m_cpuEndTimes[taskIdx][currentIterationNumber] = get_ms_since_epoch(); - - // if this is the last task and last iteration write the data to file - if (taskIdx == m_tasksNames.size() - 1 && currentIterationNumber == m_cpuEndTimes[0].size() - 1) - { - write_log(); - } } void write_log() const diff --git a/src/examples/innerproduct/CMakeLists.txt b/src/examples/innerproduct/CMakeLists.txt index be90b660..419fb7d7 100644 --- a/src/examples/innerproduct/CMakeLists.txt +++ b/src/examples/innerproduct/CMakeLists.txt @@ -1,3 +1,6 @@ add_executable(innerproduct_test innerproduct_test.cpp common/innerproduct.cpp) target_link_libraries(innerproduct_test ABY::aby ENCRYPTO_utils::encrypto_utils) +if(ABY_ENABLE_MATRIX) + target_compile_definitions(innerproduct_test PRIVATE ABY_ENABLE_MATRIX) +endif() diff --git a/src/examples/innerproduct/common/innerproduct.cpp b/src/examples/innerproduct/common/innerproduct.cpp index 0f97ef6f..2cefdf0c 100644 --- a/src/examples/innerproduct/common/innerproduct.cpp +++ b/src/examples/innerproduct/common/innerproduct.cpp @@ -128,6 +128,10 @@ int32_t test_inner_product_circuit(e_role role, const std::string& address, uint party->ExecCircuit(); log.endSubTask("ExecCircuit", 0); +#ifdef ABY_ENABLE_MATRIX + log.write_log(); +#endif + /** Step 10: Type caste the plaintext output to 16 bit unsigned integer. */