int min;
int max;
int d;
+ int next;
msg_task_t task_sent;
task_data_t req_data;
task_data_t task_data = (task_data_t) MSG_task_get_data(task);
}
switch (type) {
/* Try to join the ring */
- case TASK_JOIN: {
- int next = routing_next(node, task_data->answer_id);
+ case TASK_JOIN:
+ next = routing_next(node, task_data->answer_id);
XBT_DEBUG("Join request from %08x forwarding to %08x", task_data->answer_id, next);
type = TASK_JOIN_LAST_REPLY;
task_free(task_sent);
}
break;
- }
/* Join reply from all the node touched by the join */
case TASK_JOIN_LAST_REPLY:
// if last node touched reply, copy its namespace set
- // TODO: it's work only if the two nodes are side to side (is it really the case ?)
+ // TODO: it works only if the two nodes are side to side (is it really the case ?)
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];
sg_size_t write = MSG_file_write(file, MSG_file_get_size(file)*1024);
XBT_INFO("Have written %llu bytes to '%s'.",write,filename);
- msg_host_t src, dest;
- src= MSG_host_self();
- dest = MSG_host_by_name(argv[3]);
+ msg_host_t src= MSG_host_self();
+ msg_host_t dest = MSG_host_by_name(argv[3]);
if (xbt_str_parse_int(argv[5], "Argument 5 (move or copy) must be an int, not '%s'")) {
XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename,MSG_file_get_size(file), MSG_host_get_name(src),
argv[3]);
/* - Create a 200,000 bytes file named './tmp/data.txt' on /sd1 */
char* file_name = xbt_strdup("/home/tmp/data.txt");
- msg_file_t file = NULL;
- sg_size_t write, read, file_size;
/* - Open an non-existing file which amounts to create it. */
- file = MSG_file_open(file_name, NULL);
- write = MSG_file_write(file, 200000); // Write 200,000 bytes
+ msg_file_t file = MSG_file_open(file_name, NULL);
+ sg_size_t write = MSG_file_write(file, 200000); // Write 200,000 bytes
XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, file_name);
MSG_file_dump(file);
XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage));
/* - Retrieve the size of created file and read it completely */
- file_size = MSG_file_get_size(file);
+ sg_size_t file_size = MSG_file_get_size(file);
MSG_file_seek(file, 0, SEEK_SET);
- read = MSG_file_read(file, file_size);
+ sg_size_t read = MSG_file_read(file, file_size);
XBT_INFO("Read %llu bytes on %s", read, file_name);
/* - Then write 100,000 bytes in tmp/data.txt */
XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self()));
xbt_dict_t contents = NULL;
contents = MSG_host_get_storage_content(MSG_host_self()); // contents is a dict of dicts
- xbt_dict_cursor_t curs, curs2 = NULL;
+ xbt_dict_cursor_t curs;
+ xbt_dict_cursor_t curs2 = NULL;
char* mountname;
xbt_dict_t content;
char* path;
xbt_dict_foreach(content,curs2,path,size){
XBT_INFO("%s size: %llu bytes", path,*((sg_size_t*)size));
}
- xbt_dict_free(&content);
+ xbt_dict_free(&content);
}
xbt_dict_free(&contents);
return 1;
msg_host_t thehost = MSG_host_by_name(hostname);
xbt_dict_t props = MSG_host_get_properties(thehost);
xbt_dict_cursor_t cursor = NULL;
- char *key, *data;
+ char *key;
+ char *data;
const char *noexist = "Unknown";
const char *value;
char exist[] = "Hdd";
/* Get the property list of current bob process */
xbt_dict_t props = MSG_process_get_properties(MSG_process_self());
xbt_dict_cursor_t cursor = NULL;
- char *key, *data;
+ char *key;
+ char *data;
const char *noexist = "UnknownProcessProp";
XBT_ATTRIB_UNUSED const char *value;
XBT_LOG_NEW_DEFAULT_CATEGORY(goal, "The GOAL loader into SimDag");
typedef struct {
- int i, j, k;
-} s_bcast_task_t,*bcast_task_t;
-
+ int i;
+ int j;
+ int k;
+} s_bcast_task_t;
+typedef s_bcast_task_t *bcast_task_t;
const sg_host_t* ws_list;
int count = 0;
xbt_dynar_t reclaimed;
static void send_one(int from, int to) {
- //XBT_DEBUG("send_one(%d, %d)",from,to);
if (count %100000 == 0)
XBT_INFO("Sending task #%d",count);
int main(int argc, char **argv)
{
xbt_dict_cursor_t cursor = NULL;
- char *key, *data;
+ char *key;
+ char *data;
char noexist[] = "NoProp";
const char *value;
char exist[] = "Hdd";
{
unsigned int cursor;
double min_finish_time = -1.0;
- SD_task_t task, selected_task = NULL;
+ SD_task_t task;
+ SD_task_t selected_task = NULL;
xbt_dynar_t ready_tasks;
sg_host_t selected_host = NULL;
char * tracefilename = NULL;
int main(int argc, char *argv[])
{
- int rank, pstates;
+ int rank;
int i;
char buf[1024];
- char *s;
- size_t sz, x;
- int err;
- err = MPI_Init(&argc, &argv);
+ int err = MPI_Init(&argc, &argv);
if (err != MPI_SUCCESS) {
fprintf(stderr, "MPI_init failed: %d\n", err);
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
- pstates = smpi_get_host_nb_pstates();
+ int pstates = smpi_get_host_nb_pstates();
- s = buf;
- sz = sizeof buf;
- x = snprintf(s, sz,
+ char *s = buf;
+ size_t sz = sizeof buf;
+ size_t x = snprintf(s, sz,
"[%.6f] [rank %d] Pstates: %d; Powers: %.0f",
MPI_Wtime(), rank, pstates, smpi_get_host_power_peak_at(0));
if (x < sz) {
void L07Action::updateBound()
{
double lat_current = 0.0;
- double lat_bound = -1.0;
- int i, j;
int hostNb = hostList_->size();
if (communicationAmount_ != nullptr) {
- for (i = 0; i < hostNb; i++) {
- for (j = 0; j < hostNb; j++) {
+ for (int i = 0; i < hostNb; i++) {
+ for (int j = 0; j < hostNb; j++) {
if (communicationAmount_[i * hostNb + j] > 0) {
double lat = 0.0;
}
}
}
- lat_bound = sg_tcp_gamma / (2.0 * lat_current);
+ double lat_bound = sg_tcp_gamma / (2.0 * lat_current);
XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
if ((latency_ == 0.0) && (suspended_ == 0)) {
if (rate_ < 0)
*/
xbt_fifo_t xbt_fifo_new(void)
{
- xbt_fifo_t fifo;
- fifo = xbt_new0(struct xbt_fifo, 1);
+ xbt_fifo_t fifo = xbt_new0(struct xbt_fifo, 1);
return fifo;
}
*/
xbt_fifo_item_t xbt_fifo_push(xbt_fifo_t l, void *t)
{
- xbt_fifo_item_t new;
-
- new = xbt_fifo_new_item();
+ xbt_fifo_item_t new = xbt_fifo_new_item();
new->content = t;
xbt_fifo_push_item(l, new);
*/
void *xbt_fifo_pop(xbt_fifo_t l)
{
- void *content;
-
if (l == NULL)
return NULL;
xbt_fifo_item_t item = xbt_fifo_pop_item(l);
if (!item)
return NULL;
- content = item->content;
+ void *content = item->content;
xbt_fifo_free_item(item);
return content;
}
*/
xbt_fifo_item_t xbt_fifo_unshift(xbt_fifo_t l, void *t)
{
- xbt_fifo_item_t new;
-
- new = xbt_fifo_new_item();
+ xbt_fifo_item_t new = xbt_fifo_new_item();
new->content = t;
xbt_fifo_unshift_item(l, new);
return new;
*/
void *xbt_fifo_shift(xbt_fifo_t l)
{
- void *content;
-
if (l == NULL)
return NULL;
xbt_fifo_item_t item = xbt_fifo_shift_item(l);
if (!item)
return NULL;
- content = item->content;
+ void *content = item->content;
xbt_fifo_free_item(item);
return content;
}
*/
xbt_fifo_item_t xbt_fifo_pop_item(xbt_fifo_t l)
{
- xbt_fifo_item_t item;
-
if (l->tail == NULL)
return NULL;
- item = l->tail;
+ xbt_fifo_item_t item = l->tail;
l->tail = item->prev;
if (l->tail == NULL)
*/
xbt_fifo_item_t xbt_fifo_shift_item(xbt_fifo_t l)
{
- xbt_fifo_item_t item;
-
if (l->head == NULL)
return NULL;
- item = l->head;
+ xbt_fifo_item_t item = l->head;
l->head = item->next;
if (l->head == NULL)
*/
int xbt_fifo_remove(xbt_fifo_t l, void *t)
{
- xbt_fifo_item_t current, current_next;
+ xbt_fifo_item_t current;
+ xbt_fifo_item_t current_next;
for (current = l->head; current; current = current_next) {
current_next = current->next;
*/
int xbt_fifo_remove_all(xbt_fifo_t l, void *t)
{
- xbt_fifo_item_t current, current_next;
+ xbt_fifo_item_t current;
+ xbt_fifo_item_t current_next;
int res = 0;
for (current = l->head; current; current = current_next) {
*/
xbt_fifo_t xbt_fifo_copy(xbt_fifo_t f)
{
- xbt_fifo_t copy = NULL;
+ xbt_fifo_t copy = xbt_fifo_new();
xbt_fifo_item_t b;
- copy = xbt_fifo_new();
-
for (b = xbt_fifo_get_first_item(f); b; b = b->next) {
xbt_fifo_push(copy, b->content);
}
*/
xbt_graph_t xbt_graph_new_graph(unsigned short int directed, void *data)
{
- xbt_graph_t graph = NULL;
- graph = xbt_new0(struct xbt_graph, 1);
+ xbt_graph_t graph = xbt_new0(struct xbt_graph, 1);
graph->directed = directed;
graph->data = data;
graph->nodes = xbt_dynar_new(sizeof(xbt_node_t), NULL);
/** @brief add a node to the given graph */
xbt_node_t xbt_graph_new_node(xbt_graph_t g, void *data)
{
- xbt_node_t node = NULL;
- node = xbt_new0(struct xbt_node, 1);
+ xbt_node_t node= xbt_new0(struct xbt_node, 1);
node->data = data;
if (g->directed)
/* only the "out" field is used */
/** @brief add an edge to the given graph */
xbt_edge_t xbt_graph_new_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst, void *data)
{
- xbt_edge_t edge = NULL;
-
- edge = xbt_new0(struct xbt_edge, 1);
+ xbt_edge_t edge = xbt_new0(struct xbt_edge, 1);
xbt_dynar_push(src->out, &edge);
if (g->directed)
xbt_dynar_push(dst->in, &edge);
*/
void xbt_floyd_algorithm(xbt_graph_t g, double *adj, double *d, xbt_node_t * p)
{
- unsigned long i, j, k;
- unsigned long n;
- n = xbt_dynar_length(g->nodes);
+ unsigned long i;
+ unsigned long j;
+ unsigned long k;
+ unsigned long n = xbt_dynar_length(g->nodes);
# define D(u,v) d[(u)*n+(v)]
# define P(u,v) p[(u)*n+(v)]
unsigned int cursor = 0;
xbt_node_t node = NULL;
xbt_edge_t edge = NULL;
- FILE *file = NULL;
const char *name = NULL;
- file = fopen(filename, "w");
+ FILE *file = fopen(filename, "w");
xbt_assert(file, "Failed to open %s \n", filename);
if (g->directed)
}else{
c = c_ndir;
}
- const char *src_name, *dst_name;
if (node_name){
- src_name = node_name(edge->src);
- dst_name = node_name(edge->dst);
+ const char *src_name = node_name(edge->src);
+ const char *dst_name = node_name(edge->dst);
fprintf(file, " \"%s\" %s \"%s\"", src_name, c, dst_name);
}else{
fprintf(file, " \"%p\" %s \"%p\"", edge->src, c, edge->dst);
void xbt_log_init(int *argc, char **argv)
{
unsigned help_requested = 0; /* 1: logs; 2: categories */
- int i, j;
+ int i;
+ int j;
char *opt;
/* uncomment to set the LOG category to debug directly */
/* First, try with a static buffer */
if (XBT_LOG_STATIC_BUFFER_SIZE) {
char buff[XBT_LOG_STATIC_BUFFER_SIZE];
- int done;
ev->buffer = buff;
ev->buffer_size = sizeof buff;
va_start(ev->ap, fmt);
- done = cat->layout->do_layout(cat->layout, ev, fmt);
+ int done = cat->layout->do_layout(cat->layout, ev, fmt);
va_end(ev->ap);
if (done) {
appender->do_append(appender, buff);
ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE;
ev->buffer = xbt_malloc(ev->buffer_size);
while (1) {
- int done;
va_start(ev->ap, fmt);
- done = cat->layout->do_layout(cat->layout, ev, fmt);
+ int done = cat->layout->do_layout(cat->layout, ev, fmt);
va_end(ev->ap);
if (done)
break; /* Got it */
{
const char *orig_control_string = control_string;
xbt_log_setting_t set = xbt_new(s_xbt_log_setting_t, 1);
- const char *name, *dot, *eq;
set->catname = NULL;
set->thresh = xbt_log_priority_uninitialized;
XBT_DEBUG("Parse log setting '%s'", control_string);
control_string += strspn(control_string, " ");
- name = control_string;
+ const char *name = control_string;
control_string += strcspn(control_string, ".= ");
- dot = control_string;
+ const char *dot = control_string;
control_string += strcspn(control_string, ":= ");
- eq = control_string;
+ const char *eq = control_string;
if(*dot != '.' && (*eq == '=' || *eq == ':'))
xbt_die ("Invalid control string '%s'", orig_control_string);
if (!strncmp(neweq, "file:", 5)) {
set->appender = xbt_log_appender_file_new(neweq + 5);
}else if (!strncmp(neweq, "rollfile:", 9)) {
- set->appender = xbt_log_appender2_file_new(neweq + 9,1);
+ set->appender = xbt_log_appender2_file_new(neweq + 9,1);
}else if (!strncmp(neweq, "splitfile:", 10)) {
- set->appender = xbt_log_appender2_file_new(neweq + 10,0);
+ set->appender = xbt_log_appender2_file_new(neweq + 10,0);
} else {
THROWF(arg_error, 0, "Unknown appender log type: '%s'", neweq);
}
static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat, char *name)
{
- xbt_log_category_t child, res;
+ xbt_log_category_t child;
+ xbt_log_category_t res;
XBT_DEBUG("Search '%s' into '%s' (firstChild='%s'; nextSibling='%s')", name,
cat->name, (cat->firstChild ? cat->firstChild->name : "none"),
{
char *this_prefix;
char *child_prefix;
- xbt_dynar_t dynar;
unsigned i;
xbt_log_category_t cat;
child_prefix = xbt_strdup(prefix);
}
- dynar = xbt_dynar_new(sizeof(xbt_log_category_t), NULL);
+ xbt_dynar_t dynar = xbt_dynar_new(sizeof(xbt_log_category_t), NULL);
for (cat = category ; cat != NULL; cat = cat->nextSibling)
xbt_dynar_push_as(dynar, xbt_log_category_t, cat);
#define show_it(data, letter) \
if (1) { \
- int len, wd; \
+ int len; \
+ int wd; \
if (length == -1) { \
wd = 0; \
} else { \
int rem_size = ev->buffer_size;
int precision = -1;
int length = -1;
- char *q;
- for (q = l->data ; *q != '\0' ; q++) {
+ for (char* q = l->data ; *q != '\0' ; q++) {
if (*q == '%') {
q++;
handle_modifier:
show_string(ev->fileName);
break;
case 'l': { /* location; LOG4J compliant */
- int len, sz;
+ int sz;
set_sz_from_precision();
- len = snprintf(p, sz, "%s:%d", ev->fileName, ev->lineNum);
+ int len = snprintf(p, sz, "%s:%d", ev->fileName, ev->lineNum);
check_overflow(MIN(sz, len));
break;
}
show_double(surf_get_clock() - format_begin_of_time);
break;
case 'm': { /* user-provided message; LOG4J compliant */
- int len, sz;
+ int sz;
set_sz_from_precision();
- len = vsnprintf(p, sz, msg_fmt, ev->ap);
+ int len = vsnprintf(p, sz, msg_fmt, ev->ap);
check_overflow(MIN(sz, len));
break;
}
{
xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t));
res->data = xbt_strdup(ctn);
- res->used = res->size = strlen(ctn);
+ res->size = strlen(ctn);
+ res->used = res->size;
return res;
}
void xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns)
{
char *end; /* pointers around the parsed chunk */
- int in_simple_quote = 0, in_double_quote = 0;
+ int in_simple_quote = 0;
+ int in_double_quote = 0;
int done = 0;
if (b->data[0] == '\0')
case '$':
if (!in_simple_quote) {
/* Go for the substitution. First search the variable name */
- char *beg_var, *end_var; /* variable name boundary */
- char *beg_subst, *end_subst = NULL; /* where value should be written to */
- char *value, *default_value = NULL;
+ char *beg_var;
+ char *end_var; /* variable name boundary */
+ char *beg_subst = end;
+ char *end_subst = NULL; /* where value should be written to */
+ char *value;
+ char *default_value = NULL;
int val_len;
- beg_subst = end;
if (*(++end) == '{') {
/* the variable name is enclosed in braces. */
static void display_storage_properties(msg_storage_t storage){
xbt_dict_cursor_t cursor = NULL;
- char *key, *data;
+ char *key;
+ char *data;
xbt_dict_t props = MSG_storage_get_properties(storage);
if (xbt_dict_length(props) > 0){
XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage));
static sg_size_t write_local_file(const char *dest, sg_size_t file_size)
{
- sg_size_t written;
msg_file_t file = MSG_file_open(dest, NULL);
- written = MSG_file_write(file, file_size);
+ sg_size_t written = MSG_file_write(file, file_size);
XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1",written, file_size,
MSG_host_get_name(MSG_host_self()));
MSG_file_close(file);
static sg_size_t read_local_file(const char *src)
{
- sg_size_t read, file_size;
msg_file_t file = MSG_file_open(src, NULL);
- file_size = MSG_file_get_size(file);
+ sg_size_t file_size = MSG_file_get_size(file);
- read = MSG_file_read(file, file_size);
+ sg_size_t read = MSG_file_read(file, file_size);
XBT_INFO("%s has read %llu on %s",MSG_host_get_name(MSG_host_self()),read,src);
MSG_file_close(file);
int main(int argc, char **argv)
{
- int i, j;
+ int i;
+ int j;
xbt_os_timer_t timer = xbt_os_timer_new();
SD_init(&argc, argv);