MPI_Comm comm;
smx_action_t action;
unsigned flags;
+ int detached;
#ifdef HAVE_TRACING
int send;
int recv;
request->comm = comm;
request->action = NULL;
request->flags = flags;
+ request->detached = 0;
#ifdef HAVE_TRACING
request->send = 0;
request->recv = 0;
void smpi_mpi_start(MPI_Request request)
{
smx_rdv_t mailbox;
- int detached = 0;
xbt_assert(!request->action,
"Cannot (re)start a non-finished communication");
mailbox = smpi_process_remote_mailbox(receiver);
}
if (request->size < 64*1024 ) { //(FIXME: this limit should be configurable)
- void *oldbuf = request->buf;
- detached = 1;
- request->buf = malloc(request->size);
- if (oldbuf)
- memcpy(request->buf,oldbuf,request->size);
+ void *oldbuf = NULL;
+ if(request->old_type->has_subtype == 0){
+ oldbuf = request->buf;
+ request->detached = 1;
+ request->buf = malloc(request->size);
+ if (oldbuf)
+ memcpy(request->buf,oldbuf,request->size);
+ }
XBT_DEBUG("Send request %p is detached; buf %p copied into %p",request,oldbuf,request->buf);
}
&smpi_mpi_request_free_voidp, // how to free the userdata if a detached send fails
request,
// detach if msg size < eager/rdv switch limit
- detached);
+ request->detached);
#ifdef HAVE_TRACING
/* FIXME: detached sends are not traceable (request->action == NULL) */
if(req->flags & RECV) {
subtype->unserialize(req->buf, req->old_buf, req->size/smpi_datatype_size(datatype) , datatype->substruct);
}
- //FIXME: I am not sure that if the send is detached we have to free
- //the sender buffer thus I do it only for the reciever
- if(req->flags & RECV) free(req->buf);
+ if(req->detached == 0) free(req->buf);
}
if(req->flags & NON_PERSISTENT) {
request->src, request->dst, request->tag, request->flags);
}
+void SMPI_comm_copy_buffer_callback(smx_action_t comm, void* buff, size_t buff_size)
+{
+ XBT_DEBUG("Copy the data over");
+ memcpy(comm->comm.dst_buff, buff, buff_size);
+ if (comm->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);
+ xbt_free(comm->comm.src_data);// inside SMPI the request is keep
+ //inside the user data and should be free
+ comm->comm.src_buff = NULL;
+ }
+}
+
void smpi_global_init(void)
{
int i;
MPI_Group group;
char name[MAILBOX_NAME_MAXLEN];
- SIMIX_comm_set_copy_data_callback(&SIMIX_comm_copy_buffer_callback);
+ SIMIX_comm_set_copy_data_callback(&SMPI_comm_copy_buffer_callback);
process_count = SIMIX_process_count();
process_data = xbt_new(smpi_process_data_t, process_count);
for (i = 0; i < process_count; i++) {
noncontiguous_vector_char += type_c->block_stride*type_c->size_oldtype;
}
}
+
/*
* Copies contiguous data into noncontiguous memory.
* @param noncontiguous_vector - output vector
void smpi_datatype_create(MPI_Datatype* new_type, int size, int has_subtype,
void *struct_type, int flags){
MPI_Datatype new_t= xbt_new(s_smpi_mpi_datatype_t,1);
- new_t->size=size;
- new_t->has_subtype=has_subtype;
- new_t->lb=0;
- new_t->ub=size;
- new_t->flags=flags;
- new_t->substruct=struct_type;
+ new_t->size = size;
+ new_t->has_subtype = has_subtype;
+ new_t->lb = 0;
+ new_t->ub = size;
+ new_t->flags = flags;
+ new_t->substruct = struct_type;
*new_type = new_t;
}
int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type)
{
int i;
- size_t size; //Khalid added this
-
- size = 0;
+ size_t size = 0;
for(i=0; i< count; i++){
if (blocklens[i]<=0)
return MPI_ERR_ARG;