Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / smpi / include / smpi_op.hpp
index 403b230..ff1c128 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2020. The SimGrid Team.
+/* Copyright (c) 2009-2022. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -17,15 +17,19 @@ class Op : public F2C{
   bool is_commutative_;
   bool is_fortran_op_ = false;
   int refcount_ = 1;
-  bool predefined_;
+  bool is_predefined_;
+  int types_; //bitmask of the allowed datatypes flags
 
 public:
-  Op(MPI_User_function* function, bool commutative, bool predefined=false) : func_(function), is_commutative_(commutative), predefined_(predefined) {}
-  bool is_commutative() { return is_commutative_; }
-  bool is_fortran_op() { return is_fortran_op_; }
+  Op(MPI_User_function* function, bool commutative, bool predefined=false, int types=0) : func_(function), is_commutative_(commutative), is_predefined_(predefined), types_(types) {if(not predefined) this->add_f();}
+  bool is_commutative() const { return is_commutative_; }
+  bool is_predefined() const { return is_predefined_; }
+  bool is_fortran_op() const { return is_fortran_op_; }
+  int allowed_types() const { return types_; }
+  std::string name() const override {return std::string("MPI_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(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype);
+  void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype) const;
   static Op* f2c(int id);
   void ref();
   static void unref(MPI_Op* op);