Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
removing references to mpi_comm_world from internal code
[simgrid.git] / src / smpi / smpi_global.c
index ba2db8b..0d069d0 100644 (file)
@@ -129,9 +129,10 @@ void smpi_global_init()
        smpi_global->start_stop_mutex                    = SIMIX_mutex_init();
        smpi_global->start_stop_cond                     = SIMIX_cond_init();
 
-       // processes
-       smpi_global->sender_processes                    = xbt_new(smx_process_t, size);
-       smpi_global->receiver_processes                  = xbt_new(smx_process_t, size);
+       // host info blank until sim starts
+       // FIXME: is this okay?
+       smpi_global->hosts                               = NULL;
+       smpi_global->host_count                          = 0;
 
        // running hosts
        smpi_global->running_hosts_count_mutex           = SIMIX_mutex_init();
@@ -151,6 +152,10 @@ void smpi_global_init()
        smpi_global->received_message_queues             = xbt_new(xbt_fifo_t,  size);
        smpi_global->received_message_queues_mutexes     = xbt_new(smx_mutex_t, size);
 
+       // sender/receiver processes
+       smpi_global->sender_processes                    = xbt_new(smx_process_t, size);
+       smpi_global->receiver_processes                  = xbt_new(smx_process_t, size);
+
        // timers
        smpi_global->timers                              = xbt_new(xbt_os_timer_t, size);
        smpi_global->timers_mutexes                      = xbt_new(smx_mutex_t, size);
@@ -214,6 +219,17 @@ void smpi_global_destroy()
        smpi_global = NULL;
 }
 
+// FIXME: smarter algorithm?
+int smpi_host_index()
+{
+       int i;
+       smx_host_t host = SIMIX_host_self();
+
+       for(i = smpi_global->host_count - 1; i > 0 && host != smpi_global->hosts[i]; i--);
+
+       return i;
+}
+
 int smpi_run_simulation(int argc, char **argv)
 {
        xbt_fifo_item_t cond_item   = NULL;