From 094b45e76baa5a4bd85b1440d993e036455cd0ce Mon Sep 17 00:00:00 2001 From: Edward Chen Date: Mon, 23 May 2022 15:06:58 -0400 Subject: [PATCH] test --- examples/C/mpc/benchmarks/db/db_join.c | 4 ++-- examples/C/mpc/playground.c | 13 +++++------ scripts/build_mpc_c_test.zsh | 4 ++-- src/front/c/mod.rs | 30 +++++++++++++------------- src/ir/opt/mod.rs | 2 ++ 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/examples/C/mpc/benchmarks/db/db_join.c b/examples/C/mpc/benchmarks/db/db_join.c index 08195f3d..0ab8b511 100644 --- a/examples/C/mpc/benchmarks/db/db_join.c +++ b/examples/C/mpc/benchmarks/db/db_join.c @@ -2,8 +2,8 @@ * Example on how to merge two data sets and to perform various analyses */ -#define LEN_A 50 -#define LEN_B 50 +#define LEN_A 11 +#define LEN_B 11 #define ATT_A 2 //Number of attributes #define ATT_B 2 diff --git a/examples/C/mpc/playground.c b/examples/C/mpc/playground.c index b5a53041..1d3096b4 100644 --- a/examples/C/mpc/playground.c +++ b/examples/C/mpc/playground.c @@ -1,21 +1,22 @@ -int fa(int * c) { - for (int i = 0; i < 500; i++) { - c[i] = c[i] + 1; +int fa(int * c, int a) { + for (int i = 0; i < 5; i++) { + c[i] = c[i] + a; } return 1; } int main(__attribute__((private(0))) int a, __attribute__((private(1))) int b) { - int c[500]; - int ret = fa(c); + int c[5]; + int ret = fa(c, a); int sum = ret; - for (int i = 0; i < 500; i++) { + for (int i = 0; i < 5; i++) { sum += c[i]; } return sum; } + // int fa(int a, int b, int c) { // return a + b + c + 1; // } diff --git a/scripts/build_mpc_c_test.zsh b/scripts/build_mpc_c_test.zsh index 97fde407..f953ad05 100755 --- a/scripts/build_mpc_c_test.zsh +++ b/scripts/build_mpc_c_test.zsh @@ -30,10 +30,10 @@ function mpc_test_2 { RUST_BACKTRACE=1 measure_time $BIN --parties $parties $cpath mpc --cost-model "hycc" --selection-scheme "a+b" } -mpc_test_2 2 ./examples/C/mpc/playground.c +# mpc_test_2 2 ./examples/C/mpc/playground.c # mpc_test 2 ./examples/C/mpc/benchmarks/kmeans/2pc_kmeans_.c # mpc_test_2 2 ./examples/C/mpc/benchmarks/gauss/2pc_gauss_inline.c -# mpc_test_2 2 ./examples/C/mpc/benchmarks/db/db_join.c +mpc_test_2 2 ./examples/C/mpc/benchmarks/db/db_join.c # # build mpc arithmetic tests # mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_add.c diff --git a/src/front/c/mod.rs b/src/front/c/mod.rs index 7c7339e3..86202ff5 100644 --- a/src/front/c/mod.rs +++ b/src/front/c/mod.rs @@ -1336,21 +1336,10 @@ impl CGen { self.gen_stmt(f.body.clone()); - let ret_names = &rets.keys().collect::>(); - let rets = self.circ.exit_fn_call(ret_names); - for (name, val) in rets { - let ret_terms = val.unwrap_term().term.terms(self.circ.cir_ctx()); - self.circ - .cir_ctx() - .cs - .borrow_mut() - .outputs - .extend(ret_terms); - } - - // if let Some(r) = self.circ.exit_fn() { - // let ret_term = r.unwrap_term(); - // let ret_terms = ret_term.term.terms(self.circ.cir_ctx()); + // let ret_names = &rets.keys().collect::>(); + // let rets = self.circ.exit_fn_call(ret_names); + // for (name, val) in rets { + // let ret_terms = val.unwrap_term().term.terms(self.circ.cir_ctx()); // self.circ // .cir_ctx() // .cs @@ -1359,6 +1348,17 @@ impl CGen { // .extend(ret_terms); // } + if let Some(r) = self.circ.exit_fn() { + let ret_term = r.unwrap_term(); + let ret_terms = ret_term.term.terms(self.circ.cir_ctx()); + self.circ + .cir_ctx() + .cs + .borrow_mut() + .outputs + .extend(ret_terms); + } + // match self.mode { // Mode::Mpc(_) => { // let ret_term = r.unwrap_term(); diff --git a/src/ir/opt/mod.rs b/src/ir/opt/mod.rs index 108edb44..4c5ef0cd 100644 --- a/src/ir/opt/mod.rs +++ b/src/ir/opt/mod.rs @@ -58,6 +58,8 @@ pub fn opt>(mut fs: Functions, optimizations: I) -> let _lock = super::term::COLLECT.read().unwrap(); let mut cache = TermCache::new(TERM_CACHE_LIMIT); for a in &mut comp.outputs { + // println!("cfold: {}", a); + // println!(); // allow unbounded size during a single fold_cache call cache.resize(std::usize::MAX); *a = cfold::fold_cache(a, &mut cache, &*ignore.clone());