Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some cleanups, some smells
[simgrid.git] / src / smpi / smpi_datatype.hpp
index b639ceb..1cec8fb 100644 (file)
@@ -10,6 +10,7 @@
 #include <xbt/base.h>
 
 #include "private.h"
+#include <unordered_map>
 
 #define DT_FLAG_DESTROYED     0x0001  /**< user destroyed but some other layers still have a reference */
 #define DT_FLAG_COMMITED      0x0002  /**< ready to be used for a send/recv operation */
 
 extern const MPI_Datatype MPI_PTR;
 
+typedef struct s_smpi_mpi_type_key_elem {
+  MPI_Type_copy_attr_function* copy_fn;
+  MPI_Type_delete_attr_function* delete_fn;
+} s_smpi_mpi_type_key_elem_t; 
+typedef struct s_smpi_mpi_type_key_elem *smpi_type_key_elem;
+
 //The following are datatypes for the MPI functions MPI_MAXLOC and MPI_MINLOC.
 typedef struct {
   float value;
@@ -85,7 +92,11 @@ class Datatype : public F2C{
     MPI_Aint ub_;
     int flags_;
     xbt_dict_t attributes_;
-    int in_use_;
+    int refcount_;
+
+    static std::unordered_map<int, smpi_type_key_elem> keyvals_;
+    static int keyval_id_;
+
   public:
     static MPI_Datatype null_id_;
 
@@ -93,8 +104,8 @@ class Datatype : public F2C{
     Datatype(char* name, int size,MPI_Aint lb, MPI_Aint ub, int flags);
     Datatype(Datatype *datatype, int* ret);
     virtual ~Datatype();
-    void use();
-    void unuse();
+    void ref();
+    static void unref(MPI_Datatype datatype);
     void commit();
     bool is_valid();
     size_t size();