From: Frederic Suter Date: Mon, 29 Feb 2016 10:44:22 +0000 (+0100) Subject: yet another cleaning pass X-Git-Tag: v3_13~628 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b5b953be4c43bad172a39f8917200ed84b534ec5 yet another cleaning pass + still some work to do in chord and pastry --- diff --git a/examples/msg/README b/examples/msg/README index ecdfac5f89..58db3bdb58 100644 --- a/examples/msg/README +++ b/examples/msg/README @@ -57,7 +57,7 @@ communications, there is several other examples in the archive: * msg/icomms/peer2.c: demonstrates the MSG_comm_waitall() function * msg/icomms/peer3.c: demonstrates the MSG_comm_waitany() function -Tracing and vizualization features +Tracing and visualization features ================================== * tracing/simple.c very simple program that creates, executes and destroy a task diff --git a/examples/msg/actions/actions.c b/examples/msg/actions/actions.c index f8b1b886df..df86b80081 100644 --- a/examples/msg/actions/actions.c +++ b/examples/msg/actions/actions.c @@ -4,9 +4,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ +#include "simgrid/msg.h" #include "simgrid/simix.h" /* semaphores for the barrier */ #include @@ -14,28 +12,19 @@ * * @section MSG_ex_actions Trace driven simulations * - * The actions/actions.c example demonstrates how to run trace-driven simulations. It - * is very handy when you want to test an algorithm or protocol that - * does nothing unless it receives some events from outside. For - * example, a P2P protocol reacts to requests from the user, but - * does nothing if there is no such event. + * The actions/actions.c example demonstrates how to run trace-driven simulations. It is very handy when you + * want to test an algorithm or protocol that does nothing unless it receives some events from outside. For example, + * a P2P protocol reacts to requests from the user, but does nothing if there is no such event. * - * In such situations, SimGrid allows to write your protocol in your - * C file, and the events to react to in a separate text file. - * Declare a function handling each of the events that you want to - * accept in your trace files, register them using \ref - * xbt_replay_action_register in your main, and then use \ref - * MSG_action_trace_run to launch the simulation. You can either - * have one trace file containing all your events, or a file per - * simulated process. Check the tesh files in the example directory - * for details on how to do it. + * In such situations, SimGrid allows to write your protocol in your C file, and the events to react to in a separate + * text file. Declare a function handling each of the events that you want to accept in your trace files, register + * them using \ref xbt_replay_action_register in your main, and then use \ref MSG_action_trace_run to launch the + * simulation. You can either have one trace file containing all your events, or a file per simulated process. Check + * the tesh files in the example directory for details on how to do it. * - * This example uses this approach to replay MPI-like traces. It - * comes with a set of event handlers reproducing MPI events. This - * is somehow similar to SMPI, yet differently implemented. This - * code should probably be changed to use SMPI internals instead, - * but wasn't, so far. - * + * This example uses this approach to replay MPI-like traces. It comes with a set of event handlers reproducing MPI + * events. This is somehow similar to SMPI, yet differently implemented. This code should probably be changed to use + * SMPI internals instead, but wasn't, so far. */ XBT_LOG_NEW_DEFAULT_CATEGORY(actions, "Messages specific for this msg example"); @@ -84,8 +73,7 @@ static void log_action(const char *const *action, double date) static void asynchronous_cleanup(void) { - process_globals_t globals = - (process_globals_t) MSG_process_get_data(MSG_process_self()); + process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self()); /* Destroy any isend which correspond to completed communications */ int found; @@ -102,7 +90,7 @@ static void action_send(const char *const *action) char to[250]; const char *size_str = action[3]; double size = parse_double(size_str); - double clock = MSG_get_clock(); /* this "call" is free thanks to inlining */ + double clock = MSG_get_clock(); sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]); @@ -122,12 +110,10 @@ static void action_Isend(const char *const *action) char to[250]; const char *size = action[3]; double clock = MSG_get_clock(); - process_globals_t globals = - (process_globals_t) MSG_process_get_data(MSG_process_self()); + process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self()); sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]); - msg_comm_t comm = - MSG_task_isend(MSG_task_create(to, 0, parse_double(size), NULL), to); + msg_comm_t comm = MSG_task_isend(MSG_task_create(to, 0, parse_double(size), NULL), to); xbt_dynar_push(globals->isends, &comm); XBT_DEBUG("Isend on %s", MSG_process_get_name(MSG_process_self())); @@ -135,15 +121,13 @@ static void action_Isend(const char *const *action) asynchronous_cleanup(); } - static void action_recv(const char *const *action) { char mailbox_name[250]; msg_task_t task = NULL; double clock = MSG_get_clock(); - sprintf(mailbox_name, "%s_%s", action[2], - MSG_process_get_name(MSG_process_self())); + sprintf(mailbox_name, "%s_%s", action[2], MSG_process_get_name(MSG_process_self())); ACT_DEBUG("Receiving: %s", NAME); msg_error_t res = MSG_task_receive(&task, mailbox_name); @@ -159,36 +143,28 @@ static void action_Irecv(const char *const *action) { char mailbox[250]; double clock = MSG_get_clock(); - process_globals_t globals = - (process_globals_t) MSG_process_get_data(MSG_process_self()); + process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self()); XBT_DEBUG("Irecv on %s", MSG_process_get_name(MSG_process_self())); - sprintf(mailbox, "%s_%s", action[2], - MSG_process_get_name(MSG_process_self())); + sprintf(mailbox, "%s_%s", action[2], MSG_process_get_name(MSG_process_self())); msg_task_t t = NULL; xbt_dynar_push(globals->tasks, &t); - msg_comm_t c = - MSG_task_irecv(xbt_dynar_get_ptr - (globals->tasks, xbt_dynar_length(globals->tasks) - 1), - mailbox); + msg_comm_t c = MSG_task_irecv(xbt_dynar_get_ptr(globals->tasks, xbt_dynar_length(globals->tasks) - 1), mailbox); xbt_dynar_push(globals->irecvs, &c); log_action(action, MSG_get_clock() - clock); asynchronous_cleanup(); } - static void action_wait(const char *const *action) { msg_task_t task = NULL; msg_comm_t comm; double clock = MSG_get_clock(); - process_globals_t globals = - (process_globals_t) MSG_process_get_data(MSG_process_self()); + process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self()); - xbt_assert(xbt_dynar_length(globals->irecvs), - "action wait not preceded by any irecv: %s", + xbt_assert(xbt_dynar_length(globals->irecvs), "action wait not preceded by any irecv: %s", xbt_str_join_array(action, " ")); ACT_DEBUG("Entering %s", NAME); @@ -213,8 +189,7 @@ static void action_barrier(const char *const *action) cond = simcall_cond_init(); processes_arrived_sofar = 0; } - ACT_DEBUG("Entering barrier: %s (%d already there)", NAME, - processes_arrived_sofar); + ACT_DEBUG("Entering barrier: %s (%d already there)", NAME, processes_arrived_sofar); simcall_mutex_lock(mutex); if (++processes_arrived_sofar == communicator_size) { @@ -246,11 +221,9 @@ static void action_reduce(const char *const *action) const char *process_name; double clock = MSG_get_clock(); - process_globals_t counters = - (process_globals_t) MSG_process_get_data(MSG_process_self()); + process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self()); - xbt_assert(communicator_size, "Size of Communicator is not defined, " - "can't use collective operations"); + xbt_assert(communicator_size, "Size of Communicator is not defined can't use collective operations"); process_name = MSG_process_get_name(MSG_process_self()); @@ -278,13 +251,11 @@ static void action_reduce(const char *const *action) MSG_task_execute(comp_task); MSG_task_destroy(comp_task); XBT_DEBUG("%s: computed", reduce_identifier); - } else { XBT_DEBUG("%s: %s sends", reduce_identifier, process_name); sprintf(mailbox, "%s_%s_p0", reduce_identifier, process_name); XBT_DEBUG("put on %s", mailbox); - MSG_task_send(MSG_task_create(reduce_identifier, 0, comm_size, NULL), - mailbox); + MSG_task_send(MSG_task_create(reduce_identifier, 0, comm_size, NULL), mailbox); } log_action(action, MSG_get_clock() - clock); @@ -301,11 +272,9 @@ static void action_bcast(const char *const *action) const char *process_name; double clock = MSG_get_clock(); - process_globals_t counters = - (process_globals_t) MSG_process_get_data(MSG_process_self()); + process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self()); - xbt_assert(communicator_size, "Size of Communicator is not defined, " - "can't use collective operations"); + xbt_assert(communicator_size, "Size of Communicator is not defined, can't use collective operations"); process_name = MSG_process_get_name(MSG_process_self()); @@ -318,17 +287,14 @@ static void action_bcast(const char *const *action) for (i = 1; i < communicator_size; i++) { sprintf(mailbox, "%s_p0_p%d", bcast_identifier, i); - comms[i - 1] = - MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox); + comms[i - 1] = MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox); } MSG_comm_waitall(comms, communicator_size - 1, -1); for (i = 1; i < communicator_size; i++) MSG_comm_destroy(comms[i - 1]); xbt_free(comms); - XBT_DEBUG("%s: all messages sent by %s have been received", - bcast_identifier, process_name); - + XBT_DEBUG("%s: all messages sent by %s have been received", bcast_identifier, process_name); } else { sprintf(mailbox, "%s_p0_%s", bcast_identifier, process_name); MSG_task_receive(&task, mailbox); @@ -340,7 +306,6 @@ static void action_bcast(const char *const *action) xbt_free(bcast_identifier); } - static void action_sleep(const char *const *action) { const char *duration = action[2]; @@ -362,11 +327,9 @@ static void action_allReduce(const char *const *action) const char *process_name; double clock = MSG_get_clock(); - process_globals_t counters = - (process_globals_t) MSG_process_get_data(MSG_process_self()); + process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self()); - xbt_assert(communicator_size, "Size of Communicator is not defined, " - "can't use collective operations"); + xbt_assert(communicator_size, "Size of Communicator is not defined, can't use collective operations"); process_name = MSG_process_get_name(MSG_process_self()); @@ -396,23 +359,19 @@ static void action_allReduce(const char *const *action) for (i = 1; i < communicator_size; i++) { sprintf(mailbox, "%s_p0_p%d", allreduce_identifier, i); - comms[i - 1] = - MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox); + comms[i - 1] = MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox); } MSG_comm_waitall(comms, communicator_size - 1, -1); for (i = 1; i < communicator_size; i++) MSG_comm_destroy(comms[i - 1]); xbt_free(comms); - XBT_DEBUG("%s: all messages sent by %s have been received", - allreduce_identifier, process_name); - + XBT_DEBUG("%s: all messages sent by %s have been received", allreduce_identifier, process_name); } else { XBT_DEBUG("%s: %s sends", allreduce_identifier, process_name); sprintf(mailbox, "%s_%s_p0", allreduce_identifier, process_name); XBT_DEBUG("put on %s", mailbox); - MSG_task_send(MSG_task_create(allreduce_identifier, 0, comm_size, NULL), - mailbox); + MSG_task_send(MSG_task_create(allreduce_identifier, 0, comm_size, NULL), mailbox); sprintf(mailbox, "%s_p0_%s", allreduce_identifier, process_name); MSG_task_receive(&task, mailbox); @@ -448,19 +407,16 @@ static void action_compute(const char *const *action) static void action_init(const char *const *action) { XBT_DEBUG("Initialize the counters"); - process_globals_t globals = - (process_globals_t) calloc(1, sizeof(s_process_globals_t)); + process_globals_t globals = (process_globals_t) calloc(1, sizeof(s_process_globals_t)); globals->isends = xbt_dynar_new(sizeof(msg_comm_t), NULL); globals->irecvs = xbt_dynar_new(sizeof(msg_comm_t), NULL); globals->tasks = xbt_dynar_new(sizeof(msg_task_t), NULL); MSG_process_set_data(MSG_process_self(), globals); - } static void action_finalize(const char *const *action) { - process_globals_t globals = - (process_globals_t) MSG_process_get_data(MSG_process_self()); + process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self()); if (globals) { asynchronous_cleanup(); xbt_dynar_free_container(&(globals->isends)); @@ -489,14 +445,10 @@ int main(int argc, char *argv[]) argv[0],argv[0],argv[0]); printf("WARNING: THIS BINARY IS KINDA DEPRECATED\n" - "This example is still relevant if you want to learn about MSG-based trace replay, " - "but if you want to simulate MPI-like traces, you should use the newer version " - "that is in the examples/smpi/replay directory instead.\n"); + "This example is still relevant if you want to learn about MSG-based trace replay, but if you want to simulate " + "MPI-like traces, you should use the newer version that is in the examples/smpi/replay directory instead.\n"); - /* Simulation setting */ MSG_create_environment(argv[1]); - - /* No need to register functions as in classical MSG programs: the actions get started anyway */ MSG_launch_application(argv[2]); /* Action registration */ @@ -515,7 +467,6 @@ int main(int argc, char *argv[]) xbt_replay_action_register("sleep", action_sleep); xbt_replay_action_register("compute", action_compute); - /* Actually do the simulation using MSG_action_trace_run */ res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here @@ -525,4 +476,4 @@ int main(int argc, char *argv[]) MSG_action_exit(); return res != MSG_OK; -} /* end_of_main */ +} diff --git a/examples/msg/actions/storage_actions.c b/examples/msg/actions/storage_actions.c index aa1ef5b41e..0d29d49857 100644 --- a/examples/msg/actions/storage_actions.c +++ b/examples/msg/actions/storage_actions.c @@ -4,10 +4,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include #include "simgrid/msg.h" -#include "xbt.h" /* calloc, printf */ #include XBT_LOG_NEW_DEFAULT_CATEGORY(storage_actions, "Messages specific for this example"); @@ -43,28 +40,26 @@ static msg_file_t get_file_descriptor(const char *file_name){ static sg_size_t parse_size(const char *string){ sg_size_t size; char *endptr; - + size = strtoul(string, &endptr, 10); if (*endptr != '\0') THROWF(unknown_error, 0, "%s is not a long unsigned int (a.k.a. sg_size_t)", string); return size; } - static void action_open(const char *const *action) { const char *file_name = action[2]; char full_name[1024]; msg_file_t file = NULL; - double clock = MSG_get_clock(); /* this "call" is free thanks to inlining */ + double clock = MSG_get_clock(); - sprintf(full_name, "%s:%s", MSG_process_get_name(MSG_process_self()), - file_name); + sprintf(full_name, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name); ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name); file = MSG_file_open(file_name, NULL); - + xbt_dict_set(opened_files, full_name, file, NULL); - + log_action(action, MSG_get_clock() - clock); } @@ -73,11 +68,11 @@ static void action_read(const char *const *action) { const char *size_str = action[3]; msg_file_t file = NULL; sg_size_t size = parse_size(size_str); - - double clock = MSG_get_clock(); /* this "call" is free thanks to inlining */ + + double clock = MSG_get_clock(); file = get_file_descriptor(file_name); - + ACT_DEBUG("Entering Read: %s (size: %llu)", NAME, size); MSG_file_read(file, size); @@ -87,7 +82,7 @@ static void action_read(const char *const *action) { static void action_close(const char *const *action) { const char *file_name = action[2]; msg_file_t file; - double clock = MSG_get_clock(); /* this "call" is free thanks to inlining */ + double clock = MSG_get_clock(); file = get_file_descriptor(file_name); @@ -100,33 +95,23 @@ static void action_close(const char *const *action) { int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; - /* Check the given arguments */ MSG_init(&argc, argv); /* Explicit initialization of the action module is required now*/ MSG_action_init(); - if (argc < 3) { - printf("Usage: %s platform_file deployment_file [action_files]\n", argv[0]); - printf - ("example: %s msg_platform.xml msg_deployment.xml actions # if all actions are in the same file\n", - argv[0]); - printf - ("example: %s msg_platform.xml msg_deployment.xml # if actions are in separate files, specified in deployment\n", - argv[0]); - exit(1); - } + xbt_assert(argc > 3,"Usage: %s platform_file deployment_file [action_files]\n" + "\texample: %s platform.xml deployment.xml actions # if all actions are in the same file\n" + "\texample: %s platform.xml deployment.xml # if actions are in separate files, specified in deployment\n", + argv[0], argv[0], argv[0]); - /* Simulation setting */ MSG_create_environment(argv[1]); - - /* No need to register functions as in classical MSG programs: the actions get started anyway */ MSG_launch_application(argv[2]); /* Action registration */ xbt_replay_action_register("open", action_open); xbt_replay_action_register("read", action_read); xbt_replay_action_register("close", action_close); - + if (!opened_files) opened_files = xbt_dict_new_homogeneous(NULL); /* Actually do the simulation using MSG_action_trace_run */ @@ -140,5 +125,5 @@ int main(int argc, char *argv[]) { /* Explicit finalization of the action module is required now*/ MSG_action_exit(); - return !!res; -} /* end_of_main */ + return res!=MSG_OK; +} diff --git a/examples/msg/bittorrent/connection.c b/examples/msg/bittorrent/connection.c index c0ee2a546a..847a6c4413 100644 --- a/examples/msg/bittorrent/connection.c +++ b/examples/msg/bittorrent/connection.c @@ -38,5 +38,4 @@ void connection_free(void *data) xbt_free(co->bitfield); xbt_free(co->mailbox); xbt_free(co); - } diff --git a/examples/msg/chainsend/CMakeLists.txt b/examples/msg/chainsend/CMakeLists.txt index 773c0cb7a4..b90e420c23 100644 --- a/examples/msg/chainsend/CMakeLists.txt +++ b/examples/msg/chainsend/CMakeLists.txt @@ -23,10 +23,3 @@ set(examples_src ${CMAKE_CURRENT_SOURCE_DIR}/peer.c ${CMAKE_CURRENT_SOURCE_DIR}/chainsend.c PARENT_SCOPE) -set(bin_files - ${bin_files} - PARENT_SCOPE) -set(txt_files - ${txt_files} - ${CMAKE_CURRENT_SOURCE_DIR}/README - PARENT_SCOPE) diff --git a/examples/msg/chainsend/README b/examples/msg/chainsend/README deleted file mode 100644 index 17b605b28f..0000000000 --- a/examples/msg/chainsend/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains a MSG implementation of a file broadcasting -system, similar to Kastafior (from the Kadeploy). diff --git a/examples/msg/chainsend/broadcaster.c b/examples/msg/chainsend/broadcaster.c index 112bb25db2..f14a1be7fc 100644 --- a/examples/msg/chainsend/broadcaster.c +++ b/examples/msg/chainsend/broadcaster.c @@ -6,8 +6,7 @@ #include "broadcaster.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_broadcaster, - "Messages specific for the broadcaster"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_broadcaster, "Messages specific for the broadcaster"); xbt_dynar_t build_hostlist_from_hostcount(int hostcount) { @@ -38,8 +37,7 @@ int broadcaster_build_chain(broadcaster_t bc) next = *cur; bc->first = next; - /* This iterator iterates one step ahead: cur is current iterated element, - but it's actually the next one in the chain */ + /* This iterator iterates one step ahead: cur is current iterated element, but is actually next in the chain */ do { /* following steps: prev=last, host=next, next=cur */ cur = (char**)xbt_dynar_iterator_next(bc->it); @@ -49,8 +47,8 @@ int broadcaster_build_chain(broadcaster_t bc) next = *cur; else next = NULL; - XBT_DEBUG("Building chain -- broadcaster:\"%s\" dest:\"%s\" prev:\"%s\" next:\"%s\"", me, current_host, prev, next); - + XBT_DEBUG("Building chain--broadcaster:\"%s\" dest:\"%s\" prev:\"%s\" next:\"%s\"", me, current_host, prev, next); + /* Send message to current peer */ task = task_message_chain_new(prev, next, bc->piece_count); MSG_task_send(task, current_host); diff --git a/examples/msg/chainsend/broadcaster.h b/examples/msg/chainsend/broadcaster.h index c1f9198239..e9aca94e69 100644 --- a/examples/msg/chainsend/broadcaster.h +++ b/examples/msg/chainsend/broadcaster.h @@ -4,16 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef KADEPLOY_BROADCASTER_H -#define KADEPLOY_BROADCASTER_H - -#include "simgrid/msg.h" -#include "xbt/sysdep.h" - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" +#ifndef BROADCASTER_H +#define BROADCASTER_H +#include "xbt/dynar.h" #include "messages.h" #include "iterator.h" #include "common.h" @@ -46,4 +40,4 @@ int broadcaster_send_file(broadcaster_t bc); /* Tasks */ int broadcaster(int argc, char *argv[]); -#endif /* KADEPLOY_BROADCASTER_H */ +#endif /* BROADCASTER_H */ diff --git a/examples/msg/chainsend/chainsend.c b/examples/msg/chainsend/chainsend.c index 51ca4d7e1f..e7316ac581 100644 --- a/examples/msg/chainsend/chainsend.c +++ b/examples/msg/chainsend/chainsend.c @@ -4,16 +4,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include - -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc */ - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" - +#include "simgrid/msg.h" #include "iterator.h" #include "messages.h" #include "broadcaster.h" @@ -21,33 +12,18 @@ /** @addtogroup MSG_examples * - * - chainsend/chainsend.c: Chainsend implementation. + * - chainsend: MSG implementation of a file broadcasting system, similar to Kastafior (from Kadeploy).. */ +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chainsend, "Messages specific for chainsend"); -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chainsend, - "Messages specific for chainsend"); - -/* - Data structures - */ - -/* Initialization stuff */ -msg_error_t test_all(const char *platform_file, - const char *application_file); - - -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) +int main(int argc, char *argv[]) { - msg_error_t res = MSG_OK; - XBT_DEBUG("test_all"); + MSG_init(&argc, argv); - /* Simulation setting */ - MSG_create_environment(platform_file); + MSG_create_environment(argv[1]); /* Trace categories */ TRACE_category_with_color("host0", "0 0 1"); @@ -64,33 +40,11 @@ msg_error_t test_all(const char *platform_file, MSG_function_register("broadcaster", broadcaster); MSG_function_register("peer", peer); - MSG_launch_application(application_file); + MSG_launch_application(argv[2]); res = MSG_main(); - return res; -} /* end_of_test_all */ - - -/** Main function */ -int main(int argc, char *argv[]) -{ - msg_error_t res = MSG_OK; - -#ifdef _MSC_VER - unsigned int prev_exponent_format = - _set_output_format(_TWO_DIGIT_EXPONENT); -#endif - - MSG_init(&argc, argv); - - res = test_all(argv[1], argv[2]); - XBT_INFO("Total simulation time: %e", MSG_get_clock()); -#ifdef _MSC_VER - _set_output_format(prev_exponent_format); -#endif - return res != MSG_OK; } diff --git a/examples/msg/chainsend/common.h b/examples/msg/chainsend/common.h index 8b0249d3d0..57ca331a25 100644 --- a/examples/msg/chainsend/common.h +++ b/examples/msg/chainsend/common.h @@ -4,8 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef KADEPLOY_COMMON_H -#define KADEPLOY_COMMON_H +#ifndef COMMON_H +#define COMMON_H #include "simgrid/msg.h" #include "xbt/sysdep.h" @@ -17,4 +17,4 @@ static XBT_INLINE void queue_pending_connection(msg_comm_t comm, xbt_dynar_t q) int process_pending_connections(xbt_dynar_t q); -#endif /* KADEPLOY_COMMON_H */ +#endif /* COMMON_H */ diff --git a/examples/msg/chainsend/iterator.h b/examples/msg/chainsend/iterator.h index dfc26938f0..5d3d06d559 100644 --- a/examples/msg/chainsend/iterator.h +++ b/examples/msg/chainsend/iterator.h @@ -4,10 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef KADEPLOY_ITERATOR_H -#define KADEPLOY_ITERATOR_H - -#include +#ifndef ITERATOR_H +#define ITERATOR_H #include "xbt/dynar.h" #include "xbt/sysdep.h" @@ -45,4 +43,4 @@ void xbt_dynar_shuffle_in_place(xbt_dynar_t indices_list); xbt_dynar_get_as(indices_list, (unsigned int)i, type)); \ xbt_dynar_set_as(indices_list, (unsigned int)i, type, tmp); -#endif /* KADEPLOY_ITERATOR_H */ +#endif /* ITERATOR_H */ diff --git a/examples/msg/chainsend/messages.h b/examples/msg/chainsend/messages.h index 9e976d402c..e90bf626fc 100644 --- a/examples/msg/chainsend/messages.h +++ b/examples/msg/chainsend/messages.h @@ -4,11 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef KADEPLOY_MESSAGES_H -#define KADEPLOY_MESSAGES_H +#ifndef MESSAGES_H +#define MESSAGES_H #include "simgrid/msg.h" -#include "xbt/sysdep.h" #define MESSAGE_BUILD_CHAIN_SIZE 40 #define MESSAGE_SEND_DATA_HEADER_SIZE 1 @@ -36,4 +35,4 @@ msg_task_t task_message_chain_new(const char* prev, const char *next, const unsi msg_task_t task_message_data_new(const char *block, unsigned int len); void task_message_delete(void *); -#endif /* KADEPLOY_MESSAGES_H */ +#endif /* MESSAGES_H */ diff --git a/examples/msg/chainsend/peer.c b/examples/msg/chainsend/peer.c index 6be29c17b7..433200e22a 100644 --- a/examples/msg/chainsend/peer.c +++ b/examples/msg/chainsend/peer.c @@ -6,12 +6,7 @@ #include "peer.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_peer, - "Messages specific for the peer"); - -/******************************************************* - * Peer * - *******************************************************/ +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_peer, "Messages specific for the peer"); void peer_init_chain(peer_t peer, message_t msg) { @@ -161,4 +156,4 @@ int peer(int argc, char *argv[]) peer_delete(p); return status; -} /* end_of_receiver */ +} diff --git a/examples/msg/chainsend/peer.h b/examples/msg/chainsend/peer.h index 71306b1b82..4ed5bcc085 100644 --- a/examples/msg/chainsend/peer.h +++ b/examples/msg/chainsend/peer.h @@ -4,11 +4,11 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef KADEPLOY_PEER_H -#define KADEPLOY_PEER_H +#ifndef PEER_H +#define PEER_H #include "simgrid/msg.h" -#include "xbt/sysdep.h" +#include "xbt/dynar.h" #include "messages.h" #include "common.h" @@ -39,4 +39,4 @@ void peer_print_stats(peer_t p, float elapsed_time); int peer(int argc, char *argv[]); -#endif /* KADEPLOY_PEER_H */ +#endif /* PEER_H */ diff --git a/examples/msg/chord/chord.c b/examples/msg/chord/chord.c index ef8324c8e3..800a648bcf 100644 --- a/examples/msg/chord/chord.c +++ b/examples/msg/chord/chord.c @@ -4,10 +4,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/asserts.h" #include "simgrid/modelchecker.h" #include #include "src/mc/mc_replay.h" // FIXME: this is an internal header @@ -15,15 +12,13 @@ /** @addtogroup MSG_examples * * - chord/chord.c: Classical Chord P2P protocol - * This example implements the well known Chord P2P protocol. Its - * main advantage is that it constitute a fully working non-trivial - * example. In addition, its implementation is rather efficient, as - * demonstrated in http://hal.inria.fr/inria-00602216/ + * This example implements the well known Chord P2P protocol. Its main advantage is that it constitute a fully + * working non-trivial example. In addition, its implementation is rather efficient, as demonstrated in + * http://hal.inria.fr/inria-00602216/ */ -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chord, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chord, "Messages specific for this msg example"); #define COMM_SIZE 10 #define COMP_SIZE 0 @@ -42,17 +37,13 @@ static const double sleep_delay = 4.9999; extern long int smx_total_comms; -/* - * Finger element. - */ +/* Finger element. */ typedef struct s_finger { int id; char mailbox[MAILBOX_NAME_SIZE]; // string representation of the id } s_finger_t, *finger_t; -/* - * Node data. - */ +/* Node data. */ typedef struct s_node { int id; // my id char mailbox[MAILBOX_NAME_SIZE]; // my mailbox name (string representation of the id) @@ -65,9 +56,7 @@ typedef struct s_node { RngStream stream; //RngStream for } s_node_t, *node_t; -/** - * Types of tasks exchanged between nodes. - */ +/* Types of tasks exchanged between nodes. */ typedef enum { TASK_FIND_SUCCESSOR, TASK_FIND_SUCCESSOR_ANSWER, @@ -80,9 +69,7 @@ typedef enum { TASK_PREDECESSOR_ALIVE_ANSWER } e_task_type_t; -/* - * Data attached with the tasks sent and received - */ +/* Data attached with the tasks sent and received */ typedef struct s_task_data { e_task_type_t type; // type of task int request_id; // id paramater (used by some types of tasks) @@ -96,7 +83,6 @@ static int *powers2; static xbt_dynar_t host_list; // utility functions -static void chord_initialize(void); static void chord_exit(void); static int normalize(int id); static int is_in_interval(int id, int start, int end); @@ -126,9 +112,7 @@ static void check_predecessor(node_t node); static void random_lookup(node_t); static void quit_notify(node_t node); -/** - * \brief Global initialization of the Chord simulation. - */ +/* \brief Global initialization of the Chord simulation. */ static void chord_initialize(void) { // compute the powers of 2 once for all @@ -994,7 +978,8 @@ static void check_predecessor(node_t node) node->comm_receive = NULL; handle_task(node, task_received); }else{ - XBT_DEBUG("Received the answer to my 'Predecessor Alive' request (task %p) : my predecessor %d is alive", task_received, node->pred_id); + XBT_DEBUG("Received the answer to my 'Predecessor Alive' request (task %p) : my predecessor %d is alive", + task_received, node->pred_id); stop = 1; MSG_comm_destroy(node->comm_receive); node->comm_receive = NULL; @@ -1019,16 +1004,12 @@ static void random_lookup(node_t node) } -/** - * \brief Main function. - */ int main(int argc, char *argv[]) { MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n" - "\tExample: %s ../msg_platform.xml chord.xml\n", - argv[0], argv[0]); + "\tExample: %s ../msg_platform.xml chord.xml\n", argv[0], argv[0]); char **options = &argv[1]; while (!strncmp(options[0], "-", 1)) { diff --git a/examples/msg/cloud/master_worker_vm.c b/examples/msg/cloud/master_worker_vm.c index 8e4209ed60..bd0bfc788e 100644 --- a/examples/msg/cloud/master_worker_vm.c +++ b/examples/msg/cloud/master_worker_vm.c @@ -4,15 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc, printf */ -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); #define MAXMBOXLEN 64 @@ -25,15 +19,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, const double task_comp_size = 10000000; const double task_comm_size = 10000000; - -int master_fun(int argc, char *argv[]); -int worker_fun(int argc, char *argv[]); - - static void send_tasks(int nb_workers) { - int i; - for (i = 0; i < nb_workers; i++) { + for (int i = 0; i < nb_workers; i++) { char *tname = bprintf("Task%02d", i); char *mbox = bprintf("MBOX:WRK%02d", i); @@ -47,7 +35,38 @@ static void send_tasks(int nb_workers) } } -int master_fun(int argc, char *argv[]) +static int worker_fun(int argc, char *argv[]) +{ + const char *pr_name = MSG_process_get_name(MSG_process_self()); + char mbox[MAXMBOXLEN]; + snprintf(mbox, MAXMBOXLEN, "MBOX:%s", pr_name); + + XBT_INFO("%s is listening on mailbox(%s)", pr_name, mbox); + + for (;;) { + msg_task_t task = NULL; + + msg_error_t res = MSG_task_receive(&task, mbox); + if (res != MSG_OK) { + XBT_CRITICAL("MSG_task_get failed"); + DIE_IMPOSSIBLE; + } + + XBT_INFO("%s received task(%s) from mailbox(%s)", pr_name, MSG_task_get_name(task), mbox); + + if (!strcmp(MSG_task_get_name(task), "finalize")) { + MSG_task_destroy(task); + break; + } + + MSG_task_execute(task); + XBT_INFO("%s executed task(%s)", pr_name, MSG_task_get_name(task)); + MSG_task_destroy(task); + } + return 0; +} + +static int master_fun(int argc, char *argv[]) { msg_vm_t vm; unsigned int i; @@ -57,11 +76,9 @@ int master_fun(int argc, char *argv[]) xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL); - /* Launch VMs and worker processes. One VM per PM, and one worker process per VM. */ - XBT_INFO("# Launch %d VMs", nb_workers); - for (i = 0; i< nb_workers; i++) { + for (int i = 0; i< nb_workers; i++) { char *vm_name = bprintf("VM%02d", i); char *pr_name = bprintf("WRK%02d", i); @@ -85,7 +102,6 @@ int master_fun(int argc, char *argv[]) xbt_free(pr_name); } - /* Send a bunch of work to every one */ XBT_INFO("# Send a task to %d worker process", nb_workers); send_tasks(nb_workers); @@ -105,7 +121,6 @@ int master_fun(int argc, char *argv[]) MSG_vm_resume(vm); } - XBT_INFO("# Sleep long enough for everyone to be done with previous batch of work"); MSG_process_sleep(1000 - MSG_get_clock()); @@ -138,7 +153,6 @@ int master_fun(int argc, char *argv[]) MSG_vm_migrate(vm, worker_pm1); } - XBT_INFO("# Shutdown the half of worker processes gracefuly. The remaining half will be forcibly killed."); for (i = 0; i < nb_workers; i++) { char mbox[MAXMBOXLEN]; @@ -150,7 +164,6 @@ int master_fun(int argc, char *argv[]) XBT_INFO("# Wait a while before effective shutdown."); MSG_process_sleep(2); - XBT_INFO("# Shutdown and destroy all the VMs. The remaining worker processes will be forcibly killed."); xbt_dynar_foreach(vms, i, vm) { XBT_INFO("shutdown %s", MSG_host_get_name(vm)); @@ -161,56 +174,16 @@ int master_fun(int argc, char *argv[]) XBT_INFO("# Goodbye now!"); xbt_dynar_free(&vms); - return 0; } /** Receiver function */ -int worker_fun(int argc, char *argv[]) -{ - const char *pr_name = MSG_process_get_name(MSG_process_self()); - char mbox[MAXMBOXLEN]; - snprintf(mbox, MAXMBOXLEN, "MBOX:%s", pr_name); - - XBT_INFO("%s is listenning on mailbox(%s)", pr_name, mbox); - - for (;;) { - msg_task_t task = NULL; - - msg_error_t res = MSG_task_receive(&task, mbox); - if (res != MSG_OK) { - XBT_CRITICAL("MSG_task_get failed"); - DIE_IMPOSSIBLE; - } - - XBT_INFO("%s received task(%s) from mailbox(%s)", - pr_name, MSG_task_get_name(task), mbox); - - if (!strcmp(MSG_task_get_name(task), "finalize")) { - MSG_task_destroy(task); - break; - } - - MSG_task_execute(task); - XBT_INFO("%s executed task(%s)", pr_name, MSG_task_get_name(task)); - MSG_task_destroy(task); - } - - return 0; -} - - - - int main(int argc, char *argv[]) { const int nb_workers = 2; MSG_init(&argc, argv); - if (argc != 2) { - printf("Usage: %s example/msg/msg_platform.xml\n", argv[0]); - return 1; - } + xbt_assert(argc >1,"Usage: %s example/msg/msg_platform.xml\n", argv[0]); /* Load the platform file */ MSG_create_environment(argv[1]); @@ -219,22 +192,17 @@ int main(int argc, char *argv[]) xbt_dynar_t pms = MSG_hosts_as_dynar(); /* we need a master node and worker nodes */ - if (xbt_dynar_length(pms) < nb_workers + 1) { - XBT_CRITICAL("need %d hosts", nb_workers + 1); - return 1; - } + xbt_assert(xbt_dynar_length(pms) > nb_workers,"need %d hosts", nb_workers + 1); /* the first pm is the master, the others are workers */ msg_host_t master_pm = xbt_dynar_get_as(pms, 0, msg_host_t); xbt_dynar_t worker_pms = xbt_dynar_new(sizeof(msg_host_t), NULL); - int i; - for (i = 1; i < nb_workers + 1; i++) { + for (int i = 1; i < nb_workers + 1; i++) { msg_host_t pm = xbt_dynar_get_as(pms, i, msg_host_t); xbt_dynar_push(worker_pms, &pm); } - /* Start the master process on the master pm. */ MSG_process_create("master", master_fun, worker_pms, master_pm); diff --git a/examples/msg/cloud/master_worker_vm.tesh b/examples/msg/cloud/master_worker_vm.tesh index 3d01d421c5..66ee4581ad 100644 --- a/examples/msg/cloud/master_worker_vm.tesh +++ b/examples/msg/cloud/master_worker_vm.tesh @@ -7,11 +7,11 @@ $ $SG_TEST_EXENV ${bindir:=.}/master_worker_vm$EXEEXT --log=no_loc ${srcdir:=.}/ > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] create VM00 on PM(Intel) > [0.000000] [surf_vm/INFO] Create VM(VM00)@PM(Intel) with 0 mounted disks > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] put a process (WRK00) on VM00 -> [VM00:WRK00:(2) 0.000000] [msg_test/INFO] WRK00 is listenning on mailbox(MBOX:WRK00) +> [VM00:WRK00:(2) 0.000000] [msg_test/INFO] WRK00 is listening on mailbox(MBOX:WRK00) > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] create VM01 on PM(Provost) > [0.000000] [surf_vm/INFO] Create VM(VM01)@PM(Provost) with 0 mounted disks > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] put a process (WRK01) on VM01 -> [VM01:WRK01:(3) 0.000000] [msg_test/INFO] WRK01 is listenning on mailbox(MBOX:WRK01) +> [VM01:WRK01:(3) 0.000000] [msg_test/INFO] WRK01 is listening on mailbox(MBOX:WRK01) > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] # Send a task to 2 worker process > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] Send task(Task00) to mailbox(MBOX:WRK00) > [VM00:WRK00:(2) 23.846402] [msg_test/INFO] WRK00 received task(Task00) from mailbox(MBOX:WRK00) @@ -27,9 +27,9 @@ $ $SG_TEST_EXENV ${bindir:=.}/master_worker_vm$EXEEXT --log=no_loc ${srcdir:=.}/ > [VM01:WRK01:(3) 50.726576] [msg_test/INFO] WRK01 executed task(Task01) > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] # Add one more process on each VM > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] put a process (WRK02) on VM00 -> [VM00:WRK02:(4) 1000.000000] [msg_test/INFO] WRK02 is listenning on mailbox(MBOX:WRK02) +> [VM00:WRK02:(4) 1000.000000] [msg_test/INFO] WRK02 is listening on mailbox(MBOX:WRK02) > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] put a process (WRK03) on VM01 -> [VM01:WRK03:(5) 1000.000000] [msg_test/INFO] WRK03 is listenning on mailbox(MBOX:WRK03) +> [VM01:WRK03:(5) 1000.000000] [msg_test/INFO] WRK03 is listening on mailbox(MBOX:WRK03) > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] # Send a task to 4 worker process > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] Send task(Task00) to mailbox(MBOX:WRK00) > [VM00:WRK00:(2) 1023.846402] [msg_test/INFO] WRK00 received task(Task00) from mailbox(MBOX:WRK00) diff --git a/examples/msg/cloud/migrate_vm.c b/examples/msg/cloud/migrate_vm.c index 3eaed071e3..1c92fb5c85 100644 --- a/examples/msg/cloud/migrate_vm.c +++ b/examples/msg/cloud/migrate_vm.c @@ -4,16 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc, printf */ - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm) { @@ -67,8 +60,6 @@ static int master_main(int argc, char *argv[]) s_vm_params_t params; memset(¶ms, 0, sizeof(params)); - - vm0 = MSG_vm_create_core(pm0, "VM0"); params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes MSG_host_set_params(vm0, ¶ms); @@ -79,8 +70,6 @@ static int master_main(int argc, char *argv[]) MSG_vm_destroy(vm0); - - vm0 = MSG_vm_create_core(pm0, "VM0"); params.ramsize = 1L * 1000 * 1000 * 100; // 100Mbytes MSG_host_set_params(vm0, ¶ms); @@ -91,8 +80,6 @@ static int master_main(int argc, char *argv[]) MSG_vm_destroy(vm0); - - vm0 = MSG_vm_create_core(pm0, "VM0"); vm1 = MSG_vm_create_core(pm0, "VM1"); @@ -110,8 +97,6 @@ static int master_main(int argc, char *argv[]) MSG_vm_destroy(vm0); MSG_vm_destroy(vm1); - - vm0 = MSG_vm_create_core(pm0, "VM0"); vm1 = MSG_vm_create_core(pm0, "VM1"); @@ -129,7 +114,6 @@ static int master_main(int argc, char *argv[]) MSG_vm_destroy(vm0); MSG_vm_destroy(vm1); - return 0; } @@ -143,7 +127,6 @@ static void launch_master(msg_host_t host) MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv); } - int main(int argc, char *argv[]) { /* Get the arguments */ @@ -159,6 +142,5 @@ int main(int argc, char *argv[]) int res = MSG_main(); XBT_INFO("Bye (simulation time %g)", MSG_get_clock()); - return !(res == MSG_OK); } diff --git a/examples/msg/cloud/multicore.c b/examples/msg/cloud/multicore.c index c6bd09f7c0..32229cf1f5 100644 --- a/examples/msg/cloud/multicore.c +++ b/examples/msg/cloud/multicore.c @@ -4,19 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc, printf */ - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); - - - - static int worker_main(int argc, char *argv[]) { msg_task_t task = MSG_process_get_data(MSG_process_self()); @@ -27,21 +17,18 @@ static int worker_main(int argc, char *argv[]) return 0; } - struct task_data { msg_task_t task; double prev_computation_amount; double prev_clock; }; - static void task_data_init_clock(struct task_data *t) { t->prev_computation_amount = MSG_task_get_flops_amount(t->task); t->prev_clock = MSG_get_clock(); } - static void task_data_get_clock(struct task_data *t) { double now_computation_amount = MSG_task_get_flops_amount(t->task); @@ -56,7 +43,6 @@ static void task_data_get_clock(struct task_data *t) t->prev_clock = now_clock; } - static void test_pm_pin(void) { xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar(); @@ -64,7 +50,6 @@ static void test_pm_pin(void) msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); - struct task_data t1; struct task_data t2; struct task_data t3; @@ -80,7 +65,6 @@ static void test_pm_pin(void) MSG_process_create("worker3", worker_main, t3.task, pm1); MSG_process_create("worker4", worker_main, t4.task, pm1); - XBT_INFO("## 1. start 4 tasks on PM1 (2 cores)"); task_data_init_clock(&t1); task_data_init_clock(&t2); @@ -93,7 +77,6 @@ static void test_pm_pin(void) task_data_get_clock(&t3); task_data_get_clock(&t4); - XBT_INFO("## 2. pin all tasks to CPU0"); MSG_task_set_affinity(t1.task, pm1, 0x01); MSG_task_set_affinity(t2.task, pm1, 0x01); @@ -106,7 +89,6 @@ static void test_pm_pin(void) task_data_get_clock(&t3); task_data_get_clock(&t4); - XBT_INFO("## 3. clear the affinity of task4"); MSG_task_set_affinity(t4.task, pm1, 0); @@ -116,7 +98,6 @@ static void test_pm_pin(void) task_data_get_clock(&t3); task_data_get_clock(&t4); - XBT_INFO("## 4. clear the affinity of task3"); MSG_task_set_affinity(t3.task, pm1, 0); @@ -126,7 +107,6 @@ static void test_pm_pin(void) task_data_get_clock(&t3); task_data_get_clock(&t4); - XBT_INFO("## 5. clear the affinity of task2"); MSG_task_set_affinity(t2.task, pm1, 0); @@ -136,7 +116,6 @@ static void test_pm_pin(void) task_data_get_clock(&t3); task_data_get_clock(&t4); - XBT_INFO("## 6. pin all tasks to CPU0 of another PM (no effect now)"); MSG_task_set_affinity(t1.task, pm0, 0); MSG_task_set_affinity(t2.task, pm0, 0); @@ -149,8 +128,6 @@ static void test_pm_pin(void) task_data_get_clock(&t3); task_data_get_clock(&t4); - - MSG_task_cancel(t1.task); MSG_task_cancel(t2.task); MSG_task_cancel(t3.task); @@ -162,7 +139,6 @@ static void test_pm_pin(void) MSG_task_destroy(t4.task); } - static void test_vm_pin(void) { xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar(); @@ -170,7 +146,6 @@ static void test_vm_pin(void) msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); // 2 cores msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); // 4 cores - /* set up VMs on PM2 (4 cores) */ msg_vm_t vm0 = MSG_vm_create_core(pm2, "VM0"); msg_vm_t vm1 = MSG_vm_create_core(pm2, "VM1"); @@ -193,7 +168,6 @@ static void test_vm_pin(void) MSG_vm_start(vm2); MSG_vm_start(vm3); - /* set up tasks and processes */ struct task_data t0; struct task_data t1; @@ -210,7 +184,6 @@ static void test_vm_pin(void) MSG_process_create("worker2", worker_main, t2.task, vm2); MSG_process_create("worker3", worker_main, t3.task, vm3); - /* start experiments */ XBT_INFO("## 1. start 4 VMs on PM2 (4 cores)"); task_data_init_clock(&t0); @@ -224,7 +197,6 @@ static void test_vm_pin(void) task_data_get_clock(&t2); task_data_get_clock(&t3); - XBT_INFO("## 2. pin all VMs to CPU0 of PM2"); MSG_vm_set_affinity(vm0, pm2, 0x01); MSG_vm_set_affinity(vm1, pm2, 0x01); @@ -237,7 +209,6 @@ static void test_vm_pin(void) task_data_get_clock(&t2); task_data_get_clock(&t3); - XBT_INFO("## 3. pin all VMs to CPU0 of PM1 (no effect at now)"); /* Because VMs are on PM2, the below operations do not effect computation now. */ MSG_vm_set_affinity(vm0, pm1, 0x01); @@ -251,7 +222,6 @@ static void test_vm_pin(void) task_data_get_clock(&t2); task_data_get_clock(&t3); - XBT_INFO("## 4. unpin VM0, and pin VM2 and VM3 to CPU1 of PM2"); MSG_vm_set_affinity(vm0, pm2, 0x00); MSG_vm_set_affinity(vm2, pm2, 0x02); @@ -263,7 +233,6 @@ static void test_vm_pin(void) task_data_get_clock(&t2); task_data_get_clock(&t3); - XBT_INFO("## 5. migrate all VMs to PM0 (only 1 CPU core)"); MSG_vm_migrate(vm0, pm0); MSG_vm_migrate(vm1, pm0); @@ -282,7 +251,6 @@ static void test_vm_pin(void) task_data_get_clock(&t2); task_data_get_clock(&t3); - XBT_INFO("## 6. migrate all VMs to PM1 (2 CPU cores, with affinity settings)"); MSG_vm_migrate(vm0, pm1); MSG_vm_migrate(vm1, pm1); @@ -320,7 +288,6 @@ static void test_vm_pin(void) task_data_get_clock(&t2); task_data_get_clock(&t3); - /* clean up everything */ MSG_task_cancel(t0.task); MSG_task_cancel(t1.task); @@ -338,7 +305,6 @@ static void test_vm_pin(void) MSG_vm_destroy(vm3); } - static int master_main(int argc, char *argv[]) { XBT_INFO("=== Test PM (set affinity) ==="); @@ -350,7 +316,6 @@ static int master_main(int argc, char *argv[]) return 0; } - int main(int argc, char *argv[]) { /* Get the arguments */ @@ -369,21 +334,17 @@ int main(int argc, char *argv[]) msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); - - XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm0), MSG_host_get_core_number(pm0), MSG_get_host_speed(pm0)); - XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm1), MSG_host_get_core_number(pm1), MSG_get_host_speed(pm1)); - XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm2), MSG_host_get_core_number(pm2), MSG_get_host_speed(pm2)); - - + XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm0), MSG_host_get_core_number(pm0), + MSG_get_host_speed(pm0)); + XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm1), MSG_host_get_core_number(pm1), + MSG_get_host_speed(pm1)); + XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm2), MSG_host_get_core_number(pm2), + MSG_get_host_speed(pm2)); MSG_process_create("master", master_main, NULL, pm0); - - - int res = MSG_main(); XBT_INFO("Bye (simulation time %g)", MSG_get_clock()); - return !(res == MSG_OK); } diff --git a/examples/msg/cloud/scale.c b/examples/msg/cloud/scale.c index 1c45b8cddc..9cc1153d86 100644 --- a/examples/msg/cloud/scale.c +++ b/examples/msg/cloud/scale.c @@ -4,16 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc, printf */ -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /* * Usage: @@ -26,12 +20,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, static double time_precise(void) { struct timeval tv; int ret = gettimeofday(&tv, NULL); - if (ret < 0) - xbt_die("gettimeofday"); - - double now = (double) tv.tv_sec + tv.tv_usec * 0.001 * 0.001; - - return now; + xbt_assert(ret >= 0, "gettimeofday"); + return (double) tv.tv_sec + tv.tv_usec * 0.001 * 0.001; } static int computation_fun(int argc, char *argv[]) { @@ -46,8 +36,6 @@ static int computation_fun(int argc, char *argv[]) { // XBT_INFO("%f", clock_end - clock_sta); } - - return 0; } @@ -81,7 +69,6 @@ static int master_main(int argc, char *argv[]) xbt_free(vm_name); } - XBT_INFO("## Test (start)"); for (i = 0; i < 10; i++) { @@ -91,13 +78,11 @@ static int master_main(int argc, char *argv[]) XBT_INFO("duration %f", clock_end - clock_sta); } - for (i = 0; i < nvm; i++) { MSG_vm_destroy(vm[i]); } XBT_INFO("## Test (ended)"); - return 0; } @@ -128,6 +113,5 @@ int main(int argc, char *argv[]) int res = MSG_main(); XBT_INFO("Bye (simulation time %g)", MSG_get_clock()); - return !(res == MSG_OK); } diff --git a/examples/msg/cloud/simple_vm.c b/examples/msg/cloud/simple_vm.c index aac646c667..4140f38498 100644 --- a/examples/msg/cloud/simple_vm.c +++ b/examples/msg/cloud/simple_vm.c @@ -4,16 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc, printf */ - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); - +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); static int computation_fun(int argc, char *argv[]) { @@ -81,9 +73,7 @@ static int communication_rx_fun(int argc, char *argv[]) struct task_priv *priv = MSG_task_get_data(task); double clock_end = MSG_get_clock(); - XBT_INFO("%s:%s to %s:%s => %g sec", - MSG_host_get_name(priv->tx_host), - MSG_process_get_name(priv->tx_proc), + XBT_INFO("%s:%s to %s:%s => %g sec", MSG_host_get_name(priv->tx_host), MSG_process_get_name(priv->tx_proc), host_name, pr_name, clock_end - priv->clock_sta); xbt_free(priv); @@ -94,9 +84,7 @@ static int communication_rx_fun(int argc, char *argv[]) static void launch_communication_worker(msg_host_t tx_host, msg_host_t rx_host) { - char *mbox = bprintf("MBOX:%s-%s", - MSG_host_get_name(tx_host), - MSG_host_get_name(rx_host)); + char *mbox = bprintf("MBOX:%s-%s", MSG_host_get_name(tx_host), MSG_host_get_name(rx_host)); char **argv = NULL; const char *pr_name_tx = "comm_tx"; @@ -146,7 +134,6 @@ static int master_main(int argc, char *argv[]) XBT_INFO("## Test 1 (ended)"); - XBT_INFO("## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)"); XBT_INFO("### Put a VM on a PM, and put a task to the VM"); @@ -158,7 +145,6 @@ static int master_main(int argc, char *argv[]) XBT_INFO("## Test 2 (ended)"); - XBT_INFO("## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)"); XBT_INFO("### Put a VM on a PM, and put a task to the PM"); @@ -170,8 +156,8 @@ static int master_main(int argc, char *argv[]) XBT_INFO("## Test 3 (ended)"); - - XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1"); + XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for" + " the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1"); XBT_INFO("### Put two VMs on a PM, and put a task to each VM"); vm0 = MSG_vm_create_core(pm0, "VM0"); @@ -196,7 +182,6 @@ static int master_main(int argc, char *argv[]) MSG_vm_destroy(vm1); XBT_INFO("## Test 4 (ended)"); - XBT_INFO("## Test 5 (started): Analyse network impact"); XBT_INFO("### Make a connection between PM0 and PM1"); launch_communication_worker(pm0, pm1); @@ -250,8 +235,8 @@ static int master_main(int argc, char *argv[]) XBT_INFO("## Test 5 (ended)"); - - XBT_INFO("## Test 6 (started): Check migration impact (not yet implemented neither on the CPU resource nor on the network one"); + XBT_INFO("## Test 6 (started): Check migration impact (not yet implemented neither on the CPU resource nor on the" + " network one"); XBT_INFO("### Relocate VM0 between PM0 and PM1"); vm0 = MSG_vm_create_core(pm0, "VM0"); { @@ -269,7 +254,7 @@ static int master_main(int argc, char *argv[]) MSG_process_sleep(5); MSG_vm_destroy(vm0); XBT_INFO("## Test 6 (ended)"); - + xbt_dynar_free(&hosts_dynar); return 0; } @@ -284,7 +269,6 @@ static void launch_master(msg_host_t host) MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv); } - int main(int argc, char *argv[]) { /* Get the arguments */ diff --git a/examples/msg/cloud/two_tasks_vm.c b/examples/msg/cloud/two_tasks_vm.c index d2e826305c..15c96989c9 100644 --- a/examples/msg/cloud/two_tasks_vm.c +++ b/examples/msg/cloud/two_tasks_vm.c @@ -4,14 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/sysdep.h" -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); msg_task_t atask = NULL; @@ -108,6 +103,3 @@ int main(int argc, char *argv[]){ return !(res == MSG_OK); } - - - diff --git a/examples/msg/energy/consumption/energy_consumption.c b/examples/msg/energy/consumption/energy_consumption.c index 092515ddea..5e1bd00f34 100644 --- a/examples/msg/energy/consumption/energy_consumption.c +++ b/examples/msg/energy/consumption/energy_consumption.c @@ -4,60 +4,42 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc */ #include "simgrid/plugins/energy.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); - -int dvfs(int argc, char *argv[]); - - -int dvfs(int argc, char *argv[]) +static int dvfs(int argc, char *argv[]) { - msg_host_t host = NULL; - msg_task_t task1 = NULL; - host = MSG_host_by_name("MyHost1"); + msg_host_t host = MSG_host_by_name("MyHost1"); - - XBT_INFO("Energetic profile: %s", - MSG_host_get_property_value(host,"watt_per_state")); - XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", - MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host)); + XBT_INFO("Energetic profile: %s",MSG_host_get_property_value(host,"watt_per_state")); + XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", MSG_host_get_current_power_peak(host), + sg_host_get_consumed_energy(host)); double start = MSG_get_clock(); XBT_INFO("Sleep for 10 seconds"); MSG_process_sleep(10); - XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J", - MSG_get_clock()-start, + XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J", MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host)); // Run a task start = MSG_get_clock(); - task1 = MSG_task_create ("t1", 100E6, 0, NULL); + msg_task_t task1 = MSG_task_create ("t1", 100E6, 0, NULL); XBT_INFO("Run a task of %.0E flops",MSG_task_get_flops_amount(task1)); MSG_task_execute (task1); MSG_task_destroy(task1); - XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW depending on load; Energy dissipated=%.0f J", - MSG_get_clock()-start, - MSG_host_get_current_power_peak(host), sg_host_get_wattmin_at(host,MSG_host_get_pstate(host)), - sg_host_get_wattmax_at(host,MSG_host_get_pstate(host)), - sg_host_get_consumed_energy(host)); + XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW" + " depending on load; Energy dissipated=%.0f J", MSG_get_clock()-start, + MSG_host_get_current_power_peak(host), sg_host_get_wattmin_at(host,MSG_host_get_pstate(host)), + sg_host_get_wattmax_at(host,MSG_host_get_pstate(host)), sg_host_get_consumed_energy(host)); // ========= Change power peak ========= int pstate=2; MSG_host_set_pstate(host, pstate); XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", - pstate, - MSG_host_get_power_peak_at(host, pstate), - MSG_host_get_current_power_peak(host)); + pstate, MSG_host_get_power_peak_at(host, pstate), MSG_host_get_current_power_peak(host)); // Run a second task start = MSG_get_clock(); @@ -66,15 +48,13 @@ int dvfs(int argc, char *argv[]) MSG_task_execute (task1); MSG_task_destroy(task1); XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - MSG_get_clock()-start, - MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host)); + MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host)); start = MSG_get_clock(); XBT_INFO("Sleep for 4 seconds"); MSG_process_sleep(4); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - MSG_get_clock()-start, - MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host)); + MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host)); // =========== Turn the other host off ========== XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.", @@ -83,8 +63,7 @@ int dvfs(int argc, char *argv[]) start = MSG_get_clock(); MSG_process_sleep(10); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - MSG_get_clock()-start, - MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host)); + MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host)); return 0; } @@ -95,12 +74,9 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); - - MSG_create_environment(argv[1]); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - /* Application deployment */ + MSG_create_environment(argv[1]); MSG_function_register("dvfs_test", dvfs); MSG_launch_application(argv[2]); @@ -111,4 +87,3 @@ int main(int argc, char *argv[]) return res != MSG_OK; } - diff --git a/examples/msg/energy/onoff/onoff.c b/examples/msg/energy/onoff/onoff.c index 4f0b9277c3..78ced0e812 100644 --- a/examples/msg/energy/onoff/onoff.c +++ b/examples/msg/energy/onoff/onoff.c @@ -4,21 +4,13 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc */ #include "simgrid/plugins/energy.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" - -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); static void simulate_bootup(msg_host_t host) { - int previous_pstate = MSG_host_get_pstate(host); XBT_INFO("Switch to virtual pstate 3, that encodes the shutting down state in the XML file of that example"); @@ -42,7 +34,6 @@ static void simulate_bootup(msg_host_t host) { } static void simulate_shutdown(msg_host_t host) { - int previous_pstate = MSG_host_get_pstate(host); XBT_INFO("Switch to virtual pstate 4, that encodes the shutting down state in the XML file of that example"); @@ -67,8 +58,7 @@ static void simulate_shutdown(msg_host_t host) { static int onoff(int argc, char *argv[]) { msg_host_t host1 = MSG_host_by_name("MyHost1"); - XBT_INFO("Energetic profile: %s", - MSG_host_get_property_value(host1,"watt_per_state")); + XBT_INFO("Energetic profile: %s", MSG_host_get_property_value(host1,"watt_per_state")); XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1)); @@ -90,7 +80,6 @@ static int onoff(int argc, char *argv[]) { XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1)); - return 0; } @@ -101,14 +90,11 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); MSG_create_environment(argv[1]); - /* Application deployment */ MSG_function_register("onoff_test", onoff); - MSG_launch_application(argv[2]); res = MSG_main(); @@ -117,4 +103,3 @@ int main(int argc, char *argv[]) return res != MSG_OK; } - diff --git a/examples/msg/energy/pstate/pstate.c b/examples/msg/energy/pstate/pstate.c index cd37f4d81b..817e1ea617 100644 --- a/examples/msg/energy/pstate/pstate.c +++ b/examples/msg/energy/pstate/pstate.c @@ -5,38 +5,21 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc */ - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" - /** @addtogroup MSG_examples * - * - energy/e1/e1.c Shows how a set of pstates can be defined - * for a host and how the current pstate can be accessed/changed - * with @ref MSG_get_host_current_power_peak and @ref - * MSG_set_host_pstate. - * Make sure to read the platform XML file for details on how - * to declare the CPU capacity for each pstate. - * + * - energy/e1/e1.c Shows how a set of pstates can be defined for a host and how the current pstate can be + * accessed/changed with @ref MSG_get_host_current_power_peak and @ref MSG_set_host_pstate. + * Make sure to read the platform XML file for details on how to declare the CPU capacity for each pstate. */ -XBT_LOG_NEW_DEFAULT_CATEGORY(test, - "Pstate properties test"); - -int dvfs(int argc, char *argv[]); - +XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test"); -int dvfs(int argc, char *argv[]) +static int dvfs(int argc, char *argv[]) { - msg_host_t host = NULL; - msg_task_t task1 = NULL; - double task_time = 0; double workload = 100E6; int new_peak_index=2; - host = MSG_host_self();; //MSG_get_host_by_name("MyHost1"); + msg_host_t host = MSG_host_self();; //MSG_get_host_by_name("MyHost1"); int nb = MSG_host_get_nb_pstates(host); XBT_INFO("Count of Processor states=%d", nb); @@ -45,19 +28,18 @@ int dvfs(int argc, char *argv[]) XBT_INFO("Current power peak=%f", current_peak); // Run a task - task1 = MSG_task_create ("t1", workload, 0, NULL); + msg_task_t task1 = MSG_task_create ("t1", workload, 0, NULL); MSG_task_execute (task1); MSG_task_destroy(task1); - task_time = MSG_get_clock(); + double task_time = MSG_get_clock(); XBT_INFO("Task1 simulation time: %e", task_time); // Change power peak - if ((new_peak_index >= nb) || (new_peak_index < 0)) - { + if ((new_peak_index >= nb) || (new_peak_index < 0)){ XBT_INFO("Cannot set pstate %d, host supports only %d pstates", new_peak_index, nb); return 0; - } + } double peak_at = MSG_host_get_power_peak_at(host, new_peak_index); XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_peak_index); @@ -75,7 +57,6 @@ int dvfs(int argc, char *argv[]) task_time = MSG_get_clock() - task_time; XBT_INFO("Task2 simulation time: %e", task_time); - // Verify the default pstate is set to 0 host = MSG_host_by_name("MyHost2"); int nb2 = MSG_host_get_nb_pstates(host); @@ -93,14 +74,11 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); - + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + MSG_create_environment(argv[1]); - /* Application deployment */ MSG_function_register("dvfs_test", dvfs); - MSG_launch_application(argv[2]); res = MSG_main(); @@ -109,4 +87,3 @@ int main(int argc, char *argv[]) return res != MSG_OK; } - diff --git a/examples/msg/energy/vm/CMakeLists.txt b/examples/msg/energy/vm/CMakeLists.txt index 982bc54eb7..3959b1fe74 100644 --- a/examples/msg/energy/vm/CMakeLists.txt +++ b/examples/msg/energy/vm/CMakeLists.txt @@ -5,10 +5,6 @@ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/energy_vm.tesh PARENT_SCOPE) -set(xml_files - ${xml_files} - ${CMAKE_CURRENT_SOURCE_DIR}/deployment_consumption.xml - PARENT_SCOPE) set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/energy_vm.c diff --git a/examples/msg/energy/vm/deployment_consumption.xml b/examples/msg/energy/vm/deployment_consumption.xml deleted file mode 100644 index 52ebe54c03..0000000000 --- a/examples/msg/energy/vm/deployment_consumption.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/msg/energy/vm/energy_vm.c b/examples/msg/energy/vm/energy_vm.c index 14a41d67f9..96175d320c 100644 --- a/examples/msg/energy/vm/energy_vm.c +++ b/examples/msg/energy/vm/energy_vm.c @@ -4,19 +4,12 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/sysdep.h" /* calloc */ #include "simgrid/plugins/energy.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" - XBT_LOG_NEW_DEFAULT_CATEGORY(energy_vm, "Messages of this example"); - static int worker_func() { msg_task_t task1 = MSG_task_create("t1", 300E6, 0, NULL); MSG_task_execute (task1); @@ -50,7 +43,8 @@ static int dvfs(int argc, char *argv[]) MSG_process_create("p31", worker_func, NULL, vm_host3); MSG_process_create("p32", worker_func, NULL, vm_host3); - XBT_INFO("Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, so they run for 6 seconds)"); + XBT_INFO("Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, " + "so they run for 6 seconds)"); MSG_process_sleep(5); XBT_INFO("Wait another 5 seconds. The tasks stop at some point in between"); MSG_process_sleep(5); @@ -67,13 +61,10 @@ int main(int argc, char *argv[]) sg_energy_plugin_init(); MSG_init(&argc, argv); - xbt_assert(argc > 1, "Usage: %s platform_file\n" - "\tExample: %s msg_platform.xml\n", - argv[0], argv[0]); + xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]); MSG_create_environment(argv[1]); - /* Application deployment */ MSG_process_create("dvfs",dvfs,NULL,MSG_host_by_name("MyHost1")); res = MSG_main(); diff --git a/examples/msg/exception/exception.c b/examples/msg/exception/exception.c index 3a11d2eadd..77e3406fa1 100644 --- a/examples/msg/exception/exception.c +++ b/examples/msg/exception/exception.c @@ -4,11 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "xbt/log.h" #include "simgrid/msg.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test_exception, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test_exception, "Messages specific for this msg example"); /** @addtogroup MSG_examples * @@ -17,7 +15,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test_exception, /** Victim. This process gets a lot of remote exceptions */ static int victim(int argc, char *argv[]) { - xbt_ex_t e; msg_error_t res = MSG_OK; @@ -36,7 +33,6 @@ static int victim(int argc, char *argv[]) { xbt_ex_free(e); } - XBT_INFO("Let's get suspended."); int gotit = 0; TRY { @@ -51,7 +47,7 @@ static int victim(int argc, char *argv[]) { if(!gotit) { xbt_die("I was expecting an exception during my suspension!"); } - + XBT_INFO("Let's sleep for 10 seconds."); TRY { res = MSG_process_sleep(10); @@ -71,7 +67,6 @@ static int victim(int argc, char *argv[]) { MSG_process_sleep(10); XBT_INFO("That's enough now. I quit."); - return 0; } @@ -89,7 +84,6 @@ static int terrorist(int argc, char *argv[]) XBT_INFO("Send a first exception (host failure)"); SIMIX_process_throw(victim_process, host_error, 0, "First Trick: Let's pretend that the host failed"); - XBT_INFO("Sweet, let's prepare a second trick!"); XBT_INFO("Going to sleep for 2 seconds"); @@ -115,14 +109,12 @@ int main(int argc, char *argv[]) { MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); MSG_function_register("terrorist", terrorist); MSG_create_environment(argv[1]); MSG_launch_application(argv[2]); - // Launch the simulation res = MSG_main(); diff --git a/examples/msg/gpu/test_MSG_gpu_task_create.c b/examples/msg/gpu/test_MSG_gpu_task_create.c index 771352ddaa..07f85b9f43 100644 --- a/examples/msg/gpu/test_MSG_gpu_task_create.c +++ b/examples/msg/gpu/test_MSG_gpu_task_create.c @@ -9,17 +9,10 @@ * - gpu/test_MSG_gpu_task_create.c Example of use of the very experimental (for now) GPU resource. */ -#include -#include #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for GPU msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for GPU msg example"); - -/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; diff --git a/examples/msg/gtnets/gtnets.c b/examples/msg/gtnets/gtnets.c index a2bed8d2be..83758ac032 100644 --- a/examples/msg/gtnets/gtnets.c +++ b/examples/msg/gtnets/gtnets.c @@ -4,25 +4,15 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples * * - gtnets Simple ping-pong using GTNeTs instead of the SimGrid network models. */ -int master(int argc, char *argv[]); -int slave(int argc, char *argv[]); -msg_error_t test_all(const char *platform_file, - const char *application_file); - int timer_start = 1; //keep a pointer to all surf running tasks. @@ -36,8 +26,7 @@ const char *masternames[NTASKS]; int gl_task_array_id = 0; int count_finished = 0; -/** master */ -int master(int argc, char *argv[]) +static int master(int argc, char *argv[]) { char *slavename = NULL; double task_comm_size = 0; @@ -46,8 +35,7 @@ int master(int argc, char *argv[]) //unique id to control statistics int id = -1; - xbt_assert(argc == 4, "Strange number of arguments expected 3 got %d", - argc - 1); + xbt_assert(argc == 4, "Strange number of arguments expected 3 got %d", argc - 1); /* data size */ int read; @@ -80,38 +68,32 @@ int master(int argc, char *argv[]) MSG_task_send(todo, id_alias); end_time = MSG_get_clock(); - return 0; -} /* end_of_master */ +} -/** Receiver function */ -int slave(int argc, char *argv[]) +static int slave(int argc, char *argv[]) { - msg_task_t task = NULL; - int a; - int id = 0; #ifdef HAVE_LATENCY_BOUND_TRACKING int limited_latency = 0; #endif double remaining = 0; char id_alias[10]; - xbt_assert(argc == 2, "Strange number of arguments expected 1 got %d", - argc - 1); + xbt_assert(argc == 2, "Strange number of arguments expected 1 got %d", argc - 1); - id = atoi(argv[1]); + int id = atoi(argv[1]); sprintf(id_alias, "%d", id); int trace_id = id; - a = MSG_task_receive(&(task), id_alias); + int a = MSG_task_receive(&(task), id_alias); count_finished--; if(count_finished == 0){ timer_start = 0; } - xbt_assert(a == MSG_OK,"Hey?! What's up? Unexpected behavior"); + xbt_assert(a == MSG_OK,"Hey?! What's up? Unexpected behavior"); elapsed_time = MSG_get_clock() - start_time; @@ -127,15 +109,12 @@ int slave(int argc, char *argv[]) XBT_INFO("WARNING FLOW[%d] is limited by latency!!", id); } #endif - XBT_INFO - ("===> Estimated Bw of FLOW[%d] : %f ; message from %s to %s with remaining : %f", - id, gl_data_size[id] / elapsed_time, masternames[id], - slavenames[id], 0.0); + XBT_INFO ("===> Estimated Bw of FLOW[%d] : %f ; message from %s to %s with remaining : %f", + id, gl_data_size[id] / elapsed_time, masternames[id], slavenames[id], 0.0); MSG_task_destroy(gl_task_array[id]); gl_task_array[id]=NULL; } else { - remaining = - MSG_task_get_remaining_communication(gl_task_array[id]); + remaining = MSG_task_get_remaining_communication(gl_task_array[id]); #ifdef HAVE_LATENCY_BOUND_TRACKING limited_latency = MSG_task_is_latency_bounded(gl_task_array[id]); @@ -143,10 +122,8 @@ int slave(int argc, char *argv[]) XBT_INFO("WARNING FLOW[%d] is limited by latency!!", id); } #endif - XBT_INFO - ("===> Estimated Bw of FLOW[%d] : %f ; message from %s to %s with remaining : %f", - id, (gl_data_size[id] - remaining) / elapsed_time, - masternames[id], slavenames[id], remaining); + XBT_INFO ("===> Estimated Bw of FLOW[%d] : %f ; message from %s to %s with remaining : %f", + id, (gl_data_size[id] - remaining) / elapsed_time, masternames[id], slavenames[id], remaining); if(remaining==0) { MSG_task_destroy(gl_task_array[id]); gl_task_array[id]=NULL; @@ -162,43 +139,26 @@ int slave(int argc, char *argv[]) if(bool_printed==2 && gl_task_array[trace_id]) MSG_task_destroy(gl_task_array[trace_id]); return 0; -} /* end_of_slave */ +} -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) +int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; + bool_printed = 0; - { /* Simulation setting */ - MSG_create_environment(platform_file); - } + MSG_init(&argc, argv); + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]); + + MSG_create_environment(argv[1]); TRACE_declare_mark("endmark"); - { /* Application deployment */ - MSG_function_register("master", master); - MSG_function_register("slave", slave); + MSG_function_register("master", master); + MSG_function_register("slave", slave); + MSG_launch_application(argv[2]); - MSG_launch_application(application_file); - } res = MSG_main(); - return res; -} /* end_of_test_all */ - -/** Main function */ -int main(int argc, char *argv[]) -{ - msg_error_t res = MSG_OK; - bool_printed = 0; - - MSG_init(&argc, argv); - xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s platform.xml deployment.xml\n", - argv[0], argv[0]); - - res = test_all(argv[1], argv[2]); return res != MSG_OK; } - diff --git a/examples/msg/icomms/peer.c b/examples/msg/icomms/peer.c index 1e322b4e0c..feb2564f0f 100644 --- a/examples/msg/icomms/peer.c +++ b/examples/msg/icomms/peer.c @@ -4,15 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc, printf */ -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples * @@ -25,14 +19,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, * * - msg/icomms/peer.c: basic example of async functions (@ref MSG_task_isend, @ref MSG_task_irecv, @ref MSG_comm_wait) */ -int sender(int argc, char *argv[]); -int receiver(int argc, char *argv[]); -msg_error_t test_all(const char *platform_file, - const char *application_file); - -/** Sender function */ -int sender(int argc, char *argv[]) +static int sender(int argc, char *argv[]) { long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); double task_comp_size = xbt_str_parse_double(argv[2], "Invalid compute size: %s"); @@ -41,8 +29,7 @@ int sender(int argc, char *argv[]) double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s"); double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s"); - XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, - sleep_test_time); + XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time); msg_comm_t comm = NULL; int i; @@ -55,9 +42,7 @@ int sender(int argc, char *argv[]) sprintf(mailbox, "receiver-%ld", i % receivers_count); sprintf(sprintf_buffer, "Task_%d", i); - task = - MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, - NULL); + task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL); comm = MSG_task_isend(task, mailbox); XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i); @@ -69,7 +54,6 @@ int sender(int argc, char *argv[]) }; } MSG_comm_destroy(comm); - } for (i = 0; i < receivers_count; i++) { @@ -86,15 +70,13 @@ int sender(int argc, char *argv[]) }; } MSG_comm_destroy(comm); - } XBT_INFO("Goodbye now!"); return 0; -} /* end_of_sender */ +} -/** Receiver function */ -int receiver(int argc, char *argv[]) +static int receiver(int argc, char *argv[]) { msg_task_t task = NULL; XBT_ATTRIB_UNUSED msg_error_t res; @@ -103,13 +85,11 @@ int receiver(int argc, char *argv[]) msg_comm_t res_irecv; double sleep_start_time = xbt_str_parse_double(argv[2], "Invalid sleep start parameter: %s"); double sleep_test_time = xbt_str_parse_double(argv[3], "Invalid sleep test parameter: %s"); - XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, - sleep_test_time); + XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time); XBT_ATTRIB_UNUSED int read; read = sscanf(argv[1], "%d", &id); - xbt_assert(read, - "Invalid argument %s\n", argv[1]); + xbt_assert(read, "Invalid argument %s\n", argv[1]); MSG_process_sleep(sleep_start_time); @@ -142,40 +122,25 @@ int receiver(int argc, char *argv[]) } XBT_INFO("I'm done. See you!"); return 0; -} /* end_of_receiver */ - -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) -{ - msg_error_t res = MSG_OK; - - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - MSG_function_register("sender", sender); - MSG_function_register("receiver", receiver); - MSG_launch_application(application_file); - } - res = MSG_main(); - - XBT_INFO("Simulation time %g", MSG_get_clock()); - return res; -} /* end_of_test_all */ - +} -/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - res = test_all(argv[1], argv[2]); + MSG_create_environment(argv[1]); + + MSG_function_register("sender", sender); + MSG_function_register("receiver", receiver); + MSG_launch_application(argv[2]); + + res = MSG_main(); + + XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; } diff --git a/examples/msg/icomms/peer2.c b/examples/msg/icomms/peer2.c index a2cf462a27..73823ea377 100644 --- a/examples/msg/icomms/peer2.c +++ b/examples/msg/icomms/peer2.c @@ -4,29 +4,16 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc, printf */ +#include "simgrid/msg.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples * * - msg/icomms/peer2.c: demonstrates the @ref MSG_comm_waitall function */ -int sender(int argc, char *argv[]); -int receiver(int argc, char *argv[]); - -msg_error_t test_all(const char *platform_file, - const char *application_file); - -/** Sender function */ -int sender(int argc, char *argv[]) +static int sender(int argc, char *argv[]) { long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); @@ -63,10 +50,9 @@ int sender(int argc, char *argv[]) XBT_INFO("Goodbye now!"); xbt_free(comm); return 0; -} /* end_of_sender */ +} -/** Receiver function */ -int receiver(int argc, char *argv[]) +static int receiver(int argc, char *argv[]) { msg_task_t task = NULL; XBT_ATTRIB_UNUSED msg_error_t res; @@ -98,40 +84,24 @@ int receiver(int argc, char *argv[]) } XBT_INFO("I'm done. See you!"); return 0; -} /* end_of_receiver */ - -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) -{ - msg_error_t res = MSG_OK; - - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - MSG_function_register("sender", sender); - MSG_function_register("receiver", receiver); - MSG_launch_application(application_file); - } - res = MSG_main(); - - XBT_INFO("Simulation time %g", MSG_get_clock()); - return res; -} /* end_of_test_all */ - +} -/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - res = test_all(argv[1], argv[2]); + MSG_create_environment(argv[1]); + MSG_function_register("sender", sender); + MSG_function_register("receiver", receiver); + MSG_launch_application(argv[2]); + + res = MSG_main(); + + XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; } diff --git a/examples/msg/icomms/peer3.c b/examples/msg/icomms/peer3.c index a0fe6c6196..818f8918d6 100644 --- a/examples/msg/icomms/peer3.c +++ b/examples/msg/icomms/peer3.c @@ -4,29 +4,16 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc, printf */ -#include -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +#include "simgrid/msg.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples * * - msg/icomms/peer3.c: demonstrates the @ref MSG_comm_waitany function */ -int sender(int argc, char *argv[]); -int receiver(int argc, char *argv[]); - -msg_error_t test_all(const char *platform_file, - const char *application_file); - -/** Sender function */ -int sender(int argc, char *argv[]) +static int sender(int argc, char *argv[]) { long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); @@ -54,8 +41,7 @@ int sender(int argc, char *argv[]) task_comm_size / coef, NULL); comm = MSG_task_isend(task, mailbox); xbt_dynar_push_as(d, msg_comm_t, comm); - XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, - sprintf_buffer, task_comm_size / coef); + XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, sprintf_buffer, task_comm_size / coef); } /* Here we are waiting for the completion of all communications */ @@ -81,13 +67,11 @@ int sender(int argc, char *argv[]) XBT_INFO("Goodbye now!"); return 0; -} /* end_of_sender */ +} -/** Receiver function */ -int receiver(int argc, char *argv[]) +static int receiver(int argc, char *argv[]) { int id = -1; - int i; char mailbox[80]; xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL); int tasks = xbt_str_parse_int(argv[2], "Invalid amount of tasks: %s"); @@ -99,7 +83,7 @@ int receiver(int argc, char *argv[]) sprintf(mailbox, "receiver-%d", id); MSG_process_sleep(10); msg_comm_t res_irecv; - for (i = 0; i < tasks; i++) { + for (int i = 0; i < tasks; i++) { XBT_INFO("Wait to receive task %d", i); task[i] = NULL; res_irecv = MSG_task_irecv(&task[i], mailbox); @@ -129,40 +113,25 @@ int receiver(int argc, char *argv[]) MSG_comm_destroy(res_irecv); XBT_INFO("I'm done. See you!"); return 0; -} /* end_of_receiver */ +} -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) +int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - MSG_function_register("sender", sender); - MSG_function_register("receiver", receiver); - MSG_launch_application(application_file); - } - res = MSG_main(); + MSG_init(&argc, argv); + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - XBT_INFO("Simulation time %g", MSG_get_clock()); - return res; -} /* end_of_test_all */ + MSG_create_environment(argv[1]); + MSG_function_register("sender", sender); + MSG_function_register("receiver", receiver); + MSG_launch_application(argv[2]); -/** Main function */ -int main(int argc, char *argv[]) -{ - msg_error_t res = MSG_OK; + res = MSG_main(); + + XBT_INFO("Simulation time %g", MSG_get_clock()); - MSG_init(&argc, argv); - xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); - - res = test_all(argv[1], argv[2]); - return res != MSG_OK; } diff --git a/examples/msg/io/file.c b/examples/msg/io/file.c index e42f2b6b35..c72e615c66 100644 --- a/examples/msg/io/file.c +++ b/examples/msg/io/file.c @@ -20,16 +20,11 @@ #define FILENAME3 "/home/doc/simgrid/examples/platforms/g5k_cabinets.xml" #define FILENAME4 "/home/doc/simgrid/examples/platforms/nancy.xml" -#include -#include #include "simgrid/msg.h" -int host(int argc, char *argv[]); +XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example"); -XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, - "Messages specific for this io example"); - -int host(int argc, char *argv[]) +static int host(int argc, char *argv[]) { msg_file_t file = NULL; sg_size_t read,write; @@ -65,32 +60,27 @@ int host(int argc, char *argv[]) /* Write 100KB in file from the current position, i.e, end of file or 10MB */ write = MSG_file_write(file, 100000); - XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu",write,filename, - MSG_file_get_size(file)); + XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu",write,filename, MSG_file_get_size(file)); XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st)); /* rewind to the beginning of the file */ - XBT_INFO("\tComing back to the beginning of the stream for file '%s'", - filename); + XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename); MSG_file_seek(file, 0, SEEK_SET); /* Try to read 110KB */ read = MSG_file_read(file, 110000); - XBT_INFO("\tHave read %llu from '%s' (of size %llu)",read,filename, - MSG_file_get_size(file)); + XBT_INFO("\tHave read %llu from '%s' (of size %llu)",read,filename, MSG_file_get_size(file)); /* rewind once again to the beginning of the file */ - XBT_INFO("\tComing back to the beginning of the stream for file '%s'", - filename); + XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename); MSG_file_seek(file, 0, SEEK_SET); /* Write 110KB in file from the current position, i.e, end of file or 10MB */ write = MSG_file_write(file, 110000); - XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write,filename, - MSG_file_get_size(file)); + XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write,filename, MSG_file_get_size(file)); XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st)); @@ -98,28 +88,25 @@ int host(int argc, char *argv[]) XBT_INFO("\tClose file '%s'",filename); MSG_file_close(file); - return 0; } int main(int argc, char **argv) { - int i,res; MSG_init(&argc, argv); MSG_create_environment(argv[1]); xbt_dynar_t hosts = MSG_hosts_as_dynar(); MSG_function_register("host", host); unsigned long nb_hosts = xbt_dynar_length(hosts); XBT_INFO("Number of host '%lu'",nb_hosts); - for(i = 0 ; i -#include #include "simgrid/msg.h" -int host(int argc, char *argv[]); +XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example"); -XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, - "Messages specific for this io example"); - -int host(int argc, char *argv[]) +static int host(int argc, char *argv[]) { - msg_file_t file = NULL; - sg_size_t write; - // First open XBT_INFO("\tOpen file '%s'",FILENAME1); - file = MSG_file_open(FILENAME1, NULL); + msg_file_t file = MSG_file_open(FILENAME1, NULL); // Unlink the file XBT_INFO("\tUnlink file '%s'",MSG_file_get_name(file)); @@ -38,7 +30,7 @@ int host(int argc, char *argv[]) file = MSG_file_open(FILENAME1, NULL); // Write into the new file - write = MSG_file_write(file,100000); // Write for 100Ko + sg_size_t write = MSG_file_write(file,100000); // Write for 100Ko XBT_INFO("\tHave written %llu on %s",write,MSG_file_get_name(file)); // Write into the new file @@ -54,7 +46,6 @@ int host(int argc, char *argv[]) int main(int argc, char **argv) { - int res; MSG_init(&argc, argv); MSG_create_environment(argv[1]); xbt_dynar_t hosts = MSG_hosts_as_dynar(); @@ -67,7 +58,7 @@ int main(int argc, char **argv) xbt_dynar_free(&hosts); - res = MSG_main(); + int res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; } diff --git a/examples/msg/io/remote.c b/examples/msg/io/remote.c index cc84983669..0d90d37c09 100644 --- a/examples/msg/io/remote.c +++ b/examples/msg/io/remote.c @@ -9,32 +9,21 @@ * - io/remote.c Example of delegated I/O operations */ -#include -#include #include "simgrid/msg.h" #define INMEGA (1024*1024) -int host(int argc, char *argv[]); +XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example"); -XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, - "Messages specific for this io example"); - - -int host(int argc, char *argv[]){ - msg_file_t file = NULL; - const char* filename; - sg_size_t read, write; - - file = MSG_file_open(argv[1], NULL); - filename = MSG_file_get_name(file); +static int host(int argc, char *argv[]){ + msg_file_t file = MSG_file_open(argv[1], NULL); + char *filename = MSG_file_get_name(file); XBT_INFO("Opened file '%s'",filename); MSG_file_dump(file); XBT_INFO("Try to read %llu from '%s'",MSG_file_get_size(file),filename); - read = MSG_file_read(file, MSG_file_get_size(file)); - XBT_INFO("Have read %llu from '%s'. Offset is now at: %llu",read,filename, - MSG_file_tell(file)); + sg_size_t read = MSG_file_read(file, MSG_file_get_size(file)); + XBT_INFO("Have read %llu from '%s'. Offset is now at: %llu",read,filename, MSG_file_tell(file)); XBT_INFO("Seek back to the begining of the stream..."); MSG_file_seek(file, 0, SEEK_SET); XBT_INFO("Offset is now at: %llu", MSG_file_tell(file)); @@ -45,24 +34,20 @@ int host(int argc, char *argv[]){ file = MSG_file_open(argv[2], NULL); filename = MSG_file_get_name(file); XBT_INFO("Opened file '%s'",filename); - XBT_INFO("Try to write %llu MiB to '%s'", - MSG_file_get_size(file)/1024, - filename); - write = MSG_file_write(file, MSG_file_get_size(file)*1024); + XBT_INFO("Try to write %llu MiB to '%s'", MSG_file_get_size(file)/1024, filename); + 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]); 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]); + XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename,MSG_file_get_size(file), MSG_host_get_name(src), + argv[3]); MSG_file_rmove(file, dest, argv[4]); } else { - XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, - MSG_file_get_size(file), MSG_host_get_name(src), - argv[3]); + XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, MSG_file_get_size(file), MSG_host_get_name(src), + argv[3]); MSG_file_rcopy(file, dest, argv[4]); MSG_file_close(file); } @@ -71,13 +56,9 @@ int host(int argc, char *argv[]){ return 0; } - - int main(int argc, char **argv) { - int res; unsigned int cur; - xbt_dynar_t storages; msg_storage_t st; MSG_init(&argc, argv); @@ -85,19 +66,15 @@ int main(int argc, char **argv) MSG_function_register("host", host); MSG_launch_application(argv[2]); - storages = MSG_storages_as_dynar(); + xbt_dynar_t storages = MSG_storages_as_dynar(); xbt_dynar_foreach(storages, cur, st){ - XBT_INFO("Init: %llu MiB used on '%s'", - MSG_storage_get_used_size(st)/INMEGA, - MSG_storage_get_name(st)); + XBT_INFO("Init: %llu MiB used on '%s'", MSG_storage_get_used_size(st)/INMEGA, MSG_storage_get_name(st)); } - res = MSG_main(); + int res = MSG_main(); xbt_dynar_foreach(storages, cur, st){ - XBT_INFO("Init: %llu MiB used on '%s'", - MSG_storage_get_used_size(st)/INMEGA, - MSG_storage_get_name(st)); + XBT_INFO("Init: %llu MiB used on '%s'", MSG_storage_get_used_size(st)/INMEGA, MSG_storage_get_name(st)); } xbt_dynar_free_container(&storages); diff --git a/examples/msg/io/storage.c b/examples/msg/io/storage.c index ddae501738..ce10c42189 100644 --- a/examples/msg/io/storage.c +++ b/examples/msg/io/storage.c @@ -24,8 +24,6 @@ ******************************************************************************/ #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/dict.h" XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); @@ -59,7 +57,6 @@ static int host(int argc, char *argv[]){ } xbt_dict_free(&storage_list); - // 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; @@ -75,7 +72,6 @@ static int host(int argc, char *argv[]){ XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size(storage)); XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage)); - // Now retrieve the size of created file and read it completely file_size = MSG_file_get_size(file); MSG_file_seek(file, 0, SEEK_SET); @@ -116,7 +112,6 @@ static int host(int argc, char *argv[]){ xbt_free(data); xbt_free(storage_name); - // Dump disks contents XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self())); xbt_dict_t contents = NULL; @@ -137,10 +132,8 @@ static int host(int argc, char *argv[]){ return 1; } - int main(int argc, char *argv[]) { - MSG_init(&argc, argv); MSG_create_environment(argv[1]); MSG_function_register("host", host); diff --git a/examples/msg/kademlia/kademlia.c b/examples/msg/kademlia/kademlia.c index f7e2195ef2..6eae1ee293 100644 --- a/examples/msg/kademlia/kademlia.c +++ b/examples/msg/kademlia/kademlia.c @@ -9,8 +9,6 @@ #include "task.h" #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/asserts.h" /** @addtogroup MSG_examples * kademlia/kademlia.c: Kademlia protocol * Implements the Kademlia protocol, using 32 bits identifiers. diff --git a/examples/msg/kademlia/node.c b/examples/msg/kademlia/node.c index bc0c9e5155..08aa37c036 100644 --- a/examples/msg/kademlia/node.c +++ b/examples/msg/kademlia/node.c @@ -6,10 +6,8 @@ #include "node.h" #include "routing_table.h" - #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/asserts.h" + XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_node, "Messages specific for this msg example"); /** @brief Initialization of a node diff --git a/examples/msg/kademlia/routing_table.c b/examples/msg/kademlia/routing_table.c index dae7c95857..20757af158 100644 --- a/examples/msg/kademlia/routing_table.c +++ b/examples/msg/kademlia/routing_table.c @@ -7,8 +7,7 @@ #include "routing_table.h" #include "node.h" #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/asserts.h" + XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_routing_table, "Messages specific for this msg example"); /** @brief Initialization of a node routing table. */ diff --git a/examples/msg/masterslave/masterslave_arg.c b/examples/msg/masterslave/masterslave_arg.c index 611b26d14d..b859965ed1 100644 --- a/examples/msg/masterslave/masterslave_arg.c +++ b/examples/msg/masterslave/masterslave_arg.c @@ -4,15 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc, printf */ +#include "simgrid/msg.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); #define task_comp_size 50000000 #define task_comm_size 1000000 @@ -25,7 +19,6 @@ static long my_random(long n) return n * (rand() / ((double)RAND_MAX + 1)); } -/** Emitter function */ static int master(int argc, char *argv[]) { int i; @@ -38,8 +31,7 @@ static int master(int argc, char *argv[]) sprintf(mailbox, "slave-%ld", i % number_of_slaves); sprintf(sprintf_buffer, "Task_%d", i); task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL); - XBT_DEBUG("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, - number_of_jobs, mailbox); + XBT_DEBUG("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_jobs, mailbox); MSG_task_send(task, mailbox); } @@ -55,9 +47,8 @@ static int master(int argc, char *argv[]) XBT_DEBUG("Goodbye now!"); return 0; -} /* end_of_master */ +} -/** Receiver function */ static int slave(int argc, char *argv[]) { msg_task_t task = NULL; @@ -80,9 +71,8 @@ static int slave(int argc, char *argv[]) task = NULL; } return 0; -} /* end_of_slave */ /* end_of_test_all */ +} -/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; @@ -90,8 +80,7 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); xbt_assert(argc > 3, "Usage: %s platform_file number_of_jobs number_of_slaves\n" - "\tExample: %s msg_platform.xml 10 5\n", - argv[0], argv[0]); + "\tExample: %s msg_platform.xml 10 5\n", argv[0], argv[0]); MSG_function_register("master", master); MSG_function_register("slave", slave); @@ -106,17 +95,11 @@ int main(int argc, char *argv[]) msg_host_t *host_table = xbt_dynar_to_array(host_dynar); - MSG_process_create( "master", master, - NULL, - host_table[my_random(number_max)] - ); + MSG_process_create("master", master, NULL, host_table[my_random(number_max)]); for(i = 0 ; i -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc, printf */ +#include "simgrid/msg.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); - -int master(int argc, char *argv[]); -int slave(int argc, char *argv[]); -msg_error_t test_all(const char *platform_file, - const char *application_file); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); #define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */ -/** Emitter function */ -int master(int argc, char *argv[]) +static int master(int argc, char *argv[]) { int slaves_count = 0; msg_host_t *slaves = NULL; @@ -59,31 +47,26 @@ int master(int argc, char *argv[]) XBT_INFO("Got %d task to process :", number_of_tasks); for (i = 0; i < number_of_tasks; i++) { - msg_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, - xbt_new0(double, 1)); - msg_error_t a; + msg_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, xbt_new0(double, 1)); *((double *) task->data) = MSG_get_clock(); - a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i % slaves_count]),10.0); + msg_error_t a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i % slaves_count]),10.0); if (a == MSG_OK) { XBT_INFO("Send completed"); } else if (a == MSG_HOST_FAILURE) { - XBT_INFO - ("Gloups. The cpu on which I'm running just turned off!. See you!"); + XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!"); free(task->data); MSG_task_destroy(task); free(slaves); return 0; } else if (a == MSG_TRANSFER_FAILURE) { - XBT_INFO - ("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", - MSG_host_get_name(slaves[i % slaves_count])); + XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", + MSG_host_get_name(slaves[i % slaves_count])); free(task->data); MSG_task_destroy(task); } else if (a == MSG_TIMEOUT) { - XBT_INFO - ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", + XBT_INFO ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", MSG_host_get_name(slaves[i % slaves_count])); free(task->data); MSG_task_destroy(task); @@ -93,27 +76,23 @@ int master(int argc, char *argv[]) } } - XBT_INFO - ("All tasks have been dispatched. Let's tell everybody the computation is over."); + XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over."); for (i = 0; i < slaves_count; i++) { msg_task_t task = MSG_task_create("finalize", 0, 0, FINALIZE); int a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i]),1.0); if (a == MSG_OK) continue; if (a == MSG_HOST_FAILURE) { - XBT_INFO - ("Gloups. The cpu on which I'm running just turned off!. See you!"); + XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!"); MSG_task_destroy(task); free(slaves); return 0; } else if (a == MSG_TRANSFER_FAILURE) { - XBT_INFO("Mmh. Can't reach '%s'! Nevermind. Let's keep going!", - MSG_host_get_name(slaves[i])); + XBT_INFO("Mmh. Can't reach '%s'! Nevermind. Let's keep going!", MSG_host_get_name(slaves[i])); MSG_task_destroy(task); } else if (a == MSG_TIMEOUT) { - XBT_INFO - ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", - MSG_host_get_name(slaves[i % slaves_count])); + XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", + MSG_host_get_name(slaves[i % slaves_count])); MSG_task_destroy(task); } else { XBT_INFO("Hey ?! What's up ? "); @@ -124,10 +103,9 @@ int master(int argc, char *argv[]) XBT_INFO("Goodbye now!"); free(slaves); return 0; -} /* end_of_master */ +} -/** Receiver function */ -int slave(int argc, char *argv[]) +static int slave(int argc, char *argv[]) { while (1) { msg_task_t task = NULL; @@ -153,8 +131,7 @@ int slave(int argc, char *argv[]) free(task->data); MSG_task_destroy(task); } else if (a == MSG_HOST_FAILURE) { - XBT_INFO - ("Gloups. The cpu on which I'm running just turned off!. See you!"); + XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!"); free(task->data); MSG_task_destroy(task); return 0; @@ -163,8 +140,7 @@ int slave(int argc, char *argv[]) xbt_die("Unexpected behavior"); } } else if (a == MSG_HOST_FAILURE) { - XBT_INFO - ("Gloups. The cpu on which I'm running just turned off!. See you!"); + XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!"); return 0; } else if (a == MSG_TRANSFER_FAILURE) { XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!"); @@ -175,40 +151,25 @@ int slave(int argc, char *argv[]) } XBT_INFO("I'm done. See you!"); return 0; -} /* end_of_slave */ +} -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) +int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - MSG_function_register("master", master); - MSG_function_register("slave", slave); - MSG_launch_application(application_file); - } - res = MSG_main(); + MSG_init(&argc, argv); + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - XBT_INFO("Simulation time %g", MSG_get_clock()); - return res; -} /* end_of_test_all */ + MSG_create_environment(argv[1]); + MSG_function_register("master", master); + MSG_function_register("slave", slave); + MSG_launch_application(argv[2]); -/** Main function */ -int main(int argc, char *argv[]) -{ - msg_error_t res = MSG_OK; + res = MSG_main(); - MSG_init(&argc, argv); - xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); - - res = test_all(argv[1], argv[2]); + XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; } diff --git a/examples/msg/masterslave/masterslave_forwarder.c b/examples/msg/masterslave/masterslave_forwarder.c index 8628584291..74e385806f 100644 --- a/examples/msg/masterslave/masterslave_forwarder.c +++ b/examples/msg/masterslave/masterslave_forwarder.c @@ -4,35 +4,21 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc, printf */ +#include "simgrid/msg.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples * - * - masterslave/masterslave_forwarder.c: Master/slaves - * example. This good old example is also very simple. Its basic - * version is fully commented on this page: \ref MSG_ex_master_slave, - * but several variants can be found in the same directory. + * - masterslave/masterslave_forwarder.c: Master/slaves example. This good old example is also very simple. Its + * basic version is fully commented on this page: \ref MSG_ex_master_slave, but several variants can be found in the + * same directory. */ - -int master(int argc, char *argv[]); -int slave(int argc, char *argv[]); -int forwarder(int argc, char *argv[]); -msg_error_t test_all(const char *platform_file, - const char *application_file); - #define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */ /** Emitter function */ -int master(int argc, char *argv[]) +static int master(int argc, char *argv[]) { int slaves_count = 0; msg_host_t *slaves = NULL; @@ -57,9 +43,7 @@ int master(int argc, char *argv[]) for (i = 0; i < number_of_tasks; i++) { sprintf(sprintf_buffer, "Task_%d", i); - todo[i] = - MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, - NULL); + todo[i] = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL); } } @@ -69,19 +53,16 @@ int master(int argc, char *argv[]) for (i = 4; i < argc; i++) { slaves[i - 4] = MSG_host_by_name(argv[i]); - xbt_assert(slaves[i - 4] != NULL, "Unknown host %s. Stopping Now! ", - argv[i]); + xbt_assert(slaves[i - 4] != NULL, "Unknown host %s. Stopping Now! ", argv[i]); } } - XBT_INFO("Got %d slaves and %d tasks to process", slaves_count, - number_of_tasks); + XBT_INFO("Got %d slaves and %d tasks to process", slaves_count, number_of_tasks); for (i = 0; i < slaves_count; i++) XBT_DEBUG("%s", MSG_host_get_name(slaves[i])); for (i = 0; i < number_of_tasks; i++) { - XBT_INFO("Sending \"%s\" to \"%s\"", - todo[i]->name, MSG_host_get_name(slaves[i % slaves_count])); + XBT_INFO("Sending \"%s\" to \"%s\"", todo[i]->name, MSG_host_get_name(slaves[i % slaves_count])); if (MSG_host_self() == slaves[i % slaves_count]) { XBT_INFO("Hey ! It's me ! :)"); } @@ -90,8 +71,7 @@ int master(int argc, char *argv[]) XBT_INFO("Sent"); } - XBT_INFO - ("All tasks have been dispatched. Let's tell everybody the computation is over."); + XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over."); for (i = 0; i < slaves_count; i++) { msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE); MSG_task_send(finalize, MSG_host_get_name(slaves[i])); @@ -101,10 +81,9 @@ int master(int argc, char *argv[]) free(slaves); free(todo); return 0; -} /* end_of_master */ +} -/** Receiver function */ -int slave(int argc, char *argv[]) +static int slave(int argc, char *argv[]) { msg_task_t task = NULL; XBT_ATTRIB_UNUSED int res; @@ -126,10 +105,9 @@ int slave(int argc, char *argv[]) } XBT_INFO("I'm done. See you!"); return 0; -} /* end_of_slave */ +} -/** Forwarder function */ -int forwarder(int argc, char *argv[]) +static int forwarder(int argc, char *argv[]) { int i; int slaves_count; @@ -156,16 +134,13 @@ int forwarder(int argc, char *argv[]) if (a == MSG_OK) { XBT_INFO("Received \"%s\"", MSG_task_get_name(task)); if (MSG_task_get_data(task) == FINALIZE) { - XBT_INFO - ("All tasks have been dispatched. Let's tell everybody the computation is over."); + XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over."); for (i = 0; i < slaves_count; i++) - MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE), - MSG_host_get_name(slaves[i])); + MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE), MSG_host_get_name(slaves[i])); MSG_task_destroy(task); break; } - XBT_INFO("Sending \"%s\" to \"%s\"", - MSG_task_get_name(task), MSG_host_get_name(slaves[i % slaves_count])); + XBT_INFO("Sending \"%s\" to \"%s\"", MSG_task_get_name(task), MSG_host_get_name(slaves[i % slaves_count])); MSG_task_send(task, MSG_host_get_name(slaves[i % slaves_count])); i++; } else { @@ -177,41 +152,26 @@ int forwarder(int argc, char *argv[]) XBT_INFO("I'm done. See you!"); return 0; -} /* end_of_forwarder */ +} -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) +int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - MSG_function_register("master", master); - MSG_function_register("slave", slave); - MSG_function_register("forwarder", forwarder); - MSG_launch_application(application_file); - } - res = MSG_main(); + MSG_init(&argc, argv); + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - XBT_INFO("Simulation time %g", MSG_get_clock()); - return res; -} /* end_of_test_all */ + MSG_create_environment(argv[1]); + MSG_function_register("master", master); + MSG_function_register("slave", slave); + MSG_function_register("forwarder", forwarder); + MSG_launch_application(argv[2]); -/** Main function */ -int main(int argc, char *argv[]) -{ - msg_error_t res = MSG_OK; + res = MSG_main(); - MSG_init(&argc, argv); - xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); - - res = test_all(argv[1], argv[2]); + XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; } diff --git a/examples/msg/masterslave/masterslave_kill.c b/examples/msg/masterslave/masterslave_kill.c index 91e99146df..365ebb3427 100644 --- a/examples/msg/masterslave/masterslave_kill.c +++ b/examples/msg/masterslave/masterslave_kill.c @@ -4,13 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc */ +#include "simgrid/msg.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** Lazy guy function. This process suspends itself asap. */ static int slave(int argc, char *argv[]) @@ -22,7 +18,7 @@ static int slave(int argc, char *argv[]) MSG_task_execute(MSG_task_create("toto", 1e9, 0, NULL)); XBT_INFO("Bye!"); return 0; -} /* end_of_lazy_guy */ +} static int master(int argc, char *argv[]) { @@ -40,37 +36,25 @@ static int master(int argc, char *argv[]) XBT_INFO("OK, goodbye now."); return 0; -} /* end_of_dram_master */ +} -/** Test function */ -static msg_error_t test_all(const char *platform_file, - const char *application_file) +int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; - MSG_create_environment(platform_file); + MSG_init(&argc, argv); + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment_suspend.xml\n", argv[0], argv[0]); + + MSG_create_environment(argv[1]); + MSG_function_register("master", master); MSG_function_register("slave", slave); - MSG_launch_application(application_file); + MSG_launch_application(argv[2]); res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); - return res; -} /* end_of_test_all */ - - -/** Main function */ -int main(int argc, char *argv[]) -{ - msg_error_t res = MSG_OK; - - MSG_init(&argc, argv); - xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment_suspend.xml\n", - argv[0], argv[0]); - - test_all(argv[1], argv[2]); return res != MSG_OK; } diff --git a/examples/msg/masterslave/masterslave_mailbox.c b/examples/msg/masterslave/masterslave_mailbox.c index 8c4c100720..8aed047e36 100644 --- a/examples/msg/masterslave/masterslave_mailbox.c +++ b/examples/msg/masterslave/masterslave_mailbox.c @@ -4,21 +4,11 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" +#include "simgrid/msg.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); -int master(int argc, char *argv[]); -int slave(int argc, char *argv[]); - -/** Sender function */ -int master(int argc, char *argv[]) +static int master(int argc, char *argv[]) { long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); @@ -36,18 +26,14 @@ int master(int argc, char *argv[]) sprintf(mailbox, "slave-%ld", i % slaves_count); sprintf(sprintf_buffer, "Task_%d", i); - task = - MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, - NULL); + task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL); if (number_of_tasks < 10000 || i % 10000 == 0) - XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, - number_of_tasks, mailbox); + XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox); MSG_task_send(task, mailbox); } - XBT_INFO - ("All tasks have been dispatched. Let's tell everybody the computation is over."); + XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over."); for (i = 0; i < slaves_count; i++) { char mailbox[80]; @@ -56,12 +42,10 @@ int master(int argc, char *argv[]) MSG_task_send(finalize, mailbox); } -// XBT_INFO("Goodbye now!"); return 0; -} /* end_of_master */ +} -/** Receiver function */ -int slave(int argc, char *argv[]) +static int slave(int argc, char *argv[]) { msg_task_t task = NULL; XBT_ATTRIB_UNUSED int res; @@ -91,32 +75,21 @@ int slave(int argc, char *argv[]) } XBT_INFO("I'm done. See you!"); return 0; -} /* end_of_slave */ +} -/** Main function */ int main(int argc, char *argv[]) { - msg_error_t res; - const char *platform_file; - const char *application_file; - MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); - - platform_file = argv[1]; - application_file = argv[2]; - - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - MSG_function_register("master", master); - MSG_function_register("slave", slave); - MSG_launch_application(application_file); - } - res = MSG_main(); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + + MSG_create_environment(argv[1]); + + MSG_function_register("master", master); + MSG_function_register("slave", slave); + MSG_launch_application(argv[2]); + + msg_error_t res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); diff --git a/examples/msg/migration/migration.c b/examples/msg/migration/migration.c index 9a6bd212a2..9fdc4a8642 100644 --- a/examples/msg/migration/migration.c +++ b/examples/msg/migration/migration.c @@ -4,20 +4,14 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "simgrid/msg.h" /* core library */ -#include "xbt/sysdep.h" /* calloc */ -#include "xbt/synchro_core.h" +#include "simgrid/msg.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples * - * - migration/migration.c Demonstrates how to use the @ref - * MSG_process_migrate function to let processes change the host they - * run on after their start. + * - migration/migration.c Demonstrates how to use the @ref MSG_process_migrate function to let processes + * change the host they run on after their start. */ xbt_mutex_t mutex = NULL; @@ -28,10 +22,9 @@ static msg_process_t process_to_migrate = NULL; static int emigrant(int argc, char *argv[]) { msg_task_t task; - XBT_INFO - ("I'll look for a new job on another machine where the grass is greener."); + XBT_INFO("I'll look for a new job on another machine where the grass is greener."); MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin")); - + XBT_INFO("Yeah, found something to do"); task = MSG_task_create("job", 98095000, 0, NULL); MSG_task_execute(task); @@ -50,13 +43,11 @@ static int emigrant(int argc, char *argv[]) XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h)); XBT_INFO("Uh, nothing to do here. Stopping now"); return 0; -} /* end_of_emigrant */ - +} /* This function move the emigrant on Jacquelin */ static int policeman(int argc, char *argv[]) { - xbt_mutex_acquire(mutex); XBT_INFO("Wait a bit before migrating the emigrant."); while (process_to_migrate == NULL) xbt_cond_wait(cond, mutex); @@ -66,29 +57,22 @@ static int policeman(int argc, char *argv[]) xbt_mutex_release(mutex); return 0; -} /* end_of_policeman */ - +} -/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; - /* Argument checking */ MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment_suspend.xml\n", - argv[0], argv[0]); + "\tExample: %s msg_platform.xml msg_deployment_suspend.xml\n", argv[0], argv[0]); - /* Simulation setting */ MSG_create_environment(argv[1]); - /* Application deployment */ MSG_function_register("emigrant", emigrant); MSG_function_register("policeman", policeman); MSG_launch_application(argv[2]); - /* Run the simulation */ mutex = xbt_mutex_init(); cond = xbt_cond_init(); res = MSG_main(); diff --git a/examples/msg/ns3/ns3.c b/examples/msg/ns3/ns3.c index 42fa9d1594..f2fb14bf13 100644 --- a/examples/msg/ns3/ns3.c +++ b/examples/msg/ns3/ns3.c @@ -4,14 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples @@ -20,24 +15,14 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, * * @subsection MSG_ex_PLS Packet level simulators * - * These examples demonstrate how to use the bindings to classical - * Packet-Level Simulators (PLS), as explained in \ref pls. The most - * interesting is probably not the C files since they are unchanged - * from the other simulations, but the associated files, such as the - * platform files to see how to declare a platform to be used with - * the PLS bindings of SimGrid and the tesh files to see how to - * actually start a simulation in these settings. + * These examples demonstrate how to use the bindings to classicalPacket-Level Simulators (PLS), as explained in + * \ref pls. The most interesting is probably not the C files since they are unchanged from the other simulations, + * but the associated files, such as the platform files to see how to declare a platform to be used with the PLS + * bindings of SimGrid and the tesh files to see how to actually start a simulation in these settings. * * - ns3: Simple ping-pong using ns3 instead of the SimGrid network models. - * */ -int master(int argc, char *argv[]); -int slave(int argc, char *argv[]); -int timer(int argc, char *argv[]); -msg_error_t test_all(const char *platform_file, - const char *application_file); - int timer_start; //set as 1 in the master process //keep a pointer to all surf running tasks. @@ -53,8 +38,7 @@ int count_finished = 0; #define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */ -/** master */ -int master(int argc, char *argv[]) +static int master(int argc, char *argv[]) { msg_task_t todo; @@ -82,9 +66,7 @@ int master(int argc, char *argv[]) gl_data_size[id] = task_comm_size; } - { /* Process organization */ - MSG_host_by_name(slavename); - } + MSG_host_by_name(slavename); count_finished++; timer_start = 1 ; @@ -98,10 +80,8 @@ int master(int argc, char *argv[]) XBT_DEBUG ("Finished"); xbt_free(id_alias); return 0; -} /* end_of_master */ - +} -/** Timer function */ int timer(int argc, char *argv[]) { double sleep_time; @@ -120,81 +100,48 @@ int timer(int argc, char *argv[]) do { XBT_DEBUG ("Get sleep"); - MSG_process_sleep(sleep_time); + MSG_process_sleep(sleep_time); } while(timer_start); XBT_DEBUG ("Finished"); return 0; } -/** Receiver function */ -int slave(int argc, char *argv[]) +static int slave(int argc, char *argv[]) { - msg_task_t task = NULL; - int a = MSG_OK; - int id = 0; char id_alias[10]; xbt_assert(argc==2,"Strange number of arguments expected 1 got %d", argc - 1); XBT_DEBUG ("Slave started"); - id = xbt_str_parse_int(argv[1], "Invalid id: %s"); + int id = xbt_str_parse_int(argv[1], "Invalid id: %s"); sprintf(id_alias, "%d", id); - a = MSG_task_receive(&(task), id_alias); + msg_error_t a = MSG_task_receive(&(task), id_alias); count_finished--; if(count_finished == 0){ timer_start = 0; } - - if (a != MSG_OK) { XBT_INFO("Hey?! What's up?"); xbt_die("Unexpected behavior."); } elapsed_time = MSG_get_clock() - start_time; - - XBT_INFO("FLOW[%d] : Receive %.0f bytes from %s to %s", - id, - MSG_task_get_bytes_amount(task), - masternames[id], - slavenames[id]); + + XBT_INFO("FLOW[%d] : Receive %.0f bytes from %s to %s", id, MSG_task_get_bytes_amount(task), masternames[id], + slavenames[id]); // MSG_task_execute(task); MSG_task_destroy(task); XBT_DEBUG ("Finished"); return 0; -} /* end_of_slave */ - -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) -{ - msg_error_t res = MSG_OK; - - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - - TRACE_declare_mark("endmark"); - - { /* Application deployment */ - MSG_function_register("master", master); - MSG_function_register("slave", slave); - MSG_function_register("timer", timer); - - MSG_launch_application(application_file); - } - res = MSG_main(); - return res; -} /* end_of_test_all */ +} -/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; @@ -202,11 +149,18 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s platform.xml deployment.xml\n", - argv[0], argv[0]); - + "\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]); + + MSG_create_environment(argv[1]); + TRACE_declare_mark("endmark"); - res = test_all(argv[1], argv[2]); + MSG_function_register("master", master); + MSG_function_register("slave", slave); + MSG_function_register("timer", timer); + + MSG_launch_application(argv[2]); + + res = MSG_main(); return res != MSG_OK; } diff --git a/examples/msg/parallel_task/parallel_task.c b/examples/msg/parallel_task/parallel_task.c index e291efdd79..3308119ff1 100644 --- a/examples/msg/parallel_task/parallel_task.c +++ b/examples/msg/parallel_task/parallel_task.c @@ -16,7 +16,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example") * interfaces, but it's not possible ATM). */ - static int runner(int argc, char *argv[]) { /* Retrieve the list of all hosts as an array of hosts */ @@ -24,7 +23,8 @@ static int runner(int argc, char *argv[]) int slaves_count = xbt_dynar_length(slaves_dynar); msg_host_t *slaves = xbt_dynar_to_array(slaves_dynar); - XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, and 10MB to exchange between each pair"); + XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, " + "and 10MB to exchange between each pair"); double *computation_amounts = xbt_new0(double, slaves_count); double *communication_amounts = xbt_new0(double, slaves_count * slaves_count); diff --git a/examples/msg/pastry/pastry.c b/examples/msg/pastry/pastry.c index 37d443cfd6..2b6efe9703 100644 --- a/examples/msg/pastry/pastry.c +++ b/examples/msg/pastry/pastry.c @@ -4,14 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include #include "simgrid/msg.h" -#include "xbt/log.h" -#include "xbt/asserts.h" - XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pastry, - "Messages specific for this msg example"); + XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pastry, "Messages specific for this msg example"); /*************************************** * PASTRY * @@ -40,7 +36,6 @@ static int max_simulation_time = 1000; extern long int smx_total_comms; - typedef struct s_node { int id; //128bits generated random(2^128 -1) int known_id; @@ -60,9 +55,7 @@ typedef struct s_state { int routing_table[LEVELS_COUNT][LEVEL_SIZE]; } s_state_t, *state_t; -/** - * Types of tasks exchanged between nodes. - */ +/** Types of tasks exchanged between nodes. */ typedef enum { TASK_JOIN, TASK_JOIN_REPLY, @@ -96,7 +89,6 @@ static int routing_next(node_t node, int dest); static void create(node_t node); static int join(node_t node); - /** * \brief Gets the mailbox name of a host given its chord id. * \param node_id id of a node diff --git a/examples/msg/pmm/msg_pmm.c b/examples/msg/pmm/msg_pmm.c index c9ef8674c9..5d4f6629ef 100644 --- a/examples/msg/pmm/msg_pmm.c +++ b/examples/msg/pmm/msg_pmm.c @@ -8,7 +8,6 @@ #include "simgrid/msg.h" #include "xbt/matrix.h" -#include "xbt/log.h" #include "xbt/xbt_os_time.h" /** @addtogroup MSG_examples diff --git a/examples/msg/semaphores/synchro.c b/examples/msg/semaphores/synchro.c index 7fab442c3f..9d4e0a9df8 100644 --- a/examples/msg/semaphores/synchro.c +++ b/examples/msg/semaphores/synchro.c @@ -4,9 +4,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include #include "simgrid/msg.h" -#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_CATEGORY(msg_semaphore_example, "Messages specific for this msg example"); diff --git a/examples/msg/start_kill_time/sk_time.c b/examples/msg/start_kill_time/sk_time.c index 820cc7efd2..0de9b4a2e3 100644 --- a/examples/msg/start_kill_time/sk_time.c +++ b/examples/msg/start_kill_time/sk_time.c @@ -17,7 +17,7 @@ static int sleeper(int argc, char *argv[]) { XBT_INFO("Hello! I go to sleep."); MSG_process_on_exit(my_onexit, NULL); - + MSG_process_sleep(xbt_str_parse_int(argv[1], "sleeper process expects an integer parameter but got %s")); XBT_INFO("Done sleeping."); return 0;