|
@@ -61,44 +61,47 @@ static void epoch(NetIO &netio, char **args) {
|
|
|
const Config &config = netio.config();
|
|
|
uint16_t msg_size = config.msg_size;
|
|
|
nodenum_t my_node_num = config.my_node_num;
|
|
|
-
|
|
|
- uint8_t *msgs = new uint8_t[tot_tokens * msg_size];
|
|
|
- uint8_t *nextmsg = msgs;
|
|
|
- uint32_t dest_uid_mask = (1 << DEST_UID_BITS) - 1;
|
|
|
- uint32_t rem_tokens = tot_tokens;
|
|
|
- while (rem_tokens > 0) {
|
|
|
- // Pick a random remaining token
|
|
|
- uint32_t r = uint32_t(lrand48()) % rem_tokens;
|
|
|
- for (nodenum_t j=0;j<num_nodes;++j) {
|
|
|
- if (r < num_tokens[j]) {
|
|
|
- // Use a token from node j
|
|
|
- *((uint32_t*)nextmsg) =
|
|
|
- (j << DEST_UID_BITS) +
|
|
|
- (((r<<8)+(my_node_num&0xff)) & dest_uid_mask);
|
|
|
- // Put a bunch of copies of r as the message body
|
|
|
- for (uint16_t i=1;i<msg_size/4;++i) {
|
|
|
- ((uint32_t*)nextmsg)[i] = r;
|
|
|
+ uint8_t my_roles = config.nodes[my_node_num].roles;
|
|
|
+
|
|
|
+ if (my_roles & ROLE_INGESTION) {
|
|
|
+ uint8_t *msgs = new uint8_t[tot_tokens * msg_size];
|
|
|
+ uint8_t *nextmsg = msgs;
|
|
|
+ uint32_t dest_uid_mask = (1 << DEST_UID_BITS) - 1;
|
|
|
+ uint32_t rem_tokens = tot_tokens;
|
|
|
+ while (rem_tokens > 0) {
|
|
|
+ // Pick a random remaining token
|
|
|
+ uint32_t r = uint32_t(lrand48()) % rem_tokens;
|
|
|
+ for (nodenum_t j=0;j<num_nodes;++j) {
|
|
|
+ if (r < num_tokens[j]) {
|
|
|
+ // Use a token from node j
|
|
|
+ *((uint32_t*)nextmsg) =
|
|
|
+ (j << DEST_UID_BITS) +
|
|
|
+ (((r<<8)+(my_node_num&0xff)) & dest_uid_mask);
|
|
|
+ // Put a bunch of copies of r as the message body
|
|
|
+ for (uint16_t i=1;i<msg_size/4;++i) {
|
|
|
+ ((uint32_t*)nextmsg)[i] = r;
|
|
|
+ }
|
|
|
+ num_tokens[j] -= 1;
|
|
|
+ rem_tokens -= 1;
|
|
|
+ nextmsg += msg_size;
|
|
|
+ } else {
|
|
|
+ r -= num_tokens[j];
|
|
|
}
|
|
|
- num_tokens[j] -= 1;
|
|
|
- rem_tokens -= 1;
|
|
|
- nextmsg += msg_size;
|
|
|
- } else {
|
|
|
- r -= num_tokens[j];
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- /*
|
|
|
- for (uint32_t i=0;i<tot_tokens;++i) {
|
|
|
- for(uint16_t j=0;j<msg_size/4;++j) {
|
|
|
- printf("%08x ", ((uint32_t*)msgs)[i*msg_size/4+j]);
|
|
|
+ /*
|
|
|
+ for (uint32_t i=0;i<tot_tokens;++i) {
|
|
|
+ for(uint16_t j=0;j<msg_size/4;++j) {
|
|
|
+ printf("%08x ", ((uint32_t*)msgs)[i*msg_size/4+j]);
|
|
|
+ }
|
|
|
+ printf("\n");
|
|
|
}
|
|
|
- printf("\n");
|
|
|
- }
|
|
|
- */
|
|
|
+ */
|
|
|
|
|
|
- if (!ecall_ingest_raw(msgs, tot_tokens)) {
|
|
|
- printf("Ingestion failed\n");
|
|
|
- return;
|
|
|
+ if (!ecall_ingest_raw(msgs, tot_tokens)) {
|
|
|
+ printf("Ingestion failed\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Epoch epoch(netio.io_context(), epoch_num);
|