Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a refcount for MPI_Op
[simgrid.git] / src / smpi / include / smpi_op.hpp
index 14e60da..c0eb212 100644 (file)
@@ -13,18 +13,21 @@ namespace simgrid{
 namespace smpi{
 
 class Op : public F2C{
-  private:
-    MPI_User_function *func_;
-    bool is_commutative_;
-    bool is_fortran_op_;
-  public:
-
-    Op(MPI_User_function * function, bool commutative);
-    bool is_commutative();
-    bool is_fortran_op();
-    void set_fortran_op();
-    void apply(void *invec, void *inoutvec, int *len, MPI_Datatype datatype);
-    static Op* f2c(int id);
+  MPI_User_function* func_;
+  bool is_commutative_;
+  bool is_fortran_op_ = false;
+  int refcount_ = 1;
+
+public:
+  Op(MPI_User_function* function, bool commutative) : func_(function), is_commutative_(commutative) {}
+  bool is_commutative() { return is_commutative_; }
+  bool is_fortran_op() { return is_fortran_op_; }
+  // tell that we were created from fortran, so we need to translate the type to fortran when called
+  void set_fortran_op() { is_fortran_op_ = true; }
+  void apply(void* invec, void* inoutvec, int* len, MPI_Datatype datatype);
+  static Op* f2c(int id);
+  void ref();
+  static void unref(MPI_Op* op);
 };
 
 }