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;
}
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;
+ }
}
}
}
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;
}
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){
+ recvcount=0;
+ }
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){
+ recvcount=0;
+ }
+
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);
+
+ 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_reduce_fun(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
+
+ if( sendbuf == MPI_IN_PLACE ) {
+ xbt_free(sendtmpbuf);
+ }
+
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
}