Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make it compile when SMPI is disabled
[simgrid.git] / src / simix / smx_process.cpp
index 493977b..3f74714 100644 (file)
 #include "mc/mc.h"
 #include "src/mc/mc_replay.h"
 #include "src/mc/mc_client.h"
+#include "src/simix/smx_private.hpp"
+
+#ifdef HAVE_SMPI
+#include "src/smpi/private.h"
+#endif
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
                                 "Logging specific to SIMIX (process)");
@@ -261,9 +266,22 @@ smx_process_t SIMIX_process_create(
     process->data = data;
     process->comms = xbt_fifo_new();
     process->simcall.issuer = process;
+    /* Initiliaze data segment to default value */
+    SIMIX_segment_index_set(process, -1);
 
-     if (parent_process) {
+     if (parent_process != NULL) {
        process->ppid = SIMIX_process_get_PID(parent_process);
+       /* SMPI process have their own data segment and
+          each other inherit from their father */
+#ifdef HAVE_SMPI
+       if(smpi_privatize_global_variables){
+         if( parent_process->pid != 0){
+           SIMIX_segment_index_set(process, parent_process->segment_index);
+         } else {
+           SIMIX_segment_index_set(process, process->pid - 1);
+         }
+       }
+#endif
      } else {
        process->ppid = -1;
      }
@@ -654,6 +672,10 @@ sg_host_t SIMIX_process_get_host(smx_process_t process)
   return process->host;
 }
 
+xbt_main_func_t SIMIX_process_get_code(void){
+  return SIMIX_process_self()->code;
+}
+
 /* needs to be public and without simcall because it is called
    by exceptions and logging events */
 const char* SIMIX_process_self_get_name(void) {
@@ -874,6 +896,9 @@ void SIMIX_process_yield(smx_process_t self)
     SMX_THROW();
   }
 
+  if(SMPI_switch_data_segment && self->segment_index != -1){
+    SMPI_switch_data_segment(self->segment_index);
+  }
 }
 
 /* callback: context fetching */
@@ -1013,3 +1038,7 @@ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer)
   }
   return new_process;
 }
+
+void SIMIX_segment_index_set(smx_process_t proc, int index){
+  proc->segment_index = index;
+}