|
@@ -4,12 +4,14 @@
|
|
|
#include "mpcio.hpp"
|
|
|
#include "preproc.hpp"
|
|
|
#include "online.hpp"
|
|
|
+#include "options.hpp"
|
|
|
|
|
|
static void usage(const char *progname)
|
|
|
{
|
|
|
std::cerr << "Usage: " << progname << " [-p] [-t num] player_num player_addrs args ...\n";
|
|
|
std::cerr << "-p: preprocessing mode\n";
|
|
|
std::cerr << "-t num: use num threads\n";
|
|
|
+ std::cerr << "-c: store DPFs compressed (default is expanded)\n";
|
|
|
std::cerr << "player_num = 0 or 1 for the computational players\n";
|
|
|
std::cerr << "player_num = 2 for the server player\n";
|
|
|
std::cerr << "player_addrs is omitted for player 0\n";
|
|
@@ -19,20 +21,20 @@ static void usage(const char *progname)
|
|
|
}
|
|
|
|
|
|
static void comp_player_main(boost::asio::io_context &io_context,
|
|
|
- unsigned player, bool preprocessing, int num_threads, const char *p0addr,
|
|
|
+ unsigned player, const PRACOptions &opts, const char *p0addr,
|
|
|
char **args)
|
|
|
{
|
|
|
std::deque<tcp::socket> peersocks, serversocks;
|
|
|
- mpcio_setup_computational(player, io_context, p0addr, num_threads,
|
|
|
- peersocks, serversocks);
|
|
|
- MPCPeerIO mpcio(player, preprocessing, peersocks, serversocks);
|
|
|
+ mpcio_setup_computational(player, io_context, p0addr,
|
|
|
+ opts.num_threads, peersocks, serversocks);
|
|
|
+ MPCPeerIO mpcio(player, opts.preprocessing, peersocks, serversocks);
|
|
|
|
|
|
|
|
|
boost::asio::post(io_context, [&]{
|
|
|
- if (preprocessing) {
|
|
|
- preprocessing_comp(mpcio, num_threads, args);
|
|
|
+ if (opts.preprocessing) {
|
|
|
+ preprocessing_comp(mpcio, opts, args);
|
|
|
} else {
|
|
|
- online_main(mpcio, num_threads, args);
|
|
|
+ online_main(mpcio, opts, args);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -45,20 +47,20 @@ static void comp_player_main(boost::asio::io_context &io_context,
|
|
|
}
|
|
|
|
|
|
static void server_player_main(boost::asio::io_context &io_context,
|
|
|
- bool preprocessing, int num_threads, const char *p0addr,
|
|
|
+ const PRACOptions &opts, const char *p0addr,
|
|
|
const char *p1addr, char **args)
|
|
|
{
|
|
|
std::deque<tcp::socket> p0socks, p1socks;
|
|
|
- mpcio_setup_server(io_context, p0addr, p1addr, num_threads,
|
|
|
- p0socks, p1socks);
|
|
|
- MPCServerIO mpcserverio(preprocessing, p0socks, p1socks);
|
|
|
+ mpcio_setup_server(io_context, p0addr, p1addr,
|
|
|
+ opts.num_threads, p0socks, p1socks);
|
|
|
+ MPCServerIO mpcserverio(opts.preprocessing, p0socks, p1socks);
|
|
|
|
|
|
|
|
|
boost::asio::post(io_context, [&]{
|
|
|
- if (preprocessing) {
|
|
|
- preprocessing_server(mpcserverio, num_threads, args);
|
|
|
+ if (opts.preprocessing) {
|
|
|
+ preprocessing_server(mpcserverio, opts, args);
|
|
|
} else {
|
|
|
- online_main(mpcserverio, num_threads, args);
|
|
|
+ online_main(mpcserverio, opts, args);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -73,26 +75,28 @@ static void server_player_main(boost::asio::io_context &io_context,
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
char **args = argv+1;
|
|
|
- bool preprocessing = false;
|
|
|
+ PRACOptions opts;
|
|
|
unsigned player = 0;
|
|
|
- int num_threads = 1;
|
|
|
const char *p0addr = NULL;
|
|
|
const char *p1addr = NULL;
|
|
|
|
|
|
while (*args && *args[0] == '-') {
|
|
|
if (!strcmp("-p", *args)) {
|
|
|
- preprocessing = true;
|
|
|
+ opts.preprocessing = true;
|
|
|
++args;
|
|
|
} else if (!strcmp("-t", *args)) {
|
|
|
if (args[1]) {
|
|
|
- num_threads = atoi(args[1]);
|
|
|
- if (num_threads < 1) {
|
|
|
+ opts.num_threads = atoi(args[1]);
|
|
|
+ if (opts.num_threads < 1) {
|
|
|
usage(argv[0]);
|
|
|
}
|
|
|
args += 2;
|
|
|
} else {
|
|
|
usage(argv[0]);
|
|
|
}
|
|
|
+ } else if (!strcmp("-c", *args)) {
|
|
|
+ opts.expand_rdpfs = false;
|
|
|
+ ++args;
|
|
|
}
|
|
|
}
|
|
|
if (*args == NULL) {
|
|
@@ -144,9 +148,9 @@ int main(int argc, char **argv)
|
|
|
boost::asio::io_context io_context;
|
|
|
|
|
|
if (player < 2) {
|
|
|
- comp_player_main(io_context, player, preprocessing, num_threads, p0addr, args);
|
|
|
+ comp_player_main(io_context, player, opts, p0addr, args);
|
|
|
} else {
|
|
|
- server_player_main(io_context, preprocessing, num_threads, p0addr, p1addr, args);
|
|
|
+ server_player_main(io_context, opts, p0addr, p1addr, args);
|
|
|
}
|
|
|
|
|
|
return 0;
|