Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
privatization : perform the initialization at process launch, not at MPI_Init time
authorAugustin Degomme <degomme@idpann.imag.fr>
Fri, 28 Mar 2014 12:22:15 +0000 (13:22 +0100)
committerAugustin Degomme <degomme@idpann.imag.fr>
Fri, 28 Mar 2014 12:22:15 +0000 (13:22 +0100)
Also switch at destroy time, to avoid deallocation problems in user code

src/smpi/smpi_bench.c
src/smpi/smpi_global.c

index 126d181..537092b 100644 (file)
@@ -590,7 +590,15 @@ void switch_data_segment(int dest){
 
   if (loaded_page==dest)//no need to switch either
     return;
+
+
 #ifdef HAVE_MMAP
+  int i;
+  if(loaded_page==-1){//initial switch, do the copy from the real page here
+    for (i=0; i< SIMIX_process_count(); i++){
+      memcpy(mappings[i],TOPAGE(start_data_exe),size_data_exe);
+    }
+  }
   int current= fds[dest];
   XBT_VERB("Switching data frame to the one of process %d", dest);
   void* tmp = mmap (TOPAGE(start_data_exe), size_data_exe, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, current, 0);
index 44ca24a..75815c1 100644 (file)
@@ -72,6 +72,7 @@ void smpi_process_init(int *argc, char ***argv)
 #ifdef SMPI_F2C
     smpi_current_rank = index;
 #endif
+
     data = smpi_process_remote_data(index);
     simcall_process_set_data(proc, data);
     if (*argc > 2) {
@@ -85,6 +86,11 @@ void smpi_process_init(int *argc, char ***argv)
     // set the process attached to the mailbox
     simcall_rdv_set_receiver(data->mailbox_small, proc);
     XBT_DEBUG("<%d> New process in the game: %p", index, proc);
+
+    if(smpi_privatize_global_variables){
+      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.");
@@ -93,6 +99,9 @@ void smpi_process_init(int *argc, char ***argv)
 void smpi_process_destroy(void)
 {
   int index = smpi_process_index();
+  if(smpi_privatize_global_variables){
+    switch_data_segment(index);
+  }
   process_data[index]->state = SMPI_FINALIZED;
   XBT_DEBUG("<%d> Process left the game", index);
 }