* under the terms of the license (GNU LGPL) which comes with this package. */
#include <simgrid/s4u/host.hpp>
+#include <src/smpi/smpi_group.hpp>
#include <xbt/ex.hpp>
#include "private.h"
if (group == nullptr) {
return MPI_ERR_ARG;
} else {
- smpi_group_destroy(*group);
+ (*group)->destroy();
*group = MPI_GROUP_NULL;
return MPI_SUCCESS;
}
} else if (size == nullptr) {
return MPI_ERR_ARG;
} else {
- *size = smpi_group_size(group);
+ *size = group->size();
return MPI_SUCCESS;
}
}
} else if (rank == nullptr) {
return MPI_ERR_ARG;
} else {
- *rank = smpi_group_rank(group, smpi_process_index());
+ *rank = group->rank(smpi_process_index());
return MPI_SUCCESS;
}
}
if(ranks1[i]==MPI_PROC_NULL){
ranks2[i]=MPI_PROC_NULL;
}else{
- int index = smpi_group_index(group1, ranks1[i]);
- ranks2[i] = smpi_group_rank(group2, index);
+ int index = group1->index(ranks1[i]);
+ ranks2[i] = group2->rank(index);
}
}
return MPI_SUCCESS;
} else if (result == nullptr) {
return MPI_ERR_ARG;
} else {
- *result = smpi_group_compare(group1, group2);
+ *result = group1->compare(group2);
return MPI_SUCCESS;
}
}
} else if (newgroup == nullptr) {
return MPI_ERR_ARG;
} else {
- int size = smpi_group_size(group1);
- int size2 = smpi_group_size(group2);
- for (int i = 0; i < size2; i++) {
- int proc2 = smpi_group_index(group2, i);
- int proc1 = smpi_group_rank(group1, proc2);
- if (proc1 == MPI_UNDEFINED) {
- size++;
- }
- }
- if (size == 0) {
- *newgroup = MPI_GROUP_EMPTY;
- } else {
- *newgroup = smpi_group_new(size);
- size2 = smpi_group_size(group1);
- for (int i = 0; i < size2; i++) {
- int proc1 = smpi_group_index(group1, i);
- smpi_group_set_mapping(*newgroup, proc1, i);
- }
- for (int i = size2; i < size; i++) {
- int proc2 = smpi_group_index(group2, i - size2);
- smpi_group_set_mapping(*newgroup, proc2, i);
- }
- }
- return MPI_SUCCESS;
+ return group1->group_union(group2, newgroup);
}
}
} else if (newgroup == nullptr) {
return MPI_ERR_ARG;
} else {
- int size = smpi_group_size(group2);
- for (int i = 0; i < size; i++) {
- int proc2 = smpi_group_index(group2, i);
- int proc1 = smpi_group_rank(group1, proc2);
- if (proc1 == MPI_UNDEFINED) {
- size--;
- }
- }
- if (size == 0) {
- *newgroup = MPI_GROUP_EMPTY;
- } else {
- *newgroup = smpi_group_new(size);
- int j=0;
- for (int i = 0; i < smpi_group_size(group2); i++) {
- int proc2 = smpi_group_index(group2, i);
- int proc1 = smpi_group_rank(group1, proc2);
- if (proc1 != MPI_UNDEFINED) {
- smpi_group_set_mapping(*newgroup, proc2, j);
- j++;
- }
- }
- }
- return MPI_SUCCESS;
+ return group1->intersection(group2,newgroup);
}
}
} else if (newgroup == nullptr) {
return MPI_ERR_ARG;
} else {
- int size = smpi_group_size(group1);
- int size2 = size;
- for (int i = 0; i < size2; i++) {
- int proc1 = smpi_group_index(group1, i);
- int proc2 = smpi_group_rank(group2, proc1);
- if (proc2 != MPI_UNDEFINED) {
- size--;
- }
- }
- if (size == 0) {
- *newgroup = MPI_GROUP_EMPTY;
- } else {
- *newgroup = smpi_group_new(size);
- for (int i = 0; i < size2; i++) {
- int proc1 = smpi_group_index(group1, i);
- int proc2 = smpi_group_rank(group2, proc1);
- if (proc2 == MPI_UNDEFINED) {
- smpi_group_set_mapping(*newgroup, proc1, i);
- }
- }
- }
- return MPI_SUCCESS;
+ return group1->difference(group2,newgroup);
}
}
} else if (newgroup == nullptr) {
return MPI_ERR_ARG;
} else {
- return smpi_group_incl(group, n, ranks, newgroup);
+ return group->incl(n, ranks, newgroup);
}
}
} else {
if (n == 0) {
*newgroup = group;
- if (group != smpi_comm_group(MPI_COMM_WORLD)
- && group != smpi_comm_group(MPI_COMM_SELF) && group != MPI_GROUP_EMPTY)
- smpi_group_use(group);
- } else if (n == smpi_group_size(group)) {
+ if (group != MPI_COMM_WORLD->group()
+ && group != MPI_COMM_SELF->group() && group != MPI_GROUP_EMPTY)
+ group->use();
+ return MPI_SUCCESS;
+ } else if (n == group->size()) {
*newgroup = MPI_GROUP_EMPTY;
+ return MPI_SUCCESS;
} else {
- int oldsize = smpi_group_size(group);
- int newsize = oldsize - n;
- *newgroup = smpi_group_new(newsize);
-
- int* to_exclude=xbt_new0(int, smpi_group_size(group));
- for (int i = 0; i < oldsize; i++)
- to_exclude[i]=0;
- for (int i = 0; i < n; i++)
- to_exclude[ranks[i]]=1;
-
- int j = 0;
- for (int i = 0; i < oldsize; i++) {
- if(to_exclude[i]==0){
- int index = smpi_group_index(group, i);
- smpi_group_set_mapping(*newgroup, index, j);
- j++;
- }
- }
-
- xbt_free(to_exclude);
+ return group->excl(n,ranks,newgroup);
}
- return MPI_SUCCESS;
}
}
} else {
if (n == 0) {
*newgroup = MPI_GROUP_EMPTY;
+ return MPI_SUCCESS;
} else {
- int size = 0;
- for (int i = 0; i < n; i++) {
- for (int rank = ranges[i][0]; /* First */
- rank >= 0 && rank < smpi_group_size(group); /* Last */
- ) {
- size++;
- if(rank == ranges[i][1]){/*already last ?*/
- 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;
- }
- }
- }
-
- *newgroup = smpi_group_new(size);
- int j = 0;
- for (int i = 0; i < n; i++) {
- for (int rank = ranges[i][0]; /* First */
- rank >= 0 && rank < smpi_group_size(group); /* Last */
- ) {
- int index = smpi_group_index(group, rank);
- smpi_group_set_mapping(*newgroup, index, j);
- j++;
- if(rank == ranges[i][1]){/*already last ?*/
- 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;
- }
- }
- }
+ return group->range_incl(n,ranges,newgroup);
}
- return MPI_SUCCESS;
}
}
} else {
if (n == 0) {
*newgroup = group;
- if (group != smpi_comm_group(MPI_COMM_WORLD) && group != smpi_comm_group(MPI_COMM_SELF) &&
+ if (group != MPI_COMM_WORLD->group() && group != MPI_COMM_SELF->group() &&
group != MPI_GROUP_EMPTY)
- smpi_group_use(group);
+ group->use();
+ return MPI_SUCCESS;
} else {
- int size = smpi_group_size(group);
- for (int i = 0; i < n; i++) {
- for (int rank = ranges[i][0]; /* First */
- rank >= 0 && rank < smpi_group_size(group); /* Last */
- ) {
- size--;
- if(rank == ranges[i][1]){/*already last ?*/
- 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 (size == 0) {
- *newgroup = MPI_GROUP_EMPTY;
- } else {
- *newgroup = smpi_group_new(size);
- int newrank = 0;
- int oldrank = 0;
- while (newrank < size) {
- int add = 1;
- for (int i = 0; i < n; i++) {
- for (int rank = ranges[i][0]; rank >= 0 && rank < smpi_group_size(group);) {
- if(rank==oldrank){
- add = 0;
- break;
- }
- if(rank == ranges[i][1]){/*already last ?*/
- 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){
- int index = smpi_group_index(group, oldrank);
- smpi_group_set_mapping(*newgroup, index, newrank);
- newrank++;
- }
- oldrank++;
- }
- }
+ return group->range_excl(n,ranges,newgroup);
}
- return MPI_SUCCESS;
}
}
} else if (rank == nullptr) {
return MPI_ERR_ARG;
} else {
- *rank = smpi_comm_rank(comm);
+ *rank = comm->rank();
return MPI_SUCCESS;
}
}
} else if (size == nullptr) {
return MPI_ERR_ARG;
} else {
- *size = smpi_comm_size(comm);
+ *size = comm->size();
return MPI_SUCCESS;
}
}
} else if (name == nullptr || len == nullptr) {
return MPI_ERR_ARG;
} else {
- smpi_comm_get_name(comm, name, len);
+ comm->get_name(name, len);
return MPI_SUCCESS;
}
}
} else if (group == nullptr) {
return MPI_ERR_ARG;
} else {
- *group = smpi_comm_group(comm);
- if (*group != smpi_comm_group(MPI_COMM_WORLD) && *group != MPI_GROUP_NULL && *group != MPI_GROUP_EMPTY)
- smpi_group_use(*group);
+ *group = comm->group();
+ if (*group != MPI_COMM_WORLD->group() && *group != MPI_GROUP_NULL && *group != MPI_GROUP_EMPTY)
+ (*group)->use();
return MPI_SUCCESS;
}
}
if (comm1 == comm2) { /* Same communicators means same groups */
*result = MPI_IDENT;
} else {
- *result = smpi_group_compare(smpi_comm_group(comm1), smpi_comm_group(comm2));
+ *result = comm1->group()->compare(comm2->group());
if (*result == MPI_IDENT) {
*result = MPI_CONGRUENT;
}
} else if (newcomm == nullptr) {
return MPI_ERR_ARG;
} else {
- return smpi_comm_dup(comm, newcomm);
+ return comm->dup(newcomm);
}
}
return MPI_ERR_GROUP;
} else if (newcomm == nullptr) {
return MPI_ERR_ARG;
- } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
+ } else if(group->rank(smpi_process_index())==MPI_UNDEFINED){
*newcomm= MPI_COMM_NULL;
return MPI_SUCCESS;
}else{
- smpi_group_use(group);
- *newcomm = smpi_comm_new(group, nullptr);
+ group->use();
+ *newcomm = new simgrid::SMPI::Comm(group, nullptr);
return MPI_SUCCESS;
}
}
} else if (*comm == MPI_COMM_NULL) {
return MPI_ERR_COMM;
} else {
- smpi_comm_destroy(*comm);
+ (*comm)->destroy();
*comm = MPI_COMM_NULL;
return MPI_SUCCESS;
}
} else if (*comm == MPI_COMM_NULL) {
return MPI_ERR_COMM;
} else {
- smpi_comm_destroy(*comm);
+ (*comm)->destroy();
*comm = MPI_COMM_NULL;
return MPI_SUCCESS;
}
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
} else {
- *comm_out = smpi_comm_split(comm, color, key);
+ *comm_out = comm->split(color, key);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
} else if (src == MPI_PROC_NULL) {
*request = MPI_REQUEST_NULL;
retval = MPI_SUCCESS;
- } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
+ } else if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int src_traced = smpi_group_index(smpi_comm_group(comm), src);
+ int src_traced = comm->group()->index(src);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_IRECV;
} else if (dst == MPI_PROC_NULL) {
*request = MPI_REQUEST_NULL;
retval = MPI_SUCCESS;
- } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
+ } else if (dst >= comm->group()->size() || dst <0){
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
retval = MPI_ERR_TAG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
+ int dst_traced = comm->group()->index(dst);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_ISEND;
extra->src = rank;
} else if (dst == MPI_PROC_NULL) {
*request = MPI_REQUEST_NULL;
retval = MPI_SUCCESS;
- } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
+ } else if (dst >= comm->group()->size() || dst <0){
retval = MPI_ERR_RANK;
} else if ((count < 0)|| (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
retval = MPI_ERR_TAG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
+ int dst_traced = comm->group()->index(dst);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_ISSEND;
extra->src = rank;
smpi_empty_status(status);
status->MPI_SOURCE = MPI_PROC_NULL;
retval = MPI_SUCCESS;
- } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
+ } else if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
retval = MPI_ERR_TAG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int src_traced = smpi_group_index(smpi_comm_group(comm), src);
+ int src_traced = comm->group()->index(src);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_RECV;
extra->src = src_traced;
// the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
if (status != MPI_STATUS_IGNORE) {
- src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
+ src_traced = comm->group()->index(status->MPI_SOURCE);
if (!TRACE_smpi_view_internals()) {
TRACE_smpi_recv(rank, src_traced, rank, tag);
}
retval = MPI_ERR_COMM;
} else if (dst == MPI_PROC_NULL) {
retval = MPI_SUCCESS;
- } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
+ } else if (dst >= comm->group()->size() || dst <0){
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf == nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
retval = MPI_ERR_TAG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
+ int dst_traced = comm->group()->index(dst);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_SEND;
extra->src = rank;
retval = MPI_ERR_COMM;
} else if (dst == MPI_PROC_NULL) {
retval = MPI_SUCCESS;
- } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
+ } else if (dst >= comm->group()->size() || dst <0){
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
retval = MPI_ERR_TAG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
+ int dst_traced = comm->group()->index(dst);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_SSEND;
extra->src = rank;
smpi_empty_status(status);
status->MPI_SOURCE = MPI_PROC_NULL;
retval = MPI_SUCCESS;
- }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
- (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
+ }else if (dst >= comm->group()->size() || dst <0 ||
+ (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0))){
retval = MPI_ERR_RANK;
} else if ((sendcount < 0 || recvcount<0) ||
(sendbuf==nullptr && sendcount > 0) || (recvbuf==nullptr && recvcount>0)) {
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
- int src_traced = smpi_group_index(smpi_comm_group(comm), src);
+ int dst_traced = comm->group()->index(dst);
+ int src_traced = comm->group()->index(src);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_SENDRECV;
extra->src = src_traced;
if (is_wait_for_receive) {
if(src_traced==MPI_ANY_SOURCE)
src_traced = (status!=MPI_STATUS_IGNORE) ?
- smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE) :
+ comm->group()->rank(status->MPI_SOURCE) :
src_traced;
TRACE_smpi_recv(rank, src_traced, dst_traced, tag_traced);
}
if (is_wait_for_receive) {
if(savedvals[*index].src==MPI_ANY_SOURCE)
src_traced = (status != MPI_STATUSES_IGNORE)
- ? smpi_group_rank(smpi_comm_group(savedvals[*index].comm), status->MPI_SOURCE)
+ ? savedvals[*index].comm->group()->rank(status->MPI_SOURCE)
: savedvals[*index].src;
TRACE_smpi_recv(rank_traced, src_traced, dst_traced, savedvals[*index].tag);
}
if (is_wait_for_receive) {
if(src_traced==MPI_ANY_SOURCE)
src_traced = (status!=MPI_STATUSES_IGNORE) ?
- smpi_group_rank(smpi_comm_group(savedvals[i].comm), status[i].MPI_SOURCE) : savedvals[i].src;
+ savedvals[i].comm->group()->rank(status[i].MPI_SOURCE) : savedvals[i].src;
TRACE_smpi_recv(rank_traced, src_traced, dst_traced,savedvals[i].tag);
}
}
retval = MPI_ERR_ARG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+ int root_traced = comm->group()->index(root);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_BCAST;
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count * dt_size_send;
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
- if (smpi_comm_size(comm) > 1)
+ if (comm->size() > 1)
mpi_coll_bcast_fun(buf, count, datatype, root, comm);
retval = MPI_SUCCESS;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
} else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
- ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
+ ((comm->rank() == root) && (recvtype == MPI_DATATYPE_NULL))){
retval = MPI_ERR_TYPE;
- } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) || ((smpi_comm_rank(comm) == root) && (recvcount <0))){
+ } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) || ((comm->rank() == root) && (recvcount <0))){
retval = MPI_ERR_COUNT;
} else {
char* sendtmpbuf = static_cast<char*>(sendbuf);
int sendtmpcount = sendcount;
MPI_Datatype sendtmptype = sendtype;
- if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
+ if( (comm->rank() == root) && (sendbuf == MPI_IN_PLACE )) {
sendtmpcount=0;
sendtmptype=recvtype;
}
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+ int root_traced = comm->group()->index(root);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_GATHER;
extra->root = root_traced;
extra->send_size = sendtmpcount * dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
- if ((smpi_comm_rank(comm) == root) && known == 0)
+ if ((comm->rank() == root) && known == 0)
dt_size_recv = smpi_datatype_size(recvtype);
extra->recv_size = recvcount * dt_size_recv;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
} else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
- ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
+ ((comm->rank() == root) && (recvtype == MPI_DATATYPE_NULL))){
retval = MPI_ERR_TYPE;
} else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
retval = MPI_ERR_COUNT;
char* sendtmpbuf = static_cast<char*>(sendbuf);
int sendtmpcount = sendcount;
MPI_Datatype sendtmptype = sendtype;
- if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
+ if( (comm->rank() == root) && (sendbuf == MPI_IN_PLACE )) {
sendtmpcount=0;
sendtmptype=recvtype;
}
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+ int root_traced = comm->group()->index(root);
int i = 0;
- int size = smpi_comm_size(comm);
+ int size = comm->size();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_GATHERV;
extra->num_processes = size;
int dt_size_recv = 1;
if (known == 0)
dt_size_recv = smpi_datatype_size(recvtype);
- if ((smpi_comm_rank(comm) == root)) {
+ if ((comm->rank() == root)) {
extra->recvcounts = xbt_new(int, size);
for (i = 0; i < size; i++) // copy data to avoid bad free
extra->recvcounts[i] = recvcounts[i] * dt_size_recv;
retval = MPI_ERR_COUNT;
} else {
if(sendbuf == MPI_IN_PLACE) {
- sendbuf=static_cast<char*>(recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
+ sendbuf=static_cast<char*>(recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*comm->rank();
sendcount=recvcount;
sendtype=recvtype;
}
} else {
if(sendbuf == MPI_IN_PLACE) {
- sendbuf=static_cast<char*>(recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
- sendcount=recvcounts[smpi_comm_rank(comm)];
+ sendbuf=static_cast<char*>(recvbuf)+smpi_datatype_get_extent(recvtype)*displs[comm->rank()];
+ sendcount=recvcounts[comm->rank()];
sendtype=recvtype;
}
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
int i = 0;
- int size = smpi_comm_size(comm);
+ int size = comm->size();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_ALLGATHERV;
extra->num_processes = size;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (((smpi_comm_rank(comm) == root) && (!is_datatype_valid(sendtype))) ||
+ } else if (((comm->rank() == root) && (!is_datatype_valid(sendtype))) ||
((recvbuf != MPI_IN_PLACE) && (!is_datatype_valid(recvtype)))) {
retval = MPI_ERR_TYPE;
} else if ((sendbuf == recvbuf) ||
- ((smpi_comm_rank(comm)==root) && sendcount>0 && (sendbuf == nullptr))){
+ ((comm->rank()==root) && sendcount>0 && (sendbuf == nullptr))){
retval = MPI_ERR_BUFFER;
}else {
recvcount = sendcount;
}
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+ int root_traced = comm->group()->index(root);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_SCATTER;
extra->root = root_traced;
int known = 0;
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
- if ((smpi_comm_rank(comm) == root) && known == 0)
+ if ((comm->rank() == root) && known == 0)
dt_size_send = smpi_datatype_size(sendtype);
extra->send_size = sendcount * dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
retval = MPI_ERR_COMM;
} else if (sendcounts == nullptr || displs == nullptr) {
retval = MPI_ERR_ARG;
- } else if (((smpi_comm_rank(comm) == root) && (sendtype == MPI_DATATYPE_NULL)) ||
+ } else if (((comm->rank() == 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)];
+ recvcount = sendcounts[comm->rank()];
}
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+ int root_traced = comm->group()->index(root);
int i = 0;
- int size = smpi_comm_size(comm);
+ int size = comm->size();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_SCATTERV;
extra->num_processes = size;
int dt_size_send = 1;
if (known == 0)
dt_size_send = smpi_datatype_size(sendtype);
- if ((smpi_comm_rank(comm) == root)) {
+ if ((comm->rank() == root)) {
extra->sendcounts = xbt_new(int, size);
for (i = 0; i < size; i++) // copy data to avoid bad free
extra->sendcounts[i] = sendcounts[i] * dt_size_send;
retval = MPI_ERR_ARG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
- int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+ int root_traced = comm->group()->index(root);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_REDUCE;
int known = 0;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
int i = 0;
- int size = smpi_comm_size(comm);
+ int size = comm->size();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_REDUCE_SCATTER;
extra->num_processes = size;
} else if (recvcount < 0) {
retval = MPI_ERR_ARG;
} else {
- int count = smpi_comm_size(comm);
+ int count = comm->size();
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
int sendtmpcount = sendcount;
MPI_Datatype sendtmptype = sendtype;
if (sendbuf == MPI_IN_PLACE) {
- sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * smpi_comm_size(comm) * smpi_datatype_size(recvtype)));
- memcpy(sendtmpbuf, recvbuf, recvcount * smpi_comm_size(comm) * smpi_datatype_size(recvtype));
+ sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * comm->size() * smpi_datatype_size(recvtype)));
+ memcpy(sendtmpbuf, recvbuf, recvcount * comm->size() * smpi_datatype_size(recvtype));
sendtmpcount = recvcount;
sendtmptype = recvtype;
}
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
int i = 0;
- int size = smpi_comm_size(comm);
+ int size = comm->size();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->type = TRACING_ALLTOALLV;
extra->send_size = 0;
}
int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
- if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) {
+ if(comm == MPI_COMM_NULL || comm->topo() == nullptr) {
return MPI_ERR_TOPOLOGY;
}
if (coords == nullptr) {
}
int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
- if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) {
+ if(comm == MPI_COMM_NULL || comm->topo() == nullptr) {
return MPI_ERR_TOPOLOGY;
}
if (source == nullptr || dest == nullptr || direction < 0 ) {
}
int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
- if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) {
+ if(comm == MPI_COMM_NULL || comm->topo() == nullptr) {
return MPI_ERR_TOPOLOGY;
}
- if (rank < 0 || rank >= smpi_comm_size(comm)) {
+ if (rank < 0 || rank >= comm->size()) {
return MPI_ERR_RANK;
}
if (maxdims <= 0) {
}
int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
- if(comm == nullptr || smpi_comm_topo(comm) == nullptr) {
+ if(comm == nullptr || comm->topo() == nullptr) {
return MPI_ERR_TOPOLOGY;
}
if(maxdims <= 0 || dims == nullptr || periods == nullptr || coords == nullptr) {
}
int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
- if (comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) {
+ if (comm == MPI_COMM_NULL || comm->topo() == nullptr) {
return MPI_ERR_TOPOLOGY;
}
if (ndims == nullptr) {
}
int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
- if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) {
+ if(comm == MPI_COMM_NULL || comm->topo() == nullptr) {
return MPI_ERR_TOPOLOGY;
}
if (comm_new == nullptr) {
return MPI_ERR_WIN;
}else {
smpi_mpi_win_get_group(win, group);
- smpi_group_use(*group);
+ (*group)->use();
return MPI_SUCCESS;
}
}
int rank = smpi_process_index();
MPI_Group group;
smpi_mpi_win_get_group(win, &group);
- int src_traced = smpi_group_index(group, target_rank);
+ int src_traced = group->index(target_rank);
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, nullptr);
retval = smpi_mpi_get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
int rank = smpi_process_index();
MPI_Group group;
smpi_mpi_win_get_group(win, &group);
- int dst_traced = smpi_group_index(group, target_rank);
+ int dst_traced = group->index(target_rank);
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, nullptr);
TRACE_smpi_send(rank, rank, dst_traced, SMPI_RMA_TAG, origin_count*smpi_datatype_size(origin_datatype));
int rank = smpi_process_index();
MPI_Group group;
smpi_mpi_win_get_group(win, &group);
- int src_traced = smpi_group_index(group, target_rank);
+ int src_traced = group->index(target_rank);
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, nullptr);
retval = smpi_mpi_accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
else if (comm==MPI_COMM_NULL)
return MPI_ERR_COMM;
else
- return smpi_comm_attr_delete(comm, keyval);
+ return comm->attr_delete(keyval);
}
int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
*static_cast<int**>(attr_value) = &one;
return MPI_SUCCESS;
default:
- return smpi_comm_attr_get(comm, keyval, attr_value, flag);
+ return comm->attr_get(keyval, attr_value, flag);
}
}
else if (comm==MPI_COMM_NULL)
return MPI_ERR_COMM;
else
- return smpi_comm_attr_put(comm, keyval, attr_value);
+ return comm->attr_put(keyval, attr_value);
}
int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)