smx_global_t simix_global = NULL;
static xbt_heap_t simix_timers = NULL;
+void (*SMPI_switch_data_segment)(int) = NULL;
+
static void* SIMIX_synchro_mallocator_new_f(void);
static void SIMIX_synchro_mallocator_free_f(void* synchro);
static void SIMIX_synchro_mallocator_reset_f(void* synchro);
#include "mc/mc_replay.h"
#include "mc/mc_client.h"
+#ifdef HAVE_SMPI
+#include "smpi/private.h"
+#endif
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
"Logging specific to SIMIX (process)");
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 */
+ 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);
+ }
+ }
} else {
process->ppid = -1;
}
SMX_THROW();
}
+ if(SMPI_switch_data_segment && self->segment_index != -1){
+ SMPI_switch_data_segment(self->segment_index);
+ }
}
/* callback: context fetching */
}
return new_process;
}
+
+void SIMIX_segment_index_set(smx_process_t proc, int index){
+ proc->segment_index = index;
+}
int argc;
char **argv;
smx_timer_t kill_timer;
+ int segment_index; /*Reference to an SMPI process' data segment. Default value is -1 if not in SMPI context*/
} s_smx_process_t;
XBT_PRIVATE void SIMIX_process_auto_restart_set(smx_process_t process, int auto_restart);
XBT_PRIVATE smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer);
+void SIMIX_segment_index_set(smx_process_t, int);
+extern void (*SMPI_switch_data_segment)(int);
+
SG_END_DECL()
#endif
#ifdef HAVE_PRIVATIZATION
int i;
if(smpi_loaded_page==-1){//initial switch, do the copy from the real page here
- for (i=0; i< SIMIX_process_count(); i++){
+ for (i=0; i< smpi_process_count(); i++){
memcpy(smpi_privatisation_regions[i].address,
TOPAGE(smpi_start_data_exe), smpi_size_data_exe);
}
smpi_privatisation_regions = (smpi_privatisation_region_t) malloc(
smpi_process_count() * sizeof(struct s_smpi_privatisation_region));
- for (i=0; i< SIMIX_process_count(); i++){
+ for (i=0; i< smpi_process_count(); i++){
//create SIMIX_process_count() mappings of this size with the same data inside
void *address = NULL;
char path[] = "/dev/shm/my-buffer-XXXXXX";
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);
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.");
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();