Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / src / smpi / include / smpi_op.hpp
1 /* Copyright (c) 2009-2023. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SMPI_OP_HPP
8 #define SMPI_OP_HPP
9
10 #include "smpi_info.hpp"
11
12 namespace simgrid::smpi {
13
14 class Op : public F2C{
15   MPI_User_function* func_;
16   bool is_commutative_;
17   bool is_fortran_op_ = false;
18   int refcount_ = 1;
19   bool is_predefined_;
20   int types_; //bitmask of the allowed datatypes flags
21   std::string name_;
22
23 public:
24   Op(MPI_User_function* function, bool commutative, bool predefined = false, int types = 0, std::string name = "MPI_Op")
25       : func_(function), is_commutative_(commutative), is_predefined_(predefined), types_(types), name_(std::move(name))
26   {
27     if (not predefined)
28       this->add_f();
29   }
30   bool is_commutative() const { return is_commutative_; }
31   bool is_predefined() const { return is_predefined_; }
32   bool is_fortran_op() const { return is_fortran_op_; }
33   int allowed_types() const { return types_; }
34   std::string name() const override {return name_;}
35   // tell that we were created from fortran, so we need to translate the type to fortran when called
36   void set_fortran_op() { is_fortran_op_ = true; }
37   void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype) const;
38   static Op* f2c(int id);
39   void ref();
40   static void unref(MPI_Op* op);
41 };
42
43 } // namespace simgrid::smpi
44
45 #endif