|
@@ -2,8 +2,11 @@
|
|
|
#include "Enclave_t.h"
|
|
|
#include "config.hpp"
|
|
|
#include "utils.hpp"
|
|
|
+#include "sort.hpp"
|
|
|
#include "route.hpp"
|
|
|
|
|
|
+#define PROFILE_ROUTING
|
|
|
+
|
|
|
struct MsgBuffer {
|
|
|
pthread_mutex_t mutex;
|
|
|
uint8_t *buf;
|
|
@@ -13,7 +16,9 @@ struct MsgBuffer {
|
|
|
// The number of messages definitely in the buffer
|
|
|
uint32_t inserted;
|
|
|
|
|
|
- MsgBuffer() : buf(NULL), reserved(0), inserted(0) {}
|
|
|
+ MsgBuffer() : buf(NULL), reserved(0), inserted(0) {
|
|
|
+ pthread_mutex_init(&mutex, NULL);
|
|
|
+ }
|
|
|
|
|
|
~MsgBuffer() {
|
|
|
delete[] buf;
|
|
@@ -132,9 +137,54 @@ bool route_init()
|
|
|
route_state.max_msg_to_each_str = max_msg_to_each_str;
|
|
|
route_state.max_round2_msgs = max_round2_msgs;
|
|
|
|
|
|
+ threadid_t nthreads = g_teems_config.nthreads;
|
|
|
+#ifdef PROFILE_ROUTING
|
|
|
+ unsigned long start = printf_with_rtclock("begin precompute evalplans (%u,%hu) (%u,%hu)\n", tot_msg_per_ing, nthreads, max_round2_msgs, nthreads);
|
|
|
+#endif
|
|
|
+ sort_precompute_evalplan(tot_msg_per_ing, nthreads);
|
|
|
+ sort_precompute_evalplan(max_round2_msgs, nthreads);
|
|
|
+#ifdef PROFILE_ROUTING
|
|
|
+ printf_with_rtclock_diff(start, "end precompute evalplans\n");
|
|
|
+#endif
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+// Precompute the WaksmanNetworks needed for the sorts. If you pass -1,
|
|
|
+// it will return the number of different sizes it needs. If you pass
|
|
|
+// [0,sizes-1], it will compute one WaksmanNetwork with that size index
|
|
|
+// and return the number of available WaksmanNetworks of that size.
|
|
|
+
|
|
|
+size_t ecall_precompute_sort(int sizeidx)
|
|
|
+{
|
|
|
+ size_t ret = 0;
|
|
|
+
|
|
|
+ switch(sizeidx) {
|
|
|
+ case 0:
|
|
|
+#ifdef PROFILE_ROUTING
|
|
|
+ {unsigned long start = printf_with_rtclock("begin precompute WaksmanNetwork (%u)\n", route_state.tot_msg_per_ing);
|
|
|
+#endif
|
|
|
+ ret = sort_precompute(route_state.tot_msg_per_ing);
|
|
|
+#ifdef PROFILE_ROUTING
|
|
|
+ printf_with_rtclock_diff(start, "end precompute Waksman Network (%u)\n", route_state.tot_msg_per_ing);}
|
|
|
+#endif
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+#ifdef PROFILE_ROUTING
|
|
|
+ {unsigned long start = printf_with_rtclock("begin precompute WaksmanNetwork (%u)\n", route_state.max_round2_msgs);
|
|
|
+#endif
|
|
|
+ ret = sort_precompute(route_state.max_round2_msgs);
|
|
|
+#ifdef PROFILE_ROUTING
|
|
|
+ printf_with_rtclock_diff(start, "end precompute Waksman Network (%u)\n", route_state.max_round2_msgs);}
|
|
|
+#endif
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ ret = 2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
// Directly ingest a buffer of num_msgs messages into the round1 buffer.
|
|
|
// Return true on success, false on failure.
|
|
|
bool ecall_ingest_raw(uint8_t *msgs, uint32_t num_msgs)
|