Logo AND Algorithmique Numérique Distribuée

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