Example #1
0
void smpi_comm_copy_buffer_callback(smx_synchro_t synchro, void *buff, size_t buff_size)
{
  XBT_DEBUG("Copy the data over");
  void* tmpbuff=buff;
  simgrid::simix::Comm *comm = dynamic_cast<simgrid::simix::Comm*>(synchro);

  if((smpi_privatize_global_variables) && ((char*)buff >= smpi_start_data_exe)
      && ((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)(((simdata_process_t)SIMIX_process_get_data(comm->src_proc))->data))->index);
       tmpbuff = (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(((smpi_process_data_t)(((simdata_process_t)SIMIX_process_get_data(comm->dst_proc))->data))->index);
  }

  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
    xbt_free(buff);
    //It seems that the request is used after the call there this should be free somewhere else but where???
    //xbt_free(comm->comm.src_data);// inside SMPI the request is kept inside the user data and should be free
    comm->src_buff = NULL;
  }

  if(tmpbuff!=buff)xbt_free(tmpbuff);
}
Example #2
0
void smpi_process_destroy(void)
{
  int index = smpi_process_index();
  if(smpi_privatize_global_variables){
    smpi_switch_data_segment(index);
  }
  process_data[index_to_process_data[index]]->state = SMPI_FINALIZED;
  XBT_DEBUG("<%d> Process left the game", index);
}
Example #3
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
    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);

    if(!index_to_process_data){
      index_to_process_data=(int*)xbt_malloc(SIMIX_process_count()*sizeof(int));
    }
    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));
    simcall_process_set_data(proc, 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_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.");
}