Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ include_directories(${OPENSSL_INCLUDE_DIR})


add_library(${NAME} SHARED ${sources})
#target_compile_definitions(${NAME} PRIVATE ENABLE_COMM_STATS)

install(DIRECTORY emp-tool DESTINATION include/)
install(DIRECTORY cmake/ DESTINATION cmake/)
Expand Down
28 changes: 23 additions & 5 deletions emp-tool/io/io_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,36 @@
#include "emp-tool/utils/prg.h"
#include "emp-tool/utils/group.h"
#include <memory>
#include <cassert>
#include <cassert>

namespace emp {
template<typename T>
class IOChannel { public:
template<typename T>
class IOChannel {
#ifdef ENABLE_COMM_STATS
enum CommOpType { NONE, SEND, RECV };
#endif // ENABLE_COMM_STATS
public:
uint64_t counter = 0;
#ifdef ENABLE_COMM_STATS
uint64_t comm_rounds = 0;
CommOpType previous_op = NONE;
#endif // ENABLE_COMM_STATS
void send_data(const void * data, size_t nbyte) {
counter +=nbyte;
#ifdef ENABLE_COMM_STATS
if (previous_op == RECV)
comm_rounds++;
previous_op = SEND
#endif // ENABLE_COMM_STATS
derived().send_data_internal(data, nbyte);
}

void recv_data(void * data, size_t nbyte) {
#ifdef ENABLE_COMM_STATS
if (previous_op == SEND)
comm_rounds++;
previous_op = RECV
#endif // ENABLE_COMM_STATS
derived().recv_data_internal(data, nbyte);
}

Expand Down Expand Up @@ -48,7 +66,7 @@ class IOChannel { public:
recv_data(tmp, len);
A[i].from_bin(g, tmp, len);
}
}
}

void send_bool(bool * data, size_t length) {
void * ptr = (void *)data;
Expand Down Expand Up @@ -119,7 +137,7 @@ class IOChannel { public:
#endif
memcpy(data64, &unpack, sizeof(unpack));
data64 += sizeof(unpack);

}
if (8*i != length)
recv_data(data + 8*i, length - 8*i);
Expand Down