Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
013b78007e5ab8b0430d1d4020f3c57a7c22e00a
[simgrid.git] / src / smpi / bindings / smpi_pmpi_op.cpp
1 /* Copyright (c) 2007-2017. 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.h"
7 #include "smpi_op.hpp"
8
9 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
10
11 /* PMPI User level calls */
12 extern "C" { // Obviously, the C MPI interface should use the C linkage
13
14 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
15 {
16   if (function == nullptr || op == nullptr) {
17     return MPI_ERR_ARG;
18   } else {
19     *op = new simgrid::smpi::Op(function, (commute!=0));
20     return MPI_SUCCESS;
21   }
22 }
23
24 int PMPI_Op_free(MPI_Op * op)
25 {
26   if (op == nullptr) {
27     return MPI_ERR_ARG;
28   } else if (*op == MPI_OP_NULL) {
29     return MPI_ERR_OP;
30   } else {
31     delete (*op);
32     *op = MPI_OP_NULL;
33     return MPI_SUCCESS;
34   }
35 }
36
37 int PMPI_Op_commutative(MPI_Op op, int* commute){
38   if (op == MPI_OP_NULL) {
39     return MPI_ERR_OP;
40   } else if (commute==nullptr){
41     return MPI_ERR_ARG;
42   } else {
43     *commute = op->is_commutative();
44     return MPI_SUCCESS;
45   }
46 }
47
48 MPI_Op PMPI_Op_f2c(MPI_Fint op){
49   return static_cast<MPI_Op>(simgrid::smpi::Op::f2c(op));
50 }
51
52 MPI_Fint PMPI_Op_c2f(MPI_Op op){
53   return op->c2f();
54 }
55
56 }