Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / smpi / bindings / smpi_pmpi_op.cpp
1 /* Copyright (c) 2007-2021. 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
9 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
10
11 /* PMPI User level calls */
12
13 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
14 {
15   CHECK_NULL(1, MPI_ERR_ARG, function)
16   CHECK_NULL(3, MPI_ERR_ARG, op)
17   *op = new simgrid::smpi::Op(function, (commute!=0));
18   return MPI_SUCCESS;
19 }
20
21 int PMPI_Op_free(MPI_Op * op)
22 {
23   CHECK_NULL(1, MPI_ERR_ARG, op)
24   CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, *op)
25   simgrid::smpi::Op::unref(op);
26   *op = MPI_OP_NULL;
27   return MPI_SUCCESS;
28 }
29
30 int PMPI_Op_commutative(MPI_Op op, int* commute){
31   CHECK_OP(1)
32   CHECK_NULL(1, MPI_ERR_ARG, commute)
33   *commute = op->is_commutative();
34   return MPI_SUCCESS;
35 }
36
37 MPI_Op PMPI_Op_f2c(MPI_Fint op){
38   if(op==-1)
39     return MPI_OP_NULL;
40   return simgrid::smpi::Op::f2c(op);
41 }
42
43 MPI_Fint PMPI_Op_c2f(MPI_Op op){
44   if(op==MPI_OP_NULL)
45     return -1;
46   return op->c2f();
47 }