Prechádzať zdrojové kódy

change outputformat

avadapal 1 rok pred
rodič
commit
df4457b1c7
1 zmenil súbory, kde vykonal 13 pridanie a 7 odobranie
  1. 13 7
      2p-preprocessing/preprocessing.cpp

+ 13 - 7
2p-preprocessing/preprocessing.cpp

@@ -14,6 +14,9 @@
 #include <bsd/stdlib.h> // arc4random_buf
 #include <x86intrin.h>	// SSE and AVX intrinsics
 #include <boost/asio/thread_pool.hpp>
+
+size_t communication_cost = 0;
+
 #include "bitutils.h"
 #include "block.h"
 #include "prg.h"
@@ -153,8 +156,9 @@ void compute_CW(bool party, tcp::socket &sout, __m128i L, __m128i R, uint8_t bit
 
 	boost::asio::write(sout, boost::asio::buffer(&blinds_sent, sizeof(blinds_sent)));
 	boost::asio::read(sout, boost::asio::buffer(&blinds_recv, sizeof(blinds_recv)));
-
-	blinded_bit_read = blinds_recv.blinded_bit;
+ communication_cost += sizeof(blinds_recv);
+	
+ blinded_bit_read = blinds_recv.blinded_bit;
 	blinded_L_read = blinds_recv.blinded_message;
 
 	__m128i out_ = R ^ gamma_b; //_mm_setzero_si128;
@@ -171,7 +175,9 @@ void compute_CW(bool party, tcp::socket &sout, __m128i L, __m128i R, uint8_t bit
 	__m128i out_reconstruction;
 	boost::asio::write(sout, boost::asio::buffer(&out_, sizeof(out_)));
 	boost::asio::read(sout, boost::asio::buffer(&out_reconstruction, sizeof(out_reconstruction)));
-	out_reconstruction = out_ ^ out_reconstruction;
+ communication_cost += sizeof(out_reconstruction);
+	
+ out_reconstruction = out_ ^ out_reconstruction;
 
 	CW = out_reconstruction;
 
@@ -336,7 +342,7 @@ inline void evalfull_mpc(const size_t &nodes_per_leaf, const size_t &depth, cons
 
 	boost::asio::write(socketsPb[socket_no + 3], boost::asio::buffer(&Gamma, sizeof(Gamma)));
 	boost::asio::read(socketsPb[socket_no + 3], boost::asio::buffer(&final_correction_word, sizeof(final_correction_word)));
-
+ communication_cost += sizeof(Gamma);
 	final_correction_word = Gamma; // final_correction_word + Gamma;
 
 } // dpf::__evalinterval
@@ -519,9 +525,9 @@ bool party;
 	convert_shares(output, flags, n_threads, db_nitems, final_correction_word, socketsPb[0], party);
 	auto end = std::chrono::steady_clock::now();
 	std::chrono::duration<double> elapsed_seconds = end - start;
-	std::cout << "time to generate and evaluate " << n_threads << " dpfs of size 2^" << expo << " is: " << elapsed_seconds.count() << "s" << std::endl<< std::endl;
-
- std::cout << "done with preproecessing" << std::endl;
+	std::cout << "WallClockTime: " << elapsed_seconds.count() << "s" << std::endl<< std::endl;
+ std::cout << "CommunicationCost: " << communication_cost/1024 << " KiB" << std::endl;
+ 
 
 	if(!party)
 	{