Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
A lot has been moved over to simix, but getting rid of tasks requires
authormarkls <markls@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 28 Jun 2007 14:55:00 +0000 (14:55 +0000)
committermarkls <markls@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 28 Jun 2007 14:55:00 +0000 (14:55 +0000)
duplicating a lot of infrastructure...

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3608 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/smpi/scripts/smpicc
src/smpi/src/smpi_base.c
src/smpi/src/smpi_mpi.c

index 87700d6..4aefe17 100755 (executable)
@@ -21,7 +21,7 @@ function modsource {
   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"
@@ -33,21 +33,8 @@ HEADER
   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
index 66c5a7d..543a029 100644 (file)
@@ -35,6 +35,60 @@ static xbt_os_timer_t smpi_timer;
 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;
 }
index 4dc2648..924bbde 100644 (file)
@@ -45,7 +45,7 @@ int MPI_Comm_rank(MPI_Comm comm, int *rank) {
   } 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;
@@ -54,7 +54,7 @@ int MPI_Comm_rank(MPI_Comm comm, int *rank) {
 /*
 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);
@@ -113,7 +113,7 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
   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);
@@ -130,7 +130,7 @@ int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_
   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);
@@ -146,7 +146,7 @@ int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI
   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);
@@ -163,7 +163,7 @@ int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_
   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);
@@ -179,7 +179,7 @@ int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm co
   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);
@@ -214,7 +214,7 @@ int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recv
   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);
@@ -258,7 +258,7 @@ int MPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, M
   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);