From: degomme Date: Wed, 27 Mar 2019 15:04:31 +0000 (+0100) Subject: Add MPI_Request_get_status, MPI_Status_set_cancelled, MPI_Status_set_elements X-Git-Tag: v3_22~25^2~5 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7286db70052377cc68be20134867bf68aa2e4a6a Add MPI_Request_get_status, MPI_Status_set_cancelled, MPI_Status_set_elements --- diff --git a/src/smpi/bindings/smpi_mpi.cpp b/src/smpi/bindings/smpi_mpi.cpp index 30ced0be0c..5c905b79d3 100644 --- a/src/smpi/bindings/smpi_mpi.cpp +++ b/src/smpi/bindings/smpi_mpi.cpp @@ -193,6 +193,7 @@ WRAPPED_PMPI_CALL(int,MPI_Testall,(int count, MPI_Request* requests, int* flag, WRAPPED_PMPI_CALL(int,MPI_Testany,(int count, MPI_Request requests[], int *index, int *flag, MPI_Status * status),(count, requests, index, flag, status)) WRAPPED_PMPI_CALL(int,MPI_Test,(MPI_Request * request, int *flag, MPI_Status * status),(request, flag, status)) WRAPPED_PMPI_CALL(int,MPI_Testsome,(int incount, MPI_Request* requests, int* outcount, int* indices, MPI_Status* statuses) ,(incount, requests, outcount, indices, statuses)) +WRAPPED_PMPI_CALL(int,MPI_Request_get_status,( MPI_Request request, int *flag, MPI_Status *status),( request, flag, status)) WRAPPED_PMPI_CALL(int,MPI_Grequest_complete,( MPI_Request request),( request)) WRAPPED_PMPI_CALL(int,MPI_Grequest_start,(MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn,MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request),( query_fn, free_fn, cancel_fn, extra_state, request)) WRAPPED_PMPI_CALL(int,MPI_Type_commit,(MPI_Datatype* datatype) ,(datatype)) @@ -277,8 +278,10 @@ WRAPPED_PMPI_CALL_NORETURN(MPI_Info, MPI_Info_f2c,(MPI_Fint info),(info)) WRAPPED_PMPI_CALL_NORETURN(MPI_Op, MPI_Op_f2c,(MPI_Fint op),(op)) WRAPPED_PMPI_CALL_NORETURN(MPI_Request, MPI_Request_f2c,(MPI_Fint request),(request)) WRAPPED_PMPI_CALL_NORETURN(MPI_Win, MPI_Win_f2c,(MPI_Fint win),(win)) -WRAPPED_PMPI_CALL(int,MPI_Cancel,(MPI_Request* request) ,(request)) +WRAPPED_PMPI_CALL(int, MPI_Cancel,(MPI_Request* request) ,(request)) WRAPPED_PMPI_CALL(int, MPI_Test_cancelled,(MPI_Status* status, int* flag) ,(status, flag)) +WRAPPED_PMPI_CALL(int, MPI_Status_set_cancelled,(MPI_Status *status,int flag),(status,flag)) +WRAPPED_PMPI_CALL(int,MPI_Status_set_elements,( MPI_Status *status, MPI_Datatype datatype, int count),( status, datatype, count)) /* Unimplemented Calls - both PMPI and MPI calls are generated. When implementing, please move ahead, swap UNIMPLEMENTED_WRAPPED_PMPI_CALL for WRAPPED_PMPI_CALL, @@ -398,8 +401,6 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Pcontrol,(const int level, ... ),(level) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Publish_name,( char *service_name, MPI_Info info, char *port_name),( service_name, info, port_name)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Rsend_init,(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request),(buf, count, datatype, dest, tag, comm, request)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Rsend,(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) ,(buf, count, datatype, dest, tag, comm)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Status_set_cancelled,(MPI_Status *status,int flag),(status,flag)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Status_set_elements,( MPI_Status *status, MPI_Datatype datatype, int count),( status, datatype, count)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Topo_test,(MPI_Comm comm, int* top_type) ,(comm, top_type)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Type_create_darray,(int size, int rank, int ndims, int* array_of_gsizes, int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,int order, MPI_Datatype oldtype, MPI_Datatype *newtype) ,(size, rank, ndims, array_of_gsizes,array_of_distribs, array_of_dargs, array_of_psizes,order,oldtype, newtype)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Type_get_contents,(MPI_Datatype datatype, int max_integers, int max_addresses, int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses, MPI_Datatype *array_of_datatypes),(datatype, max_integers, max_addresses,max_datatypes, array_of_integers, array_of_addresses, array_of_datatypes)) diff --git a/src/smpi/bindings/smpi_pmpi_request.cpp b/src/smpi/bindings/smpi_pmpi_request.cpp index ab2bf5649b..ff6c1c6943 100644 --- a/src/smpi/bindings/smpi_pmpi_request.cpp +++ b/src/smpi/bindings/smpi_pmpi_request.cpp @@ -789,6 +789,21 @@ int PMPI_Test_cancelled(MPI_Status* status, int* flag){ return MPI_SUCCESS; } +int PMPI_Status_set_cancelled(MPI_Status* status, int flag){ + if(status==MPI_STATUS_IGNORE){ + return MPI_ERR_ARG; + } + simgrid::smpi::Status::set_cancelled(status,flag); + return MPI_SUCCESS; +} + +int PMPI_Status_set_elements(MPI_Status* status, MPI_Datatype datatype, int count){ + if(status==MPI_STATUS_IGNORE){ + return MPI_ERR_ARG; + } + simgrid::smpi::Status::set_elements(status,datatype, count); + return MPI_SUCCESS; +} int PMPI_Grequest_start( MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request){ return simgrid::smpi::Request::grequest_start(query_fn, free_fn,cancel_fn, extra_state, request); @@ -798,6 +813,16 @@ int PMPI_Grequest_complete( MPI_Request request){ return simgrid::smpi::Request::grequest_complete(request); } + +int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){ + if(request==MPI_REQUEST_NULL){ + return MPI_ERR_REQUEST; + } else if (flag==NULL || status ==NULL){ + return MPI_ERR_ARG; + } + return simgrid::smpi::Request::get_status(request,flag,status); +} + MPI_Request PMPI_Request_f2c(MPI_Fint request){ return static_cast(simgrid::smpi::Request::f2c(request)); } diff --git a/src/smpi/include/smpi_request.hpp b/src/smpi/include/smpi_request.hpp index 0c166fd14e..e15735375e 100644 --- a/src/smpi/include/smpi_request.hpp +++ b/src/smpi/include/smpi_request.hpp @@ -108,6 +108,8 @@ public: static int grequest_start( MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request); static int grequest_complete( MPI_Request request); + static int get_status(MPI_Request req, int* flag, MPI_Status * status); + int add_f() override; static void free_f(int id); static Request* f2c(int); diff --git a/src/smpi/include/smpi_status.hpp b/src/smpi/include/smpi_status.hpp index 4a9ddd4624..4018f9e71d 100644 --- a/src/smpi/include/smpi_status.hpp +++ b/src/smpi/include/smpi_status.hpp @@ -18,6 +18,8 @@ class Status{ public: static void empty(MPI_Status * status); static int cancelled (MPI_Status * status); +static void set_cancelled (MPI_Status * status, int flag); +static void set_elements (MPI_Status * status, MPI_Datatype , int count); static int get_count(MPI_Status * status, MPI_Datatype datatype); }; diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index b398ff0718..694a2b18d9 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -1058,6 +1058,32 @@ void Request::free_f(int id) } +int Request::get_status(MPI_Request req, int* flag, MPI_Status * status){ + *flag=0; + + if(req != MPI_REQUEST_NULL && req->action_ != nullptr) { + req->iprobe(req->src_, req->tag_, req->comm_, flag, status); + if(flag) + return MPI_SUCCESS; + } + if (req != MPI_REQUEST_NULL && + (req->flags_ & MPI_REQ_GENERALIZED) + && !(req->flags_ & MPI_REQ_COMPLETE)) { + *flag=0; + return MPI_SUCCESS; + } + + *flag=1; + if(status != MPI_STATUS_IGNORE) { + int src = req->src_ == MPI_ANY_SOURCE ? req->real_src_ : req->src_; + status->MPI_SOURCE = req->comm_->group()->rank(src); + status->MPI_TAG = req->tag_ == MPI_ANY_TAG ? req->real_tag_ : req->tag_; + status->MPI_ERROR = req->truncated_ ? MPI_ERR_TRUNCATE : MPI_SUCCESS; + status->count = req->real_size_; + } + return MPI_SUCCESS; +} + int Request::grequest_start( MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request){ *request = new Request(); diff --git a/src/smpi/mpi/smpi_status.cpp b/src/smpi/mpi/smpi_status.cpp index 0af84e2154..22690e27d5 100644 --- a/src/smpi/mpi/smpi_status.cpp +++ b/src/smpi/mpi/smpi_status.cpp @@ -27,6 +27,15 @@ int Status::cancelled(MPI_Status * status) return status->cancelled!=0; } +void Status::set_cancelled(MPI_Status * status, int flag) +{ + status->cancelled=flag; +} + +void Status::set_elements (MPI_Status * status, MPI_Datatype , int count){ + status->count=count; +} + int Status::get_count(MPI_Status * status, MPI_Datatype datatype) { return status->count / datatype->size();