From 705485394e47913f9196fb381b9fe34df7e86aa7 Mon Sep 17 00:00:00 2001 From: Martin Kromm Date: Thu, 2 May 2019 13:59:49 +0200 Subject: [PATCH] Fixed a bug which caused the communication and performance evaluation to be evaluated into the false category or not to be evaluated at all. --- src/abycore/aby/abyparty.cpp | 13 ++++++++----- src/abycore/aby/abyparty.h | 2 +- src/abycore/aby/abysetup.cpp | 2 +- src/abycore/aby/abysetup.h | 7 +++++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/abycore/aby/abyparty.cpp b/src/abycore/aby/abyparty.cpp index 5d2600f6..112549ab 100644 --- a/src/abycore/aby/abyparty.cpp +++ b/src/abycore/aby/abyparty.cpp @@ -51,6 +51,9 @@ class ABYParty::CPartyWorkerThread: public CThread { m_evt.Set(); } + CEvent* GetEvent() { + return &m_evt; + } private: void ThreadMain(); uint32_t threadid; @@ -211,7 +214,7 @@ void ABYParty::ExecCircuit() { std::cout << "Performing setup phase for " << m_vSharings[i]->sharing_type() << " sharing" << std::endl; #endif if(i == S_YAO) { - StartWatch("Starting Circuit Garbling", P_GARBLE); + StartRecording("Starting Circuit Garbling", P_GARBLE, m_vSockets); if(m_eRole == SERVER) { m_vSharings[S_YAO]->PerformSetupPhase(m_pSetup.get()); m_vSharings[S_YAO_REV]->PerformSetupPhase(m_pSetup.get()); @@ -223,7 +226,7 @@ void ABYParty::ExecCircuit() { m_vSharings[S_YAO_REV]->PerformSetupPhase(m_pSetup.get());*/ m_vSharings[S_YAO]->FinishSetupPhase(m_pSetup.get()); m_vSharings[S_YAO_REV]->FinishSetupPhase(m_pSetup.get()); - StopWatch("Time for Circuit garbling: ", P_GARBLE); + StopRecording("Time for Circuit garbling: ", P_GARBLE, m_vSockets); } else if (i == S_YAO_REV) { //Do nothing, was done in parallel to Yao } else { @@ -409,7 +412,7 @@ BOOL ABYParty::PerformInteraction() { return success; } -BOOL ABYParty::ThreadSendValues() { +BOOL ABYParty::ThreadSendValues(uint32_t id) { std::vector >sendbuf(m_vSharings.size()); std::vector >sndbytes(m_vSharings.size()); @@ -440,7 +443,7 @@ BOOL ABYParty::ThreadSendValues() { //gettimeofday(&tstart, NULL); if(snd_buf_size_total > 0) { //m_vSockets[2]->Send(snd_buf_total, snd_buf_size_total); - m_tPartyChan->send(snd_buf_total, snd_buf_size_total); + m_tPartyChan->blocking_send(m_vThreads[id]->GetEvent(), snd_buf_total, snd_buf_size_total); } free(snd_buf_total); @@ -697,7 +700,7 @@ void ABYParty::CPartyWorkerThread::ThreadMain() { return; case e_Party_Comm: if (threadid == 0){ - bSuccess = m_pCallback->ThreadSendValues(); + bSuccess = m_pCallback->ThreadSendValues(threadid); } else{ bSuccess = m_pCallback->ThreadReceiveValues(); diff --git a/src/abycore/aby/abyparty.h b/src/abycore/aby/abyparty.h index 9017d0ed..7f9f711a 100644 --- a/src/abycore/aby/abyparty.h +++ b/src/abycore/aby/abyparty.h @@ -83,7 +83,7 @@ class ABYParty { void UsedGate(uint32_t gateid); BOOL PerformInteraction(); - BOOL ThreadSendValues(); + BOOL ThreadSendValues(uint32_t id); BOOL ThreadReceiveValues(); void PrintPerformanceStatistics(); diff --git a/src/abycore/aby/abysetup.cpp b/src/abycore/aby/abysetup.cpp index bd9779ea..a66a9bf4 100644 --- a/src/abycore/aby/abysetup.cpp +++ b/src/abycore/aby/abysetup.cpp @@ -485,7 +485,7 @@ void ABYSetup::AddReceiveTask(BYTE* rcvbuf, uint64_t rcvbytes) { } BOOL ABYSetup::ThreadSendData(uint32_t threadid) { - m_tSetupChan->send(m_tsndtask.sndbuf, m_tsndtask.sndbytes); + m_tSetupChan->blocking_send(m_vThreads[threadid]->GetEvent(), m_tsndtask.sndbuf, m_tsndtask.sndbytes); return true; } diff --git a/src/abycore/aby/abysetup.h b/src/abycore/aby/abysetup.h index bfd13544..bdafab47 100644 --- a/src/abycore/aby/abysetup.h +++ b/src/abycore/aby/abysetup.h @@ -161,8 +161,8 @@ class ABYSetup { BOOL ThreadRunKKSnd(uint32_t exec); BOOL ThreadRunKKRcv(uint32_t exec); - BOOL ThreadSendData(uint32_t exec); - BOOL ThreadReceiveData(uint32_t exec); + BOOL ThreadSendData(uint32_t id); + BOOL ThreadReceiveData(uint32_t id); BOOL ThreadRunPaillierMTGen(uint32_t exec); BOOL ThreadRunDGKMTGen(uint32_t threadid); @@ -220,6 +220,9 @@ class ABYSetup { m_eJob = e; m_evt.Set(); } + CEvent* GetEvent() { + return &m_evt; + } private: void ThreadMain(); uint32_t threadid;