|
@@ -17,16 +17,34 @@ bool FOREGROUND_PRECOMPUTE = true;
|
|
|
|
|
|
#define CEILDIV(x,y) (((x)+(y)-1)/(y))
|
|
#define CEILDIV(x,y) (((x)+(y)-1)/(y))
|
|
|
|
|
|
|
|
+// #define DEBUG_PUB_TIMES
|
|
|
|
+
|
|
class Epoch {
|
|
class Epoch {
|
|
NetIO &netio;
|
|
NetIO &netio;
|
|
uint32_t epoch_num;
|
|
uint32_t epoch_num;
|
|
std::mutex m;
|
|
std::mutex m;
|
|
std::condition_variable cv;
|
|
std::condition_variable cv;
|
|
bool epoch_complete;
|
|
bool epoch_complete;
|
|
|
|
+ #ifdef DEBUG_PUB_TIMES
|
|
|
|
+ unsigned long lt = 0;
|
|
|
|
+ #endif
|
|
|
|
|
|
void round_cb(uint32_t round_num) {
|
|
void round_cb(uint32_t round_num) {
|
|
if (round_num) {
|
|
if (round_num) {
|
|
printf("Round %u complete\n", round_num);
|
|
printf("Round %u complete\n", round_num);
|
|
|
|
+
|
|
|
|
+ #ifdef DEBUG_PUB_TIMES
|
|
|
|
+ struct timespec tp;
|
|
|
|
+ clock_gettime(CLOCK_REALTIME_COARSE, &tp);
|
|
|
|
+ unsigned long time = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
|
|
|
|
+ if(lt == 0) {
|
|
|
|
+ printf("Time now = %lu\n", time);
|
|
|
|
+ lt = time;
|
|
|
|
+ } else {
|
|
|
|
+ printf("Time since last round_cb = %lu.%lu\n", (time-lt)/1000000, (time-lt)%1000000);
|
|
|
|
+ }
|
|
|
|
+ #endif
|
|
|
|
+
|
|
boost::asio::post(netio.io_context(), [this]{
|
|
boost::asio::post(netio.io_context(), [this]{
|
|
proceed();
|
|
proceed();
|
|
});
|
|
});
|
|
@@ -37,6 +55,15 @@ class Epoch {
|
|
epoch_complete = true;
|
|
epoch_complete = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ #ifdef DEBUG_PUB_TIMES
|
|
|
|
+ struct timespec tp;
|
|
|
|
+ clock_gettime(CLOCK_REALTIME_COARSE, &tp);
|
|
|
|
+ unsigned long time = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
|
|
|
|
+ printf("Epoch end. Time since last round_cb = %lu.%lu\n", (time-lt)/1000000, (time-lt)%1000000);
|
|
|
|
+ lt = 0;
|
|
|
|
+ #endif
|
|
|
|
+
|
|
const NodeConfig &my_conf = netio.myconfig();
|
|
const NodeConfig &my_conf = netio.myconfig();
|
|
if(my_conf.roles & ROLE_STORAGE) {
|
|
if(my_conf.roles & ROLE_STORAGE) {
|
|
boost::asio::post(netio.io_context(), [this]{
|
|
boost::asio::post(netio.io_context(), [this]{
|
|
@@ -130,12 +157,35 @@ static void epoch(NetIO &netio, char **args) {
|
|
// Launch threads to refill the precomputed Waksman networks we
|
|
// Launch threads to refill the precomputed Waksman networks we
|
|
// used, but just let them run in the background.
|
|
// used, but just let them run in the background.
|
|
size_t num_sizes = ecall_precompute_sort(-1);
|
|
size_t num_sizes = ecall_precompute_sort(-1);
|
|
|
|
+ for (int i=0;i<int(num_sizes);++i) {
|
|
|
|
+ boost::thread t([i] {
|
|
|
|
+ ecall_precompute_sort(i);
|
|
|
|
+ });
|
|
|
|
+ t.detach();
|
|
|
|
+ }
|
|
|
|
+ ++epoch_num;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static unsigned long epoch_clients(NetIO &netio) {
|
|
|
|
+ static uint32_t epoch_num = 1;
|
|
|
|
+ Epoch epoch(netio, epoch_num);
|
|
|
|
+ epoch.proceed();
|
|
|
|
+ epoch.wait();
|
|
|
|
+
|
|
|
|
+ struct timespec tp;
|
|
|
|
+ clock_gettime(CLOCK_REALTIME_COARSE, &tp);
|
|
|
|
+ unsigned long end = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
|
|
|
|
+ printf("Epoch end time = %lu\n", end);
|
|
|
|
+
|
|
|
|
+ // Launch threads to refill the precomputed Waksman networks we used.
|
|
|
|
+ size_t num_sizes = ecall_precompute_sort(-1);
|
|
std::vector<boost::thread> ts;
|
|
std::vector<boost::thread> ts;
|
|
for (int i=0;i<int(num_sizes);++i) {
|
|
for (int i=0;i<int(num_sizes);++i) {
|
|
if(!FOREGROUND_PRECOMPUTE) {
|
|
if(!FOREGROUND_PRECOMPUTE) {
|
|
boost::thread t([i] {
|
|
boost::thread t([i] {
|
|
ecall_precompute_sort(i);
|
|
ecall_precompute_sort(i);
|
|
});
|
|
});
|
|
|
|
+ t.detach();
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
ts.emplace_back([i] {
|
|
ts.emplace_back([i] {
|
|
@@ -149,33 +199,15 @@ static void epoch(NetIO &netio, char **args) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
++epoch_num;
|
|
++epoch_num;
|
|
-}
|
|
|
|
-
|
|
|
|
-static void epoch_clients(NetIO &netio) {
|
|
|
|
- static uint32_t epoch_num = 1;
|
|
|
|
- Epoch epoch(netio, epoch_num);
|
|
|
|
- epoch.proceed();
|
|
|
|
- epoch.wait();
|
|
|
|
- // Launch threads to refill the precomputed Waksman networks we
|
|
|
|
- // used, but just let them run in the background.
|
|
|
|
- size_t num_sizes = ecall_precompute_sort(-1);
|
|
|
|
- for (int i=0;i<int(num_sizes);++i) {
|
|
|
|
- boost::thread t([i] {
|
|
|
|
- ecall_precompute_sort(i);
|
|
|
|
- });
|
|
|
|
- t.detach();
|
|
|
|
- }
|
|
|
|
- ++epoch_num;
|
|
|
|
|
|
+ return end;
|
|
}
|
|
}
|
|
|
|
|
|
static void route_clients_test(NetIO &netio)
|
|
static void route_clients_test(NetIO &netio)
|
|
{
|
|
{
|
|
|
|
|
|
// Default epoch_interval is 5 sec
|
|
// Default epoch_interval is 5 sec
|
|
- size_t epoch_interval = epoch_duration * 1000000;
|
|
|
|
|
|
+ unsigned long epoch_interval = epoch_duration * 1000000;
|
|
printf("Epoch duration = %d\n", epoch_duration);
|
|
printf("Epoch duration = %d\n", epoch_duration);
|
|
- // Sleep one epoch_interval for clients to connect
|
|
|
|
- usleep(epoch_interval);
|
|
|
|
|
|
|
|
// Precompute some WaksmanNetworks
|
|
// Precompute some WaksmanNetworks
|
|
size_t num_sizes = ecall_precompute_sort(-2);
|
|
size_t num_sizes = ecall_precompute_sort(-2);
|
|
@@ -198,25 +230,32 @@ static void route_clients_test(NetIO &netio)
|
|
t.join();
|
|
t.join();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Sleep one epoch_interval for clients to connect
|
|
|
|
+ usleep((useconds_t) epoch_interval);
|
|
|
|
+
|
|
// Run epoch
|
|
// Run epoch
|
|
for (int i=1; i<=num_epochs; ++i) {
|
|
for (int i=1; i<=num_epochs; ++i) {
|
|
struct timespec tp;
|
|
struct timespec tp;
|
|
clock_gettime(CLOCK_REALTIME_COARSE, &tp);
|
|
clock_gettime(CLOCK_REALTIME_COARSE, &tp);
|
|
unsigned long start = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
|
|
unsigned long start = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
|
|
|
|
+ printf("Epoch start time = %lu\n", start);
|
|
|
|
|
|
- epoch_clients(netio);
|
|
|
|
|
|
+ unsigned long end = epoch_clients(netio);
|
|
|
|
|
|
clock_gettime(CLOCK_REALTIME_COARSE, &tp);
|
|
clock_gettime(CLOCK_REALTIME_COARSE, &tp);
|
|
- unsigned long end = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
|
|
|
|
- unsigned long diff = end - start;
|
|
|
|
|
|
+ //unsigned long end_post_pc = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
|
|
|
|
+ //unsigned long diff_post_pc = end_post_pc - start;
|
|
|
|
+ //printf("Epoch end_post_pc time = %lu\n", end_post_pc);
|
|
|
|
+ //printf("Epoch diff_post_pc time = %lu\n", diff_post_pc);
|
|
|
|
|
|
|
|
+ unsigned long diff = end - start;
|
|
printf("client_count = %ld\n", client_count);
|
|
printf("client_count = %ld\n", client_count);
|
|
printf("bytes_sent = %ld\n", netio.reset_bytes_sent());
|
|
printf("bytes_sent = %ld\n", netio.reset_bytes_sent());
|
|
printf("Epoch %d time: %lu.%06lu s\n", i, diff/1000000, diff%1000000);
|
|
printf("Epoch %d time: %lu.%06lu s\n", i, diff/1000000, diff%1000000);
|
|
|
|
|
|
// Sleep for the rest of the epoch interval
|
|
// Sleep for the rest of the epoch interval
|
|
if (diff < epoch_interval) {
|
|
if (diff < epoch_interval) {
|
|
- usleep(epoch_interval - (useconds_t) diff);
|
|
|
|
|
|
+ usleep((useconds_t) epoch_interval - (useconds_t) diff);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|