Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add some debug messages for smpi tracing
[simgrid.git] / src / smpi / smpi_mpi_dt_private.h
1 /* smpi_mpi_dt_private.h -- functions of smpi_mpi_dt.c that are exported to other SMPI modules. */
2
3 /* Copyright (c) 2009-2010, 2012-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef SMPI_DT_PRIVATE_H
10 #define SMPI_DT_PRIVATE_H
11
12 #include <xbt/base.h>
13
14 #include "private.h"
15
16 SG_BEGIN_DECL()
17
18 #define DT_FLAG_DESTROYED     0x0001  /**< user destroyed but some other layers still have a reference */
19 #define DT_FLAG_COMMITED      0x0002  /**< ready to be used for a send/recv operation */
20 #define DT_FLAG_CONTIGUOUS    0x0004  /**< contiguous datatype */
21 #define DT_FLAG_OVERLAP       0x0008  /**< datatype is unpropper for a recv operation */
22 #define DT_FLAG_USER_LB       0x0010  /**< has a user defined LB */
23 #define DT_FLAG_USER_UB       0x0020  /**< has a user defined UB */
24 #define DT_FLAG_PREDEFINED    0x0040  /**< cannot be removed: initial and predefined datatypes */
25 #define DT_FLAG_NO_GAPS       0x0080  /**< no gaps around the datatype */
26 #define DT_FLAG_DATA          0x0100  /**< data or control structure */
27 #define DT_FLAG_ONE_SIDED     0x0200  /**< datatype can be used for one sided operations */
28 #define DT_FLAG_UNAVAILABLE   0x0400  /**< datatypes unavailable on the build (OS or compiler dependant) */
29 #define DT_FLAG_VECTOR        0x0800  /**< valid only for loops. The loop contain only one element
30                                        **< without extent. It correspond to the vector type. */
31 /*
32  * We should make the difference here between the predefined contiguous and non contiguous
33  * datatypes. The DT_FLAG_BASIC is held by all predefined contiguous datatypes.
34  */
35 #define DT_FLAG_BASIC      (DT_FLAG_PREDEFINED | DT_FLAG_CONTIGUOUS | DT_FLAG_NO_GAPS | DT_FLAG_DATA | DT_FLAG_COMMITED)
36
37 extern const MPI_Datatype MPI_PTR;
38
39 /* Structures that handle complex data type information, used for serialization/unserialization of messages */
40 typedef struct s_smpi_mpi_contiguous{
41   s_smpi_subtype_t base;
42   MPI_Datatype old_type;
43   MPI_Aint lb;
44   size_t size_oldtype;
45   int block_count;
46 } s_smpi_mpi_contiguous_t;
47
48 typedef struct s_smpi_mpi_vector{
49   s_smpi_subtype_t base;
50   MPI_Datatype old_type;
51   size_t size_oldtype;
52   int block_stride;
53   int block_length;
54   int block_count;
55 } s_smpi_mpi_vector_t;
56
57 typedef struct s_smpi_mpi_hvector{
58   s_smpi_subtype_t base;
59   MPI_Datatype old_type;
60   size_t size_oldtype;
61   MPI_Aint block_stride;
62   int block_length;
63   int block_count;
64 } s_smpi_mpi_hvector_t;
65
66 typedef struct s_smpi_mpi_indexed{
67   s_smpi_subtype_t base;
68   MPI_Datatype old_type;
69   size_t size_oldtype;
70   int* block_lengths;
71   int* block_indices;
72   int block_count;
73 } s_smpi_mpi_indexed_t;
74
75 typedef struct s_smpi_mpi_hindexed{
76   s_smpi_subtype_t base;
77   MPI_Datatype old_type;
78   size_t size_oldtype;
79   int* block_lengths;
80   MPI_Aint* block_indices;
81   int block_count;
82 } s_smpi_mpi_hindexed_t;
83
84 typedef struct s_smpi_mpi_struct{
85   s_smpi_subtype_t base;
86   MPI_Datatype old_type;
87   size_t size_oldtype;
88   int* block_lengths;
89   MPI_Aint* block_indices;
90   int block_count;
91   MPI_Datatype* old_types;
92 } s_smpi_mpi_struct_t;
93
94 /*
95   Functions to handle serialization/unserialization of messages, 3 for each type of MPI_Type
96   One for creating the substructure to handle, one for serialization, one for unserialization
97 */
98 XBT_PRIVATE void unserialize_contiguous( const void *contiguous_vector, void *noncontiguous_vector, int count,
99                          void *type, MPI_Op op);
100 XBT_PRIVATE void serialize_contiguous( const void *noncontiguous_vector, void *contiguous_vector, int count,void *type);
101 XBT_PRIVATE void free_contiguous(MPI_Datatype* type);
102 XBT_PRIVATE void use_contiguous(MPI_Datatype* type);
103 XBT_PRIVATE s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb, int block_count,
104                                                   MPI_Datatype old_type, int size_oldtype);
105                                                   
106 XBT_PRIVATE void unserialize_vector( const void *contiguous_vector, void *noncontiguous_vector, int count,void *type,
107                          MPI_Op op);
108 XBT_PRIVATE void serialize_vector( const void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
109 XBT_PRIVATE void free_vector(MPI_Datatype* type);
110 XBT_PRIVATE void use_vector(MPI_Datatype* type);
111 XBT_PRIVATE s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride, int block_length, int block_count,
112                                                   MPI_Datatype old_type, int size_oldtype);
113
114 XBT_PRIVATE void unserialize_hvector( const void *contiguous_vector, void *noncontiguous_vector, int count, void *type,
115                          MPI_Op op);
116 XBT_PRIVATE void serialize_hvector( const void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
117 XBT_PRIVATE void free_hvector(MPI_Datatype* type);
118 XBT_PRIVATE void use_hvector(MPI_Datatype* type);
119 XBT_PRIVATE s_smpi_mpi_hvector_t* smpi_datatype_hvector_create( MPI_Aint block_stride, int block_length,
120                                                   int block_count, MPI_Datatype old_type, int size_oldtype);
121
122 XBT_PRIVATE void unserialize_indexed( const void *contiguous_indexed, void *noncontiguous_indexed, int count,
123                          void *type, MPI_Op op);
124 XBT_PRIVATE void serialize_indexed( const void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
125 XBT_PRIVATE void free_indexed(MPI_Datatype* type);
126 XBT_PRIVATE void use_indexed(MPI_Datatype* type);
127 XBT_PRIVATE s_smpi_mpi_indexed_t* smpi_datatype_indexed_create(int* block_lengths, int* block_indices,
128                                                   int block_count, MPI_Datatype old_type, int size_oldtype);
129
130 XBT_PRIVATE void unserialize_hindexed( const void *contiguous_indexed, void *noncontiguous_indexed, int count,
131                          void *type, MPI_Op op);
132 XBT_PRIVATE void serialize_hindexed( const void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
133 XBT_PRIVATE void free_hindexed(MPI_Datatype* type);
134 XBT_PRIVATE void use_hindexed(MPI_Datatype* type);
135 XBT_PRIVATE s_smpi_mpi_hindexed_t* smpi_datatype_hindexed_create(int* block_lengths, MPI_Aint* block_indices,
136                                                   int block_count, MPI_Datatype old_type, int size_oldtype);
137
138 XBT_PRIVATE void unserialize_struct( const void *contiguous_indexed, void *noncontiguous_indexed, int count, void *type,
139                          MPI_Op op);
140 XBT_PRIVATE void serialize_struct( const void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
141 XBT_PRIVATE void free_struct(MPI_Datatype* type);
142 XBT_PRIVATE void use_struct(MPI_Datatype* type);
143 XBT_PRIVATE s_smpi_mpi_struct_t* smpi_datatype_struct_create(int* block_lengths, MPI_Aint* block_indices,
144                                                   int block_count, MPI_Datatype* old_types);
145
146 SG_END_DECL()
147 #endif