+#define CHECK_COMM(num)\
+ {\
+ CHECK_INIT\
+ CHECK_COMM2((num), comm)\
+ CHECK_DELETED((num), MPI_ERR_COMM, comm)\
+ simgrid::smpi::utils::set_current_handle(comm);\
+ }
+
+#define CHECK_REQUEST(num)\
+ CHECK_ARGS(request == nullptr, MPI_ERR_REQUEST,\
+ "%s: param %d request cannot be NULL",__func__, (num));
+
+#define CHECK_REQUEST_VALID(num)\
+ {\
+ CHECK_REQUEST(num)\
+ if(request!=MPI_REQUEST_IGNORED){\
+ CHECK_DELETED((num), MPI_ERR_REQUEST, *request)\
+ simgrid::smpi::utils::set_current_handle(*request);\
+ }\
+ }
+#define SET_BUF1(buf)\
+ simgrid::smpi::utils::set_current_buffer(1, _XBT_STRINGIFY(buf), buf);
+#define SET_BUF2(buf)\
+ simgrid::smpi::utils::set_current_buffer(2, _XBT_STRINGIFY(buf), buf);
+
+#define CHECK_BUFFER2(num,buf,count)\
+ CHECK_ARGS((buf) == nullptr && (count) > 0, MPI_ERR_BUFFER,\
+ "%s: param %d %s cannot be NULL if %s > 0",__func__, (num), _XBT_STRINGIFY(buf), _XBT_STRINGIFY(count))\
+
+#define CHECK_BUFFER(num,buf,count,datatype)\
+ {\
+ CHECK_BUFFER2(num,buf,count)\
+ CHECK_ARGS( simgrid::smpi::utils::get_buffer_size(buf) < (size_t)(count*datatype->get_extent()), MPI_ERR_BUFFER,\
+ "%s: param %d message size %zd exceeds buffer %s size %zu",__func__, (num), count*datatype->get_extent(), _XBT_STRINGIFY(buf), simgrid::smpi::utils::get_buffer_size(buf))\
+ }
+
+#define CHECK_COUNT(num, count)\
+ CHECK_NEGATIVE((num), MPI_ERR_COUNT, (count))
+
+#define CHECK_TYPE(num, datatype)\
+ {\
+ CHECK_MPI_NULL((num), MPI_DATATYPE_NULL, MPI_ERR_TYPE, (datatype))\
+ CHECK_ARGS((not (datatype)->is_valid()), MPI_ERR_TYPE,\
+ "%s: param %d %s is invalid", __func__, (num), _XBT_STRINGIFY(datatype));\
+ CHECK_DELETED((num), MPI_ERR_TYPE, datatype)\
+ if (not datatype->is_basic())\
+ simgrid::smpi::utils::set_current_handle(datatype);\
+ }
+
+#define CHECK_OP(num, op, type)\
+ {\
+ CHECK_MPI_NULL((num), MPI_OP_NULL, MPI_ERR_OP, (op))\
+ CHECK_ARGS((op == MPI_REPLACE || op == MPI_NO_OP), MPI_ERR_OP,\
+ "%s: param %d op %s cannot be used in non RMA calls", __func__, (num), _XBT_STRINGIFY(op));\
+ CHECK_DELETED((num), MPI_ERR_OP, op)\
+ if (not op->is_predefined())\
+ simgrid::smpi::utils::set_current_handle(op);\
+ CHECK_ARGS(((op)->allowed_types() && (((op)->allowed_types() & (type)->flags()) == 0)), MPI_ERR_OP,\
+ "%s: param %d op %s can't be applied to type %s", __func__, (num), _XBT_STRINGIFY(op), type->name().c_str());\