1
1

- introduction of user buffer checking for pt2pt operations

This commit was SVN r9449.
Этот коммит содержится в:
Sven Stork 2006-03-29 09:26:27 +00:00
родитель cf425f6289
Коммит 711b30fbac
15 изменённых файлов: 110 добавлений и 61 удалений

Просмотреть файл

@ -27,6 +27,7 @@
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/* If compiling in the profile directory, then we don't have weak
symbols and therefore we need the defines to map from MPI->PMPI.
NOTE: pragma weak stuff is handled on a file-by-file basis; it
@ -36,7 +37,7 @@ extern "C" {
/* This variable is actually in src/mpi/runtime/ompi_mpi_init.c, but it
is used by every MPI function. */
OMPI_DECLSPEC extern bool ompi_mpi_param_check;
OMPI_DECLSPEC extern bool ompi_mpi_param_check;
/* These macros have to be used to check the corectness of the datatype depending on the
* operations that we have to do with them. They can be used on all functions, not only
@ -44,36 +45,56 @@ OMPI_DECLSPEC extern bool ompi_mpi_param_check;
* responsability to do it.
*/
#define OMPI_CHECK_DATATYPE_FOR_SEND( RC, DDT, COUNT ) \
do { \
(RC) = MPI_SUCCESS; \
if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
else if( !ompi_ddt_is_committed((DDT)) ) (RC) = MPI_ERR_TYPE; \
else if( !ompi_ddt_is_valid((DDT)) ) (RC) = MPI_ERR_TYPE; \
} while (0)
#define OMPI_CHECK_DATATYPE_FOR_RECV( RC, DDT, COUNT ) \
do { \
(RC) = MPI_SUCCESS; \
if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
else if( !ompi_ddt_is_committed((DDT)) ) (RC) = MPI_ERR_TYPE; \
/* XXX Fix flags else if( ompi_ddt_is_overlapped((DDT)) ) (RC) = MPI_ERR_TYPE; */ \
else if( !ompi_ddt_is_valid((DDT)) ) (RC) = MPI_ERR_TYPE; \
} while (0)
do { \
/* (RC) = MPI_SUCCESS; */ \
if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
else if( !ompi_ddt_is_committed((DDT)) ) (RC) = MPI_ERR_TYPE; \
else if( !ompi_ddt_is_valid((DDT)) ) (RC) = MPI_ERR_TYPE; \
} while (0)
#define OMPI_CHECK_DATATYPE_FOR_RECV( RC, DDT, COUNT ) \
do { \
/* (RC) = MPI_SUCCESS; */ \
if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
else if( !ompi_ddt_is_committed((DDT)) ) (RC) = MPI_ERR_TYPE; \
/* XXX Fix flags else if( ompi_ddt_is_overlapped((DDT)) ) (RC) = MPI_ERR_TYPE; */ \
else if( !ompi_ddt_is_valid((DDT)) ) (RC) = MPI_ERR_TYPE; \
} while (0)
#define OMPI_CHECK_DATATYPE_FOR_ONE_SIDED( RC, DDT, COUNT ) \
do { \
(RC) = MPI_SUCCESS; \
if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
else if( !ompi_ddt_is_committed((DDT)) ) (RC) = MPI_ERR_TYPE; \
else if( ompi_ddt_is_overerlapped((DDT)) ) (RC) = MPI_ERR_TYPE; \
else if( !ompi_ddt_is_acceptable_for_one_sided((DDT)) ) (RC) = MPI_ERR_TYPE; \
else if( !ompi_ddt_is_valid((DDT)) ) (RC) = MPI_ERR_TYPE; \
} while(0)
do { \
/*(RC) = MPI_SUCCESS; */ \
if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \
else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \
else if( !ompi_ddt_is_committed((DDT)) ) (RC) = MPI_ERR_TYPE; \
else if( ompi_ddt_is_overerlapped((DDT)) ) (RC) = MPI_ERR_TYPE; \
else if( !ompi_ddt_is_acceptable_for_one_sided((DDT)) ) (RC) = MPI_ERR_TYPE; \
else if( !ompi_ddt_is_valid((DDT)) ) (RC) = MPI_ERR_TYPE; \
} while(0)
/* This macro has to be used to check the correctness of the user buffer depending on the datatype.
* This macro expects that the DDT parameter is a valid pointer to an ompi datatype object.
*/
#define OMPI_CHECK_USER_BUFFER(RC, BUFFER, DDT, COUNT) \
do { \
if ( NULL == (BUFFER) && 0 < (COUNT) && MPI_SUCCESS == (RC) ) { \
if ( (DDT)->flags & DT_FLAG_PREDEFINED ) { \
(RC) = MPI_ERR_BUFFER; \
} else { \
unsigned long size = 0; \
ompi_ddt_get_size((DDT), &size); \
if ( size ) { \
(RC) = MPI_ERR_BUFFER; \
} \
} \
} \
} while (0)
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* OMPI_C_BINDINGS_H */

