ソースを参照

Computational peers can report the number of precomputed values they used in the online phase

The format of the output is that of the command line for preprocessing
Ian Goldberg 2 年 前
コミット
37e906047e
2 ファイル変更23 行追加0 行削除
  1. 18 0
      mpcio.hpp
  2. 5 0
      online.cpp

+ 18 - 0
mpcio.hpp

@@ -24,8 +24,12 @@ public:
     PreCompStorage(unsigned player, bool preprocessing,
         const char *filenameprefix, unsigned thread_num);
     void get(T& nextval);
+
+    inline size_t get_stats() { return count; }
+    inline void reset_stats() { count = 0; }
 private:
     std::ifstream storage;
+    size_t count;
 };
 
 template<typename T>
@@ -41,6 +45,7 @@ PreCompStorage<T>::PreCompStorage(unsigned player, bool preprocessing,
         std::cerr << "Failed to open " << filename << "\n";
         exit(1);
     }
+    count = 0;
 }
 
 template<typename T>
@@ -50,6 +55,7 @@ void PreCompStorage<T>::get(T& nextval) {
         std::cerr << "Failed to read precomputed value from storage\n";
         exit(1);
     }
+    ++count;
 }
 
 // A class to wrap a socket to another MPC party.  This wrapping allows
@@ -219,6 +225,18 @@ struct MPCPeerIO : public MPCIO {
             serverios.emplace_back(std::move(sock));
         }
     }
+
+    void dump_precomp_stats(std::ostream &os)
+    {
+        for (size_t i=0; i<triples.size(); ++i) {
+            if (i > 0) {
+                os << " ";
+            }
+            os << "T" << i << " t:" << triples[i].get_stats() <<
+                " h:" << halftriples[i].get_stats();
+        }
+        os << "\n";
+    }
 };
 
 // A class to represent all of the server party's IO, either to

+ 5 - 0
online.cpp

@@ -68,6 +68,11 @@ static void online_test(MPCIO &mpcio, int num_threads, char **args)
         delete[] S;
     }
 
+    if (!is_server) {
+        MPCPeerIO &mpcpio = static_cast<MPCPeerIO &>(mpcio);
+        mpcpio.dump_precomp_stats(std::cout);
+    }
+
     delete[] A;
 }