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
add a reference counter in order to avoide deleting MPI_Comm, and MPI_Group, too...
[simgrid.git]
/
src
/
smpi
/
smpi_comm.c
diff --git
a/src/smpi/smpi_comm.c
b/src/smpi/smpi_comm.c
index
d49b858
..
dac6ac3
100644
(file)
--- a/
src/smpi/smpi_comm.c
+++ b/
src/smpi/smpi_comm.c
@@
-14,6
+14,7
@@
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi,
typedef struct s_smpi_mpi_communicator {
MPI_Group group;
typedef struct s_smpi_mpi_communicator {
MPI_Group group;
+ int refcount;
} s_smpi_mpi_communicator_t;
static int smpi_compare_rankmap(const void *a, const void *b)
} s_smpi_mpi_communicator_t;
static int smpi_compare_rankmap(const void *a, const void *b)
@@
-43,12
+44,14
@@
MPI_Comm smpi_comm_new(MPI_Group group)
comm = xbt_new(s_smpi_mpi_communicator_t, 1);
comm->group = group;
smpi_group_use(comm->group);
comm = xbt_new(s_smpi_mpi_communicator_t, 1);
comm->group = group;
smpi_group_use(comm->group);
+ smpi_comm_use(comm);
return comm;
}
void smpi_comm_destroy(MPI_Comm comm)
{
return comm;
}
void smpi_comm_destroy(MPI_Comm comm)
{
- xbt_free(comm);
+ smpi_group_unuse(comm->group);
+ smpi_comm_unuse(comm);
}
MPI_Group smpi_comm_group(MPI_Comm comm)
}
MPI_Group smpi_comm_group(MPI_Comm comm)
@@
-78,7
+81,7
@@
void smpi_comm_get_name (MPI_Comm comm, char* name, int* len)
MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key)
{
MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key)
{
- int system_tag =
666
;
+ int system_tag =
123
;
int index, rank, size, i, j, count, reqs;
int* sendbuf;
int* recvbuf;
int index, rank, size, i, j, count, reqs;
int* sendbuf;
int* recvbuf;
@@
-152,3
+155,15
@@
MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key)
}
return group_out ? smpi_comm_new(group_out) : MPI_COMM_NULL;
}
}
return group_out ? smpi_comm_new(group_out) : MPI_COMM_NULL;
}
+
+void smpi_comm_use(MPI_Comm comm){
+ comm->refcount++;
+ smpi_group_use(comm->group);
+}
+
+void smpi_comm_unuse(MPI_Comm comm){
+ comm->refcount--;
+ smpi_group_unuse(comm->group);
+ if(comm->refcount==0)
+ xbt_free(comm);
+}