Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / smpi / bindings / smpi_pmpi_op.cpp
1 /* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "private.hpp"
7 #include "smpi_op.hpp"
8 #include "smpi_comm.hpp"
9
10 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
11
12 /* PMPI User level calls */
13
14 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
15 {
16   CHECK_NULL(1, MPI_ERR_ARG, function)
17   CHECK_NULL(3, MPI_ERR_ARG, op)
18   *op = new simgrid::smpi::Op(function, (commute!=0));
19   return MPI_SUCCESS;
20 }
21
22 int PMPI_Op_free(MPI_Op * op)
23 {
24   CHECK_NULL(1, MPI_ERR_ARG, op)
25   CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, *op)
26   if((*op)->is_predefined())
27     return MPI_ERR_OP;
28   (*op)->mark_as_deleted();
29   simgrid::smpi::Op::unref(op);
30   *op = MPI_OP_NULL;
31   return MPI_SUCCESS;
32 }
33
34 int PMPI_Op_commutative(MPI_Op op, int* commute){
35   CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, op)
36   CHECK_NULL(1, MPI_ERR_ARG, commute)
37   *commute = op->is_commutative();
38   return MPI_SUCCESS;
39 }
40
41 MPI_Op PMPI_Op_f2c(MPI_Fint op){
42   if(op==-1)
43     return MPI_OP_NULL;
44   return simgrid::smpi::Op::f2c(op);
45 }
46
47 MPI_Fint PMPI_Op_c2f(MPI_Op op){
48   if(op==MPI_OP_NULL)
49     return -1;
50   return op->c2f();
51 }