inline static int smpi_main_wrapper(int argc, char **argv){ int ret = smpi_simulated_main_(argc,argv); if(ret !=0){ XBT_WARN("SMPI process did not return 0. Return value : %d", ret); smpi_process_data()->return_value=ret; } return 0; }
void smpi_process_init(int *argc, char ***argv) { int index=-1; smpi_process_data_t data; smx_process_t proc; if (argc && argv) { proc = SIMIX_process_self(); //FIXME: dirty cleanup method to avoid using msg cleanup functions on these processes when using MSG+SMPI SIMIX_process_set_cleanup_function(proc, MSG_process_cleanup_from_SIMIX); char* instance_id = (*argv)[1]; int rank = xbt_str_parse_int((*argv)[2], "Invalid rank: %s"); 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)); } if(smpi_privatize_global_variables){ /* Now using segment index of the process */ index = proc->segment_index; /* 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 = smpi_process_remote_data(index); data->comm_world = temp_comm_world; if(temp_bar != NULL) data->finalization_barrier = temp_bar; data->index = index; data->instance_id = instance_id; data->replaying = 0; //xbt_free(simcall_process_get_data(proc)); simdata_process_t simdata = static_cast<simdata_process_t>(simcall_process_get_data(proc)); simdata->data = data; if (*argc > 3) { free((*argv)[1]); memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2)); (*argv)[(*argc) - 1] = NULL; (*argv)[(*argc) - 2] = NULL; } (*argc)-=2; data->argc = argc; data->argv = argv; // set the process attached to the mailbox simcall_mbox_set_receiver(data->mailbox_small, proc); XBT_DEBUG("<%d> New process in the game: %p", index, proc); } xbt_assert(smpi_process_data(), "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."); }
MPI_Comm smpi_process_comm_self(void) { smpi_process_data_t data = smpi_process_data(); if(data->comm_self==MPI_COMM_NULL){ MPI_Group group = smpi_group_new(1); data->comm_self = smpi_comm_new(group, NULL); smpi_group_set_mapping(group, smpi_process_index(), 0); } return data->comm_self; }
int smpi_process_get_sampling(void) { smpi_process_data_t data = smpi_process_data(); return data->sampling; }
void smpi_process_set_sampling(int s) { smpi_process_data_t data = smpi_process_data(); data->sampling = s; }
void smpi_process_set_comm_intra(MPI_Comm comm) { smpi_process_data_t data = smpi_process_data(); data->comm_intra = comm; }
MPI_Comm smpi_process_get_comm_intra(void) { smpi_process_data_t data = smpi_process_data(); return data->comm_intra; }
double smpi_process_simulated_elapsed(void) { smpi_process_data_t data = smpi_process_data(); return SIMIX_get_clock() - data->simulated; }
void smpi_process_set_user_data(void *data) { smpi_process_data_t process_data = smpi_process_data(); process_data->data = data; }
xbt_os_timer_t smpi_process_timer(void) { smpi_process_data_t data = smpi_process_data(); return data->timer; }
xbt_mutex_t smpi_process_mailboxes_mutex(void) { smpi_process_data_t data = smpi_process_data(); return data->mailboxes_mutex; }
smx_mailbox_t smpi_process_mailbox_small(void) { smpi_process_data_t data = smpi_process_data(); return data->mailbox_small; }
MPI_Comm smpi_process_comm_world(void) { smpi_process_data_t data = smpi_process_data(); //return MPI_COMM_NULL if not initialized return data ? *data->comm_world : MPI_COMM_NULL; }
int smpi_process_index(void) { smpi_process_data_t data = smpi_process_data(); //return -1 if not initialized return data ? data->index : MPI_UNDEFINED; }
void *smpi_process_get_user_data() { smpi_process_data_t process_data = smpi_process_data(); return process_data->data; }
void smpi_process_simulated_start(void) { smpi_process_data_t data = smpi_process_data(); data->simulated = SIMIX_get_clock(); }
smx_rdv_t smpi_process_mailbox(void) { smpi_process_data_t data = smpi_process_data(); return data->mailbox; }