Skip to content

Commit

Permalink
debug: benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
fish committed Oct 6, 2021
1 parent c674135 commit 14dd6e3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
6 changes: 3 additions & 3 deletions files/parties_WAN_3PC
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
35.166.8.86
18.218.6.145
54.153.35.13
172.31.163.52
172.31.163.53
172.31.163.54
42 changes: 39 additions & 3 deletions src/Functionalities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,8 @@ void debugDotProd()
// for (size_t i = 0; i < size; ++i)
// b[i] = aes_indep->get64Bits();

funcDotProductMPC(a, b, c, size);
for(int i = 0; i < 1000 ;i++)
funcDotProductMPC(a, b, c, size);

if (PRIMARY)
funcReconstruct2PC(c, size, "c");
Expand Down Expand Up @@ -1847,7 +1848,8 @@ void debugSS()
for (size_t i = 0; i < size; ++i)
inputs[i] = (myType)aes_indep->get8Bits();

funcSelectShares3PC(inputs, selector, outputs, size);
for(int i = 0; i < 1000 ;i++)
funcSelectShares3PC(inputs, selector, outputs, size);

if (PRIMARY)
{
Expand Down Expand Up @@ -1894,6 +1896,39 @@ void debugMatMul()
funcReconstruct2PC(c, c.size(), "c");
}

void debugReLU()
{
size_t size = 10;
vector<myType> inputs(size, 0);

if (partyNum == PARTY_A)
for (size_t i = 0; i < size; ++i)
inputs[i] = aes_indep->get8Bits() - aes_indep->get8Bits();

if (THREE_PC)
{
vector<myType> outputs(size, 0);
for (int i = 0; i< 1000;i++)
funcRELUMPC(inputs, outputs, size);
if (PRIMARY)
{
funcReconstruct2PC(inputs, size, "inputs");
funcReconstruct2PC(outputs, size, "outputs");
}
}

if (FOUR_PC)
{
vector<smallType> outputs(size, 0);
funcRELUPrime4PC(inputs, outputs, size);
if (PRIMARY)
{
funcReconstruct2PC(inputs, size, "inputs");
funcReconstructBit2PC(outputs, size, "outputs");
}
}
}

void debugReLUPrime()
{
size_t size = 10;
Expand All @@ -1906,7 +1941,8 @@ void debugReLUPrime()
if (THREE_PC)
{
vector<myType> outputs(size, 0);
funcRELUPrime3PC(inputs, outputs, size);
for (int i = 0; i< 1000;i++)
funcRELUPrime3PC(inputs, outputs, size);
if (PRIMARY)
{
funcReconstruct2PC(inputs, size, "inputs");
Expand Down
1 change: 1 addition & 0 deletions src/Functionalities.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void debugSS();
void debugMatMul();
void debugReLUPrime();
void debugMaxIndex();
void debugReLU();

//Test
void testMatMul(size_t rows, size_t common_dim, size_t columns, size_t iter);
Expand Down
15 changes: 10 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,14 @@ int main(int argc, char** argv)
aes_parallel->precompute();


/****************************** RUN NETWORK/BENCHMARKS ******************************/
start_m();

/****************************** RUN NETWORK/BENCHMARKS ******************************/
if (!STANDALONE)
initializeMPC();
start_m();
// debugDotProd();
// debugSS();
// debugReLU();
debugReLUPrime();
// whichNetwork = "Mat-Mul";
// testMatMul(784, 128, 10, NUM_ITERATIONS);
// testMatMul(1, 500, 100, NUM_ITERATIONS);
Expand Down Expand Up @@ -135,8 +140,8 @@ int main(int argc, char** argv)
// testMaxPoolDerivative(24, 24, 2, 2, 16, NUM_ITERATIONS);
// testMaxPoolDerivative(8, 8, 4, 4, 50, NUM_ITERATIONS);

whichNetwork += " train";
train(network, config);
// whichNetwork += " train";
// train(network, config);

// whichNetwork += " test";
// test(network);
Expand Down

0 comments on commit 14dd6e3

Please sign in to comment.