int flags;
/* this let us know how to serialize and unserialize*/
void *substruct;
+ int in_use;
} s_smpi_mpi_datatype_t;
//*****************************************************************************************
int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount,
MPI_Datatype recvtype);
+void smpi_datatype_use(MPI_Datatype type);
+void smpi_datatype_unuse(MPI_Datatype type);
+
int smpi_datatype_contiguous(int count, MPI_Datatype old_type,
MPI_Datatype* new_type);
int smpi_datatype_vector(int count, int blocklen, int stride,
request->send = 0;
request->recv = 0;
#endif
+ if (flags & SEND) smpi_datatype_unuse(datatype);
+
return request;
}
mailbox = smpi_process_mailbox();
// we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
request->real_size=request->size;
+ smpi_datatype_use(request->old_type);
request->action = simcall_comm_irecv(mailbox, request->buf, &request->real_size, &match_recv, request);
if (request->action)request->action->comm.refcount++;
} else {
}
// we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
request->real_size=request->size;
+ smpi_datatype_use(request->old_type);
request->action =
simcall_comm_isend(mailbox, request->size, -1.0,
}
if(req->detached == 0) free(req->buf);
}
-
+ smpi_datatype_unuse(datatype);
if(req->flags & NON_PERSISTENT) {
simcall_comm_wait((*request)->action, -1.0);
finish_wait(request, status);
}
+
// FIXME for a detached send, finish_wait is not called:
}
new_t->ub = ub;
new_t->flags = flags;
new_t->substruct = struct_type;
+ new_t->in_use=0;
*new_type = new_t;
}
void smpi_datatype_free(MPI_Datatype* type){
+
+ if((*type)->flags & DT_FLAG_PREDEFINED)return;
+
+ //if still used, mark for deletion
+ if((*type)->in_use!=0){
+ (*type)->flags |=DT_FLAG_DESTROYED;
+ return;
+ }
+
if ((*type)->has_subtype == 1){
((s_smpi_subtype_t *)(*type)->substruct)->subtype_free(type);
}
xbt_free(*type);
+
+}
+
+void smpi_datatype_use(MPI_Datatype type){
+ if(type)type->in_use++;
+}
+
+
+void smpi_datatype_unuse(MPI_Datatype type){
+ if(type && type->in_use-- == 0 && (type->flags & DT_FLAG_DESTROYED))
+ smpi_datatype_free(&type);
}
int smpi_datatype_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type)