Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix smpi_process_index_of_smx_process()
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 29 Aug 2014 10:25:27 +0000 (12:25 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 29 Aug 2014 10:25:27 +0000 (12:25 +0200)
The SMPI process ID is simply the SIMIX PID - 1. The previous solution
(getting the data field of the SIMIX process) was mostly correct but
the 'data' field was not initally set to the SMPI process data
structure (but was NULL).

src/simix/smx_process_private.h
src/smpi/private.h
src/smpi/smpi_global.c

index bff1f1a..d49eced 100644 (file)
@@ -10,6 +10,8 @@
 #include "simgrid/simix.h"
 #include "smx_smurf_private.h"
 
+SG_BEGIN_DECL()
+
 typedef struct s_smx_process_exit_fun {
   int_f_pvoid_pvoid_t fun;
   void *arg;
@@ -135,4 +137,7 @@ void SIMIX_pre_process_on_exit(smx_simcall_t simcall, smx_process_t process,
 void SIMIX_pre_process_auto_restart_set(smx_simcall_t simcall, smx_process_t process,
                                        int auto_restart);
 smx_process_t SIMIX_pre_process_restart(smx_simcall_t simcall, smx_process_t process);
+
+SG_END_DECL()
+
 #endif
index 9d1c77d..4dcd4f1 100644 (file)
@@ -693,7 +693,12 @@ const char* encode_datatype(MPI_Datatype datatype);
 extern void** mappings;
 extern int loaded_page;
 
-int smpi_process_index_of_smx_process(smx_process_t process);
+int SIMIX_process_get_PID(smx_process_t self);
+
+static inline __attribute__ ((always_inline))
+int smpi_process_index_of_smx_process(smx_process_t process) {
+  return SIMIX_process_get_PID(process) -1;
+}
 
 SG_END_DECL()
 
index ecf585d..f6ec03a 100644 (file)
@@ -78,7 +78,7 @@ 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 =  SIMIX_process_get_PID(proc) -1;
+    index = smpi_process_index_of_smx_process(proc);
 
     if(!index_to_process_data){
         index_to_process_data=(int*)xbt_malloc(SIMIX_process_count()*sizeof(int));
@@ -221,11 +221,6 @@ int smpi_process_index(void)
   return data ? data->index : MPI_UNDEFINED;
 }
 
-int smpi_process_index_of_smx_process(smx_process_t process) {
-  smpi_process_data_t data = (smpi_process_data_t) SIMIX_process_get_data(process);
-  return data ? data->index : MPI_UNDEFINED;
-}
-
 MPI_Comm smpi_process_comm_world(void)
 {
   smpi_process_data_t data = smpi_process_data();