Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modified [PATCH] Privatize data segment for SMPI process and share for MSG process
[simgrid.git] / src / smpi / smpi_global.c
index 4f00cad..580b02c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2014. The SimGrid Team.
+/* Copyright (c) 2007-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -82,11 +82,18 @@ void smpi_process_init(int *argc, char ***argv)
     proc->context->cleanup_func=SIMIX_process_cleanup;
     char* instance_id = (*argv)[1];
     int rank = atoi((*argv)[2]);
-    index = smpi_process_index_of_smx_process(proc);
+    /* Now using segment index of the process */
+    index = proc->segment_index;
 
     if(!index_to_process_data){
       index_to_process_data=(int*)xbt_malloc(SIMIX_process_count()*sizeof(int));
     }
+
+    if(smpi_privatize_global_variables){
+      /* Done at the process's creation */
+      SMPI_switch_data_segment(index);
+    }
+
     MPI_Comm* temp_comm_world;
     xbt_bar_t temp_bar;
     smpi_deployment_register_process(instance_id, rank, index, &temp_comm_world ,&temp_bar);
@@ -111,10 +118,6 @@ void smpi_process_init(int *argc, char ***argv)
     simcall_rdv_set_receiver(data->mailbox_small, proc);
     XBT_DEBUG("<%d> New process in the game: %p", index, proc);
 
-    if(smpi_privatize_global_variables){
-      smpi_switch_data_segment(index);
-    }
-
   }
   if (smpi_process_data() == NULL)
     xbt_die("smpi_process_data() returned NULL. You probably gave a NULL parameter to MPI_Init. Although it's required by MPI-2, this is currently not supported by SMPI.");
@@ -647,6 +650,9 @@ int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[])
   TRACE_add_end_function(TRACE_smpi_release);
 
   SIMIX_global_init(&argc, argv);
+  MSG_init(&argc,argv);
+
+  SMPI_switch_data_segment = smpi_switch_data_segment;
 
   smpi_init_options();
 
@@ -676,7 +682,7 @@ int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[])
     xbt_os_walltimer_stop(global_timer);
     if (sg_cfg_get_boolean("smpi/display_timing")){
       double global_time = xbt_os_timer_elapsed(global_timer);
-      XBT_INFO("Simulated time: %g seconds. \n "
+      XBT_INFO("Simulated time: %g seconds. \n\n"
           "The simulation took %g seconds (after parsing and platform setup)\n"
           "%g seconds were actual computation of the application"
           , SIMIX_get_clock(), global_time , smpi_total_benched_time);