瀏覽代碼

Adjusting client wait timers to account for time taken by each thread

Sajin Sasy 1 年之前
父節點
當前提交
7b17303223
共有 2 個文件被更改,包括 15 次插入11 次删除
  1. 14 9
      Client/clients.cpp
  2. 1 2
      Client/clients.hpp

+ 14 - 9
Client/clients.cpp

@@ -497,8 +497,12 @@ void generateClients(boost::asio::io_context &io_context,
 
 
 void sendMessageBundles(uint32_t cstart, uint32_t cstop, Client* &clients,
-    Config &config)
+    Config &config, unsigned long &time_diff)
 {
+
+    struct timespec tp;
+    clock_gettime(CLOCK_REALTIME_COARSE, &tp);
+    unsigned long start = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
     uint16_t priv_out = config.m_priv_out;
     uint16_t msg_size = config.msg_size;
     uint32_t pt_bundle_size = ptMsgBundleSize(priv_out, msg_size);
@@ -512,6 +516,10 @@ void sendMessageBundles(uint32_t cstart, uint32_t cstop, Client* &clients,
 
     free(pt_msgbundle);
     free(enc_msgbundle);
+
+    clock_gettime(CLOCK_REALTIME_COARSE, &tp);
+    unsigned long end = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+    time_diff = end - start;
 }
 /*
     Spin config.user_client actual clients. Each client:
@@ -600,25 +608,22 @@ int main(int argc, char **argv)
 
     // Multithreaded client message bundle generation and send
     uint32_t epoch = 0;
-    while(epoch < 1) {
-        struct timespec tp;
-        clock_gettime(CLOCK_REALTIME_COARSE, &tp);
-        unsigned long start = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+    while(epoch < 3) {
+        unsigned long thread_diff[nthreads] = {0};
+        unsigned long diff = 0;
 
         for(int i=0; i<nthreads; i++) {
             uint32_t cstart, cstop;
             cstart = i * clients_per_thread;
             cstop = (i==nthreads-1)? num_clients_total: (i+1) * clients_per_thread;
             threads[i] = std::thread(sendMessageBundles, cstart, cstop,
-                std::ref(clients), std::ref(config));
+                std::ref(clients), std::ref(config), std::ref(thread_diff[i]));
         }
         for(int i=0; i<nthreads; i++) {
             threads[i].join();
+            diff+=thread_diff[i];
         }
 
-        clock_gettime(CLOCK_REALTIME_COARSE, &tp);
-        unsigned long end = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
-        unsigned long diff = end - start;
         // Sleep for the rest of the epoch interval
         printf("Done with submissions for 1 epoch \n");
         if (diff < epoch_interval_us) {

+ 1 - 2
Client/clients.hpp

@@ -36,7 +36,6 @@ typedef uint8_t aes_key[SGX_AESGCM_KEY_SIZE];
 */
 
 
-
 /*
     Structure for capture each individual simulated client's state
 
@@ -82,7 +81,7 @@ public:
         uint16_t stg_id = storage_map[stg_no];
         id = stg_id << DEST_UID_BITS;
         id += (cid/num_storage_nodes);
-        printf("Client sim_id = %d, stg_id = %d, cid = %d\n", sim_id, stg_id, id);
+        //printf("Client sim_id = %d, stg_id = %d, cid = %d\n", sim_id, stg_id, id);
         memcpy(key, ckey, SGX_AESGCM_KEY_SIZE);
     }