cat > ${TMPSOURCE} <<HEADER
#define SEED ${SEED}
#include "smpi.h"
-#include "msg/msg.h"
+#include "simix/simix.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
#include "xbt/asserts.h"
grep -q "smpi_main" ${TMPSOURCE}
if [ $? -eq 0 ]; then
cat >> ${TMPSOURCE} <<FOOTER
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_simulation, "Messages specific to this simulation");
-int main(int argc, char *argv[]) {
- MSG_error_t result;
- srand(SEED);
- MSG_global_init(&argc, argv);
- MSG_set_channel_number(MAX_CHANNEL);
- MSG_function_register("smpi_main", smpi_main);
- MSG_function_register("smpi_sender", smpi_sender);
- MSG_function_register("smpi_receiver", smpi_receiver);
- MSG_create_environment(argv[1]);
- MSG_launch_application(argv[2]);
- result = MSG_main();
- INFO1("simulation time %g", MSG_get_clock());
- MSG_clean();
- return (MSG_OK != result);
+int main(int argc, char **argv) {
+ return smpi_run_simulation(&argc, argv);
}
FOOTER
fi
static int smpi_benchmarking;
static double smpi_reference;
+int smpi_run_simulation(int *argc, char **argv) {
+ smx_cond_t cond = NULL;
+ smx_action_t smx_action;
+ xbt_fifo_t actions_done = xbt_fifo_new();
+ xbt_fifo_t actions_failed = xbt_fifo_new();
+
+ srand(SEED);
+ SIMIX_global_init(&argc, argv);
+ SIMIX_function_register("smpi_main", smpi_main);
+ SIMIX_function_register("smpi_sender", smpi_sender);
+ SIMIX_function_register("smpi_receiver", smpi_receiver);
+ SIMIX_create_environment(argv[1]);
+ SIMIX_launch_application(argv[2]);
+
+ /* Prepare to display some more info when dying on Ctrl-C pressing */
+ signal(SIGINT,inthandler);
+
+ /* Clean IO before the run */
+ fflush(stdout);
+ fflush(stderr);
+
+ //surf_solve(); /* Takes traces into account. Returns 0.0 */
+ /* xbt_fifo_size(msg_global->process_to_run) */
+
+ while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
+
+ while ( (smx_action = xbt_fifo_pop(actions_failed)) ) {
+
+
+ DEBUG1("** %s failed **",smx_action->name);
+ while ( (cond = xbt_fifo_pop(smx_action->cond_list)) ) {
+ SIMIX_cond_broadcast(cond);
+ }
+ /* action finished, destroy it */
+ // SIMIX_action_destroy(smx_action);
+ }
+
+ while ( (smx_action = xbt_fifo_pop(actions_done)) ) {
+
+ DEBUG1("** %s done **",smx_action->name);
+ while ( (cond = xbt_fifo_pop(smx_action->cond_list)) ) {
+ SIMIX_cond_broadcast(cond);
+ }
+ /* action finished, destroy it */
+ //SIMIX_action_destroy(smx_action);
+ }
+ }
+ xbt_fifo_free(actions_failed);
+ xbt_fifo_free(actions_done);
+ INFO1("simulation time %g", SIMIX_get_clock());
+ SIMIX_clean();
+ return 0;
+}
+
void smpi_mpi_land_func(void *x, void *y, void *z) {
*(int *)z = *(int *)x && *(int *)y;
}
} else if (NULL == rank) {
retval = MPI_ERR_ARG;
} else {
- *rank = smpi_comm_rank(comm, MSG_host_self());
+ *rank = smpi_comm_rank(comm, SIMIX_host_self());
}
smpi_bench_begin();
return retval;
/*
int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm) {
int retval = MPI_SUCCESS;
- m_host_t host = MSG_host_self();
+ m_host_t host = SIMIX_host_self();
int rank = smpi_comm_rank(comm, host);
smpi_mpi_comm_split_table_node_t *split_table;
split_table = xbt_malloc(sizeof(smpi_mpi_comm_split_table_node_t) * comm->size);
int dst;
smpi_mpi_request_t *recvreq;
smpi_bench_end();
- dst = smpi_comm_rank(comm, MSG_host_self());
+ dst = smpi_comm_rank(comm, SIMIX_host_self());
retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, &recvreq);
if (NULL != recvreq) {
smpi_irecv(recvreq);
int dst;
smpi_mpi_request_t *recvreq;
smpi_bench_end();
- dst = smpi_comm_rank(comm, MSG_host_self());
+ dst = smpi_comm_rank(comm, SIMIX_host_self());
retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, &recvreq);
if (NULL != recvreq) {
smpi_irecv(recvreq);
int src;
smpi_mpi_request_t *sendreq;
smpi_bench_end();
- src = smpi_comm_rank(comm, MSG_host_self());
+ src = smpi_comm_rank(comm, SIMIX_host_self());
retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, &sendreq);
if (NULL != sendreq) {
smpi_isend(sendreq);
int src;
smpi_mpi_request_t *sendreq;
smpi_bench_end();
- src = smpi_comm_rank(comm, MSG_host_self());
+ src = smpi_comm_rank(comm, SIMIX_host_self());
retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, &sendreq);
if (NULL != sendreq) {
smpi_isend(sendreq);
smpi_mpi_request_t *request;
smpi_bench_end();
- rank = smpi_comm_rank(comm, MSG_host_self());
+ rank = smpi_comm_rank(comm, SIMIX_host_self());
if (root == rank) {
smpi_create_request(buf, count, datatype, root, (rank + 1) % comm->size, 0, comm, &request);
smpi_mpi_request_t **sendreqs, **recvreqs;
smpi_bench_end();
- rank = smpi_comm_rank(comm, MSG_host_self());
+ rank = smpi_comm_rank(comm, SIMIX_host_self());
sendreqs = xbt_malloc(sizeof(smpi_mpi_request_t*) * comm->size);
recvreqs = xbt_malloc(sizeof(smpi_mpi_request_t*) * comm->size);
void **scratchbuf;
smpi_bench_end();
- rank = smpi_comm_rank(comm, MSG_host_self());
+ rank = smpi_comm_rank(comm, SIMIX_host_self());
if (root == rank) {
requests = xbt_malloc(sizeof(smpi_mpi_request_t*) * comm->size);