XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void *data);
+XBT_PUBLIC(xbt_main_func_t) SIMIX_process_get_code(void);
/****************************** Communication *********************************/
XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_synchro_t, void*, size_t));
// smpi functions
XBT_PUBLIC(int) smpi_global_size(void);
XBT_PUBLIC(MPI_Comm) smpi_process_comm_self(void);
+XBT_PUBLIC(void*) smpi_process_get_user_data(void);
+XBT_PUBLIC(void) smpi_process_set_user_data(void *);
/*
XBT_PUBLIC(void) smpi_exit(int);
*/
void* args;
} s_smx_timer_t;
+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 "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)");
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;
}
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) {
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
XBT_PRIVATE smpi_process_data_t smpi_process_data(void);
XBT_PRIVATE smpi_process_data_t smpi_process_remote_data(int index);
-XBT_PRIVATE void smpi_process_set_user_data(void *);
-XBT_PRIVATE void* smpi_process_get_user_data(void);
+// smpi_process_[set/get]_user_data must be public
+/* XBT_PRIVATE void smpi_process_set_user_data(void *); */
+/* XBT_PRIVATE void* smpi_process_get_user_data(void); */
XBT_PRIVATE int smpi_process_count(void);
XBT_PRIVATE MPI_Comm smpi_process_comm_world(void);
XBT_PRIVATE MPI_Comm smpi_process_get_comm_intra(void);
#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";
#include "src/simix/smx_private.h"
#include "simgrid/sg_config.h"
#include "src/mc/mc_replay.h"
+#include "src/msg/msg_private.h"
#include <float.h> /* DBL_MAX */
#include <stdint.h>
SIMIX_process_set_cleanup_function(proc, 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);
data->index = index;
data->instance_id = instance_id;
data->replaying = 0;
- xbt_free(simcall_process_get_data(proc));
- simcall_process_set_data(proc, data);
+ //xbt_free(simcall_process_get_data(proc));
+
+ simdata_process_t simdata = simcall_process_get_data(proc);
+ simdata->data = data;
+
if (*argc > 3) {
free((*argv)[1]);
memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2));
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.");
*/
int smpi_process_initialized(void)
{
- int index = smpi_process_index();
- return ( (index != MPI_UNDEFINED)
- && (process_data[index_to_process_data[index]]->state == SMPI_INITIALIZED));
+ if (!index_to_process_data){
+ return false;
+ }
+ else{
+ int index = smpi_process_index();
+ return ( (index != MPI_UNDEFINED)
+ && (process_data[index_to_process_data[index]]->state == SMPI_INITIALIZED));
+ }
}
/**
smpi_process_data_t smpi_process_data(void)
{
- return SIMIX_process_self_get_data(SIMIX_process_self());
+ simdata_process_t simdata = SIMIX_process_self_get_data(SIMIX_process_self());
+ return simdata->data;
}
smpi_process_data_t smpi_process_remote_data(int index)
&& ((char*)buff < smpi_start_data_exe + smpi_size_data_exe )
){
XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
- smpi_switch_data_segment(((smpi_process_data_t)SIMIX_process_get_data(comm->comm.src_proc))->index);
+ smpi_switch_data_segment(((smpi_process_data_t)(((simdata_process_t)SIMIX_process_get_data(comm->comm.src_proc))->data))->index);
tmpbuff = (void*)xbt_malloc(buff_size);
memcpy(tmpbuff, buff, buff_size);
}
&& ((char*)comm->comm.dst_buff < smpi_start_data_exe + smpi_size_data_exe )
){
XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
- smpi_switch_data_segment(((smpi_process_data_t)SIMIX_process_get_data(comm->comm.dst_proc))->index);
+ smpi_switch_data_segment(((smpi_process_data_t)(((simdata_process_t)SIMIX_process_get_data(comm->comm.dst_proc))->data))->index);
}
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();
int PMPI_Init(int *argc, char ***argv)
{
- smpi_process_init(argc, argv);
- smpi_process_mark_as_initialized();
- int rank = smpi_process_index();
- TRACE_smpi_init(rank);
- TRACE_smpi_computing_init(rank);
- instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
- extra->type = TRACING_INIT;
- TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
- TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
- smpi_bench_begin();
+ // PMPI_Init is call only one time by only by SMPI process
+ int already_init;
+ MPI_Initialized(&already_init);
+ if(!(already_init)){
+ smpi_process_init(argc, argv);
+ smpi_process_mark_as_initialized();
+ int rank = smpi_process_index();
+ TRACE_smpi_init(rank);
+ TRACE_smpi_computing_init(rank);
+ instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+ extra->type = TRACING_INIT;
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+ smpi_bench_begin();
+ }
return MPI_SUCCESS;
}