Skip to content

Commit

Permalink
add Cingulata eval example
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderViand committed Jul 24, 2020
1 parent c8d7b78 commit 6631f06
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Cingulata/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh
13 changes: 13 additions & 0 deletions Cingulata/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
1 change: 1 addition & 0 deletions Cingulata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Cingulata
15 changes: 15 additions & 0 deletions Cingulata/source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions Cingulata/source/cmake/FindCingulata.cmake
Original file line number Diff line number Diff line change
@@ -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)
65 changes: 65 additions & 0 deletions Cingulata/source/main.cpp
Original file line number Diff line number Diff line change
@@ -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 <cstdint>

/* local includes */
#include <bit_exec/decorator/attach.hxx>
#include <bit_exec/decorator/depth.hxx>
#include <bit_exec/decorator/stat.hxx>
#include <bit_exec/tracker.hxx>
#include <ci_context.hxx>
#include <ci_int.hxx>
#include <int_op_gen/mult_depth.hxx>

/* 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::Attach<BitTracker, decorator::Depth<IBitExecSHE>,
decorator::Stat<IBitExecSHE>>>(),
make_shared<IntOpGenDepth>());

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<BitTracker>()->export_blif(blif_name, "hello");

CiContext::get_bit_exec_t<decorator::Depth<IBitExecSHE>>()->print();
CiContext::get_bit_exec_t<decorator::Stat<IBitExecSHE>>()->print();
}

0 comments on commit 6631f06

Please sign in to comment.