Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
used host user data to store global index values and remove some clunky
[simgrid.git] / src / smpi / smpi_global.c
index ba2db8b..dfac6a6 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,14 @@ void smpi_global_destroy()
        smpi_global = NULL;
 }
 
+int smpi_host_index()
+{
+       smx_host_t host = SIMIX_host_self();
+       smpi_host_data_t hdata = (smpi_host_data_t)SIMIX_host_get_data(host);
+
+       return hdata->index;
+}
+
 int smpi_run_simulation(int argc, char **argv)
 {
        xbt_fifo_item_t cond_item   = NULL;