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) {
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;