X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/96cedde3cdbc0b8ffc3f096a1b65d021b0226f99..30544ab58b29faec9eefb6be57a0fce5f0d76775:/src/smpi/bindings/smpi_pmpi_op.cpp diff --git a/src/smpi/bindings/smpi_pmpi_op.cpp b/src/smpi/bindings/smpi_pmpi_op.cpp index 6b3bd32268..653cfd75ba 100644 --- a/src/smpi/bindings/smpi_pmpi_op.cpp +++ b/src/smpi/bindings/smpi_pmpi_op.cpp @@ -1,10 +1,11 @@ -/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "private.hpp" #include "smpi_op.hpp" +#include "smpi_comm.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi); @@ -12,42 +13,39 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi); int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op) { - if (function == nullptr || op == nullptr) { - return MPI_ERR_ARG; - } else { - *op = new simgrid::smpi::Op(function, (commute!=0)); - return MPI_SUCCESS; - } + CHECK_NULL(1, MPI_ERR_ARG, function) + CHECK_NULL(3, MPI_ERR_ARG, op) + *op = new simgrid::smpi::Op(function, (commute!=0)); + return MPI_SUCCESS; } int PMPI_Op_free(MPI_Op * op) { - if (op == nullptr) { - return MPI_ERR_ARG; - } else if (*op == MPI_OP_NULL) { + CHECK_NULL(1, MPI_ERR_ARG, op) + CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, *op) + if((*op)->is_predefined()) return MPI_ERR_OP; - } else { - delete (*op); - *op = MPI_OP_NULL; - return MPI_SUCCESS; - } + (*op)->mark_as_deleted(); + simgrid::smpi::Op::unref(op); + *op = MPI_OP_NULL; + return MPI_SUCCESS; } int PMPI_Op_commutative(MPI_Op op, int* commute){ - if (op == MPI_OP_NULL) { - return MPI_ERR_OP; - } else if (commute==nullptr){ - return MPI_ERR_ARG; - } else { - *commute = op->is_commutative(); - return MPI_SUCCESS; - } + CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, op) + CHECK_NULL(1, MPI_ERR_ARG, commute) + *commute = op->is_commutative(); + return MPI_SUCCESS; } MPI_Op PMPI_Op_f2c(MPI_Fint op){ - return static_cast(simgrid::smpi::Op::f2c(op)); + if(op==-1) + return MPI_OP_NULL; + return simgrid::smpi::Op::f2c(op); } MPI_Fint PMPI_Op_c2f(MPI_Op op){ + if(op==MPI_OP_NULL) + return -1; return op->c2f(); }