Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
obey our coding standards and cosmetics
[simgrid.git] / src / smpi / bindings / smpi_pmpi_op.cpp
1 /* Copyright (c) 2007-2018. 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   if (function == nullptr || op == nullptr) {
16     return MPI_ERR_ARG;
17   } else {
18     *op = new simgrid::smpi::Op(function, (commute!=0));
19     return MPI_SUCCESS;
20   }
21 }
22
23 int PMPI_Op_free(MPI_Op * op)
24 {
25   if (op == nullptr) {
26     return MPI_ERR_ARG;
27   } else if (*op == MPI_OP_NULL) {
28     return MPI_ERR_OP;
29   } else {
30     delete (*op);
31     *op = MPI_OP_NULL;
32     return MPI_SUCCESS;
33   }
34 }
35
36 int PMPI_Op_commutative(MPI_Op op, int* commute){
37   if (op == MPI_OP_NULL) {
38     return MPI_ERR_OP;
39   } else if (commute==nullptr){
40     return MPI_ERR_ARG;
41   } else {
42     *commute = op->is_commutative();
43     return MPI_SUCCESS;
44   }
45 }
46
47 MPI_Op PMPI_Op_f2c(MPI_Fint op){
48   return static_cast<MPI_Op>(simgrid::smpi::Op::f2c(op));
49 }
50
51 MPI_Fint PMPI_Op_c2f(MPI_Op op){
52   return op->c2f();
53 }