[doc] Change of Task.setBound comment to fit the native semantic.
examples/msg/cloud/simple_vm
examples/msg/cloud/two_tasks_vm
examples/msg/energy/consumption/energy_consumption
-examples/msg/energy/e3/e3
examples/msg/energy/onoff/onoff
examples/msg/energy/pstate/pstate
examples/msg/gpu/test_MSG_gpu_task_create
examples/msg/kademlia/kademlia
examples/msg/masterslave/masterslave_arg
examples/msg/masterslave/masterslave_cluster
-examples/msg/masterslave/masterslave_console
examples/msg/masterslave/masterslave_failure
-examples/msg/masterslave/masterslave_failure_platfgen
examples/msg/masterslave/masterslave_forwarder
examples/msg/masterslave/masterslave_kill
examples/msg/masterslave/masterslave_mailbox
-examples/msg/masterslave/masterslave_platfgen
examples/msg/masterslave/toto.txt
examples/msg/mc/bugged1
examples/msg/mc/bugged1_liveness
message(FATAL_ERROR "Could not figure out the stack direction. Test prog returned: ${stack}; CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}.")
endif()
endif()
+# If the test ran well, remove the test binary
+execute_process(COMMAND ${CMAKE_COMMAND} -E remove test_stackgrowth)
###############
## System checks
\subsection faq_C Argh! Do I really have to code in C?
-Currently bindings on top of MSG are supported for Java, Ruby and Lua. You can find a few
-documentation about them on the doc page. Note that bindings are released separately from the main dist
-and so have their own version numbers.
-
-Moreover If you use C++,
-you should be able to use the SimGrid library as a standard C library
-and everything should work fine (simply <i>link</i> against this
-library; recompiling SimGrid with a C++ compiler won't work and it
-wouldn't help if you could).
-
-For now,
-we do not feel a real demand for any other language. But if you think there is one,
- please speak up!
+We provide Java bindings of the MSG interface, which is the main
+SimGrid user API.
+
+Moreover If you use C++, you should be able to use the SimGrid library
+as a standard C library and everything should work fine (simply
+<i>link</i> against this library; recompiling SimGrid with a C++
+compiler won't work and it wouldn't help if you could).
+
+For now, we do not feel a real demand for any other language. But if
+you think there is one, please speak up!
\section faq_howto Feature related questions
* 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
/* 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 <stdio.h>
-#include <stdlib.h>
-#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 <xbt/replay.h>
*
* @section MSG_ex_actions Trace driven simulations
*
- * The <b>actions/actions.c</b> 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 <b>actions/actions.c</b> 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");
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;
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]);
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()));
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);
{
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);
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) {
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());
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);
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());
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);
xbt_free(bcast_identifier);
}
-
static void action_sleep(const char *const *action)
{
const char *duration = action[2];
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());
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);
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));
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 */
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
MSG_action_exit();
return res != MSG_OK;
-} /* end_of_main */
+}
/* 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 <stdio.h>
-#include <stdlib.h>
#include "simgrid/msg.h"
-#include "xbt.h" /* calloc, printf */
#include <xbt/replay.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(storage_actions, "Messages specific for this example");
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);
}
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);
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);
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 */
/* Explicit finalization of the action module is required now*/
MSG_action_exit();
- return !!res;
-} /* end_of_main */
+ return res!=MSG_OK;
+}
xbt_free(co->bitfield);
xbt_free(co->mailbox);
xbt_free(co);
-
}
${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)
+++ /dev/null
-This directory contains a MSG implementation of a file broadcasting
-system, similar to Kastafior (from the Kadeploy).
#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)
{
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);
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);
/* 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"
/* Tasks */
int broadcaster(int argc, char *argv[]);
-#endif /* KADEPLOY_BROADCASTER_H */
+#endif /* BROADCASTER_H */
/* 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 <stdio.h>
-#include <stdlib.h>
-
-#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"
/** @addtogroup MSG_examples
*
- * - <b>chainsend/chainsend.c: Chainsend implementation</b>.
+ * - <b>chainsend: MSG implementation of a file broadcasting system, similar to Kastafior (from Kadeploy).</b>.
*/
+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");
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;
}
/* 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"
int process_pending_connections(xbt_dynar_t q);
-#endif /* KADEPLOY_COMMON_H */
+#endif /* COMMON_H */
/* 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 <stdlib.h>
+#ifndef ITERATOR_H
+#define ITERATOR_H
#include "xbt/dynar.h"
#include "xbt/sysdep.h"
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 */
/* 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
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 */
#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)
{
peer_delete(p);
return status;
-} /* end_of_receiver */
+}
/* 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"
int peer(int argc, char *argv[]);
-#endif /* KADEPLOY_PEER_H */
+#endif /* PEER_H */
/* 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 <stdio.h>
#include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
#include "simgrid/modelchecker.h"
#include <xbt/RngStream.h>
#include "src/mc/mc_replay.h" // FIXME: this is an internal header
/** @addtogroup MSG_examples
*
* - <b>chord/chord.c: Classical Chord P2P protocol</b>
- * 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
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)
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,
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)
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);
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
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;
}
-/**
- * \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)) {
/* 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 <stdio.h>
#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
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);
}
}
-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;
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);
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);
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());
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];
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));
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]);
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);
> [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)
> [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)
/* 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 <stdio.h>
#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)
{
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);
MSG_vm_destroy(vm0);
-
-
vm0 = MSG_vm_create_core(pm0, "VM0");
params.ramsize = 1L * 1000 * 1000 * 100; // 100Mbytes
MSG_host_set_params(vm0, ¶ms);
MSG_vm_destroy(vm0);
-
-
vm0 = MSG_vm_create_core(pm0, "VM0");
vm1 = MSG_vm_create_core(pm0, "VM1");
MSG_vm_destroy(vm0);
MSG_vm_destroy(vm1);
-
-
vm0 = MSG_vm_create_core(pm0, "VM0");
vm1 = MSG_vm_create_core(pm0, "VM1");
MSG_vm_destroy(vm0);
MSG_vm_destroy(vm1);
-
return 0;
}
MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv);
}
-
int main(int argc, char *argv[])
{
/* Get the arguments */
int res = MSG_main();
XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
-
return !(res == MSG_OK);
}
/* 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 <stdio.h>
#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());
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);
t->prev_clock = now_clock;
}
-
static void test_pm_pin(void)
{
xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
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;
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);
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);
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);
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);
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);
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);
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);
MSG_task_destroy(t4.task);
}
-
static void test_vm_pin(void)
{
xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
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");
MSG_vm_start(vm2);
MSG_vm_start(vm3);
-
/* set up tasks and processes */
struct task_data t0;
struct task_data t1;
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);
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);
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);
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);
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);
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);
task_data_get_clock(&t2);
task_data_get_clock(&t3);
-
/* clean up everything */
MSG_task_cancel(t0.task);
MSG_task_cancel(t1.task);
MSG_vm_destroy(vm3);
}
-
static int master_main(int argc, char *argv[])
{
XBT_INFO("=== Test PM (set affinity) ===");
return 0;
}
-
int main(int argc, char *argv[])
{
/* Get the arguments */
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);
}
/* 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 <stdio.h>
#include <sys/time.h>
#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:
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[]) {
// XBT_INFO("%f", clock_end - clock_sta);
}
-
-
return 0;
}
xbt_free(vm_name);
}
-
XBT_INFO("## Test (start)");
for (i = 0; i < 10; i++) {
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;
}
int res = MSG_main();
XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
-
return !(res == MSG_OK);
}
/* 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 <stdio.h>
#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[])
{
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);
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";
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");
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");
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");
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);
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");
{
MSG_process_sleep(5);
MSG_vm_destroy(vm0);
XBT_INFO("## Test 6 (ended)");
-
+
xbt_dynar_free(&hosts_dynar);
return 0;
}
MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv);
}
-
int main(int argc, char *argv[])
{
/* Get the arguments */
/* 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 <stdio.h>
#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;
return !(res == MSG_OK);
}
-
-
-
/* 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 <stdio.h>
#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();
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.",
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;
}
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]);
return res != MSG_OK;
}
-
/* 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 <stdio.h>
#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");
}
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");
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));
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;
}
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();
return res != MSG_OK;
}
-
* 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
*
- * - <b>energy/e1/e1.c</b> 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.
- *
+ * - <b>energy/e1/e1.c</b> 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);
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);
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);
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();
return res != MSG_OK;
}
-
${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
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
- <process host="MyHost1" function="dvfs_test" />
-</platform>
/* 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 <stdio.h>
#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);
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);
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();
/* 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
*
/** 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;
xbt_ex_free(e);
}
-
XBT_INFO("Let's get suspended.");
int gotit = 0;
TRY {
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);
MSG_process_sleep(10);
XBT_INFO("That's enough now. I quit.");
-
return 0;
}
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");
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();
* - <b>gpu/test_MSG_gpu_task_create.c</b> Example of use of the very experimental (for now) GPU resource.
*/
-#include <stdio.h>
-#include <stdlib.h>
#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;
/* 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 <stdio.h>
-#include <stdlib.h>
#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
*
* - <b>gtnets</b> 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.
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;
//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;
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;
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]);
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;
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;
}
-
/* 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 <stdio.h>
#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
*
*
* - <b>msg/icomms/peer.c</b>: 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");
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;
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);
};
}
MSG_comm_destroy(comm);
-
}
for (i = 0; i < receivers_count; i++) {
};
}
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;
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);
}
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;
}
/* 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 <stdio.h>
-#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
*
* - <b>msg/icomms/peer2.c</b>: 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");
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;
}
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;
}
/* 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 <stdio.h>
-#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 <math.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");
+#include "simgrid/msg.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
/** @addtogroup MSG_examples
*
* - <b>msg/icomms/peer3.c</b>: 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");
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 */
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");
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);
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;
}
#define FILENAME3 "/home/doc/simgrid/examples/platforms/g5k_cabinets.xml"
#define FILENAME4 "/home/doc/simgrid/examples/platforms/nancy.xml"
-#include <stdio.h>
-#include <stdlib.h>
#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;
/* 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));
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<nb_hosts; i++)
- {
+ for(int i = 0 ; i<nb_hosts; i++){
char* name_host = bprintf("%d",i);
MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t) );
free(name_host);
}
xbt_dynar_free(&hosts);
- res = MSG_main();
+ int res = MSG_main();
XBT_INFO("Simulation time %g", MSG_get_clock());
return res != MSG_OK;
}
#define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
-#include <stdio.h>
-#include <stdlib.h>
#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));
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
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();
xbt_dynar_free(&hosts);
- res = MSG_main();
+ int res = MSG_main();
XBT_INFO("Simulation time %g", MSG_get_clock());
return res != MSG_OK;
}
* - <b>io/remote.c</b> Example of delegated I/O operations
*/
-#include <stdio.h>
-#include <stdlib.h>
#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);
+ const 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));
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);
}
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);
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);
******************************************************************************/
#include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/dict.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
}
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;
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);
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;
return 1;
}
-
int main(int argc, char *argv[])
{
-
MSG_init(&argc, argv);
MSG_create_environment(argv[1]);
MSG_function_register("host", host);
#include "task.h"
#include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
/** @addtogroup MSG_examples
* <b>kademlia/kademlia.c: Kademlia protocol</b>
* Implements the Kademlia protocol, using 32 bits identifiers.
#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
#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. */
/* 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 <stdio.h>
-#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
return n * (rand() / ((double)RAND_MAX + 1));
}
-/** Emitter function */
static int master(int argc, char *argv[])
{
int i;
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);
}
XBT_DEBUG("Goodbye now!");
return 0;
-} /* end_of_master */
+}
-/** Receiver function */
static int slave(int argc, char *argv[])
{
msg_task_t task = NULL;
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;
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);
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<number_of_slaves; i++) {
char* name_host = bprintf("slave-%ld",i);
- MSG_process_create( name_host, slave,
- NULL,
- host_table[my_random(number_max)]
- );
+ MSG_process_create( name_host, slave, NULL, host_table[my_random(number_max)]);
free(name_host);
}
xbt_free(host_table);
/* 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 <stdio.h>
-#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;
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);
}
}
- 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 ? ");
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;
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;
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!");
}
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;
}
/* 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 <stdio.h>
-#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
*
- * - <b>masterslave/masterslave_forwarder.c: Master/slaves
- * example</b>. 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.
+ * - <b>masterslave/masterslave_forwarder.c: Master/slaves example</b>. 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;
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);
}
}
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 ! :)");
}
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]));
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;
}
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;
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 {
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;
}
/* 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[])
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[])
{
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;
}
/* 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 <stdio.h>
-#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");
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];
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;
}
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());
/* 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 "simgrid/msg.h"
#include "xbt/synchro_core.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
*
- * - <b>migration/migration.c</b> Demonstrates how to use the @ref
- * MSG_process_migrate function to let processes change the host they
- * run on after their start.
+ * - <b>migration/migration.c</b> 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;
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);
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);
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();
/* 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 <stdio.h>
-#include <stdlib.h>
#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
*
* @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.
*
* - <b>ns3</b>: 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.
#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;
gl_data_size[id] = task_comm_size;
}
- { /* Process organization */
- MSG_host_by_name(slavename);
- }
+ MSG_host_by_name(slavename);
count_finished++;
timer_start = 1 ;
XBT_DEBUG ("Finished");
xbt_free(id_alias);
return 0;
-} /* end_of_master */
-
+}
-/** Timer function */
-int timer(int argc, char *argv[])
+static int timer(int argc, char *argv[])
{
double sleep_time;
double first_sleep;
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;
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;
}
* 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 */
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);
/* 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 <stdio.h>
#include <math.h>
#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 *
extern long int smx_total_comms;
-
typedef struct s_node {
int id; //128bits generated random(2^128 -1)
int known_id;
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,
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
#include "simgrid/msg.h"
#include "xbt/matrix.h"
-#include "xbt/log.h"
#include "xbt/xbt_os_time.h"
/** @addtogroup MSG_examples
/* 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 <stdlib.h>
#include "simgrid/msg.h"
-#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_semaphore_example, "Messages specific for this msg example");
{
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;
/** The Actor that is currently running */
static Actor *current();
/** Retrieves the actor that have the given PID (or NULL if not existing) */
- static Actor *byPid(int pid);
+ //static Actor *byPid(int pid); not implemented
/** Retrieves the name of that actor */
const char*getName();
XBT_PUBLIC(int) SIMIX_process_count(void);
XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
XBT_PUBLIC(const char*) SIMIX_process_self_get_name(void);
-XBT_PUBLIC(void) SIMIX_process_self_set_data(smx_process_t self, void *data);
-XBT_PUBLIC(void*) SIMIX_process_self_get_data(smx_process_t self);
+XBT_PUBLIC(void) SIMIX_process_self_set_data(void *data);
+XBT_PUBLIC(void*) SIMIX_process_self_get_data(void);
XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t);
XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void);
XBT_PUBLIC_DATA(const char *) surf_AS_get_name(AS_t as);
XBT_PUBLIC_DATA(AS_t) surf_AS_get_by_name(const char * name);
-XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_routing_sons(AS_t as);
+XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_children(AS_t as);
XBT_PUBLIC_DATA(xbt_dynar_t) surf_AS_get_hosts(AS_t as);
XBT_PUBLIC_DATA(void) surf_AS_get_graph(AS_t as, xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
xbt_dict_cursor_t cursor = NULL;
char *key;
AS_t elem;
- xbt_dict_t routing_sons = surf_AS_get_routing_sons(current_comp);
+ xbt_dict_t routing_sons = surf_AS_get_children(current_comp);
if (xbt_dict_is_empty(routing_sons)) {
// I am no AS
}
}
-void data_deleter::operator()(void* p) const
+buffer::buffer(std::size_t size, Type type) : size_(size), type_(type)
{
switch(type_) {
- case Free:
- std::free(p);
+ case Type::Malloc:
+ data_ = malloc(size_);
break;
- case Munmap:
- munmap(p, size_);
+ case Type::Mmap:
+ data_ = mmap(nullptr, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, -1, 0);
+ if (data_ == MAP_FAILED) {
+ data_ = nullptr;
+ size_ = 0;
+ type_ = Type::Malloc;
+ throw std::bad_alloc();
+ }
+ break;
+ default:
+ abort();
+ }
+}
+
+void buffer::clear() noexcept
+{
+ switch(type_) {
+ case Type::Malloc:
+ std::free(data_);
break;
+ case Type::Mmap:
+ if (munmap(data_, size_) != 0)
+ abort();
+ break;
+ default:
+ abort();
}
+ data_ = nullptr;
+ size_ = 0;
+ type_ = Type::Malloc;
}
RegionSnapshot dense_region(
RegionType region_type,
void *start_addr, void* permanent_addr, size_t size)
{
- simgrid::mc::RegionSnapshot::flat_data_ptr data;
- if (!_sg_mc_ksm)
- data = simgrid::mc::RegionSnapshot::flat_data_ptr((char*) std::malloc(size));
- else {
- char* ptr = (char*) mmap(nullptr, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, -1, 0);
- if (ptr == MAP_FAILED)
- throw std::bad_alloc();
- simgrid::mc::data_deleter deleter(
- simgrid::mc::data_deleter::Munmap, size);
- data = simgrid::mc::RegionSnapshot::flat_data_ptr(ptr, deleter);
- }
+ simgrid::mc::buffer::Type buffer_type;
+ if (_sg_mc_ksm)
+ // We use mmap to allocate the memory in order to madvise it.
+ // We don't want to madvise the main heap.
+ // Moreover we get aligned pgaes which is merge-friendly.
+ buffer_type = simgrid::mc::buffer::Type::Mmap;
+ else
+ buffer_type = simgrid::mc::buffer::Type::Malloc;
+
+ simgrid::mc::buffer data(size, buffer_type);
+
mc_model_checker->process().read_bytes(data.get(), size,
remote(permanent_addr),
simgrid::mc::ProcessIndexDisabled);
+
if (_sg_mc_ksm)
// Mark the region as mergeable *after* we have written into it.
// There no point to let KSM do the hard work before that.
region.flat_data(std::move(data));
XBT_DEBUG("New region : type : %s, data : %p (real addr %p), size : %zu",
- to_cstr(region_type), region.flat_data(), permanent_addr, size);
+ to_cstr(region_type), region.flat_data().get(), permanent_addr, size);
return std::move(region);
}
Privatized = 3
};
-class data_deleter {
+class buffer {
public:
- enum Type {
- Free,
- Munmap
+ enum class Type {
+ Malloc,
+ Mmap
};
private:
- Type type_;
+ void* data_ = nullptr;
std::size_t size_;
+ Type type_ = Type::Malloc;
public:
- data_deleter() : type_(Free) {}
- data_deleter(Type type, std::size_t size) : type_(type), size_(size) {}
- void operator()(void* p) const;
-};
+ buffer() {}
+ buffer(std::size_t size, Type type = Type::Malloc);
+ buffer(void* data, std::size_t size, Type type = Type::Malloc) :
+ data_(data), size_(size), type_(type) {}
+ void clear() noexcept;
+ ~buffer() noexcept { clear(); }
+
+ // No copy
+ buffer(buffer const& buffer) = delete;
+ buffer& operator=(buffer const& buffer) = delete;
+
+ // Move
+ buffer(buffer&& that) noexcept
+ : data_(that.data_), size_(that.size_), type_(that.type_)
+ {
+ that.data_ = nullptr;
+ that.size_ = 0;
+ that.type_ = Type::Malloc;
+ }
+ buffer& operator=(buffer&& that) noexcept
+ {
+ clear();
+ data_ = that.data_;
+ size_ = that.size_;
+ type_ = that.type_;
+ that.data_ = nullptr;
+ that.size_ = 0;
+ that.type_ = Type::Malloc;
+ return *this;
+ }
-typedef std::unique_ptr<char[], data_deleter> unique_data_ptr;
+ void* get() { return data_; }
+ const void* get() const { return data_; }
+ std::size_t size() const { return size_; }
+ Type type() const { return type_; }
+};
/** A copy/snapshot of a given memory region
*
static const RegionType UnknownRegion = RegionType::Unknown;
static const RegionType HeapRegion = RegionType::Heap;
static const RegionType DataRegion = RegionType::Data;
-public:
- typedef unique_data_ptr flat_data_ptr;
private:
RegionType region_type_;
StorageType storage_type_;
* */
void *permanent_addr_;
- flat_data_ptr flat_data_;
+ buffer flat_data_;
ChunkedData page_numbers_;
std::vector<RegionSnapshot> privatized_regions_;
public:
storage_type_ = StorageType::NoData;
privatized_regions_.clear();
page_numbers_.clear();
- flat_data_.reset();
+ flat_data_.clear();
object_info_ = nullptr;
start_addr_ = nullptr;
size_ = 0;
void clear_data()
{
storage_type_ = StorageType::NoData;
- flat_data_.reset();
+ flat_data_.clear();
page_numbers_.clear();
privatized_regions_.clear();
}
- void flat_data(flat_data_ptr data)
+ void flat_data(buffer data)
{
storage_type_ = StorageType::Flat;
flat_data_ = std::move(data);
page_numbers_.clear();
privatized_regions_.clear();
}
- const char* flat_data() const { return flat_data_.get(); }
+ const buffer& flat_data() const { return flat_data_; }
+ buffer& flat_data() { return flat_data_; }
void page_data(ChunkedData page_data)
{
storage_type_ = StorageType::Chunked;
- flat_data_.reset();
+ flat_data_.clear();
page_numbers_ = std::move(page_data);
privatized_regions_.clear();
}
void privatized_data(std::vector<RegionSnapshot> data)
{
storage_type_ = StorageType::Privatized;
- flat_data_.reset();
+ flat_data_.clear();
page_numbers_.clear();
privatized_regions_ = std::move(data);
}
break;
case simgrid::mc::StorageType::Flat:
- mc_model_checker->process().write_bytes(region->flat_data(),
+ mc_model_checker->process().write_bytes(region->flat_data().get(),
region->size(), region->permanent_address());
break;
#include "xbt/mmalloc.h"
#include "src/xbt/mmalloc/mmprivate.h"
-#include "src/xbt/probes.h"
-
using simgrid::mc::remote;
extern "C" {
(char *) current_var.address, snapshot2, r2,
bvariable_type, 0);
if (res == 1) {
- XBT_TRACE3(mc, global_diff, -1, -1, current_var->name);
XBT_VERB("Global variable %s (%p) is different between snapshots",
current_var.name.c_str(),
(char *) current_var.address);
if (res == 1) {
// TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
- XBT_TRACE3(mc, local_diff, -1, -1, current_var1->name);
XBT_VERB
("Local variable %s (%p - %p) in frame %s "
"is different between snapshots",
if (_sg_mc_hash) {
hash_result = (s1->hash != s2->hash);
if (hash_result) {
- XBT_TRACE2(mc, hash_diff, num1, num2);
XBT_VERB("(%d - %d) Different hash : 0x%" PRIx64 "--0x%" PRIx64, num1,
num2, s1->hash, s2->hash);
#ifndef MC_DEBUG
/* Compare enabled processes */
if (s1->enabled_processes != s2->enabled_processes) {
- //XBT_TRACE3(mc, state_diff, num1, num2, "Different enabled processes");
XBT_VERB("(%d - %d) Different enabled processes", num1, num2);
// return 1; ??
}
XBT_VERB("(%d - %d) Different size used in stacks : %zu - %zu", num1,
num2, size_used1, size_used2);
#endif
- XBT_TRACE3(mc, state_diff, num1, num2, "Different stack size");
return 1;
#endif
}
errors++;
#else
#ifdef MC_VERBOSE
- XBT_TRACE3(mc, state_diff, num1, num2, "Different heap information");
XBT_VERB("(%d - %d) Different heap information", num1, num2);
#endif
else diff_local =
compare_local_variables(stack1->process_index, s1, s2, stack1, stack2);
if (diff_local > 0) {
- XBT_TRACE3(mc, state_diff, num1, num2, "Different local variables");
#ifdef MC_DEBUG
XBT_DEBUG("(%d - %d) Different local variables between stacks %d", num1,
num2, cursor + 1);
s1, s2);
if (is_diff != 0) {
- XBT_TRACE3(mc, state_diff, num1, num2, "Different global variables");
#ifdef MC_DEBUG
XBT_DEBUG("(%d - %d) Different global variables in %s",
num1, num2, name.c_str());
/* Compare heap */
if (mmalloc_compare_heap(s1, s2) > 0) {
- XBT_TRACE3(mc, state_diff, num1, num2, "Different heap");
#ifdef MC_DEBUG
XBT_DEBUG("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
case simgrid::mc::StorageType::Flat:
{
uintptr_t offset = (uintptr_t) addr - (uintptr_t) region->start().address();
- return (void *) ((uintptr_t) region->flat_data() + offset);
+ return (void *) ((uintptr_t) region->flat_data().get() + offset);
}
case simgrid::mc::StorageType::Chunked:
xbt_die("Storage type not supported");
case simgrid::mc::StorageType::Flat:
- return (char*) region->flat_data() + offset;
+ return (char*) region->flat_data().get() + offset;
case simgrid::mc::StorageType::Chunked:
{
}
xbt_dict_t MSG_environment_as_get_routing_sons(msg_as_t as) {
- xbt_dict_t res = surf_AS_get_routing_sons(as);
+ xbt_dict_t res = surf_AS_get_children(as);
return res;
}
{
xbt_ex_t e;
simdata_task_t simdata = task->simdata;
- msg_process_t self = SIMIX_process_self();
- simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data(self);
+ simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data();
e_smx_state_t comp_state;
msg_error_t status = MSG_OK;
/* Prepare the task to send */
t_simdata = task->simdata;
t_simdata->sender = process;
- t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
+ t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data())->m_host;
if (t_simdata->isused != 0) {
if (msg_global->debug_multiple_use){
msg_error_t ret = MSG_OK;
simdata_task_t t_simdata = NULL;
msg_process_t process = MSG_process_self();
- simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data(process);
+ simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data();
int call_end = TRACE_msg_task_put_start(task); //must be after CHECK_HOST()
/* Prepare the task to send */
t_simdata = task->simdata;
t_simdata->sender = process;
- t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
+ t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data())->m_host;
if (t_simdata->isused != 0) {
if (msg_global->debug_multiple_use){
// get the MSG process from the SIMIX process
if (smx_proc == SIMIX_process_self()) {
/* avoid a SIMIX request if this function is called by the process itself */
- msg_proc = (simdata_process_t) SIMIX_process_self_get_data(smx_proc);
- SIMIX_process_self_set_data(smx_proc, NULL);
+ msg_proc = (simdata_process_t) SIMIX_process_self_get_data();
+ SIMIX_process_self_set_data(NULL);
} else {
msg_proc = (simdata_process_t) simcall_process_get_data(smx_proc);
simcall_process_set_data(smx_proc, NULL);
{
simdata_process_t simdata;
if (process == NULL) {
- simdata = (simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self());
+ simdata = (simdata_process_t) SIMIX_process_self_get_data();
}
else {
simdata = (simdata_process_t) simcall_process_get_data(process);
+++ /dev/null
-TRACEPOINT_EVENT(
- mc,
- state_diff,
- TP_ARGS(
- int, state1,
- int, state2,
- char*, message
- ),
- TP_FIELDS(
- ctf_integer(int, state1, state1)
- ctf_integer(int, state2, state2)
- ctf_string(message, message)
- )
-)
-TRACEPOINT_LOGLEVEL(mc, state_diff, TRACE_INFO)
-
-TRACEPOINT_EVENT(
- mc,
- hash_diff,
- TP_ARGS(
- int, state1,
- int, state2
- ),
- TP_FIELDS(
- ctf_integer(int, state1, state1)
- ctf_integer(int, state2, state2)
- )
-)
-TRACEPOINT_LOGLEVEL(mc, hash_diff, TRACE_INFO)
-
-TRACEPOINT_EVENT(
- mc,
- global_diff,
- TP_ARGS(
- int, state1,
- int, state2,
- char*, variable
- ),
- TP_FIELDS(
- ctf_integer(int, state1, state1)
- ctf_integer(int, state2, state2)
- ctf_string(variable, variable)
- )
-)
-TRACEPOINT_LOGLEVEL(mc, global_diff, TRACE_INFO)
-
-TRACEPOINT_EVENT(
- mc,
- local_diff,
- TP_ARGS(
- int, state1,
- int, state2,
- char*, variable
- ),
- TP_FIELDS(
- ctf_integer(int, state1, state1)
- ctf_integer(int, state2, state2)
- ctf_string(variable, variable)
- )
-)
-TRACEPOINT_LOGLEVEL(mc, local_diff, TRACE_INFO)
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor,"S4U actors");
/* C main function of a actor, running this->main */
-static int s4u_actor_runner(int argc, char **argv) {
-
- smx_process_t smx_proc = SIMIX_process_self();
- simgrid::s4u::Actor *actor = (simgrid::s4u::Actor*) SIMIX_process_self_get_data(smx_proc);
+static int s4u_actor_runner(int argc, char **argv)
+{
+ simgrid::s4u::Actor *actor = (simgrid::s4u::Actor*) SIMIX_process_self_get_data();
int res = actor->main(argc,argv);
return res;
}
fprintf(stderr,"Error: You should override the method main(int, char**) in Actor class %s\n",getName());
return 0;
}
-s4u::Actor *s4u::Actor::current() {
+s4u::Actor *s4u::Actor::current()
+{
smx_process_t smx_proc = SIMIX_process_self();
- simgrid::s4u::Actor* res = (simgrid::s4u::Actor*) SIMIX_process_self_get_data(smx_proc);
+ simgrid::s4u::Actor* res = (simgrid::s4u::Actor*) SIMIX_process_self_get_data();
if (res == NULL) // The smx_process was not created by S4U (but by deployment?). Embed it in a S4U object
res = new Actor(smx_proc);
return res;
}
-s4u::Actor *s4u::Actor::byPid(int pid) {
- return (simgrid::s4u::Actor*) SIMIX_process_self_get_data(SIMIX_process_from_PID(pid));
-}
void s4u::Actor::setAutoRestart(bool autorestart) {
simcall_process_auto_restart_set(p_smx_process,autorestart);
return self->ppid;
}
-void* SIMIX_process_self_get_data(smx_process_t self)
+void* SIMIX_process_self_get_data()
{
- xbt_assert(self == SIMIX_process_self(), "This is not the current process");
+ smx_process_t self = SIMIX_process_self();
if (!self) {
return NULL;
return SIMIX_process_get_data(self);
}
-void SIMIX_process_self_set_data(smx_process_t self, void *data)
+void SIMIX_process_self_set_data(void *data)
{
- xbt_assert(self == SIMIX_process_self(), "This is not the current process");
+ smx_process_t self = SIMIX_process_self();
SIMIX_process_set_data(self, data);
}
smpi_process_data_t smpi_process_data(void)
{
- simdata_process_t simdata = static_cast<simdata_process_t>(SIMIX_process_self_get_data(SIMIX_process_self()));
+ simdata_process_t simdata = static_cast<simdata_process_t>(SIMIX_process_self_get_data());
return static_cast<smpi_process_data_t>(simdata->data);
}
return;
}
XBT_DEBUG ("Graph extraction for routing_component = %s", rc->name_);
- if (!xbt_dict_is_empty(rc->sons_)){
+ if (!xbt_dict_is_empty(rc->children_)){
xbt_dict_cursor_t cursor = NULL;
AS_t rc_son;
char *child_name;
//bottom-up recursion
- xbt_dict_foreach(surf_AS_get_routing_sons(rc), cursor, child_name, rc_son) {
+ xbt_dict_foreach(surf_AS_get_children(rc), cursor, child_name, rc_son) {
container_t child_container = (container_t) xbt_dict_get (
container->children, surf_AS_get_name(rc_son));
recursiveGraphExtraction (rc_son, child_container, filter);
static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges,
AS_t rc, container_t container)
{
- if (!xbt_dict_is_empty(surf_AS_get_routing_sons(rc))){
+ if (!xbt_dict_is_empty(surf_AS_get_children(rc))){
xbt_dict_cursor_t cursor = NULL;
AS_t rc_son;
char *child_name;
//bottom-up recursion
- xbt_dict_foreach(surf_AS_get_routing_sons(rc), cursor, child_name, rc_son) {
+ xbt_dict_foreach(surf_AS_get_children(rc), cursor, child_name, rc_son) {
container_t child_container = (container_t) xbt_dict_get (
container->children, surf_AS_get_name(rc_son));
recursiveXBTGraphExtraction (graph, nodes, edges, rc_son, child_container);
{}
As::~As()
{
- xbt_dict_free(&sons_);
+ xbt_dict_cursor_t cursor = NULL;
+ char *key;
+ AS_t elem;
+ xbt_dict_foreach(children_, cursor, key, elem) {
+ delete (As*)elem;
+ }
+
+
+ xbt_dict_free(&children_);
xbt_dynar_free(&vertices_);
xbt_dynar_free(&upDownLinks);
- if (nullptr != bypassRoutes_)
- for (auto &kv : *bypassRoutes_)
- delete kv.second;
- delete bypassRoutes_;
+ for (auto &kv : bypassRoutes_)
+ delete kv.second;
xbt_free(name_);
delete netcard_;
}
{
// If never set a bypass route return NULL without any further computations
XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name(), dst->name());
- if (bypassRoutes_ == nullptr)
+ if (bypassRoutes_.empty())
return nullptr;
std::vector<Link*> *bypassedRoute = nullptr;
if(dst->containingAS() == this && src->containingAS() == this ){
char *route_name = bprintf("%s#%s", src->name(), dst->name());
- if (bypassRoutes_->find(route_name) != bypassRoutes_->end()) {
- bypassedRoute = bypassRoutes_->at(route_name);
+ if (bypassRoutes_.find(route_name) != bypassRoutes_.end()) {
+ bypassedRoute = bypassRoutes_.at(route_name);
XBT_DEBUG("Found a bypass route with %zu links",bypassedRoute->size());
}
free(route_name);
char *route_name = bprintf("%s#%s",
(*(As **) (xbt_dynar_get_ptr(path_src, i)))->name_,
(*(As **) (xbt_dynar_get_ptr(path_dst, max)))->name_);
- if (bypassRoutes_->find(route_name) != bypassRoutes_->end())
- bypassedRoute = bypassRoutes_->at(route_name);
+ if (bypassRoutes_.find(route_name) != bypassRoutes_.end())
+ bypassedRoute = bypassRoutes_.at(route_name);
xbt_free(route_name);
}
if (bypassedRoute)
char *route_name = bprintf("%s#%s",
(*(As **) (xbt_dynar_get_ptr(path_src, max)))->name_,
(*(As **) (xbt_dynar_get_ptr(path_dst, i)))->name_);
- if (bypassRoutes_->find(route_name) != bypassRoutes_->end())
- bypassedRoute = bypassRoutes_->at(route_name);
+ if (bypassRoutes_.find(route_name) != bypassRoutes_.end())
+ bypassedRoute = bypassRoutes_.at(route_name);
xbt_free(route_name);
}
if (bypassedRoute)
(*(As **) (xbt_dynar_get_ptr(path_src, max)))->name_,
(*(As **) (xbt_dynar_get_ptr(path_dst, max)))->name_);
- if (bypassRoutes_->find(route_name) != bypassRoutes_->end())
- bypassedRoute = bypassRoutes_->at(route_name);
+ if (bypassRoutes_.find(route_name) != bypassRoutes_.end())
+ bypassedRoute = bypassRoutes_.at(route_name);
xbt_free(route_name);
}
if (bypassedRoute)
const char *src = e_route->src;
const char *dst = e_route->dst;
- if(bypassRoutes_ == nullptr)
- bypassRoutes_ = new std::map<std::string, std::vector<Link*>*>();
-
char *route_name = bprintf("%s#%s", src, dst);
/* Argument validity checks */
src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
- xbt_assert(bypassRoutes_->find(route_name) == bypassRoutes_->end(),
- "The bypass route between %s@%s and %s@%s already exists.",
+ xbt_assert(bypassRoutes_.find(route_name) == bypassRoutes_.end(), "The bypass route between %s@%s and %s@%s already exists.",
src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
} else {
XBT_DEBUG("Load bypassRoute from %s to %s", src, dst);
- xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", src, dst);
- xbt_assert(bypassRoutes_->find(route_name) == bypassRoutes_->end(), "The bypass route between %s and %s already exists.", src, dst);
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", src, dst);
+ xbt_assert(bypassRoutes_.find(route_name) == bypassRoutes_.end(), "The bypass route between %s and %s already exists.", src, dst);
}
/* Build a copy that will be stored in the dict */
newRoute->push_back(link);
/* Store it */
- bypassRoutes_->insert({route_name, newRoute});
+ bypassRoutes_.insert({route_name, newRoute});
xbt_free(route_name);
}
netcard->setId(-1);
} else if (current_routing != NULL && routing_platf->root_ != NULL) {
- xbt_assert(!xbt_dict_get_or_null(current_routing->sons_, AS->id),
+ xbt_assert(!xbt_dict_get_or_null(current_routing->children_, AS->id),
"The AS \"%s\" already exists", AS->id);
/* it is a part of the tree */
new_as->father_ = current_routing;
if (current_routing->hierarchy_ == SURF_ROUTING_NULL)
current_routing->hierarchy_ = SURF_ROUTING_RECURSIVE;
/* add to the sons dictionary */
- xbt_dict_set(current_routing->sons_, AS->id,
- (void *) new_as, NULL);
+ xbt_dict_set(current_routing->children_, AS->id, (void *) new_as, NULL);
/* add to the father element list */
netcard->setId(current_routing->addComponent(netcard));
} else {
*
* Once you've declared all the content of your AS, you have to close
* it with this call. Your AS is not usable until you call this function.
- *
- * @fixme: this call is not as robust as wanted: bad things WILL happen
- * if you call it twice for the same AS, or if you forget calling it, or
- * even if you add stuff to a closed AS
- *
*/
void routing_AS_end()
{
current_routing = current_routing->father_;
}
-/* Aux Business methods */
-
/**
* \brief Get the AS father and the first elements of the chain
*
* father in the chain
*/
static void elements_father(sg_netcard_t src, sg_netcard_t dst,
- AS_t * res_father,
- AS_t * res_src,
- AS_t * res_dst)
+ AS_t * res_father, AS_t * res_src, AS_t * res_dst)
{
xbt_assert(src && dst, "bad parameters for \"elements_father\" method");
#define ROUTING_HIERARCHY_MAXDEPTH 16 /* increase if it is not enough */
char *key;
xbt_dict_cursor_t cursor = NULL;
AS_t rc_child;
- xbt_dict_foreach(rc->sons_, cursor, key, rc_child) {
+ xbt_dict_foreach(rc->children_, cursor, key, rc_child) {
xbt_dynar_t onelink_child = _recursiveGetOneLinkRoutes(rc_child);
if (onelink_child)
xbt_dynar_merge(&ret,&onelink_child);
free(link_down);
}
-// static void routing_parse_Srandom(void)
-// {
-// double mean, std, min, max, seed;
-// char *random_id = A_surfxml_random_id;
-// char *random_radical = A_surfxml_random_radical;
-// char *rd_name = NULL;
-// char *rd_value;
-// mean = surf_parse_get_double(A_surfxml_random_mean);
-// std = surf_parse_get_double(A_surfxml_random_std___deviation);
-// min = surf_parse_get_double(A_surfxml_random_min);
-// max = surf_parse_get_double(A_surfxml_random_max);
-// seed = surf_parse_get_double(A_surfxml_random_seed);
-
-// double res = 0;
-// int i = 0;
-// random_data_t random = xbt_new0(s_random_data_t, 1);
-// char *tmpbuf;
-
-// xbt_dynar_t radical_elements;
-// unsigned int iter;
-// char *groups;
-// int start, end;
-// xbt_dynar_t radical_ends;
-
-// switch (A_surfxml_random_generator) {
-// case AU_surfxml_random_generator:
-// case A_surfxml_random_generator_NONE:
-// random->generator = NONE;
-// break;
-// case A_surfxml_random_generator_DRAND48:
-// random->generator = DRAND48;
-// break;
-// case A_surfxml_random_generator_RAND:
-// random->generator = RAND;
-// break;
-// case A_surfxml_random_generator_RNGSTREAM:
-// random->generator = RNGSTREAM;
-// break;
-// default:
-// surf_parse_error("Invalid random generator");
-// break;
-// }
-// random->seed = seed;
-// random->min = min;
-// random->max = max;
-
-// /* Check user stupidities */
-// if (max < min)
-// THROWF(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
-// if (mean < min)
-// THROWF(arg_error, 0, "random->mean < random->min (%f < %f)", mean, min);
-// if (mean > max)
-// THROWF(arg_error, 0, "random->mean > random->max (%f > %f)", mean, max);
-
-// /* normalize the mean and standard deviation before storing */
-// random->mean = (mean - min) / (max - min);
-// random->std = std / (max - min);
-
-// if (random->mean * (1 - random->mean) < random->std * random->std)
-// THROWF(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
-// random->mean, random->std);
-
-// XBT_DEBUG
-// ("id = '%s' min = '%f' max = '%f' mean = '%f' std_deviatinon = '%f' generator = '%d' seed = '%ld' radical = '%s'",
-// random_id, random->min, random->max, random->mean, random->std,
-// (int)random->generator, random->seed, random_radical);
-
-// if (!random_value)
-// random_value = xbt_dict_new_homogeneous(free);
-
-// if (!strcmp(random_radical, "")) {
-// res = random_generate(random);
-// rd_value = bprintf("%f", res);
-// xbt_dict_set(random_value, random_id, rd_value, NULL);
-// } else {
-// radical_elements = xbt_str_split(random_radical, ",");
-// xbt_dynar_foreach(radical_elements, iter, groups) {
-// radical_ends = xbt_str_split(groups, "-");
-// switch (xbt_dynar_length(radical_ends)) {
-// case 1:
-// xbt_assert(!xbt_dict_get_or_null(random_value, random_id),
-// "Custom Random '%s' already exists !", random_id);
-// res = random_generate(random);
-// tmpbuf =
-// bprintf("%s%d", random_id,
-// atoi(xbt_dynar_getfirst_as(radical_ends, char *)));
-// xbt_dict_set(random_value, tmpbuf, bprintf("%f", res), NULL);
-// xbt_free(tmpbuf);
-// break;
-
-// case 2:
-// start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
-// end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
-// for (i = start; i <= end; i++) {
-// xbt_assert(!xbt_dict_get_or_null(random_value, random_id),
-// "Custom Random '%s' already exists !", bprintf("%s%d",
-// random_id,
-// i));
-// res = random_generate(random);
-// tmpbuf = bprintf("%s%d", random_id, i);
-// xbt_dict_set(random_value, tmpbuf, bprintf("%f", res), NULL);
-// xbt_free(tmpbuf);
-// }
-// break;
-// default:
-// XBT_CRITICAL("Malformed radical");
-// break;
-// }
-// res = random_generate(random);
-// rd_name = bprintf("%s_router", random_id);
-// rd_value = bprintf("%f", res);
-// xbt_dict_set(random_value, rd_name, rd_value, NULL);
-
-// xbt_dynar_free(&radical_ends);
-// }
-// free(rd_name);
-// xbt_dynar_free(&radical_elements);
-// }
-// }
-
static void check_disk_attachment()
{
xbt_lib_cursor_t cursor;
instr_routing_define_callbacks();
}
-/**
- * \brief Recursive function for finalize
- *
- * \param rc the source host name
- *
- * This fuction is call by "finalize". It allow to finalize the
- * AS or routing components. It delete all the structures.
- */
-static void finalize_rec(simgrid::surf::As *as) {
- xbt_dict_cursor_t cursor = NULL;
- char *key;
- AS_t elem;
-
- xbt_dict_foreach(as->sons_, cursor, key, elem) {
- finalize_rec(elem);
- }
-
- delete as;;
-}
-
/** \brief Frees all memory allocated by the routing module */
void routing_exit(void) {
delete routing_platf;
}
RoutingPlatf::~RoutingPlatf()
{
- xbt_dynar_free(&lastRoute_);
- finalize_rec(root_);
+ delete root_;
}
}
return as->name_;
}
-static simgrid::surf::As *surf_AS_recursive_get_by_name(
- simgrid::surf::As *current, const char * name)
+static simgrid::surf::As *surf_AS_recursive_get_by_name(simgrid::surf::As *current, const char * name)
{
xbt_dict_cursor_t cursor = NULL;
char *key;
if(!strcmp(current->name_, name))
return current;
- xbt_dict_foreach(current->sons_, cursor, key, elem) {
+ xbt_dict_foreach(current->children_, cursor, key, elem) {
tmp = surf_AS_recursive_get_by_name(elem, name);
if(tmp != NULL ) {
break;
return as;
}
-xbt_dict_t surf_AS_get_routing_sons(simgrid::surf::As *as)
+xbt_dict_t surf_AS_get_children(simgrid::surf::As *as)
{
- return as->sons_;
+ return as->children_;
}
xbt_dynar_t surf_AS_get_hosts(simgrid::surf::As *as)
char *name_ = nullptr;
NetCard *netcard_ = nullptr; // Our representative in the father AS
As *father_ = nullptr;
- xbt_dict_t sons_ = xbt_dict_new_homogeneous(NULL); // sub-ASes
+ xbt_dict_t children_ = xbt_dict_new_homogeneous(NULL); // sub-ASes
xbt_dynar_t vertices_ = xbt_dynar_new(sizeof(char*),NULL); // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
private:
bool sealed_ = false; // We cannot add more content when sealed
- std::map<std::string, std::vector<Link*>*> *bypassRoutes_ = nullptr;
+ std::map<std::string, std::vector<Link*>*> bypassRoutes_;
public:
/**
};
/** @ingroup SURF_routing_interface
- * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the ns3 bindings
+ * @brief Link of length 1, alongside with its source and destination. This is mainly useful in the ns3 bindings
*/
class Onelink {
public:
~RoutingPlatf();
As *root_ = nullptr;
Link *loopback_;
- xbt_dynar_t lastRoute_ = xbt_dynar_new(sizeof(Link*),NULL);
xbt_dynar_t getOneLinkRoutes(void);
void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
};
namespace simgrid {
namespace surf {
+ xbt_dynar_t AsRoutedGraph::getOneLinkRoutes()
+ {
+ xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
+ sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
+ route->link_list = new std::vector<Link*>();
+
+ int table_size = (int)xbt_dynar_length(vertices_);
+ for(int src=0; src < table_size; src++) {
+ for(int dst=0; dst< table_size; dst++) {
+ route->link_list->clear();
+ NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+ NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
+ this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
+
+ if (route->link_list->size() == 1) {
+ Link *link = route->link_list->at(0);
+ Onelink *onelink;
+ if (hierarchy_ == SURF_ROUTING_BASE)
+ onelink = new Onelink(link, src_elm, dst_elm);
+ else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
+ onelink = new Onelink(link, route->gw_src, route->gw_dst);
+ else
+ onelink = new Onelink(link, NULL, NULL);
+ xbt_dynar_push(ret, &onelink);
+ }
+ }
+ }
+ return ret;
+ }
+
void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
{
int src, dst;
AsRoutedGraph(const char*name);
~AsRoutedGraph();
+ xbt_dynar_t getOneLinkRoutes() override;
+
virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
virtual sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
protected:
xbt_graph_new_edge(routeGraph_, src, dst, e_route);
}
-xbt_dynar_t AsDijkstra::getOneLinkRoutes()
-{
- xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
- sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
- route->link_list = new std::vector<Link*>();
-
- int table_size = (int)xbt_dynar_length(vertices_);
- for(int src=0; src < table_size; src++) {
- for(int dst=0; dst< table_size; dst++) {
- route->link_list->clear();
- NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
- NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
- this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
-
- if (route->link_list->size() == 1) {
- Link *link = route->link_list->at(0);
- Onelink *onelink;
- if (hierarchy_ == SURF_ROUTING_BASE)
- onelink = new Onelink(link, src_elm, dst_elm);
- else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
- onelink = new Onelink(link, route->gw_src, route->gw_dst);
- else
- onelink = new Onelink(link, NULL, NULL);
- xbt_dynar_push(ret, &onelink);
- }
- }
- }
- return ret;
-}
-
void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
getRouteCheckParams(src, dst);
* will have a loopback attached to it.
*/
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat) override;
- void getRouteAndLatency(sg_platf_route_cbarg_t route, double *lat); // FIXME: this function is dangerously not overriding because of diverging prototype
- xbt_dynar_t getOneLinkRoutes() override;
void addRoute(sg_platf_route_cbarg_t route) override;
xbt_graph_t routeGraph_ = nullptr; /* xbt_graph */
xbt_free(costTable_);
}
-/* Business methods */
-xbt_dynar_t AsFloyd::getOneLinkRoutes()
-{
- xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
- sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
- route->link_list = new std::vector<Link*>();
-
- int table_size = xbt_dynar_length(vertices_);
- for(int src=0; src < table_size; src++) {
- for(int dst=0; dst< table_size; dst++) {
- route->link_list->clear();
- NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
- NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
- this->getRouteAndLatency(src_elm, dst_elm, route, NULL);
-
- if (route->link_list->size() == 1) {
- void *link = route->link_list->at(0);
- Onelink *onelink;
- if (hierarchy_ == SURF_ROUTING_BASE)
- onelink = new Onelink(link, src_elm, dst_elm);
- else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
- onelink = new Onelink(link, route->gw_src, route->gw_dst);
- else
- onelink = new Onelink(link, NULL, NULL);
- xbt_dynar_push(ret, &onelink);
- }
- }
- }
-
- return ret;
-}
-
void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
-
size_t table_size = xbt_dynar_length(vertices_);
getRouteCheckParams(src, dst);
~AsFloyd();
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
- xbt_dynar_t getOneLinkRoutes() override;
void addRoute(sg_platf_route_cbarg_t route) override;
void Seal() override;
}
}
-xbt_dynar_t AsFull::getOneLinkRoutes()
-{
- xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
-
- int src, dst;
- int table_size = xbt_dynar_length(vertices_);
-
- for(src=0; src < table_size; src++) {
- for(dst=0; dst< table_size; dst++) {
- sg_platf_route_cbarg_t route = TO_ROUTE_FULL(src,dst);
- if (route) {
- if (route->link_list->size() == 1) {
- Link *link = route->link_list->at(0);
- Onelink *onelink;
- if (hierarchy_ == SURF_ROUTING_BASE) {
- NetCard *tmp_src = xbt_dynar_get_as(vertices_, src, sg_netcard_t);
- tmp_src->setId(src);
- NetCard *tmp_dst = xbt_dynar_get_as(vertices_, dst, sg_netcard_t);
- tmp_dst->setId(dst);
- onelink = new Onelink(link, tmp_src, tmp_dst);
- } else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
- onelink = new Onelink(link, route->gw_src, route->gw_dst);
- else
- onelink = new Onelink(link, NULL, NULL);
- xbt_dynar_push(ret, &onelink);
- XBT_DEBUG("Push route from '%d' to '%d'",
- src,
- dst);
- }
- }
- }
- }
- return ret;
-}
-
void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat)
{
XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]",
- src->name(),
- src->id(),
- dst->name(),
- dst->id());
+ src->name(), src->id(), dst->name(), dst->id());
/* set utils vars */
size_t table_size = xbt_dynar_length(vertices_);
~AsFull();
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
- xbt_dynar_t getOneLinkRoutes() override;
void addRoute(sg_platf_route_cbarg_t route) override;
sg_platf_route_cbarg_t *routingTable_ = nullptr;
AsVivaldi(const char *name);
~AsVivaldi() {};
+ xbt_dynar_t getOneLinkRoutes() override {return NULL;};
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
};
+++ /dev/null
-/* Copyright (c) 2014. The SimGrid Team.
- * All rights reserved. */
-
-/* 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. */
-
-#ifdef USE_UST
-# include <lttng/tracepoint.h>
-# include "simgrid_ust.h"
-# define XBT_TRACE0 tracepoint
-# define XBT_TRACE1 tracepoint
-# define XBT_TRACE2 tracepoint
-# define XBT_TRACE3 tracepoint
-# define XBT_TRACE4 tracepoint
-# define XBT_TRACE5 tracepoint
-# define XBT_TRACE6 tracepoint
-# define XBT_TRACE7 tracepoint
-# define XBT_TRACE8 tracepoint
-# define XBT_TRACE9 tracepoint
-# define XBT_TRACE10 tracepoint
-# define XBT_TRACE11 tracepoint
-# define XBT_TRACE12 tracepoint
-#elif USE_SDT
-# include <sys/sdt.h>
-# define XBT_TRACE0 DTRACE_PROBE0
-# define XBT_TRACE1 DTRACE_PROBE1
-# define XBT_TRACE2 DTRACE_PROBE2
-# define XBT_TRACE3 DTRACE_PROBE3
-# define XBT_TRACE4 DTRACE_PROBE4
-# define XBT_TRACE5 DTRACE_PROBE5
-# define XBT_TRACE6 DTRACE_PROBE6
-# define XBT_TRACE7 DTRACE_PROBE7
-# define XBT_TRACE8 DTRACE_PROBE8
-# define XBT_TRACE9 DTRACE_PROBE9
-# define XBT_TRACE10 DTRACE_PROBE10
-# define XBT_TRACE11 DTRACE_PROBE11
-# define XBT_TRACE12 DTRACE_PROBE12
-#else
-# define XBT_TRACE0(...)
-# define XBT_TRACE1(...)
-# define XBT_TRACE2(...)
-# define XBT_TRACE3(...)
-# define XBT_TRACE4(...)
-# define XBT_TRACE5(...)
-# define XBT_TRACE6(...)
-# define XBT_TRACE7(...)
-# define XBT_TRACE8(...)
-# define XBT_TRACE9(...)
-# define XBT_TRACE10(...)
-# define XBT_TRACE11(...)
-# define XBT_TRACE12(...)
-#endif
src/include/xbt/wine_dbghelp.h
src/msg/msg_private.h
src/portable.h
- src/probes.tp
src/simdag/dax.dtd
src/simdag/dax_dtd.c
src/simdag/dax_dtd.h
src/xbt/mmalloc/mmorecore.c
src/xbt/mmalloc/mmprivate.h
src/xbt/mmalloc/mrealloc.c
- src/xbt/probes.h
src/xbt/win32_ucontext.c
tools/tesh/generate_tesh
tools/lualib.patch
tools/cmake/Modules/FindLuaSimgrid.cmake
tools/cmake/Modules/FindNS3.cmake
tools/cmake/Modules/FindRngStream.cmake
- tools/cmake/Modules/FindRubySimgrid.cmake
tools/cmake/Modules/FindSimGrid.cmake
tools/cmake/Modules/FindValgrind.cmake
tools/cmake/Option.cmake
src/xbt/automaton/parserPromela.tab.hacc
)
-if(enable_ust)
- set(simgrid_sources ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.c ${simgrid_sources})
- ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.c
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.h
- COMMAND lttng-gen-tp -o simgrid_ust.c -o simgrid_ust.h ${CMAKE_CURRENT_SOURCE_DIR}/src/probes.tp
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src/
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/probes.tp
- )
- ADD_CUSTOM_TARGET(simgrid_ust
- DEPENDS
- ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.c
- ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.h
- )
- set(generated_src_files ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_ust.c ${generated_src_files})
-endif()
-
foreach(file ${generated_src_files})
set_source_files_properties(${file} PROPERTIES GENERATED true)
endforeach(file ${generated_src_files})
add_library(simgrid SHARED ${simgrid_sources})
set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
-if(enable_ust)
- ADD_DEPENDENCIES(simgrid simgrid_ust)
-endif()
-
add_dependencies(simgrid maintainer_files)
if(enable_model-checking)
SET(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo")
endif(HAVE_BACKTRACE_IN_LIBEXECINFO)
-# Dependencies from USR
-###################################
-if(enable_ust)
- set(SIMGRID_DEP "${SIMGRID_DEP} -llttng-ust")
-endif()
-
# Compute the dependencies of SMPI
##################################
if(enable_smpi AND APPLE)
+++ /dev/null
-include(FindRuby)
-
-if(RUBY_EXECUTABLE)
- message(STATUS "Found ruby: ${RUBY_EXECUTABLE}")
-endif()
-
-message(STATUS "Looking for ruby.h")
-if(RUBY_INCLUDE_DIR)
- message(STATUS "Looking for ruby.h - found")
-else()
- message(STATUS "Looking for ruby.h - not found")
-endif()
-
-message(STATUS "Looking for confi.h")
-if(RUBY_CONFIG_INCLUDE_DIR)
- message(STATUS "Looking for config.h - found")
-else()
- message(STATUS "Looking for config.h - not found")
-endif()
-
-message(STATUS "Looking for lib ruby")
-if(RUBY_LIBRARY)
- message(STATUS "Looking for lib ruby - found")
-else()
- message(STATUS "Looking for lib ruby - not found")
-endif()
-
-if(RUBY_LIBRARY)
- set(LIB_RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}")
- message(STATUS "Lib ruby version: ${LIB_RUBY_VERSION}")
- if(RUBY_VERSION_MAJOR MATCHES "1" AND RUBY_VERSION_MINOR MATCHES "9")
- string(REGEX MATCH "ruby.*[0-9]" RUBY_LIBRARY_NAME ${RUBY_LIBRARY})
- if(NOT RUBY_LIBRARY_NAME)
- set(RUBY_LIBRARY_NAME ruby)
- endif()
- string(REGEX REPLACE "/libruby.*$" "" RUBY_LIBRARY ${RUBY_LIBRARY})
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${RUBY_CONFIG_INCLUDE_DIR} ") #path to config.h
- string(COMPARE EQUAL "${RUBY_INCLUDE_DIR}" "${RUBY_CONFIG_INCLUDE_DIR}" operation)
- if(NOT operation)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${RUBY_INCLUDE_DIR} ") #path to ruby.h
- endif()
- ADD_DEFINITIONS("-I${CMAKE_HOME_DIRECTORY}/src/bindings/ruby -I${CMAKE_HOME_DIRECTORY}/src/simix")
- SET(HAVE_RUBY 1)
- else()
- message(STATUS "Warning: Ruby bindings need version 1.9.x, but found version ${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.x")
- SET(HAVE_RUBY 0)
- endif()
-else()
- SET(HAVE_RUBY 0)
-endif()
-
-if(NOT RUBY_EXECUTABLE)
- message(STATUS "Warning: you are missing the ruby executable, so you can compile and build examples but can't execute them!")
-endif()
\ No newline at end of file
option(enable_maintainer_mode "Whether flex and flexml files should be rebuilt." off)
option(enable_tracing "Tracing simulations for visualization." on)
option(enable_latency_bound_tracking "" off)
-
-option(enable_ust "Enable userspace static tracepoint (lttng-ust)." off)
-if(enable_sdt)
- add_definitions(-DUSE_SDT)
-endif()
-
-option(enable_sdt "Enable statically defined tracepoint (strace/systemtap)." off)
-if(enable_ust)
- add_definitions(-DUSE_UST)
-endif()
option(enable_coverage "Whether coverage should be enabled." off)
mark_as_advanced(enable_coverage)
-#!/usr/bin/env ruby
+#!/usr/bin/env python
# Wrapper around the real `as` which adds filtering capabilities.
-require "tempfile"
-require "fileutils"
-
-def wrapped_as(argv)
-
- args=[]
- input=nil
-
- i = 0
- while i<argv.size
- case argv[i]
- when "-o", "-I"
- args.push(argv[i])
- args.push(argv[i+1])
- i = i + 1
- when /^-/
- args.push(argv[i])
- else
- if input
- exit 1
- else
- input = argv[i]
- end
- end
+import os
+import re
+import subprocess
+import sys
+import tempfile
+
+# Process the arguments:
+# * build the argument array for calling the real assembler;
+# * get the input file name.
+args = []
+input_filename = None
+args.append('as')
+i = 1
+while i < len(sys.argv):
+ if sys.argv[i] == '-o' or sys.argv[i] == '-I':
+ args.append(sys.argv[i])
+ if i + 1 >= len(sys.argv):
+ sys.stderr.write("Missing argument\n")
+ sys.exit(1)
+ args.append(sys.argv[i + 1])
+ i = i + 1
+ elif re.match('^-', sys.argv[i][0]):
+ args.append(sys.argv[i])
+ elif input_filename:
+ sys.stdout.write("Too many input files\n")
+ sys.exit(1)
+ else:
+ input_filename = sys.argv[i]
i = i + 1
- end
-
- if input==nil
- # We dont handle pipe yet:
- exit 1
- end
-
- # Generate temp file
- tempfile = Tempfile.new("as-filter")
- tempfile.close
- script = File.dirname($0) + "/clean-stack-filter"
- unless system([script, script], 0 => input, 1 => tempfile.path)
- status=$?.exitstatus
- FileUtils.rm tempfile
- exit status
- end
- args.push(tempfile.path)
-
- # Call the real assembler:
- res = system("as", *args)
- status = if res != nil
- $?.exitstatus
- else
- 1
- end
- FileUtils.rm tempfile
- exit status
-
-end
-
-wrapped_as(ARGV)
+if input_filename == None:
+ sys.stderr.write("Missing input file\n")
+ sys.exit(1)
+
+temp_file, temp_filename = tempfile.mkstemp(suffix=".s", prefix="as_wrapper")
+try:
+ # Generate temporary file with modified assembly code:
+ script_file = os.path.join(
+ os.path.dirname(sys.argv[0]), "clean-stack-filter")
+ input_file = os.open(input_filename, os.O_RDONLY)
+ status = subprocess.call([script_file], stdin=input_file, stdout=temp_file)
+ os.close(input_file)
+ if status != 0:
+ sys.stderr.write("Filtering the assembly code failed.\n")
+ sys.exit(status)
+
+ # Call the real assembler on this modified assembly code:
+ args.append(temp_filename)
+ sys.exit(subprocess.call(args))
+finally:
+ os.remove(temp_filename)