Improve compilation.

This commit is contained in:
Marcel Keller
2018-10-29 23:36:26 +11:00
parent c8e028b8c0
commit d23248f696
13 changed files with 62 additions and 51 deletions

3
CONFIG
View File

@@ -11,7 +11,8 @@ PREP_DIR = '-DPREP_DIR="Player-Data/"'
# set for SHE preprocessing (SPDZ and Overdrive)
USE_NTL = 0
# set for using GF(2^128) online phase, OT, BMR, or Yao's garbled circuits
# set for using GF(2^128) online phase, OT, MASCOT, or BMR
# unset for GF(2^40) online and offline phase
USE_GF2N_LONG = 1
# set to -march=<architecture> for optimization

View File

@@ -237,9 +237,4 @@ void Instruction<T>::parse(istream& s, int pos)
}
}
template class Instruction<FakeSecret>;
template class Instruction<ReplicatedSecret>;
} /* namespace GC */

26
GC/Machine.cpp Normal file
View File

@@ -0,0 +1,26 @@
/*
* Machine.cpp
*
*/
#include "Machine.hpp"
#include "Processor.hpp"
#include "Thread.hpp"
#include "ThreadMaster.hpp"
namespace GC
{
template class Machine<FakeSecret>;
template class Machine<ReplicatedSecret>;
template class Processor<FakeSecret>;
template class Processor<ReplicatedSecret>;
template class Thread<FakeSecret>;
template class Thread<ReplicatedSecret>;
template class ThreadMaster<FakeSecret>;
template class ThreadMaster<ReplicatedSecret>;
} /* namespace GC */

View File

@@ -71,7 +71,4 @@ void Machine<T>::join_tape(int thread_number)
ThreadMaster<T>::s().join_tape(thread_number);
}
template class Machine<FakeSecret>;
template class Machine<ReplicatedSecret>;
} /* namespace GC */

View File

@@ -231,7 +231,4 @@ void Processor<T>::print_str(int n)
T::out << string((char*)&n,sizeof(n)) << flush;
}
template class Processor<FakeSecret>;
template class Processor<ReplicatedSecret>;
} /* namespace GC */

18
GC/Program.cpp Normal file
View File

@@ -0,0 +1,18 @@
/*
* Program.cpp
*
*/
#include "Instruction.hpp"
#include "Program.hpp"
namespace GC
{
template class Instruction<FakeSecret>;
template class Instruction<ReplicatedSecret>;
template class Program<FakeSecret>;
template class Program<ReplicatedSecret>;
} /* namespace GC */

View File

@@ -132,7 +132,4 @@ BreakType Program<T>::execute(Processor<T>& Proc, int PC) const
return TIME_BREAK;
}
template class Program<FakeSecret>;
template class Program<ReplicatedSecret>;
} /* namespace GC */

View File

@@ -83,7 +83,4 @@ void Thread<T>::finish()
pthread_join(thread, 0);
}
template class Thread<FakeSecret>;
template class Thread<ReplicatedSecret>;
} /* namespace GC */

View File

@@ -81,9 +81,4 @@ void ThreadMaster<T>::run()
cerr << "Time = " << timer.elapsed() << endl;
}
template class ThreadMaster<FakeSecret>;
template class ThreadMaster<ReplicatedSecret>;
} /* namespace GC */

View File

