From deb1c76a7b953888921c68a1ed77f170aca827de Mon Sep 17 00:00:00 2001 From: degomme Date: Sun, 19 Mar 2017 01:23:22 +0100 Subject: [PATCH] Add smpi_status.cpp and hpp. That's rather empty, as actually MPI_Status has to stay in C (its fields being public to the user codes). --- include/smpi/forward.hpp | 2 ++ src/smpi/colls/allgather/allgather-rdb.cpp | 4 ++-- .../colls/allgatherv/allgatherv-mpich-rdb.cpp | 4 ++-- src/smpi/colls/alltoall/alltoall-rdb.cpp | 4 ++-- .../colls/bcast/bcast-scatter-LR-allgather.cpp | 2 +- .../colls/bcast/bcast-scatter-rdb-allgather.cpp | 6 +++--- src/smpi/private.h | 5 +---- src/smpi/smpi_global.cpp | 14 -------------- src/smpi/smpi_pmpi.cpp | 14 +++++++------- src/smpi/smpi_request.cpp | 16 ++++++++-------- tools/cmake/DefinePackages.cmake | 2 ++ 11 files changed, 30 insertions(+), 43 deletions(-) diff --git a/include/smpi/forward.hpp b/include/smpi/forward.hpp index acbc310140..436c9b302f 100644 --- a/include/smpi/forward.hpp +++ b/include/smpi/forward.hpp @@ -22,7 +22,9 @@ class Group; class Info; class Keyval; class Op; +class Process; class Request; +class Status; class Topo; class Topo_Cart; class Topo_Graph; diff --git a/src/smpi/colls/allgather/allgather-rdb.cpp b/src/smpi/colls/allgather/allgather-rdb.cpp index 6d2950aa42..4564a40f0c 100644 --- a/src/smpi/colls/allgather/allgather-rdb.cpp +++ b/src/smpi/colls/allgather/allgather-rdb.cpp @@ -64,7 +64,7 @@ Coll_allgather_rdb::allgather(void *sbuf, int send_count, Request::sendrecv(recv_ptr + send_offset, curr_count, send_type, dst, tag, recv_ptr + recv_offset, mask * recv_count, recv_type, dst, tag, comm, &status); - last_recv_count = smpi_mpi_get_count(&status, recv_type); + last_recv_count = Status::get_count(&status, recv_type); curr_count += last_recv_count; } @@ -117,7 +117,7 @@ Coll_allgather_rdb::allgather(void *sbuf, int send_count, recv_type, dst, tag, comm, &status); // num_procs_completed is also equal to the no. of processes // whose data we don't have - last_recv_count = smpi_mpi_get_count(&status, recv_type); + last_recv_count = Status::get_count(&status, recv_type); curr_count += last_recv_count; } tmp_mask >>= 1; diff --git a/src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp b/src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp index 5d5f94537d..2f19e836b1 100644 --- a/src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp +++ b/src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp @@ -109,7 +109,7 @@ int Coll_allgatherv_mpich_rdb::allgatherv ( comm, &status); /* for convenience, recv is posted for a bigger amount than will be sent */ - last_recv_cnt=smpi_mpi_get_count(&status, recvtype); + last_recv_cnt=Status::get_count(&status, recvtype); curr_cnt += last_recv_cnt; } @@ -188,7 +188,7 @@ int Coll_allgatherv_mpich_rdb::allgatherv ( comm, &status); /* for convenience, recv is posted for a bigger amount than will be sent */ - last_recv_cnt=smpi_mpi_get_count(&status, recvtype); + last_recv_cnt=Status::get_count(&status, recvtype); curr_cnt += last_recv_cnt; } tmp_mask >>= 1; diff --git a/src/smpi/colls/alltoall/alltoall-rdb.cpp b/src/smpi/colls/alltoall/alltoall-rdb.cpp index f41ded7adf..2e9aa0e5d3 100644 --- a/src/smpi/colls/alltoall/alltoall-rdb.cpp +++ b/src/smpi/colls/alltoall/alltoall-rdb.cpp @@ -78,7 +78,7 @@ int Coll_alltoall_rdb::alltoall(void *send_buff, int send_count, tmp_buff + recv_offset, mask * recv_count * num_procs, recv_type, dst, tag, comm, &status); - last_recv_count = smpi_mpi_get_count(&status, recv_type); + last_recv_count = Status::get_count(&status, recv_type); curr_size += last_recv_count; } @@ -131,7 +131,7 @@ int Coll_alltoall_rdb::alltoall(void *send_buff, int send_count, mask * num_procs * send_count, send_type, dst, tag, comm, &status); - last_recv_count = smpi_mpi_get_count(&status, send_type); + last_recv_count = Status::get_count(&status, send_type); curr_size += last_recv_count; } diff --git a/src/smpi/colls/bcast/bcast-scatter-LR-allgather.cpp b/src/smpi/colls/bcast/bcast-scatter-LR-allgather.cpp index 3649c038e5..4adaa0029d 100644 --- a/src/smpi/colls/bcast/bcast-scatter-LR-allgather.cpp +++ b/src/smpi/colls/bcast/bcast-scatter-LR-allgather.cpp @@ -105,7 +105,7 @@ Coll_bcast_scatter_LR_allgather::bcast(void *buff, int count, else { Request::recv((char *) buff + relative_rank * scatter_size, recv_size, MPI_BYTE, src, tag, comm, &status); - curr_size = smpi_mpi_get_count(&status, MPI_BYTE); + curr_size = Status::get_count(&status, MPI_BYTE); } break; } diff --git a/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp b/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp index 9a94599edb..cb88efc67b 100644 --- a/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp +++ b/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp @@ -55,7 +55,7 @@ static int scatter_for_bcast( recv_size, MPI_BYTE, src, COLL_TAG_BCAST, comm, &status); /* query actual size of data received */ - curr_size=smpi_mpi_get_count(&status, MPI_BYTE); + curr_size=Status::get_count(&status, MPI_BYTE); } break; } @@ -210,7 +210,7 @@ Coll_bcast_scatter_rdb_allgather::bcast ( ((char *)tmp_buf + recv_offset), (nbytes-recv_offset < 0 ? 0 : nbytes-recv_offset), MPI_BYTE, dst, COLL_TAG_BCAST, comm, &status); - recv_size=smpi_mpi_get_count(&status, MPI_BYTE); + recv_size=Status::get_count(&status, MPI_BYTE); curr_size += recv_size; } @@ -293,7 +293,7 @@ Coll_bcast_scatter_rdb_allgather::bcast ( comm, &status); /* nprocs_completed is also equal to the no. of processes whose data we don't have */ - recv_size=smpi_mpi_get_count(&status, MPI_BYTE); + recv_size=Status::get_count(&status, MPI_BYTE); curr_size += recv_size; /* printf("Rank %d, recv from %d, offset %d, size %d\n", rank, dst, offset, recv_size); fflush(stdout);*/ diff --git a/src/smpi/private.h b/src/smpi/private.h index 047b7a821b..cfb141c510 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -26,6 +26,7 @@ #include "src/smpi/smpi_datatype.hpp" #include "src/smpi/smpi_datatype_derived.hpp" #include "src/smpi/smpi_request.hpp" +#include "src/smpi/smpi_status.hpp" #include "src/smpi/smpi_win.hpp" SG_BEGIN_DECL() @@ -93,10 +94,6 @@ XBT_PRIVATE void smpi_global_destroy(); XBT_PRIVATE double smpi_mpi_wtime(); XBT_PRIVATE void smpi_mpi_init(); -XBT_PRIVATE void smpi_empty_status(MPI_Status * status); -XBT_PRIVATE int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype); - - // utilities extern XBT_PRIVATE double smpi_cpu_threshold; extern XBT_PRIVATE double smpi_host_speed; diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index d5de9277de..6878d5d5b0 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -532,17 +532,3 @@ double smpi_mpi_wtime(){ return time; } -void smpi_empty_status(MPI_Status * status) -{ - if(status != MPI_STATUS_IGNORE) { - status->MPI_SOURCE = MPI_ANY_SOURCE; - status->MPI_TAG = MPI_ANY_TAG; - status->MPI_ERROR = MPI_SUCCESS; - status->count=0; - } -} - -int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype) -{ - return status->count / datatype->size(); -} diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index 7569a88113..33038bacda 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -873,7 +873,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (src == MPI_PROC_NULL) { - smpi_empty_status(status); + Status::empty(status); status->MPI_SOURCE = MPI_PROC_NULL; retval = MPI_SUCCESS; } else if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){ @@ -1019,7 +1019,7 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int dst, } else if (!sendtype->is_valid() || !recvtype->is_valid()) { retval = MPI_ERR_TYPE; } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) { - smpi_empty_status(status); + Status::empty(status); status->MPI_SOURCE = MPI_PROC_NULL; retval = MPI_SUCCESS; }else if (dst >= comm->group()->size() || dst <0 || @@ -1095,7 +1095,7 @@ int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status) retval = MPI_ERR_ARG; } else if (*request == MPI_REQUEST_NULL) { *flag= true; - smpi_empty_status(status); + Status::empty(status); retval = MPI_SUCCESS; } else { int rank = ((*request)->comm() != MPI_COMM_NULL) ? smpi_process()->index() : -1; @@ -1152,7 +1152,7 @@ int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) { } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (source == MPI_PROC_NULL) { - smpi_empty_status(status); + Status::empty(status); status->MPI_SOURCE = MPI_PROC_NULL; retval = MPI_SUCCESS; } else { @@ -1173,7 +1173,7 @@ int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* statu retval = MPI_ERR_COMM; } else if (source == MPI_PROC_NULL) { *flag=true; - smpi_empty_status(status); + Status::empty(status); status->MPI_SOURCE = MPI_PROC_NULL; retval = MPI_SUCCESS; } else { @@ -1190,7 +1190,7 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status) smpi_bench_end(); - smpi_empty_status(status); + Status::empty(status); if (request == nullptr) { retval = MPI_ERR_ARG; @@ -2154,7 +2154,7 @@ int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count) } else if (status->count % size != 0) { return MPI_UNDEFINED; } else { - *count = smpi_mpi_get_count(status, datatype); + *count = Status::get_count(status, datatype); return MPI_SUCCESS; } } diff --git a/src/smpi/smpi_request.cpp b/src/smpi/smpi_request.cpp index ab1b5f039d..46061fb72e 100644 --- a/src/smpi/smpi_request.cpp +++ b/src/smpi/smpi_request.cpp @@ -567,7 +567,7 @@ int Request::test(MPI_Request * request, MPI_Status * status) { if(smpi_test_sleep > 0) simcall_process_sleep(nsleeps*smpi_test_sleep); - smpi_empty_status(status); + Status::empty(status); int flag = 1; if (((*request)->flags_ & PREPARED) == 0) { if ((*request)->action_ != nullptr) @@ -650,7 +650,7 @@ int Request::testany(int count, MPI_Request requests[], int *index, MPI_Status * } else { //all requests are null or inactive, return true flag = 1; - smpi_empty_status(status); + Status::empty(status); } return flag; @@ -669,7 +669,7 @@ int Request::testall(int count, MPI_Request requests[], MPI_Status status[]) requests[i]=MPI_REQUEST_NULL; } }else{ - smpi_empty_status(pstat); + Status::empty(pstat); } if(status != MPI_STATUSES_IGNORE) { status[i] = *pstat; @@ -744,7 +744,7 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* void Request::finish_wait(MPI_Request* request, MPI_Status * status) { MPI_Request req = *request; - smpi_empty_status(status); + Status::empty(status); if(!((req->detached_ != 0) && ((req->flags_ & SEND) != 0)) && ((req->flags_ & PREPARED) == 0)){ if(status != MPI_STATUS_IGNORE) { @@ -805,7 +805,7 @@ void Request::wait(MPI_Request * request, MPI_Status * status) { (*request)->print_request("Waiting"); if ((*request)->flags_ & PREPARED) { - smpi_empty_status(status); + Status::empty(status); return; } @@ -872,7 +872,7 @@ int Request::waitany(int count, MPI_Request requests[], MPI_Status * status) } if (index==MPI_UNDEFINED) - smpi_empty_status(status); + Status::empty(status); return index; } @@ -893,9 +893,9 @@ int Request::waitall(int count, MPI_Request requests[], MPI_Status status[]) if (status != MPI_STATUSES_IGNORE) { for (int c = 0; c < count; c++) { if (requests[c] == MPI_REQUEST_NULL || requests[c]->dst_ == MPI_PROC_NULL || (requests[c]->flags_ & PREPARED)) { - smpi_empty_status(&status[c]); + Status::empty(&status[c]); } else if (requests[c]->src_ == MPI_PROC_NULL) { - smpi_empty_status(&status[c]); + Status::empty(&status[c]); status[c].MPI_SOURCE = MPI_PROC_NULL; } } diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 59e496d29f..5aa4170307 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -236,6 +236,8 @@ set(SMPI_SRC src/smpi/smpi_replay.cpp src/smpi/smpi_request.cpp src/smpi/smpi_request.hpp + src/smpi/smpi_status.cpp + src/smpi/smpi_status.hpp src/smpi/smpi_win.cpp src/smpi/smpi_win.hpp src/smpi/smpi_topo.cpp -- 2.20.1