From cfb28af59a4393bf839909e04eae9ca8ec36f580 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Mon, 19 Jul 2004 18:37:15 +0000 Subject: [PATCH] Add 3 macros to check for the correctness of a datatype and for it's suitability for a specific operation. OMPI_CHECK_DATATYPE_FOR_SEND OMPI_CHECK_DATATYPE_FOR_RECV OMPI_CHECK_DATATYPE_FOR_ONE_SIDED BE AWARE ! these macros does not trigger the error handle, they just set a error code in the first argument. You have to check for the error code after the call. This commit was SVN r1782. --- src/mpi/c/bindings.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/mpi/c/bindings.h b/src/mpi/c/bindings.h index ce22b5f9dc..16b3fe0534 100644 --- a/src/mpi/c/bindings.h +++ b/src/mpi/c/bindings.h @@ -19,4 +19,33 @@ 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 + * on the top level MPI functions, as they does not trigger the error handler. Is the user + * responsability to do it. + */ +#define OMPI_CHECK_DATATYPE_FOR_SEND( RC, DDT, COUNT ) \ +do { \ + if( (DDT) == MPI_DATATYPE_NULL ) (RC) = MPI_ERR_TYPE; \ + else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \ + else if( !ompi_ddt_is_committed((DDT)) ) (RC) = MPI_ERR_TYPE; \ +} while (0) + +#define OMPI_CHECK_DATATYPE_FOR_RECV( RC, DDT, COUNT ) \ +do { \ + if( (DDT) == MPI_DATATYPE_NULL ) (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; \ +} while (0) + +#define OMPI_CHECK_DATATYPE_FOR_ONE_SIDED( RC, DDT, COUNT ) \ +do { \ + if( (DDT) == MPI_DATATYPE_NULL ) (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; \ +} while(0) + #endif /* OMPI_C_BINDINGS_H */