@@ -17,6 +17,8 @@ endif
GC = $(patsubst %.cpp,%.o,$(wildcard GC/*.cpp)) $(PROCESSOR)
# OT needed by Yao
OT = OT/BaseOT.o OT/BitMatrix.o OT/BitVector.o OT/OTExtension.o OT/OTExtensionWithMatrix.o OT/Tools.o
# OT stuff needs GF2N_LONG, so only compile if this is enabled
ifeq ($(USE_GF2N_LONG),1)
OT = $(patsubst %.cpp,%.o,$(filter-out OT/OText_main.cpp,$(wildcard OT/*.cpp)))
@@ -103,7 +105,7 @@ gen_input_f2n.x: Scripts/gen_input_f2n.cpp $(COMMON)
gen_input_fp.x: Scripts/gen_input_fp.cpp $(COMMON)
$(CXX) $(CFLAGS) Scripts/gen_input_fp.cpp -o gen_input_fp.x $(COMMON) $(LDLIBS)
gc-emulate.x: $(GC) $(COMMON) $(PROCESSOR) gc-emulate.cpp $(BMR)
gc-emulate.x: $(GC) $(COMMON) $(PROCESSOR) gc-emulate.cpp $(GC)
$(CXX) $(CFLAGS) -o $@ $^ $(LDLIBS) $(BOOST)
ifeq ($(USE_GF2N_LONG),1)
@@ -140,10 +142,8 @@ spdz2-offline.x: $(COMMON) $(FHEOFFLINE) spdz2-offline.cpp
$(CXX) $(CFLAGS) -o $@ $^ $(LDLIBS)
endif
ifeq ($(USE_GF2N_LONG),1)
yao-player.x: $(YAO) $(COMMON) yao-player.cpp $(LIBSIMPLEOT)
$(CXX) $(CFLAGS) -o $@ $^ $(LDLIBS)
endif
yao-clean:
-rm Yao/*.o
@@ -151,7 +151,7 @@ yao-clean:
galois-degree.x: $(COMMON) galois-degree.cpp
$(CXX) $(CFLAGS) -o $@ $^ $(LDLIBS)
replicated-bin-party.x: $(BMR) replicated-bin-party.cpp
replicated-bin-party.x: $(COMMON) $(GC) replicated-bin-party.cpp
$(CXX) $(CFLAGS) -o $@ $^ $(LDLIBS) $(BOOST)
replicated-ring-party.x: replicated-ring-party.cpp $(PROCESSOR) $(COMMON)

View File

@@ -644,7 +644,7 @@ template BitMatrix& BitMatrix::add<gf2n>(BitMatrix& other);
template BitMatrix& BitMatrix::add<gfp>(BitMatrix& other);
template BitMatrix& BitMatrix::sub<gf2n>(BitMatrix& other);
template BitMatrix& BitMatrix::sub<gfp>(BitMatrix& other);
template void BitMatrixSlice::print<gf2n>();
template void BitMatrixSlice::print<gf2n_long>();
template void BitMatrixSlice::print<gfp>();
template void BitMatrixSlice::randomize<gf2n>(int row, PRNG& G);
template void BitMatrixSlice::randomize<gfp>(int row, PRNG& G);

View File

@@ -345,13 +345,13 @@ void OTExtensionWithMatrix::print(BitVector& newReceiverInput, int i)
{
if (player->my_num() == 0)
{
print_receiver<gf2n>(newReceiverInput, receiverOutputMatrix, i);
print_receiver<gf2n_long>(newReceiverInput, receiverOutputMatrix, i);
print_sender(senderOutputMatrices[0].squares[i], senderOutputMatrices[1].squares[i]);
}
else
{
print_sender(senderOutputMatrices[0].squares[i], senderOutputMatrices[1].squares[i]);
print_receiver<gf2n>(newReceiverInput, receiverOutputMatrix, i);
print_receiver<gf2n_long>(newReceiverInput, receiverOutputMatrix, i);
}
}
@@ -418,7 +418,7 @@ void OTExtensionWithMatrix::print_pre_correlate(int i)
if (player->my_num() == 0)
print_sender(receiverOutputMatrix.squares[i], t1.squares[i]);
else
print_receiver<gf2n>(baseReceiverInput, senderOutputMatrices[0], i);
print_receiver<gf2n_long>(baseReceiverInput, senderOutputMatrices[0], i);
}
void OTExtensionWithMatrix::print_post_transpose(BitVector& newReceiverInput, int i, int sender)
@@ -426,7 +426,7 @@ void OTExtensionWithMatrix::print_post_transpose(BitVector& newReceiverInput, in
cout << "post transpose, sender " << sender << endl;
if (player->my_num() == sender)
{
print_receiver<gf2n>(newReceiverInput, receiverOutputMatrix);
print_receiver<gf2n_long>(newReceiverInput, receiverOutputMatrix);
}
else
{
@@ -468,7 +468,7 @@ template void OTExtensionWithMatrix::correlate<gf2n>(int start, int slice,
BitVector& newReceiverInput, bool useConstantBase, int repeat);
template void OTExtensionWithMatrix::correlate<gfp>(int start, int slice,
BitVector& newReceiverInput, bool useConstantBase, int repeat);
template void OTExtensionWithMatrix::print_post_correlate<gf2n>(
template void OTExtensionWithMatrix::print_post_correlate<gf2n_long>(
BitVector& newReceiverInput, int j, int offset, int sender);
template void OTExtensionWithMatrix::print_post_correlate<gfp>(
BitVector& newReceiverInput, int j, int offset, int sender);
@@ -481,6 +481,6 @@ template void OTExtensionWithMatrix::expand<gfp>(int start, int slice);
template void OTExtensionWithMatrix::expand_transposed<gf2n>();
template void OTExtensionWithMatrix::expand_transposed<gfp>();
template void OTExtensionWithMatrix::reduce_squares(unsigned int nTriples,
vector<gf2n>& output);
vector<gf2n_long>& output);
template void OTExtensionWithMatrix::reduce_squares(unsigned int nTriples,
vector<gfp>& output);

View File

@@ -96,16 +96,9 @@ compute the preprocessing time for a particulor computation.
- To benchmark anything other than Yao's garbled circuits, add the following line at the top: `MY_CFLAGS = -DINSECURE`
- `PREP_DIR` should point to should be a local, unversioned directory to store preprocessing data (default is `Player-Data` in the current directory).
- For the SPDZ-2 and Overdrive offline phases, set `USE_NTL = 1` and `MOD = -DMAX_MOD_SZ=6`.
- To use GF(2^40) in the online phase, set `USE_GF2N_LONG = 1`. This will deactive anything that requires OT.
- To use GF(2^40), set `USE_GF2N_LONG = 0`. This will deactive anything that requires GF(2^128) such as MASCOT.
2) MASCOT and Yao's garbled circuits require SimpleOT:
```
git submodule update --init SimpleOT
cd SimpleOT
make -j
```
3) Run make to compile all the software (use the flag -j for faster
2) Run make to compile all the software (use the flag -j for faster
compilation multiple threads). See below on how to compile specific
parts only. Remember to run `make clean` first after changing `CONFIG`
or `CONFIG.mine`.
@@ -302,6 +295,8 @@ such as this one.
This implementation is suitable to generate the preprocessed data used in the online phase.
It requires compilation with `USE_GF2N_LONG = 0` in `CONFIG` or `CONFIG.mine`. Remember to run `make clean` before recompiling.
For quick run on one machine, you can call the following:
`./spdz2-offline.x -p 0 & ./spdz2-offline.x -p 1`
@@ -324,14 +319,7 @@ In order to compile the MASCOT code, the following must be set in CONFIG or CONF
`USE_GF2N_LONG = 1`
It also requires SimpleOT:
```
git submodule update --init SimpleOT
cd SimpleOT
make
```
If SPDZ has been built before, any compiled code needs to be removed:
If SPDZ has been built before with `USE_GF2N_LONG = 0`, any compiled code needs to be removed:
`make clean`