From f4dacdef620e6ea0930f7e8145747128b5f10c33 Mon Sep 17 00:00:00 2001 From: Kalyan Cheerla <32354220+kalyancheerla@users.noreply.github.com> Date: Mon, 14 Apr 2025 12:56:24 -0500 Subject: [PATCH 1/2] added ENABLE_COMM_STATS logic to track communication rounds --- CMakeLists.txt | 1 + emp-tool/io/io_channel.h | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9abb31..e1b2b69 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/) diff --git a/emp-tool/io/io_channel.h b/emp-tool/io/io_channel.h index 66d7750..e6a4c08 100644 --- a/emp-tool/io/io_channel.h +++ b/emp-tool/io/io_channel.h @@ -4,18 +4,36 @@ #include "emp-tool/utils/prg.h" #include "emp-tool/utils/group.h" #include -#include +#include namespace emp { -template +template class IOChannel { public: +#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); } @@ -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; @@ -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); From c783e8bf4abd842c4897f92a7afde2c7fd8b6250 Mon Sep 17 00:00:00 2001 From: Kalyan Cheerla <32354220+kalyancheerla@users.noreply.github.com> Date: Mon, 14 Apr 2025 13:33:17 -0500 Subject: [PATCH 2/2] removed double public --- emp-tool/io/io_channel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emp-tool/io/io_channel.h b/emp-tool/io/io_channel.h index e6a4c08..fcda1ce 100644 --- a/emp-tool/io/io_channel.h +++ b/emp-tool/io/io_channel.h @@ -8,7 +8,7 @@ namespace emp { template -class IOChannel { public: +class IOChannel { #ifdef ENABLE_COMM_STATS enum CommOpType { NONE, SEND, RECV }; #endif // ENABLE_COMM_STATS