|
@@ -140,47 +140,45 @@ bool route_init()
|
|
|
}
|
|
|
|
|
|
// 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.
|
|
|
+// it will return the number of different sizes it needs to regenerate.
|
|
|
+// 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. If you pass anything else, it will return the number of
|
|
|
+// different sizes it needs at all.
|
|
|
+
|
|
|
+// The list of sizes that need refilling, updated when you pass -1
|
|
|
+static std::vector<uint32_t> used_sizes;
|
|
|
|
|
|
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;
|
|
|
- case 2:
|
|
|
+ if (sizeidx == -1) {
|
|
|
+ used_sizes = sort_get_used();
|
|
|
+ ret = used_sizes.size();
|
|
|
+ } else if (sizeidx >= 0 && sizeidx < used_sizes.size()) {
|
|
|
+ uint32_t size = used_sizes[sizeidx];
|
|
|
#ifdef PROFILE_ROUTING
|
|
|
- {unsigned long start = printf_with_rtclock("begin precompute WaksmanNetwork (%u)\n", route_state.max_stg_msgs);
|
|
|
+ unsigned long start = printf_with_rtclock("begin precompute WaksmanNetwork (%u)\n", size);
|
|
|
#endif
|
|
|
- ret = sort_precompute(route_state.max_stg_msgs);
|
|
|
+ ret = sort_precompute(size);
|
|
|
#ifdef PROFILE_ROUTING
|
|
|
- printf_with_rtclock_diff(start, "end precompute Waksman Network (%u)\n", route_state.max_stg_msgs);}
|
|
|
+ printf_with_rtclock_diff(start, "end precompute Waksman Network (%u)\n", size);
|
|
|
#endif
|
|
|
- break;
|
|
|
- default:
|
|
|
- ret = 3;
|
|
|
- break;
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ uint8_t my_roles = g_teems_config.roles[g_teems_config.my_node_num];
|
|
|
|
|
|
+ if (my_roles & ROLE_INGESTION) {
|
|
|
+ used_sizes.push_back(route_state.tot_msg_per_ing);
|
|
|
+ }
|
|
|
+ if (my_roles & ROLE_ROUTING) {
|
|
|
+ used_sizes.push_back(route_state.max_round2_msgs);
|
|
|
+ }
|
|
|
+ if (my_roles & ROLE_STORAGE) {
|
|
|
+ used_sizes.push_back(route_state.max_stg_msgs);
|
|
|
+ }
|
|
|
+ ret = used_sizes.size();
|
|
|
+ }
|
|
|
return ret;
|
|
|
}
|
|
|
|