typedef struct s_state {
int id;
int namespace_set[NAMESPACE_SIZE];
int neighborhood_set[NEIGHBORHOOD_SIZE];
int routing_table[LEVELS_COUNT][LEVEL_SIZE];
typedef struct s_state {
int id;
int namespace_set[NAMESPACE_SIZE];
int neighborhood_set[NEIGHBORHOOD_SIZE];
int routing_table[LEVELS_COUNT][LEVEL_SIZE];
static int domain(unsigned int a, unsigned int level);
static int shl(int a, int b);
static int closest_in_namespace_set(node_t node, int dest);
static int domain(unsigned int a, unsigned int level);
static int shl(int a, int b);
static int closest_in_namespace_set(node_t node, int dest);
}
static void print_node_neighborood_set(node_t node) {
XBT_INFO(" Neighborhood:");
for (int i=0; i<NEIGHBORHOOD_SIZE; i++)
}
static void print_node_neighborood_set(node_t node) {
XBT_INFO(" Neighborhood:");
for (int i=0; i<NEIGHBORHOOD_SIZE; i++)
}
static void print_node_routing_table(node_t node) {
XBT_INFO(" Routing table:");
for (int i=0; i<LEVELS_COUNT; i++){
for (int j=0; j<LEVEL_SIZE; j++)
}
static void print_node_routing_table(node_t node) {
XBT_INFO(" Routing table:");
for (int i=0; i<LEVELS_COUNT; i++){
for (int j=0; j<LEVEL_SIZE; j++)
}
}
/* Print the node namespace set */
static void print_node_namespace_set(node_t node) {
XBT_INFO(" Namespace:");
for (int i=0; i<NAMESPACE_SIZE; i++)
}
}
/* Print the node namespace set */
static void print_node_namespace_set(node_t node) {
XBT_INFO(" Namespace:");
for (int i=0; i<NAMESPACE_SIZE; i++)
e_task_type_t type = task_data->type;
// If the node is not ready keep the task for later
if (node->ready != 0 && !(type==TASK_JOIN_LAST_REPLY || type==TASK_JOIN_REPLY)) {
e_task_type_t type = task_data->type;
// If the node is not ready keep the task for later
if (node->ready != 0 && !(type==TASK_JOIN_LAST_REPLY || type==TASK_JOIN_REPLY)) {
/* Try to join the ring */
case TASK_JOIN:
next = routing_next(node, task_data->answer_id);
/* Try to join the ring */
case TASK_JOIN:
next = routing_next(node, task_data->answer_id);
type = TASK_JOIN_LAST_REPLY;
req_data = xbt_new0(s_task_data_t,1);
req_data->answer_id = task_data->sender_id;
req_data->steps = task_data->steps + 1;
type = TASK_JOIN_LAST_REPLY;
req_data = xbt_new0(s_task_data_t,1);
req_data->answer_id = task_data->sender_id;
req_data->steps = task_data->steps + 1;
// if next different from current node forward the join
if (next!=node->id) {
get_mailbox(next, mailbox);
// if next different from current node forward the join
if (next!=node->id) {
get_mailbox(next, mailbox);
/* Join reply from all the node touched by the join */
case TASK_JOIN_LAST_REPLY:
// if last node touched reply, copy its namespace set
/* Join reply from all the node touched by the join */
case TASK_JOIN_LAST_REPLY:
// if last node touched reply, copy its namespace set
j = (task_data->sender_id < node->id) ? -1 : 0;
for (i=0; i<NAMESPACE_SIZE/2; i++) {
node->namespace_set[i] = task_data->state->namespace_set[i-j];
j = (task_data->sender_id < node->id) ? -1 : 0;
for (i=0; i<NAMESPACE_SIZE/2; i++) {
node->namespace_set[i] = task_data->state->namespace_set[i-j];
min = (node->id==task_data->answer_id) ? 0 : shl(node->id, task_data->answer_id);
max = shl(node->id, task_data->sender_id)+1;
for (i=min;i<max;i++) {
min = (node->id==task_data->answer_id) ? 0 : shl(node->id, task_data->answer_id);
max = shl(node->id, task_data->sender_id)+1;
for (i=min;i<max;i++) {
node->ready--;
// if the node is ready, do all the pending tasks and send update to known nodes
if (node->ready==0) {
XBT_DEBUG("Node %i is ready!!!", node->id);
node->ready--;
// if the node is ready, do all the pending tasks and send update to known nodes
if (node->ready==0) {
XBT_DEBUG("Node %i is ready!!!", node->id);
print_node_namespace_set(node);
int curr_namespace_set[NAMESPACE_SIZE];
int task_namespace_set[NAMESPACE_SIZE+1];
print_node_namespace_set(node);
int curr_namespace_set[NAMESPACE_SIZE];
int task_namespace_set[NAMESPACE_SIZE+1];
// Copy the current namespace and the task state namespace with state->id in the middle
i=0;
for (; i<NAMESPACE_SIZE/2; i++){
// Copy the current namespace and the task state namespace with state->id in the middle
i=0;
for (; i<NAMESPACE_SIZE/2; i++){
node->namespace_set[i] = curr_namespace_set[j];
j--;
} else if (curr_namespace_set[j] == task_namespace_set[min]) {
node->namespace_set[i] = curr_namespace_set[j];
j--;
min--;
node->namespace_set[i] = curr_namespace_set[j];
j--;
} else if (curr_namespace_set[j] == task_namespace_set[min]) {
node->namespace_set[i] = curr_namespace_set[j];
j--;
min--;
node->namespace_set[i] = task_namespace_set[max];
max++;
} else if (curr_namespace_set[j] == task_namespace_set[max]) {
node->namespace_set[i] = curr_namespace_set[j];
j++;
max++;
node->namespace_set[i] = task_namespace_set[max];
max++;
} else if (curr_namespace_set[j] == task_namespace_set[max]) {
node->namespace_set[i] = curr_namespace_set[j];
j++;
max++;
static int node(int argc, char *argv[])
{
double init_time = MSG_get_clock();
static int node(int argc, char *argv[])
{
double init_time = MSG_get_clock();
node.ready = -1;
node.pending_tasks = xbt_dynar_new(sizeof(msg_task_t), NULL);
get_mailbox(node.id, node.mailbox);
node.ready = -1;
node.pending_tasks = xbt_dynar_new(sizeof(msg_task_t), NULL);
get_mailbox(node.id, node.mailbox);
for (int i=0; i<LEVELS_COUNT; i++){
int d = domain(node.id, i);
for (int i=0; i<LEVELS_COUNT; i++){
int d = domain(node.id, i);