Logo AND Algorithmique Numérique Distribuée

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