Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[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
40 //*****************************************************************************************
41
42 /* 
43   These are the structures that handle complex data type information, 
44   used for serialization/unserialization of messages
45 */
46
47 typedef struct s_smpi_mpi_contiguous{
48   s_smpi_subtype_t base;
49   MPI_Datatype old_type;
50   MPI_Aint lb;
51   size_t size_oldtype;
52   int block_count;
53 } s_smpi_mpi_contiguous_t;
54
55 typedef struct s_smpi_mpi_vector{
56   s_smpi_subtype_t base;
57   MPI_Datatype old_type;
58   size_t size_oldtype;
59   int block_stride;
60   int block_length;
61   int block_count;
62 } s_smpi_mpi_vector_t;
63
64 typedef struct s_smpi_mpi_hvector{
65   s_smpi_subtype_t base;
66   MPI_Datatype old_type;
67   size_t size_oldtype;
68   MPI_Aint block_stride;
69   int block_length;
70   int block_count;
71 } s_smpi_mpi_hvector_t;
72
73 typedef struct s_smpi_mpi_indexed{
74   s_smpi_subtype_t base;
75   MPI_Datatype old_type;
76   size_t size_oldtype;
77   int* block_lengths;
78   int* block_indices;
79   int block_count;
80 } s_smpi_mpi_indexed_t;
81
82 typedef struct s_smpi_mpi_hindexed{
83   s_smpi_subtype_t base;
84   MPI_Datatype old_type;
85   size_t size_oldtype;
86   int* block_lengths;
87   MPI_Aint* block_indices;
88   int block_count;
89 } s_smpi_mpi_hindexed_t;
90
91 typedef struct s_smpi_mpi_struct{
92   s_smpi_subtype_t base;
93   MPI_Datatype old_type;
94   size_t size_oldtype;
95   int* block_lengths;
96   MPI_Aint* block_indices;
97   int block_count;
98   MPI_Datatype* old_types;
99 } s_smpi_mpi_struct_t;
100
101 /*
102   Functions to handle serialization/unserialization of messages, 3 for each type of MPI_Type
103   One for creating the substructure to handle, one for serialization, one for unserialization
104 */
105 XBT_PRIVATE void unserialize_contiguous( const void *contiguous_vector,
106                          void *noncontiguous_vector,
107                          int count,
108                          void *type,
109                          MPI_Op op);
110
111 XBT_PRIVATE void serialize_contiguous( const void *noncontiguous_vector,
112                        void *contiguous_vector,
113                        int count,
114                        void *type);
115
116 XBT_PRIVATE void free_contiguous(MPI_Datatype* type);
117
118 XBT_PRIVATE s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb,
119                                                   int block_count,
120                                                   MPI_Datatype old_type,
121                                                   int size_oldtype);
122                                                   
123 XBT_PRIVATE void unserialize_vector( const void *contiguous_vector,
124                          void *noncontiguous_vector,
125                          int count,
126                          void *type,
127                          MPI_Op op);
128
129 XBT_PRIVATE void serialize_vector( const void *noncontiguous_vector,
130                        void *contiguous_vector,
131                        int count,
132                        void *type);
133
134 XBT_PRIVATE void free_vector(MPI_Datatype* type);
135
136 XBT_PRIVATE s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride,
137                                                   int block_length,
138                                                   int block_count,
139                                                   MPI_Datatype old_type,
140                                                   int size_oldtype);
141
142 XBT_PRIVATE void unserialize_hvector( const void *contiguous_vector,
143                          void *noncontiguous_vector,
144                          int count,
145                          void *type,
146                          MPI_Op op);
147
148 XBT_PRIVATE void serialize_hvector( const void *noncontiguous_vector,
149                        void *contiguous_vector,
150                        int count,
151                        void *type);
152
153 XBT_PRIVATE void free_hvector(MPI_Datatype* type);
154
155 XBT_PRIVATE s_smpi_mpi_hvector_t* smpi_datatype_hvector_create( MPI_Aint block_stride,
156                                                   int block_length,
157                                                   int block_count,
158                                                   MPI_Datatype old_type,
159                                                   int size_oldtype);
160
161
162 XBT_PRIVATE void unserialize_indexed( const void *contiguous_indexed,
163                          void *noncontiguous_indexed,
164                          int count,
165                          void *type,
166                          MPI_Op op);
167
168 XBT_PRIVATE void serialize_indexed( const void *noncontiguous_vector,
169                        void *contiguous_vector,
170                        int count,
171                        void *type);
172
173 XBT_PRIVATE void free_indexed(MPI_Datatype* type);
174
175 XBT_PRIVATE s_smpi_mpi_indexed_t* smpi_datatype_indexed_create(int* block_lengths,
176                                                   int* block_indices,
177                                                   int block_count,
178                                                   MPI_Datatype old_type,
179                                                   int size_oldtype);
180
181 XBT_PRIVATE void unserialize_hindexed( const void *contiguous_indexed,
182                          void *noncontiguous_indexed,
183                          int count,
184                          void *type,
185                          MPI_Op op);
186
187 XBT_PRIVATE void serialize_hindexed( const void *noncontiguous_vector,
188                        void *contiguous_vector,
189                        int count,
190                        void *type);
191
192 XBT_PRIVATE void free_hindexed(MPI_Datatype* type);
193
194 XBT_PRIVATE s_smpi_mpi_hindexed_t* smpi_datatype_hindexed_create(int* block_lengths,
195                                                   MPI_Aint* block_indices,
196                                                   int block_count,
197                                                   MPI_Datatype old_type,
198                                                   int size_oldtype);
199
200 XBT_PRIVATE void unserialize_struct( const void *contiguous_indexed,
201                          void *noncontiguous_indexed,
202                          int count,
203                          void *type,
204                          MPI_Op op);
205
206 XBT_PRIVATE void serialize_struct( const void *noncontiguous_vector,
207                        void *contiguous_vector,
208                        int count,
209                        void *type);
210
211 XBT_PRIVATE void free_struct(MPI_Datatype* type);
212
213 XBT_PRIVATE s_smpi_mpi_struct_t* smpi_datatype_struct_create(int* block_lengths,
214                                                   MPI_Aint* block_indices,
215                                                   int block_count,
216                                                   MPI_Datatype* old_types);
217
218 SG_END_DECL()
219
220 #endif