From 7eca39f4b3ea15b9f4613a555408ea440911ecf5 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 29 Aug 2014 12:25:27 +0200 Subject: [PATCH] [mc] Fix smpi_process_index_of_smx_process() 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 | 5 +++++ src/smpi/private.h | 7 ++++++- src/smpi/smpi_global.c | 7 +------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/simix/smx_process_private.h b/src/simix/smx_process_private.h index bff1f1a840..d49eced5a9 100644 --- a/src/simix/smx_process_private.h +++ b/src/simix/smx_process_private.h @@ -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 diff --git a/src/smpi/private.h b/src/smpi/private.h index 9d1c77d4de..4dcd4f1f32 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -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() diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index ecf585d2ed..f6ec03a1e9 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -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(); -- 2.20.1