A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'hypervisor' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid into hypervisor
[simgrid.git]
/
src
/
smpi
/
smpi_mpi_dt.c
diff --git
a/src/smpi/smpi_mpi_dt.c
b/src/smpi/smpi_mpi_dt.c
index
17e7614
..
29471e9
100644
(file)
--- a/
src/smpi/smpi_mpi_dt.c
+++ b/
src/smpi/smpi_mpi_dt.c
@@
-153,12
+153,10
@@
MPI_Aint smpi_datatype_get_extent(MPI_Datatype datatype){
int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype)
{
int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype)
{
- int
retval,
count;
+ int count;
/* First check if we really have something to do */
/* First check if we really have something to do */
- if (recvcount == 0) {
- retval = sendcount == 0 ? MPI_SUCCESS : MPI_ERR_TRUNCATE;
- } else {
+ if (recvcount > 0 && recvbuf != sendbuf) {
/* FIXME: treat packed cases */
sendcount *= smpi_datatype_size(sendtype);
recvcount *= smpi_datatype_size(recvtype);
/* FIXME: treat packed cases */
sendcount *= smpi_datatype_size(sendtype);
recvcount *= smpi_datatype_size(recvtype);
@@
-181,7
+179,7
@@
int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)sendtype;
s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)sendtype;
- void * buf_tmp = malloc(count * type_c->size_oldtype);
+ void * buf_tmp =
xbt_
malloc(count * type_c->size_oldtype);
subtype->serialize( sendbuf, buf_tmp,1, subtype);
subtype = recvtype->substruct;
subtype->serialize( sendbuf, buf_tmp,1, subtype);
subtype = recvtype->substruct;
@@
-189,10
+187,9
@@
int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
free(buf_tmp);
}
free(buf_tmp);
}
- retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
}
}
- return
retval
;
+ return
sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS
;
}
/*
}
/*
@@
-295,14
+292,36
@@
void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int h
new_t->ub = ub;
new_t->flags = flags;
new_t->substruct = struct_type;
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){
*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);
if ((*type)->has_subtype == 1){
((s_smpi_subtype_t *)(*type)->substruct)->subtype_free(type);
+ xbt_free((*type)->substruct);
}
xbt_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)
}
int smpi_datatype_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type)