#endif
std::unordered_map<std::string, double> location2speedup;
-Process **process_data = nullptr;
+simgrid::smpi::Process **process_data = nullptr;
int process_count = 0;
int smpi_universe_size = 0;
int* index_to_process_data = nullptr;
return process_count;
}
-Process* smpi_process()
+simgrid::smpi::Process* smpi_process()
{
simgrid::MsgActorExt* msgExt = static_cast<simgrid::MsgActorExt*>(SIMIX_process_self()->data);
- return static_cast<Process*>(msgExt->data);
+ return static_cast<simgrid::smpi::Process*>(msgExt->data);
}
-Process* smpi_process_remote(int index)
+simgrid::smpi::Process* smpi_process_remote(int index)
{
return process_data[index_to_process_data[index]];
}
}
void smpi_process_init(int *argc, char ***argv){
- Process::init(argc, argv);
+ simgrid::smpi::Process::init(argc, argv);
}
int smpi_process_index(){
void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t buff_size)
{
- XBT_DEBUG("Copy the data over");
void* tmpbuff=buff;
simgrid::kernel::activity::Comm *comm = dynamic_cast<simgrid::kernel::activity::Comm*>(synchro);
- if((smpi_privatize_global_variables) && (static_cast<char*>(buff) >= smpi_start_data_exe)
- && (static_cast<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 !");
+ XBT_DEBUG("Copy the data over");
+ if(smpi_is_shared(buff)){
+ XBT_DEBUG("Sender %p is shared. Let's ignore it.", buff);
+ }else if(smpi_is_shared((char*)comm->dst_buff)){
+ XBT_DEBUG("Receiver %p is shared. Let's ignore it.", (char*)comm->dst_buff);
+ }else{
- smpi_switch_data_segment(
- (static_cast<Process*>((static_cast<simgrid::MsgActorExt*>(comm->src_proc->data)->data))->index()));
- tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
- memcpy(tmpbuff, buff, buff_size);
- }
+ if((smpi_privatize_global_variables) && (static_cast<char*>(buff) >= smpi_start_data_exe)
+ && (static_cast<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 !");
- if((smpi_privatize_global_variables) && ((char*)comm->dst_buff >= smpi_start_data_exe)
- && ((char*)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(
- (static_cast<Process*>((static_cast<simgrid::MsgActorExt*>(comm->dst_proc->data)->data))->index()));
- }
+ smpi_switch_data_segment(
+ (static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->src_proc->data)->data))->index()));
+ tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
+ memcpy(tmpbuff, buff, buff_size);
+ }
+
+ if((smpi_privatize_global_variables) && ((char*)comm->dst_buff >= smpi_start_data_exe)
+ && ((char*)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(
+ (static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->dst_proc->data)->data))->index()));
+ }
- memcpy(comm->dst_buff, tmpbuff, buff_size);
+ XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff);
+ memcpy(comm->dst_buff, tmpbuff, buff_size);
+ }
if (comm->detached) {
// if this is a detached send, the source buffer was duplicated by SMPI
// sender to make the original buffer available to the application ASAP
smpirun=1;
}
smpi_universe_size = process_count;
- process_data = new Process*[process_count];
+ process_data = new simgrid::smpi::Process*[process_count];
for (i = 0; i < process_count; i++) {
- process_data[i] = new Process(i);
+ process_data[i] = new simgrid::smpi::Process(i);
}
//if the process was launched through smpirun script we generate a global mpi_comm_world
//if not, we let MPI_COMM_NULL, and the comm world will be private to each mpi instance
if(smpirun){
- group = new Group(process_count);
- MPI_COMM_WORLD = new Comm(group, nullptr);
+ group = new simgrid::smpi::Group(process_count);
+ MPI_COMM_WORLD = new simgrid::smpi::Comm(group, nullptr);
MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, reinterpret_cast<void *>(process_count));
msg_bar_t bar = MSG_barrier_init(process_count);
int count = smpi_process_count();
smpi_bench_destroy();
+ smpi_shared_destroy();
if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){
delete MPI_COMM_WORLD->group();
MSG_barrier_destroy(process_data[0]->finalization_barrier());
}
for (int i = 0; i < count; i++) {
if(process_data[i]->comm_self()!=MPI_COMM_NULL){
- Comm::destroy(process_data[i]->comm_self());
+ simgrid::smpi::Comm::destroy(process_data[i]->comm_self());
}
if(process_data[i]->comm_intra()!=MPI_COMM_NULL){
- Comm::destroy(process_data[i]->comm_intra());
+ simgrid::smpi::Comm::destroy(process_data[i]->comm_intra());
}
xbt_os_timer_free(process_data[i]->timer());
xbt_mutex_destroy(process_data[i]->mailboxes_mutex());
if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){
MPI_COMM_WORLD->cleanup_smp();
- MPI_COMM_WORLD->cleanup_attr<Comm>();
- if(Colls::smpi_coll_cleanup_callback!=nullptr)
- Colls::smpi_coll_cleanup_callback();
+ MPI_COMM_WORLD->cleanup_attr<simgrid::smpi::Comm>();
+ if(simgrid::smpi::Colls::smpi_coll_cleanup_callback!=nullptr)
+ simgrid::smpi::Colls::smpi_coll_cleanup_callback();
delete MPI_COMM_WORLD;
}
int __attribute__ ((weak)) smpi_simulated_main_(int argc, char **argv)
{
- Process::init(&argc, &argv);
+ simgrid::smpi::Process::init(&argc, &argv);
user_main_();
return 0;
}
XBT_LOG_CONNECT(smpi_request);
XBT_LOG_CONNECT(smpi_replay);
XBT_LOG_CONNECT(smpi_rma);
+ XBT_LOG_CONNECT(smpi_shared);
XBT_LOG_CONNECT(smpi_utils);
}
}
static void smpi_init_options(){
- Colls::set_collectives();
- Colls::smpi_coll_cleanup_callback=nullptr;
+ simgrid::smpi::Colls::set_collectives();
+ simgrid::smpi::Colls::smpi_coll_cleanup_callback=nullptr;
smpi_cpu_threshold = xbt_cfg_get_double("smpi/cpu-threshold");
smpi_host_speed = xbt_cfg_get_double("smpi/host-speed");
smpi_privatize_global_variables = xbt_cfg_get_boolean("smpi/privatize-global-variables");
return time;
}
-void smpi_empty_status(MPI_Status * status)
-{
- if(status != MPI_STATUS_IGNORE) {
- status->MPI_SOURCE = MPI_ANY_SOURCE;
- status->MPI_TAG = MPI_ANY_TAG;
- status->MPI_ERROR = MPI_SUCCESS;
- status->count=0;
- }
-}
-
-int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype)
-{
- return status->count / datatype->size();
-}