Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reindent
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 3 Nov 2017 14:24:01 +0000 (15:24 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 3 Nov 2017 14:24:01 +0000 (15:24 +0100)
src/smpi/include/smpi_datatype.hpp
src/smpi/include/smpi_datatype_derived.hpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_datatype_derived.cpp

index 2fc90cf..97beb46 100644 (file)
@@ -75,59 +75,58 @@ namespace simgrid{
 namespace smpi{
 
 class Datatype : public F2C, public Keyval{
-  private:
-    char* name_;
-    size_t size_;
-    MPI_Aint lb_;
-    MPI_Aint ub_;
-    int flags_;
-    int refcount_;
-
-  public:
-    static std::unordered_map<int, smpi_key_elem> keyvals_;
-    static int keyval_id_;
-
-    Datatype(int size,MPI_Aint lb, MPI_Aint ub, int flags);
-    Datatype(char* name, int size,MPI_Aint lb, MPI_Aint ub, int flags);
-    Datatype(Datatype *datatype, int* ret);
-    virtual ~Datatype();
-
-    char* name();
-    size_t size();
-    MPI_Aint lb();
-    MPI_Aint ub();
-    int flags();
-    int refcount();
-
-    void ref();
-    static void unref(MPI_Datatype datatype);
-    void commit();
-    bool is_valid();
-    void addflag(int flag);
-    int extent(MPI_Aint * lb, MPI_Aint * extent);
-    MPI_Aint get_extent();
-    void get_name(char* name, int* length);
-    void set_name(char* name);
-    static int copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                    void *recvbuf, int recvcount, MPI_Datatype recvtype);
-    virtual void serialize( void* noncontiguous, void *contiguous,
-                            int count);
-    virtual void unserialize( void* contiguous, void *noncontiguous,
-                              int count, MPI_Op op);
-    static int keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state);
-    static int keyval_free(int* keyval);
-    int pack(void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm comm);
-    int unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm comm);
-
-
-    static int create_contiguous(int count, MPI_Datatype old_type, MPI_Aint lb, MPI_Datatype* new_type);
-    static int create_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type);
-    static int create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type);
-    static int create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type);
-    static int create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type);
-    static int create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type);
-
-    static Datatype* f2c(int id);
+  char* name_;
+  size_t size_;
+  MPI_Aint lb_;
+  MPI_Aint ub_;
+  int flags_;
+  int refcount_;
+
+public:
+  static std::unordered_map<int, smpi_key_elem> keyvals_;
+  static int keyval_id_;
+
+  Datatype(int size, MPI_Aint lb, MPI_Aint ub, int flags);
+  Datatype(char* name, int size, MPI_Aint lb, MPI_Aint ub, int flags);
+  Datatype(Datatype* datatype, int* ret);
+  virtual ~Datatype();
+
+  char* name();
+  size_t size();
+  MPI_Aint lb();
+  MPI_Aint ub();
+  int flags();
+  int refcount();
+
+  void ref();
+  static void unref(MPI_Datatype datatype);
+  void commit();
+  bool is_valid();
+  void addflag(int flag);
+  int extent(MPI_Aint* lb, MPI_Aint* extent);
+  MPI_Aint get_extent();
+  void get_name(char* name, int* length);
+  void set_name(char* name);
+  static int copy(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
+                  MPI_Datatype recvtype);
+  virtual void serialize(void* noncontiguous, void* contiguous, int count);
+  virtual void unserialize(void* contiguous, void* noncontiguous, int count, MPI_Op op);
+  static int keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
+                           void* extra_state);
+  static int keyval_free(int* keyval);
+  int pack(void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm comm);
+  int unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm comm);
+
+  static int create_contiguous(int count, MPI_Datatype old_type, MPI_Aint lb, MPI_Datatype* new_type);
+  static int create_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type);
+  static int create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type);
+  static int create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type);
+  static int create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type,
+                             MPI_Datatype* new_type);
+  static int create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types,
+                           MPI_Datatype* new_type);
+
+  static Datatype* f2c(int id);
 };
 
 }
