Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SMPI: get the main process launch the sender and receiver ones (will ease passing...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 23 Jun 2009 19:49:54 +0000 (19:49 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 23 Jun 2009 19:49:54 +0000 (19:49 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6338 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/gras/Msg/gras_msg_listener.c
src/simix/smx_process.c
src/smpi/private.h
src/smpi/smpi_base.c
src/smpi/smpi_global.c
src/smpi/smpi_receiver.c
src/smpi/smpi_sender.c
src/smpi/smpirun.in

index 3bf7c63..846fbeb 100644 (file)
@@ -98,7 +98,7 @@ gras_msg_listener_t gras_msg_listener_launch(xbt_queue_t msg_exchange)
 
   /* actually start the thread */
   arg->listener = xbt_thread_create("listener", listener_function, arg);
-  gras_os_sleep(0);             /* TODO: useless? give the listener a chance to initialize even if the main is empty and we cancel it right afterward */
+  gras_os_sleep(0); /* TODO: useless? give the listener a chance to initialize even if the main is empty and we cancel it right afterward */
   return arg;
 }
 
index 0dad0f0..76643e8 100644 (file)
@@ -18,7 +18,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
 /**
  * \brief Creates and runs a new #smx_process_t.
  *
- * Does exactly the same as #SIMIX_process_create_with_arguments but without 
+ * Does exactly the same as #SIMIX_process_create_with_arguments but without
    providing standard arguments (\a argc, \a argv).
  * \see SIMIX_process_create_with_arguments
  */
@@ -39,7 +39,7 @@ void SIMIX_process_cleanup(void *arg)
   free(arg);
 }
 
-/** 
+/**
  * \brief Creates and runs a new #smx_process_t.
  *
  * A constructor for #m_process_t taking four arguments and returning the corresponding object. The structure (and the corresponding thread) is created, and put in the list of ready process.
@@ -49,7 +49,7 @@ void SIMIX_process_cleanup(void *arg)
  * \param host the location where the new agent is executed.
  * \param argc first argument passed to \a code
  * \param argv second argument passed to \a code
- * \param clean_process_function The cleanup function of user process. It will be called when the process finish. This function have to call the SIMIX_process_cleanup.        
+ * \param clean_process_function The cleanup function of user process. It will be called when the process finish. This function have to call the SIMIX_process_cleanup.
  * \see smx_process_t
  * \return The new corresponding object.
  */
@@ -63,6 +63,8 @@ smx_process_t SIMIX_process_create(const char *name,
   smx_process_t self = NULL;
   smx_host_t host = SIMIX_host_get_by_name(hostname);
 
+  DEBUG2("Start process %s on host %s",name,hostname);
+
   if (!SIMIX_host_get_state(host)) {
     WARN2("Cannot launch process '%s' on failed host '%s'", name, hostname);
     return NULL;
@@ -111,11 +113,11 @@ smx_process_t SIMIX_process_create(const char *name,
   return process;
 }
 
-/** 
+/**
  * \brief Creates and runs a new #smx_process_t hosting a JAVA thread
  *
  * Warning: this should only be used in libsimgrid4java, since it create
- * a context with no code, which leads to segfaults in plain libsimgrid 
+ * a context with no code, which leads to segfaults in plain libsimgrid
  */
 void SIMIX_jprocess_create(const char *name, smx_host_t host,
                            void *data,
@@ -126,11 +128,11 @@ void SIMIX_jprocess_create(const char *name, smx_host_t host,
   smx_process_t self = NULL;
 
   /* HACK: We need this trick because when we xbt_context_new() do
-     syncronization stuff, the s_process field in the m_process needs 
-     to have a valid value, and we call xbt_context_new() before 
-     returning, of course, ie, before providing a right value to the 
-     caller (Java_simgrid_msg_Msg_processCreate) have time to store it  
-     in place. This way, we initialize the m_process->simdata->s_process 
+     syncronization stuff, the s_process field in the m_process needs
+     to have a valid value, and we call xbt_context_new() before
+     returning, of course, ie, before providing a right value to the
+     caller (Java_simgrid_msg_Msg_processCreate) have time to store it
+     in place. This way, we initialize the m_process->simdata->s_process
      field ourself ASAP.
 
      All this would be much simpler if the synchronization stuff would be done
index 15c29d9..f33b9ba 100644 (file)
@@ -116,6 +116,9 @@ typedef struct smpi_host_data_t {
   int index;
   smx_mutex_t mutex;
   smx_cond_t cond;
+  smx_process_t main;
+  smx_process_t sender;
+  smx_process_t receiver;
 } s_smpi_host_data_t;
 typedef struct smpi_host_data_t *smpi_host_data_t;
 
@@ -147,8 +150,7 @@ int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
                         smpi_mpi_communicator_t comm,
                         smpi_mpi_request_t * request);
 
-int smpi_sender(int argc, char **argv);
-
-int smpi_receiver(int argc, char **argv);
+int smpi_sender(int argc,char*argv[]);
+int smpi_receiver(int argc, char*argv[]);
 
 #endif
index 8c018ca..15d36a8 100644 (file)
@@ -1,4 +1,5 @@
 #include "private.h"
+#include "xbt/time.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_base, smpi,
                                 "Logging specific to SMPI (base)");
@@ -58,15 +59,22 @@ void smpi_process_init()
   host = SIMIX_host_self();
 
   hdata = xbt_new(s_smpi_host_data_t, 1);
+  SIMIX_host_set_data(host, hdata);
 
   for (i = 0; i < smpi_global->host_count && host != smpi_global->hosts[i]; i++);
 
   hdata->index = i;
   hdata->mutex = SIMIX_mutex_init();
   hdata->cond = SIMIX_cond_init();
-
-  SIMIX_host_set_data(host, hdata);
-
+  hdata->main = SIMIX_process_self();
+  hdata->sender = SIMIX_process_create("smpi_sender",
+          smpi_sender, hdata,
+          SIMIX_host_get_name(SIMIX_host_self()), 0, NULL,
+          /*props */ NULL);
+  hdata->receiver = SIMIX_process_create("smpi_receiver",
+          smpi_receiver, hdata,
+          SIMIX_host_get_name(SIMIX_host_self()), 0, NULL,
+          /*props */ NULL);
   return;
 }
 
index 91287da..0aa6636 100644 (file)
@@ -303,8 +303,6 @@ int smpi_run_simulation(int *argc, char **argv)
   SIMIX_create_environment(argv[1]);
 
   SIMIX_function_register("smpi_simulated_main", smpi_simulated_main);
-  SIMIX_function_register("smpi_sender", smpi_sender);
-  SIMIX_function_register("smpi_receiver", smpi_receiver);
   SIMIX_launch_application(argv[2]);
 
   // must initialize globals between creating environment and launching app....
index a8eeea9..efb88dd 100644 (file)
@@ -3,10 +3,11 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_receiver, smpi,
                                 "Logging specific to SMPI (receiver)");
 
-int smpi_receiver(int argc, char **argv)
+int smpi_receiver(int argc, char*argv[])
 {
+       smpi_host_data_t mydata = SIMIX_process_get_data(SIMIX_process_self());
   smx_process_t self;
-  int index;
+  int index = mydata->index;
 
   xbt_fifo_t request_queue;
   xbt_fifo_t message_queue;
@@ -21,8 +22,6 @@ int smpi_receiver(int argc, char **argv)
 
   self = SIMIX_process_self();
 
-  index = smpi_host_index();
-
   request_queue = smpi_global->pending_recv_request_queues[index];
   message_queue = smpi_global->received_message_queues[index];
 
index f8f9aa9..d366d45 100644 (file)
@@ -3,8 +3,8 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_sender, smpi,
                                 "Logging specific to SMPI (sender)");
 
-int smpi_sender(int argc, char **argv)
-{
+int smpi_sender(int argc,char*argv[]) {
+       smpi_host_data_t mydata = SIMIX_process_get_data(SIMIX_process_self());
   smx_process_t self;
   smx_host_t shost;
 
@@ -31,7 +31,7 @@ int smpi_sender(int argc, char **argv)
   self = SIMIX_process_self();
   shost = SIMIX_host_self();
 
-  index = smpi_host_index();
+  index = mydata->index;
 
   request_queue = smpi_global->pending_send_request_queues[index];
 
index bcd1e93..29e4c87 100755 (executable)
@@ -131,8 +131,8 @@ for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
        host="${hostnames[$j]}"
   fi
  
-  echo "  <process host=\"${host}\" function=\"smpi_sender\"/>" >> ${APPLICATIONTMP}
-  echo "  <process host=\"${host}\" function=\"smpi_receiver\"/>" >> ${APPLICATIONTMP}
+#  echo "  <process host=\"${host}\" function=\"smpi_sender\"/>" >> ${APPLICATIONTMP}
+#  echo "  <process host=\"${host}\" function=\"smpi_receiver\"/>" >> ${APPLICATIONTMP}
 done
 
 cat >> ${APPLICATIONTMP} <<APPLICATIONFOOT
@@ -140,10 +140,11 @@ cat >> ${APPLICATIONTMP} <<APPLICATIONFOOT
 APPLICATIONFOOT
 ##-------------------------------- end DEFAULT APPLICATION --------------------------------------
 
+echo ${EXEC} ${PLATFORMTMP} ${APPLICATIONTMP}
 ${EXEC} ${PLATFORMTMP} ${APPLICATIONTMP}
 
 echo "[$0] cleaning up temp files"
 if [ -z "${PLATFORM}" ]; then
        rm ${PLATFORMTMP} 
 fi
-rm ${APPLICATIONTMP}
+#rm ${APPLICATIONTMP}