if (group == NULL) {
retval = MPI_ERR_ARG;
} else {
- if(*group!= smpi_comm_group(MPI_COMM_WORLD))// do not free the group of the comm_world
smpi_group_destroy(*group);
*group = MPI_GROUP_NULL;
retval = MPI_SUCCESS;
MPI_Group group2, int *ranks2)
{
int retval, i, index;
-
smpi_bench_end();
if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
} else {
for (i = 0; i < n; i++) {
- index = smpi_group_index(group1, ranks1[i]);
- ranks2[i] = smpi_group_rank(group2, index);
+ if(ranks1[i]==MPI_PROC_NULL){
+ ranks2[i]=MPI_PROC_NULL;
+ }else{
+ index = smpi_group_index(group1, ranks1[i]);
+ ranks2[i] = smpi_group_rank(group2, index);
+ }
}
retval = MPI_SUCCESS;
}
smpi_group_set_mapping(*newgroup, proc2, i);
}
}
- smpi_group_use(*newgroup);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
}
}
}
- smpi_group_use(*newgroup);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
}
}
}
- smpi_group_use(*newgroup);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
*newgroup = MPI_GROUP_EMPTY;
} else if (n == smpi_group_size(group)) {
*newgroup = group;
+ if(group!= smpi_comm_group(MPI_COMM_WORLD)
+ && group != MPI_GROUP_NULL
+ && group != smpi_comm_group(MPI_COMM_SELF)
+ && group != MPI_GROUP_EMPTY)
+ smpi_group_use(group);
} else {
*newgroup = smpi_group_new(n);
for (i = 0; i < n; i++) {
smpi_group_set_mapping(*newgroup, index, i);
}
}
- smpi_group_use(*newgroup);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
} else {
if (n == 0) {
*newgroup = group;
+ if(group!= smpi_comm_group(MPI_COMM_WORLD)
+ && group != MPI_GROUP_NULL
+ && group != smpi_comm_group(MPI_COMM_SELF)
+ && group != MPI_GROUP_EMPTY)
+ smpi_group_use(group);
} else if (n == smpi_group_size(group)) {
*newgroup = MPI_GROUP_EMPTY;
} else {
xbt_free(to_exclude);
}
- smpi_group_use(*newgroup);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
size = 0;
for (i = 0; i < n; i++) {
for (rank = ranges[i][0]; /* First */
- rank >= 0 && rank <= ranges[i][1]; /* Last */
- rank += ranges[i][2] /* Stride */ ) {
+ rank >= 0; /* Last */
+ ) {
size++;
+
+ rank += ranges[i][2]; /* Stride */
+ if (ranges[i][0]<ranges[i][1]){
+ if(rank > ranges[i][1])
+ break;
+ }else{
+ if(rank < ranges[i][1])
+ break;
+ }
}
}
- if (size == smpi_group_size(group)) {
- *newgroup = group;
- } else {
- *newgroup = smpi_group_new(size);
- j = 0;
- for (i = 0; i < n; i++) {
- for (rank = ranges[i][0]; /* First */
- rank >= 0 && rank <= ranges[i][1]; /* Last */
- rank += ranges[i][2] /* Stride */ ) {
- index = smpi_group_index(group, rank);
- smpi_group_set_mapping(*newgroup, index, j);
- j++;
- }
+
+ *newgroup = smpi_group_new(size);
+ j = 0;
+ for (i = 0; i < n; i++) {
+ for (rank = ranges[i][0]; /* First */
+ rank >= 0; /* Last */
+ ) {
+ index = smpi_group_index(group, rank);
+ smpi_group_set_mapping(*newgroup, index, j);
+ j++;
+ rank += ranges[i][2]; /* Stride */
+ if (ranges[i][0]<ranges[i][1]){
+ if(rank > ranges[i][1])
+ break;
+ }else{
+ if(rank < ranges[i][1])
+ break;
+ }
}
}
}
- smpi_group_use(*newgroup);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
MPI_Group * newgroup)
{
- int retval, i, newrank, rank, size, index, add;
+ int retval, i, rank, newrank,oldrank, size, index, add;
smpi_bench_end();
if (group == MPI_GROUP_NULL) {
} else {
if (n == 0) {
*newgroup = group;
+ if(group!= smpi_comm_group(MPI_COMM_WORLD)
+ && group != MPI_GROUP_NULL
+ && group != smpi_comm_group(MPI_COMM_SELF)
+ && group != MPI_GROUP_EMPTY)
+ smpi_group_use(group);
} else {
size = smpi_group_size(group);
for (i = 0; i < n; i++) {
for (rank = ranges[i][0]; /* First */
- rank >= 0 && rank <= ranges[i][1]; /* Last */
- rank += ranges[i][2] /* Stride */ ) {
+ rank >= 0; /* Last */
+ ) {
size--;
+
+ rank += ranges[i][2]; /* Stride */
+ if (ranges[i][0]<ranges[i][1]){
+ if(rank > ranges[i][1])
+ break;
+ }else{
+ if(rank < ranges[i][1])
+ break;
+ }
}
}
if (size == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
*newgroup = smpi_group_new(size);
- newrank = 0;
+ newrank=0;
+ oldrank=0;
while (newrank < size) {
+ add=1;
for (i = 0; i < n; i++) {
- add = 1;
- for (rank = ranges[i][0]; /* First */
- rank >= 0 && rank <= ranges[i][1]; /* Last */
- rank += ranges[i][2] /* Stride */ ) {
- if (rank == newrank) {
- add = 0;
- break;
+ for (rank = ranges[i][0];rank >= 0;){
+ if(rank==oldrank){
+ add=0;
+ break;
+ }
+
+ rank += ranges[i][2]; /* Stride */
+
+ if (ranges[i][0]<ranges[i][1]){
+ if(rank > ranges[i][1])
+ break;
+ }else{
+ if(rank < ranges[i][1])
+ break;
}
- }
- if (add == 1) {
- index = smpi_group_index(group, newrank);
- smpi_group_set_mapping(*newgroup, index, newrank);
}
}
- newrank++; //added to avoid looping, need to be checked ..
+ if(add==1){
+ index = smpi_group_index(group, oldrank);
+ smpi_group_set_mapping(*newgroup, index, newrank);
+ newrank++;
+ }
+ oldrank++;
}
}
}
- smpi_group_use(*newgroup);
+
retval = MPI_SUCCESS;
}
smpi_bench_begin();
retval = MPI_ERR_ARG;
} else {
*group = smpi_comm_group(comm);
+ if(*group!= smpi_comm_group(MPI_COMM_WORLD)
+ && *group != MPI_GROUP_NULL
+ && *group != smpi_comm_group(MPI_COMM_SELF)
+ && *group != MPI_GROUP_EMPTY)
+ smpi_group_use(*group);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
retval = MPI_ERR_GROUP;
} else if (newcomm == NULL) {
retval = MPI_ERR_ARG;
- } else {
+ } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
+ *newcomm= MPI_COMM_NULL;
+ retval = MPI_SUCCESS;
+ }else{
+
*newcomm = smpi_comm_new(group);
retval = MPI_SUCCESS;
}
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
} else if (source == MPI_PROC_NULL) {
+ *flag=TRUE;
smpi_empty_status(status);
status->MPI_SOURCE = MPI_PROC_NULL;
retval = MPI_SUCCESS;
int retval;
smpi_bench_end();
- if (outcount == NULL || indices == NULL) {
+ if (outcount == NULL) {
retval = MPI_ERR_ARG;
} else {
*outcount = smpi_mpi_waitsome(incount, requests, indices, status);
int retval;
smpi_bench_end();
- if (outcount == NULL || indices == NULL) {
+ if (outcount == NULL) {
retval = MPI_ERR_ARG;
} else {
*outcount = smpi_mpi_testsome(incount, requests, indices, status);
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (sendtype == MPI_DATATYPE_NULL
- || recvtype == MPI_DATATYPE_NULL) {
+ } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
+ ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
retval = MPI_ERR_TYPE;
+ } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
+ ((smpi_comm_rank(comm) == root) && (recvcount <0))){
+ retval = MPI_ERR_COUNT;
} else {
- mpi_coll_gather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
+
+ char* sendtmpbuf = (char*) sendbuf;
+ int sendtmpcount = sendcount;
+ MPI_Datatype sendtmptype = sendtype;
+ if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
+ sendtmpcount=0;
+ sendtmptype=recvtype;
+ }
+
+ mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
recvtype, root, comm);
+
+
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (sendtype == MPI_DATATYPE_NULL
- || recvtype == MPI_DATATYPE_NULL) {
+ } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
+ ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
retval = MPI_ERR_TYPE;
+ } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
+ retval = MPI_ERR_COUNT;
} else if (recvcounts == NULL || displs == NULL) {
retval = MPI_ERR_ARG;
} else {
- smpi_mpi_gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
+
+ char* sendtmpbuf = (char*) sendbuf;
+ int sendtmpcount = sendcount;
+ MPI_Datatype sendtmptype = sendtype;
+ if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
+ sendtmpcount=0;
+ sendtmptype=recvtype;
+ }
+
+ smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
displs, recvtype, root, comm);
retval = MPI_SUCCESS;
}
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (sendtype == MPI_DATATYPE_NULL
- || recvtype == MPI_DATATYPE_NULL) {
+ } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
+ (recvtype == MPI_DATATYPE_NULL)){
retval = MPI_ERR_TYPE;
+ } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
+ (recvcount <0)){
+ retval = MPI_ERR_COUNT;
} else {
+
+ if(sendbuf == MPI_IN_PLACE) {
+ sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
+ sendcount=recvcount;
+ sendtype=recvtype;
+ }
+
mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
recvtype, comm);
retval = MPI_SUCCESS;
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (sendtype == MPI_DATATYPE_NULL
- || recvtype == MPI_DATATYPE_NULL) {
+ } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
+ (recvtype == MPI_DATATYPE_NULL)){
retval = MPI_ERR_TYPE;
+ } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
+ retval = MPI_ERR_COUNT;
} else if (recvcounts == NULL || displs == NULL) {
retval = MPI_ERR_ARG;
} else {
+
+ if(sendbuf == MPI_IN_PLACE) {
+ sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
+ sendcount=recvcounts[smpi_comm_rank(comm)];
+ sendtype=recvtype;
+ }
+
mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
displs, recvtype, comm);
retval = MPI_SUCCESS;
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (sendtype == MPI_DATATYPE_NULL
- || recvtype == MPI_DATATYPE_NULL) {
+ } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
+ || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
retval = MPI_ERR_TYPE;
} else {
+ if (recvbuf == MPI_IN_PLACE) {
+ recvtype=sendtype;
+ recvcount=sendcount;
+ }
mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
recvtype, root, comm);
retval = MPI_SUCCESS;
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (sendtype == MPI_DATATYPE_NULL
- || recvtype == MPI_DATATYPE_NULL) {
- retval = MPI_ERR_TYPE;
} else if (sendcounts == NULL || displs == NULL) {
retval = MPI_ERR_ARG;
+ } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
+ || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
+ retval = MPI_ERR_TYPE;
} else {
+ if (recvbuf == MPI_IN_PLACE) {
+ recvtype=sendtype;
+ recvcount=sendcounts[smpi_comm_rank(comm)];
+ }
smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
recvcount, recvtype, root, comm);
retval = MPI_SUCCESS;
} else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
retval = MPI_ERR_ARG;
} else {
+
mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
+
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
} else {
- mpi_coll_allreduce_fun(sendbuf, recvbuf, count, datatype, op, comm);
+
+ char* sendtmpbuf = (char*) sendbuf;
+ if( sendbuf == MPI_IN_PLACE ) {
+ sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
+ smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
+ }
+
+ mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
+
+ if( sendbuf == MPI_IN_PLACE ) {
+ xbt_free(sendtmpbuf);
+ }
+
retval = MPI_SUCCESS;
+
}
#ifdef HAVE_TRACING
TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
return retval;
}
+int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
+ MPI_Op op, MPI_Comm comm){
+ int retval;
+
+ smpi_bench_end();
+#ifdef HAVE_TRACING
+ int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+ TRACE_smpi_computing_out(rank);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
+#endif
+ if (comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else if (datatype == MPI_DATATYPE_NULL) {
+ retval = MPI_ERR_TYPE;
+ } else if (op == MPI_OP_NULL) {
+ retval = MPI_ERR_OP;
+ } else {
+ smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
+ retval = MPI_SUCCESS;
+ }
+#ifdef HAVE_TRACING
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+ TRACE_smpi_computing_in(rank);
+#endif
+ smpi_bench_begin();
+ return retval;
+}
+
int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
} else if (recvcounts == NULL) {
retval = MPI_ERR_ARG;
} else {
+ void* sendtmpbuf=sendbuf;
+ if(sendbuf==MPI_IN_PLACE){
+ sendtmpbuf=recvbuf;
+ }
- mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
+ mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
datatype, op, comm);
retval = MPI_SUCCESS;
}
NOT_YET_IMPLEMENTED
}
-int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
- MPI_Op op, MPI_Comm comm){
- NOT_YET_IMPLEMENTED
-}
-
int PMPI_Comm_set_name(MPI_Comm comm, char* name){
NOT_YET_IMPLEMENTED
}