/* Used to implement irecv+wait */
xbt_dynar_t irecvs; /* of msg_comm_t */
xbt_dynar_t tasks; /* of msg_task_t */
-} s_process_globals_t, *process_globals_t;
+} s_process_globals_t;
+
+typedef s_process_globals_t *process_globals_t;
/* Helper function */
static double parse_double(const char *string)
ACT_DEBUG("Entering barrier: %s (%d already there)", NAME, processes_arrived_sofar);
simcall_mutex_lock(mutex);
- if (++processes_arrived_sofar == communicator_size) {
+ processes_arrived_sofar++;
+ if (processes_arrived_sofar == communicator_size) {
simcall_cond_broadcast(cond);
simcall_mutex_unlock(mutex);
} else {
const char * process_name = MSG_process_get_name(MSG_process_self());
- char *bcast_identifier = bprintf("bcast_%d", counters->bcast_counter++);
+ char *bcast_identifier = bprintf("bcast_%d", counters->bcast_counter);
+ counters->bcast_counter++;
if (!strcmp(process_name, "p0")) {
XBT_DEBUG("%s: %s is the Root", bcast_identifier, process_name);
unsigned int interested:1; //Indicates if the peer is interested in one of our pieces
unsigned int choked_upload:1; //Indicates if the peer is choked for the current peer
unsigned int choked_download:1; //Indicates if the peer has choked the current peer
-} s_connection_t, *connection_t;
+} s_connection_t;
+
+typedef s_connection_t *connection_t;
/** @brief Build a new connection object from the peer id.
* @param id id of the peer
xbt_dynar_iterator_t it;
int max_pending_sends;
xbt_dynar_t pending_sends;
-} s_broadcaster_t, *broadcaster_t;
+} s_broadcaster_t;
+
+typedef s_broadcaster_t *broadcaster_t;
xbt_dynar_t build_hostlist_from_hostcount(int hostcount);
const char *data_block;
unsigned int data_length;
unsigned int num_pieces;
-} s_message_t, *message_t;
+} s_message_t;
+
+typedef s_message_t *message_t;
/* Message methods */
msg_task_t task_message_new(e_message_type type, unsigned int len);
xbt_dynar_t pending_recvs;
xbt_dynar_t pending_sends;
unsigned int total_pieces;
-} s_peer_t, *peer_t;
+} s_peer_t;
+typedef s_peer_t *peer_t;
/* Peer: helper functions */
msg_error_t peer_wait_for_message(peer_t peer);
#define MAILBOX_NAME_SIZE 10
#define NEIGHBOURS_COUNT GRID_SIZE - 1
-/*
- * The job sent to every node
- */
+/* The job sent to every node */
typedef struct s_node_job{
int row;
int col;
int nodes_in_col[NEIGHBOURS_COUNT];
xbt_matrix_t A;
xbt_matrix_t B;
-} s_node_job_t, *node_job_t;
+} s_node_job_t;
-/*
- * Structure for recovering results
- */
+typedef s_node_job_t *node_job_t;
+
+/* Structure for recovering results */
typedef struct s_result {
int row;
int col;
xbt_matrix_t sC;
-} s_result_t, *result_t;
+} s_result_t;
+
+typedef s_result_t *result_t;
int node(int argc, char **argv);
static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs);
int node(int argc, char **argv)
{
char my_mbox[MAILBOX_NAME_SIZE];
- node_job_t myjob, jobs[GRID_NUM_NODES];
+ node_job_t myjob;
+ node_job_t jobs[GRID_NUM_NODES];
xbt_matrix_t A = NULL;
xbt_matrix_t B = NULL;
xbt_matrix_t C = NULL;
jobs[node]->row = row;
jobs[node]->col = col;
- /* Compute who are the nodes in the same row and column */
- /* than the node receiving this job */
- for (int j = 0, k = 0; j < GRID_SIZE; j++) {
+ /* Compute who are the nodes in the same row and column than the node receiving this job */
+ int k=0;
+ for (int j = 0; j < GRID_SIZE; j++) {
if (node != (GRID_SIZE * row) + j) {
jobs[node]->nodes_in_row[k] = (GRID_SIZE * row) + j;
k++;
}
}
- for (int j = 0, k = 0; j < GRID_SIZE; j++) {
+ k=0;
+ for (int j = 0; j < GRID_SIZE; j++) {
if (node != (GRID_SIZE * j) + col) {
jobs[node]->nodes_in_col[k] = (GRID_SIZE * j) + col;
k++;
jobs[node]->B =
xbt_matrix_new_sub(B, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE * row, NODE_MATRIX_SIZE * col, NULL);
- if (++col >= GRID_SIZE){
+ col++;
+ if (col >= GRID_SIZE){
col = 0;
row++;
}
msg_host_t pm0 = MSG_host_by_name("Fafard");
msg_host_t pm1 = MSG_host_by_name("Tremblay");
msg_host_t pm2 = MSG_host_by_name("Bourassa");
- msg_vm_t vm0, vm1;
s_vm_params_t params;
memset(¶ms, 0, sizeof(params));
- vm0 = MSG_vm_create_core(pm0, "VM0");
+ msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
MSG_vm_set_params(vm0, ¶ms);
MSG_vm_start(vm0);
MSG_vm_destroy(vm0);
vm0 = MSG_vm_create_core(pm0, "VM0");
- vm1 = MSG_vm_create_core(pm0, "VM1");
+ msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
MSG_vm_set_params(vm0, ¶ms);
{
const char *pr_name = MSG_process_get_name(MSG_process_self());
const char *host_name = MSG_host_get_name(MSG_host_self());
- double clock_sta, clock_end;
atask = MSG_task_create("Task1", 1e9, 1e9, NULL);
- clock_sta = MSG_get_clock();
+ double clock_sta = MSG_get_clock();
XBT_INFO("%s:%s task 1 created %g", host_name, pr_name, clock_sta);
MSG_task_execute(atask);
- clock_end = MSG_get_clock();
+ double clock_end = MSG_get_clock();
XBT_INFO("%s:%s task 1 executed %g", host_name, pr_name, clock_end - clock_sta);
{
xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
msg_host_t pm0 = MSG_host_by_name("Fafard");
- msg_vm_t vm0;
- vm0 = MSG_vm_create_core(pm0, "VM0");
+ msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
MSG_vm_start(vm0);
- //MSG_process_sleep(1);
launch_computation_worker(vm0);
unsigned int destination_id;
xbt_dynar_t nodes; //Dynar of node_contact_t
unsigned int size;
-} s_answer_t, *answer_t;
+} s_answer_t;
+
+typedef s_answer_t *answer_t;
#include "node.h"
answer_t node_list;
msg_error_t status;
unsigned int trial = 0;
- unsigned int i, answer_got = 0;
+ unsigned int i;
+ unsigned int answer_got = 0;
/* Add the guy we know to our routing table and ourselves. */
node_routing_table_update(node, node->id);
unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_in_stats)
{
unsigned int i = 0;
- unsigned int queries, answers;
+ unsigned int queries;
+ unsigned int answers;
unsigned int destination_found = 0;
unsigned int nodes_added = 0;
double time_beginreceive;
- double timeout, global_timeout = MSG_get_clock() + find_node_global_timeout;
+ double timeout;
+ double global_timeout = MSG_get_clock() + find_node_global_timeout;
unsigned int steps = 0;
xbt_assert((id_to_find >= 0), "Id supplied incorrect");
*/
unsigned int send_find_node_to_best(node_t node, answer_t node_list)
{
- unsigned int i = 0, j = 0;
+ unsigned int i = 0;
+ unsigned int j = 0;
unsigned int destination = node_list->destination_id;
node_contact_t node_to_query;
while (j < kademlia_alpha && i < node_list->size) {
*/
unsigned int get_node_prefix(unsigned int id, unsigned int nb_bits)
{
- unsigned int j, size = sizeof(unsigned int) * 8;
- for (j = 0; j < size; j++) {
+ unsigned int size = sizeof(unsigned int) * 8;
+ for (unsigned int j = 0; j < size; j++) {
if (((id >> (size - 1 - j)) & 0x1) != 0) {
return nb_bits - (j);
}
typedef struct s_node_contact {
unsigned int id; //The node identifier
unsigned int distance; //The distance from the node
-} s_node_contact_t, *node_contact_t;
+} s_node_contact_t;
+
+typedef s_node_contact_t *node_contact_t;
/* Node data */
typedef struct s_node {
unsigned int find_node_success; //Number of find_node which have succeeded.
unsigned int find_node_failed; //Number of find_node which have failed.
-} s_node_t, *node_t;
+} s_node_t;
+
+typedef s_node_t *node_t;
// node functions
node_t node_init(unsigned int id);
/** @brief Initialization of a node routing table. */
routing_table_t routing_table_init(unsigned int node_id)
{
- unsigned int i;
routing_table_t table = xbt_new(s_routing_table_t, 1);
table->buckets = xbt_new(s_bucket_t, identifier_size + 1);
- for (i = 0; i < identifier_size + 1; i++) {
+ for (unsigned int i = 0; i < identifier_size + 1; i++) {
table->buckets[i].nodes = xbt_dynar_new(sizeof(unsigned int), NULL);
table->buckets[i].id = i;
}
/**@brief prints the routing table, to debug stuff. */
void routing_table_print(routing_table_t table)
{
- unsigned int i, j, value;
+ unsigned int j;
+ unsigned int value;
XBT_INFO("Routing table of %08x:", table->id);
- for (i = 0; i <= identifier_size; i++) {
+ for (unsigned int i = 0; i <= identifier_size; i++) {
if (!xbt_dynar_is_empty(table->buckets[i].nodes)) {
XBT_INFO("Bucket number %d: ", i);
xbt_dynar_foreach(table->buckets[i].nodes, j, value) {
*/
unsigned int bucket_find_id(bucket_t bucket, unsigned int id)
{
- unsigned int i, current_id;
+ unsigned int i;
+ unsigned int current_id;
xbt_dynar_foreach(bucket->nodes, i, current_id){
if (id == current_id){
return i;
typedef struct s_bucket {
xbt_dynar_t nodes; //Nodes in the bucket.
unsigned int id; //bucket id
-} s_bucket_t, *bucket_t;
+} s_bucket_t;
+
+typedef s_bucket_t *bucket_t;
/* Node routing table */
typedef struct s_routing_table {
unsigned int id; //node id of the client's routing table
s_bucket_t *buckets; //Node bucket list - 160 sized.
-} s_routing_table_t, *routing_table_t;
+} s_routing_table_t;
+
+typedef s_routing_table_t *routing_table_t;
// bucket functions
unsigned int bucket_find_id(bucket_t bucket, unsigned int id);
answer_t answer; //Answer to the request made, if needed.
char *answer_to; // mailbox to send the answer to (if not an answer).
const char *issuer_host_name; // used for logging
-} s_task_data_t, *task_data_t;
+} s_task_data_t;
+
+typedef s_task_data_t *task_data_t;
//Task handling functions
msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_id, char *mailbox, const char *hostname);