From 6631f06c9aab17a790e889e3a3a67bd02da38ec2 Mon Sep 17 00:00:00 2001 From: Alexander Viand Date: Fri, 24 Jul 2020 12:14:11 +0200 Subject: [PATCH] add Cingulata eval example --- .github/workflows/benchmark.yml | 2 +- Cingulata/.gitignore | 1 + Cingulata/Dockerfile | 13 +++++ Cingulata/README.md | 1 + Cingulata/source/CMakeLists.txt | 15 +++++ Cingulata/source/cmake/FindCingulata.cmake | 12 ++++ Cingulata/source/main.cpp | 65 ++++++++++++++++++++++ 7 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 Cingulata/.gitignore create mode 100644 Cingulata/Dockerfile create mode 100644 Cingulata/README.md create mode 100644 Cingulata/source/CMakeLists.txt create mode 100644 Cingulata/source/cmake/FindCingulata.cmake create mode 100644 Cingulata/source/main.cpp diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index fca3e03..108190b 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: # this must match the tool's directory name in the SoK repo - tool: [SEAL, Lobster, ALCHEMY] + tool: [SEAL, Lobster, ALCHEMY, Cingulata] steps: - name: create a new AWS EC2 instance with Ubuntu 20.04 + Docker and wait until VM is ready diff --git a/Cingulata/.gitignore b/Cingulata/.gitignore new file mode 100644 index 0000000..c97f963 --- /dev/null +++ b/Cingulata/.gitignore @@ -0,0 +1 @@ +*.sh diff --git a/Cingulata/Dockerfile b/Cingulata/Dockerfile new file mode 100644 index 0000000..26afc99 --- /dev/null +++ b/Cingulata/Dockerfile @@ -0,0 +1,13 @@ +FROM marblehe/base_cingulata + +# copy eval program into container +COPY source /root/eval + +# build the benchmark +WORKDIR /root/eval +RUN mkdir build +WORKDIR /root/eval/build +RUN cmake ..; make + +# execute the benchmark and upload benchmark results to S3 +CMD ["sh", "-c", "./benchmark > result_benchmark_cingulata.csv; aws s3 cp result_benchmark_cingulata.csv s3://sok-repository-cingulata-benchmarks"] \ No newline at end of file diff --git a/Cingulata/README.md b/Cingulata/README.md new file mode 100644 index 0000000..7101253 --- /dev/null +++ b/Cingulata/README.md @@ -0,0 +1 @@ +# Cingulata diff --git a/Cingulata/source/CMakeLists.txt b/Cingulata/source/CMakeLists.txt new file mode 100644 index 0000000..ebbb652 --- /dev/null +++ b/Cingulata/source/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.10) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") + +project(eval_benchmark) + +set(CMAKE_CXX_STANDARD 17) + +find_package(Cingulata REQUIRED) +find_package(Threads REQUIRED) + +add_executable(benchmark main.cpp) + +target_include_directories(benchmark PRIVATE ${Cingulata_INCLUDE_DIR}) +target_link_libraries(benchmark PRIVATE ${Cingulata_LIBRARY}) +target_link_libraries(benchmark PRIVATE Threads::Threads) \ No newline at end of file diff --git a/Cingulata/source/cmake/FindCingulata.cmake b/Cingulata/source/cmake/FindCingulata.cmake new file mode 100644 index 0000000..698e01c --- /dev/null +++ b/Cingulata/source/cmake/FindCingulata.cmake @@ -0,0 +1,12 @@ +find_path(Cingulata_INCLUDE_DIR NAMES ci_int.hxx PATHS /cingu/common/include) +find_library(Cingulata_LIBRARY NAMES common PATHS /cingu/build_bfv/common/src) + + +set(Cingulata_INCLUDE_DIRS ${Cingulata_INCLUDE_DIR}) +set(Cingulata_LIBRARIES ${Cingulata_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Cingulata DEFAULT_MSG + Cingulata_LIBRARIES Cingulata_INCLUDE_DIRS) + +mark_as_advanced(Cingulata_LIBRARY Cingulata_INCLUDE_DIR) \ No newline at end of file diff --git a/Cingulata/source/main.cpp b/Cingulata/source/main.cpp new file mode 100644 index 0000000..51950af --- /dev/null +++ b/Cingulata/source/main.cpp @@ -0,0 +1,65 @@ +/* + (C) Copyright 2019 CEA LIST. All Rights Reserved. + Contributor(s): Cingulata team (formerly Armadillo team) + + This software is governed by the CeCILL-C license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL-C + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited + liability. + + The fact that you are presently reading this means that you have had + knowledge of the CeCILL-C license and that you accept its terms. +*/ + +#define blif_name "bfv-hello.blif" + +#include + +/* local includes */ +#include +#include +#include +#include +#include +#include +#include + +/* namespaces */ +using namespace std; +using namespace cingulata; + +int main() { + /* Set context to bit tracker and multiplicative depth minimized integer + * operations */ + CiContext::set_config( + make_shared, + decorator::Stat>>(), + make_shared()); + + CiInt a{CiInt::u8}; // create from unsigned 8-bit template + CiInt b{CiInt::u8v(42)}; // use helper function to create an unsigned 8-bit + CiInt c{-1, 16, false}; // or manually specify value, size and signedness + + a.read("a"); // read variable a and set name + + b.set_name("b"); // set name and ... + cin >> b; // read variable b + + c = a + b; + + cout << c.set_name("c"); // set name and write variable + // c.write("c"); // or do it at once + + /* Export to file the "tracked" circuit */ + CiContext::get_bit_exec_t()->export_blif(blif_name, "hello"); + + CiContext::get_bit_exec_t>()->print(); + CiContext::get_bit_exec_t>()->print(); +}