index b450bd9..5c46639 100644 (file)
@@ -13,91 +13,84 @@ namespace simgrid{
 namespace smpi{
 
 class Type_Contiguous: public Datatype {
-  private:
-    int block_count_;
-    MPI_Datatype old_type_;
-  public:
-    Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type);
-    ~Type_Contiguous();
-    void serialize( void* noncontiguous, void *contiguous,
-                            int count);
-    void unserialize( void* contiguous_vector, void *noncontiguous_vector,
-                              int count, MPI_Op op);
+  int block_count_;
+  MPI_Datatype old_type_;
+
+public:
+  Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type);
+  ~Type_Contiguous();
+  void serialize(void* noncontiguous, void* contiguous, int count);
+  void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
 class Type_Vector: public Datatype{
-  private:
-    int block_count_;
-    int block_length_;
-    int block_stride_;
-    MPI_Datatype old_type_;
-  public:
-    Type_Vector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int blocklen, int stride, MPI_Datatype old_type);
-    ~Type_Vector();
-    void serialize( void* noncontiguous, void *contiguous,
-                            int count);
-    void unserialize( void* contiguous_vector, void *noncontiguous_vector,
-                              int count, MPI_Op op);
+  int block_count_;
+  int block_length_;
+  int block_stride_;
+  MPI_Datatype old_type_;
+
+public:
+  Type_Vector(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, int blocklen, int stride,
+              MPI_Datatype old_type);
+  ~Type_Vector();
+  void serialize(void* noncontiguous, void* contiguous, int count);
+  void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
 class Type_Hvector: public Datatype{
-  private:
-    int block_count_;
-    int block_length_;
-    MPI_Aint block_stride_;
-    MPI_Datatype old_type_;
-  public:
-    Type_Hvector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int block_length, MPI_Aint block_stride, MPI_Datatype old_type);
-    ~Type_Hvector();
-    void serialize( void* noncontiguous, void *contiguous,
-                            int count);
-    void unserialize( void* contiguous_vector, void *noncontiguous_vector,
-                              int count, MPI_Op op);
+  int block_count_;
+  int block_length_;
+  MPI_Aint block_stride_;
+  MPI_Datatype old_type_;
+
+public:
+  Type_Hvector(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int block_length, MPI_Aint block_stride,
+               MPI_Datatype old_type);
+  ~Type_Hvector();
+  void serialize(void* noncontiguous, void* contiguous, int count);
+  void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
 class Type_Indexed: public Datatype{
-  private:
-    int block_count_;
-    int* block_lengths_;
-    int* block_indices_;
-    MPI_Datatype old_type_;
-  public:
-    Type_Indexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, int* block_indices, MPI_Datatype old_type);
-    ~Type_Indexed();
-    void serialize( void* noncontiguous, void *contiguous,
-                            int count);
-    void unserialize( void* contiguous_vector, void *noncontiguous_vector,
-                              int count, MPI_Op op);
+  int block_count_;
+  int* block_lengths_;
+  int* block_indices_;
+  MPI_Datatype old_type_;
+
+public:
+  Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, int* block_indices,
+               MPI_Datatype old_type);
+  ~Type_Indexed();
+  void serialize(void* noncontiguous, void* contiguous, int count);
+  void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
 class Type_Hindexed: public Datatype{
-  private:
-    int block_count_;
-    int* block_lengths_;
-    MPI_Aint* block_indices_;
-    MPI_Datatype old_type_;
-  public:
-    Type_Hindexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype old_type);
-    ~Type_Hindexed();
-    void serialize( void* noncontiguous, void *contiguous,
-                            int count);
-    void unserialize( void* contiguous_vector, void *noncontiguous_vector,
-                              int count, MPI_Op op);
+  int block_count_;
+  int* block_lengths_;
+  MPI_Aint* block_indices_;
+  MPI_Datatype old_type_;
+
+public:
+  Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths,
+                MPI_Aint* block_indices, MPI_Datatype old_type);
+  ~Type_Hindexed();
+  void serialize(void* noncontiguous, void* contiguous, int count);
+  void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
 class Type_Struct: public Datatype{
-  private:
-    int block_count_;
-    int* block_lengths_;
-    MPI_Aint* block_indices_;
-    MPI_Datatype* old_types_;
-  public:
-    Type_Struct(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype* old_types);
-    ~Type_Struct();
-    void serialize( void* noncontiguous, void *contiguous,
-                            int count);
-    void unserialize( void* contiguous_vector, void *noncontiguous_vector,
-                              int count, MPI_Op op);
+  int block_count_;
+  int* block_lengths_;
+  MPI_Aint* block_indices_;
+  MPI_Datatype* old_types_;
+
+public:
+  Type_Struct(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths,
+              MPI_Aint* block_indices, MPI_Datatype* old_types);
+  ~Type_Struct();
+  void serialize(void* noncontiguous, void* contiguous, int count);
+  void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
 
index e23986d..b738b7b 100644 (file)
@@ -189,7 +189,6 @@ void Datatype::commit()
   flags_ |= DT_FLAG_COMMITED;
 }
 
-
 bool Datatype::is_valid(){
   return (flags_ & DT_FLAG_COMMITED);
 }
index 3be87a2..2624ca3 100644 (file)
@@ -8,29 +8,29 @@
 #include "smpi_op.hpp"
 #include <xbt/log.h>
 
-XBT_LOG_EXTERNAL_CATEGORY(smpi_datatype);
-
 namespace simgrid{
 namespace smpi{
 
-
-Type_Contiguous::Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(block_count), old_type_(old_type){
+Type_Contiguous::Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type)
+    : Datatype(size, lb, ub, flags), block_count_(block_count), old_type_(old_type)
+{
   old_type_->ref();
 }
 
-Type_Contiguous::~Type_Contiguous(){
+Type_Contiguous::~Type_Contiguous()
+{
   Datatype::unref(old_type_);
 }
 
-
-void Type_Contiguous::serialize( void* noncontiguous_buf, void *contiguous_buf,
-                            int count){
+void Type_Contiguous::serialize(void* noncontiguous_buf, void* contiguous_buf, int count)
+{
   char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
   char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb();
   memcpy(contiguous_buf_char, noncontiguous_buf_char, count * block_count_ * old_type_->size());
 }
-void Type_Contiguous::unserialize( void* contiguous_buf, void *noncontiguous_buf,
-                              int count, MPI_Op op){
+
+void Type_Contiguous::unserialize(void* contiguous_buf, void* noncontiguous_buf, int count, MPI_Op op)
+{
   char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
   char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb();
   int n= count*block_count_;