replace netmp::count

This commit is contained in:
Andrew Morris
2025-01-29 13:38:03 +11:00
parent be5394b510
commit 6c937c9129
4 changed files with 25 additions and 16 deletions

View File

@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
}
mpc->online(&input, &output);
uint64_t band2 = io.count();
uint64_t band2 = count_multi_io(io);
cout <<"bandwidth\t"<<party<<"\t"<<band2<<endl;
cout <<"ONLINE:\t"<<party<<"\n";

View File

@@ -160,6 +160,19 @@ void check_correctness(int nP, NetIOMP* io, bool * r, int length, int party) {
}
}
uint64_t count_multi_io(IMultiIO& mio) {
uint64_t res = 0;
for (int i = 1; i <= mio.size(); ++i) {
if (i != mio.party()) {
res += *mio.send_channel(i).counter;
res += *mio.recv_channel(i).counter;
}
}
return res;
}
inline const char* hex_char_to_bin(char c) {
switch(toupper(c)) {
case '0': return "0000";

View File

@@ -13,7 +13,7 @@ private:
int nP;
Vec<std::optional<IOChannel>> ios;
Vec<std::optional<IOChannel>> ios2;
int party;
int mParty;
std::shared_ptr<NetIO> make_net_io(const char * address, int port) {
auto io = std::make_shared<NetIO>(address, port);
@@ -28,7 +28,7 @@ public:
nP(nP),
ios(nP+1),
ios2(nP+1),
party(party)
mParty(party)
{
for(int i = 1; i <= nP; ++i)for(int j = 1; j <= nP; ++j)if(i < j){
if(i == party) {
@@ -67,30 +67,25 @@ public:
}
}
int party() {
return mParty;
}
int size() {
return nP;
}
int64_t count() {
int64_t res = 0;
for(int i = 1; i <= nP; ++i) if(i != party){
res += *ios[i]->counter;
res += *ios2[i]->counter;
}
return res;
}
IOChannel& send_channel(int party2) {
assert(party2 != 0);
assert(party2 != party);
assert(party2 != party());
return party < party2 ? *ios[party2] : *ios2[party2];
return party() < party2 ? *ios[party2] : *ios2[party2];
}
IOChannel& recv_channel(int party2) {
assert(party2 != 0);
assert(party2 != party);
assert(party2 != party());
return party2 < party ? *ios[party2] : *ios2[party2];
return party2 < party() ? *ios[party2] : *ios2[party2];
}
};

View File

@@ -5,6 +5,7 @@
struct IMultiIO {
virtual int size() = 0;
virtual int party() = 0;
virtual emp::IOChannel& send_channel(int party2) = 0;
virtual emp::IOChannel& recv_channel(int party2) = 0;
virtual ~IMultiIO() = default;