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 #define DT_FLAG_DESTROYED     0x0001  /**< user destroyed but some other layers still have a reference */
17 #define DT_FLAG_COMMITED      0x0002  /**< ready to be used for a send/recv operation */
18 #define DT_FLAG_CONTIGUOUS    0x0004  /**< contiguous datatype */
19 #define DT_FLAG_OVERLAP       0x0008  /**< datatype is unpropper for a recv operation */
20 #define DT_FLAG_USER_LB       0x0010  /**< has a user defined LB */
21 #define DT_FLAG_USER_UB       0x0020  /**< has a user defined UB */
22 #define DT_FLAG_PREDEFINED    0x0040  /**< cannot be removed: initial and predefined datatypes */
23 #define DT_FLAG_NO_GAPS       0x0080  /**< no gaps around the datatype */
24 #define DT_FLAG_DATA          0x0100  /**< data or control structure */
25 #define DT_FLAG_ONE_SIDED     0x0200  /**< datatype can be used for one sided operations */
26 #define DT_FLAG_UNAVAILABLE   0x0400  /**< datatypes unavailable on the build (OS or compiler dependant) */
27 #define DT_FLAG_VECTOR        0x0800  /**< valid only for loops. The loop contain only one element
28                                        **< without extent. It correspond to the vector type. */
29 /*
30  * We should make the difference here between the predefined contiguous and non contiguous
31  * datatypes. The DT_FLAG_BASIC is held by all predefined contiguous datatypes.
32  */
33 #define DT_FLAG_BASIC         (DT_FLAG_PREDEFINED | DT_FLAG_CONTIGUOUS | DT_FLAG_NO_GAPS | DT_FLAG_DATA | DT_FLAG_COMMITED)
34
35 extern MPI_Datatype MPI_PTR;
36
37
38 //*****************************************************************************************
39
40 /* 
41   These are the structures that handle complex data type information, 
42   used for serialization/unserialization of messages
43 */
44
45 typedef struct s_smpi_mpi_contiguous{
46   s_smpi_subtype_t base;
47   MPI_Datatype old_type;
48   MPI_Aint lb;
49   size_t size_oldtype;
50   int block_count;
51 } s_smpi_mpi_contiguous_t;
52
53 typedef struct s_smpi_mpi_vector{
54   s_smpi_subtype_t base;
55   MPI_Datatype old_type;
56   size_t size_oldtype;
57   int block_stride;
58   int block_length;
59   int block_count;
60 } s_smpi_mpi_vector_t;
61
62 typedef struct s_smpi_mpi_hvector{
63   s_smpi_subtype_t base;
64   MPI_Datatype old_type;
65   size_t size_oldtype;
66   MPI_Aint block_stride;
67   int block_length;
68   int block_count;
69 } s_smpi_mpi_hvector_t;
70
71 typedef struct s_smpi_mpi_indexed{
72   s_smpi_subtype_t base;
73   MPI_Datatype old_type;
74   size_t size_oldtype;
75   int* block_lengths;
76   int* block_indices;
77   int block_count;
78 } s_smpi_mpi_indexed_t;
79
80 typedef struct s_smpi_mpi_hindexed{
81   s_smpi_subtype_t base;
82   MPI_Datatype old_type;
83   size_t size_oldtype;
84   int* block_lengths;
85   MPI_Aint* block_indices;
86   int block_count;
87 } s_smpi_mpi_hindexed_t;
88
89 typedef struct s_smpi_mpi_struct{
90   s_smpi_subtype_t base;
91   MPI_Datatype old_type;
92   size_t size_oldtype;
93   int* block_lengths;
94   MPI_Aint* block_indices;
95   int block_count;
96   MPI_Datatype* old_types;
97 } s_smpi_mpi_struct_t;
98
99 /*
100   Functions to handle serialization/unserialization of messages, 3 for each type of MPI_Type
101   One for creating the substructure to handle, one for serialization, one for unserialization
102 */
103 XBT_PRIVATE void unserialize_contiguous( const void *contiguous_vector,
104                          void *noncontiguous_vector,
105                          int count,
106                          void *type,
107                          MPI_Op op);
108
109 XBT_PRIVATE void serialize_contiguous( const void *noncontiguous_vector,
110                        void *contiguous_vector,
111                        int count,
112                        void *type);
113
114 XBT_PRIVATE void free_contiguous(MPI_Datatype* type);
115
116 XBT_PRIVATE s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb,
117                                                   int block_count,
118                                                   MPI_Datatype old_type,
119                                                   int size_oldtype);
120                                                   
121 XBT_PRIVATE void unserialize_vector( const void *contiguous_vector,
122                          void *noncontiguous_vector,
123                          int count,
124                          void *type,
125                          MPI_Op op);
126
127 XBT_PRIVATE void serialize_vector( const void *noncontiguous_vector,
128                        void *contiguous_vector,
129                        int count,
130                        void *type);
131
132 XBT_PRIVATE void free_vector(MPI_Datatype* type);
133
134 XBT_PRIVATE s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride,
135                                                   int block_length,
136                                                   int block_count,
137                                                   MPI_Datatype old_type,
138                                                   int size_oldtype);
139
140 XBT_PRIVATE void unserialize_hvector( const void *contiguous_vector,
141                          void *noncontiguous_vector,
142                          int count,
143                          void *type,
144                          MPI_Op op);
145
146 XBT_PRIVATE void serialize_hvector( const void *noncontiguous_vector,
147                        void *contiguous_vector,
148                        int count,
149                        void *type);
150
151 XBT_PRIVATE void free_hvector(MPI_Datatype* type);
152
153 XBT_PRIVATE s_smpi_mpi_hvector_t* smpi_datatype_hvector_create( MPI_Aint block_stride,
154                                                   int block_length,
155                                                   int block_count,
156                                                   MPI_Datatype old_type,
157                                                   int size_oldtype);
158
159
160 XBT_PRIVATE void unserialize_indexed( const void *contiguous_indexed,
161                          void *noncontiguous_indexed,
162                          int count,
163                          void *type,
164                          MPI_Op op);
165
166 XBT_PRIVATE void serialize_indexed( const void *noncontiguous_vector,
167                        void *contiguous_vector,
168                        int count,
169                        void *type);
170
171 XBT_PRIVATE void free_indexed(MPI_Datatype* type);
172
173 XBT_PRIVATE s_smpi_mpi_indexed_t* smpi_datatype_indexed_create(int* block_lengths,
174                                                   int* block_indices,
175                                                   int block_count,
176                                                   MPI_Datatype old_type,
177                                                   int size_oldtype);
178
179 XBT_PRIVATE void unserialize_hindexed( const void *contiguous_indexed,
180                          void *noncontiguous_indexed,
181                          int count,
182                          void *type,
183                          MPI_Op op);
184
185 XBT_PRIVATE void serialize_hindexed( const void *noncontiguous_vector,
186                        void *contiguous_vector,
187                        int count,
188                        void *type);
189
190 XBT_PRIVATE void free_hindexed(MPI_Datatype* type);
191
192 XBT_PRIVATE s_smpi_mpi_hindexed_t* smpi_datatype_hindexed_create(int* block_lengths,
193                                                   MPI_Aint* block_indices,
194                                                   int block_count,
195                                                   MPI_Datatype old_type,
196                                                   int size_oldtype);
197
198 XBT_PRIVATE void unserialize_struct( const void *contiguous_indexed,
199                          void *noncontiguous_indexed,
200                          int count,
201                          void *type,
202                          MPI_Op op);
203
204 XBT_PRIVATE void serialize_struct( const void *noncontiguous_vector,
205                        void *contiguous_vector,
206                        int count,
207                        void *type);
208
209 XBT_PRIVATE void free_struct(MPI_Datatype* type);
210
211 XBT_PRIVATE s_smpi_mpi_struct_t* smpi_datatype_struct_create(int* block_lengths,
212                                                   MPI_Aint* block_indices,
213                                                   int block_count,
214                                                   MPI_Datatype* old_types);
215
216 #endif