Просмотреть файл

@ -35,13 +35,13 @@ static const char FUNC_NAME[] = "MPI_Bsend";
int MPI_Bsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm)
{
int rc;
int rc = MPI_SUCCESS;
if (dest == MPI_PROC_NULL) {
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
int rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
@ -53,6 +53,9 @@ int MPI_Bsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Co
rc = MPI_ERR_TAG;
} else if (ompi_comm_peer_invalid(comm, dest)) {
rc = MPI_ERR_RANK;
} else {
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -34,7 +34,8 @@ static const char FUNC_NAME[] = "MPI_Get_count";
int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count)
{
int size, rc;
int size = 0;
int rc = MPI_SUCCESS;
if (MPI_PARAM_CHECK) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);

Просмотреть файл

@ -36,14 +36,14 @@ static const char FUNC_NAME[] = "MPI_Ibsend";
int MPI_Ibsend(void *buf, int count, MPI_Datatype type, int dest,
int tag, MPI_Comm comm, MPI_Request *request)
{
int rc;
int rc = MPI_SUCCESS;
if (dest == MPI_PROC_NULL) {
*request = &ompi_request_empty;
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
@ -57,6 +57,9 @@ int MPI_Ibsend(void *buf, int count, MPI_Datatype type, int dest,
rc = MPI_ERR_RANK;
} else if (request == NULL) {
rc = MPI_ERR_REQUEST;
} else {
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -35,17 +35,18 @@ static const char FUNC_NAME[] = "MPI_Irecv";
int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source,
int tag, MPI_Comm comm, MPI_Request *request)
{
int rc;
int rc = MPI_SUCCESS;
if (source == MPI_PROC_NULL) {
*request = &ompi_request_empty;
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
OMPI_CHECK_DATATYPE_FOR_RECV(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
} else if (((tag < 0) && (tag != MPI_ANY_TAG)) || (tag > mca_pml.pml_max_tag)) {

Просмотреть файл

@ -36,14 +36,14 @@ static const char FUNC_NAME[] = "MPI_Isend";
int MPI_Isend(void *buf, int count, MPI_Datatype type, int dest,
int tag, MPI_Comm comm, MPI_Request *request)
{
int rc;
int rc = MPI_SUCCESS;
if (dest == MPI_PROC_NULL) {
*request = &ompi_request_empty;
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
@ -57,6 +57,9 @@ int MPI_Isend(void *buf, int count, MPI_Datatype type, int dest,
rc = MPI_ERR_RANK;
} else if (request == NULL) {
rc = MPI_ERR_REQUEST;
} else {
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -36,14 +36,14 @@ static const char FUNC_NAME[] = "MPI_Issend";
int MPI_Issend(void *buf, int count, MPI_Datatype type, int dest,
int tag, MPI_Comm comm, MPI_Request *request)
{
int rc;
int rc = MPI_SUCCESS;
if (dest == MPI_PROC_NULL) {
*request = &ompi_request_empty;
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
@ -57,10 +57,13 @@ int MPI_Issend(void *buf, int count, MPI_Datatype type, int dest,
rc = MPI_ERR_RANK;
} else if (request == NULL) {
rc = MPI_ERR_REQUEST;
} else {
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}
rc = MCA_PML_CALL(isend(buf,count,type,dest,tag,
MCA_PML_BASE_SEND_SYNCHRONOUS,comm,request));
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);

Просмотреть файл

@ -35,7 +35,8 @@ static const char FUNC_NAME[] = "MPI_Recv";
int MPI_Recv(void *buf, int count, MPI_Datatype type, int source,
int tag, MPI_Comm comm, MPI_Status *status)
{
int rc;
int rc = MPI_SUCCESS;
if (MPI_PROC_NULL == source) {
if (MPI_STATUS_IGNORE != status) {
status->MPI_SOURCE = MPI_PROC_NULL;
@ -47,10 +48,10 @@ int MPI_Recv(void *buf, int count, MPI_Datatype type, int source,
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
OMPI_CHECK_DATATYPE_FOR_RECV(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
} else if (((tag < 0) && (tag != MPI_ANY_TAG)) || (tag > mca_pml.pml_max_tag)) {
@ -58,6 +59,7 @@ int MPI_Recv(void *buf, int count, MPI_Datatype type, int source,
} else if (source != MPI_ANY_SOURCE && ompi_comm_peer_invalid(comm, source)) {
rc = MPI_ERR_RANK;
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -35,17 +35,18 @@ static const char FUNC_NAME[] = "MPI_Recv_init";
int MPI_Recv_init(void *buf, int count, MPI_Datatype type, int source,
int tag, MPI_Comm comm, MPI_Request *request)
{
int rc;
int rc = MPI_SUCCESS;
if (source == MPI_PROC_NULL) {
*request = &ompi_request_empty;
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
OMPI_CHECK_DATATYPE_FOR_RECV(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
} else if (((tag < 0) && (tag != MPI_ANY_TAG)) || (tag > mca_pml.pml_max_tag)) {
@ -53,6 +54,7 @@ int MPI_Recv_init(void *buf, int count, MPI_Datatype type, int source,
} else if (source != MPI_ANY_SOURCE && ompi_comm_peer_invalid(comm, source)) {
rc = MPI_ERR_RANK;
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -35,13 +35,13 @@ static const char FUNC_NAME[] = "MPI_Rsend";
int MPI_Rsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm)
{
int rc;
int rc = MPI_SUCCESS;
if (dest == MPI_PROC_NULL) {
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
@ -53,6 +53,9 @@ int MPI_Rsend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Co
rc = MPI_ERR_TAG;
} else if (ompi_comm_peer_invalid(comm, dest)) {
rc = MPI_ERR_RANK;
} else {
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -36,13 +36,13 @@ static const char FUNC_NAME[] = "MPI_Send";
int MPI_Send(void *buf, int count, MPI_Datatype type, int dest,
int tag, MPI_Comm comm)
{
int rc;
int rc = MPI_SUCCESS;
if (dest == MPI_PROC_NULL) {
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
int rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
@ -53,7 +53,8 @@ int MPI_Send(void *buf, int count, MPI_Datatype type, int dest,
} else if (ompi_comm_peer_invalid(comm, dest)) {
rc = MPI_ERR_RANK;
} else {
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}
@ -61,4 +62,3 @@ int MPI_Send(void *buf, int count, MPI_Datatype type, int dest,
rc = MCA_PML_CALL(send(buf, count, type, dest, tag, MCA_PML_BASE_SEND_STANDARD, comm));
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -37,14 +37,14 @@ int MPI_Send_init(void *buf, int count, MPI_Datatype type,
int dest, int tag, MPI_Comm comm,
MPI_Request *request)
{
int rc;
int rc = MPI_SUCCESS;
if (dest == MPI_PROC_NULL) {
*request = &ompi_request_empty;
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
@ -58,6 +58,9 @@ int MPI_Send_init(void *buf, int count, MPI_Datatype type,
rc = MPI_ERR_RANK;
} else if (request == NULL) {
rc = MPI_ERR_REQUEST;
} else {
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -38,14 +38,15 @@ int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
MPI_Comm comm, MPI_Status *status)
{
ompi_request_t* req;
int rc;
int rc = MPI_SUCCESS;
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
OMPI_CHECK_DATATYPE_FOR_SEND(rc, sendtype, sendcount);
OMPI_CHECK_DATATYPE_FOR_RECV(rc, recvtype, recvcount);
OMPI_CHECK_USER_BUFFER(rc, sendbuf, sendtype, sendcount);
OMPI_CHECK_USER_BUFFER(rc, recvbuf, recvtype, recvcount);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
} else if (dest != MPI_PROC_NULL && ompi_comm_peer_invalid(comm, dest)) {
@ -55,7 +56,7 @@ int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
} else if (source != MPI_PROC_NULL && source != MPI_ANY_SOURCE && ompi_comm_peer_invalid(comm, source)) {
rc = MPI_ERR_RANK;
} else if (((recvtag < 0) && (recvtag != MPI_ANY_TAG)) || (recvtag > mca_pml.pml_max_tag)) {
rc = MPI_ERR_TAG;
rc = MPI_ERR_TAG;
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}

Просмотреть файл

@ -39,7 +39,7 @@ int MPI_Sendrecv_replace(void * buf, int count, MPI_Datatype datatype,
MPI_Comm comm, MPI_Status *status)
{
int rc;
int rc = MPI_SUCCESS;
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;

Просмотреть файл

@ -34,13 +34,13 @@ static const char FUNC_NAME[] = "MPI_Ssend";
int MPI_Ssend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Comm comm)
{
int rc;
int rc = MPI_SUCCESS;
if (dest == MPI_PROC_NULL) {
return MPI_SUCCESS;
}
if ( MPI_PARAM_CHECK ) {
rc = MPI_SUCCESS;
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
@ -52,6 +52,9 @@ int MPI_Ssend(void *buf, int count, MPI_Datatype type, int dest, int tag, MPI_Co
rc = MPI_ERR_TAG;
} else if (ompi_comm_peer_invalid(comm, dest)) {
rc = MPI_ERR_RANK;
} else {
OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count);
OMPI_CHECK_USER_BUFFER(rc, buf, type, count);
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}