xt_redist.h 7.18 KB
Newer Older
1
2
3
4
5
/**
 * @file xt_redist.h
 * @brief redistribution of data
 *
 * contains declaration the redistribution data structure, which
6
 * is derived from one or more xt_xmaps
7
 *
Thomas Jahns's avatar
Thomas Jahns committed
8
 * @copyright Copyright  (C)  2016 Jörg Behrens <behrens@dkrz.de>
9
10
11
12
13
14
15
16
17
18
19
20
 *                                 Moritz Hanke <hanke@dkrz.de>
 *                                 Thomas Jahns <jahns@dkrz.de>
 *
 * @author Jörg Behrens <behrens@dkrz.de>
 *         Moritz Hanke <hanke@dkrz.de>
 *         Thomas Jahns <jahns@dkrz.de>
 */
/*
 * Keywords:
 * Maintainer: Jörg Behrens <behrens@dkrz.de>
 *             Moritz Hanke <hanke@dkrz.de>
 *             Thomas Jahns <jahns@dkrz.de>
Moritz Hanke's avatar
Moritz Hanke committed
21
 * URL: https://doc.redmine.dkrz.de/yaxt/html/
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are  permitted provided that the following conditions are
 * met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 *
 * Neither the name of the DKRZ GmbH nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

51
52
53
#ifndef XT_REDIST_H
#define XT_REDIST_H

Thomas Jahns's avatar
Thomas Jahns committed
54
55
56
57
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

58
59
#include <mpi.h>

Thomas Jahns's avatar
Thomas Jahns committed
60
#include "xt/xt_core.h"
61
#include "xt/xt_request.h"
62

63
64
65
struct Xt_redist_msg {

  int rank;
66
67
68
#if SIZEOF_MPI_DATATYPE == 2 * SIZEOF_INT
  int padding;
#endif
69
70
71
  MPI_Datatype datatype;
};

72
73
74
75
/**
 * \example test_redist_common.c
 */

Thomas Jahns's avatar
Thomas Jahns committed
76
77
78
79
80
81
82
/**
 * redist copy constructor
 *
 * @param[in,out] redist redistribution structure
 */
Xt_redist xt_redist_copy(Xt_redist redist);

83
84
85
86
87
88
89
90
/**
 * destructor
 *
 * @param[in,out] redist redistribution structure
 */
void xt_redist_delete(Xt_redist redist);

/**
Thomas Jahns's avatar
Thomas Jahns committed
91
 * synchronous redistribution of data
92
 *
Moritz Hanke's avatar
Moritz Hanke committed
93
94
95
96
97
98
 * @param[in]     redist     redistribution structure
 * @param[in]     num_arrays number of base addresses in src_data and dst_data
 * @param[in]     src_data   array containing the addresses of the first
 *                           elements of the input data
 * @param[in,out] dst_data   array containing the addresses of the first
 *                           elements of the output data
99
100
101
 *
 * @remark The above implies that NULL or any other invalid pointer
 * must not be used in either @a src_data or @a dst_data.
102
103
 * @par See Also
 *   \ref correct_addresses
104
 */
105
void xt_redist_s_exchange(Xt_redist redist, int num_arrays,
106
                          const void **src_data, void **dst_data);
107

108
109
110
111
112
113
114
115
116
/**
 * asynchronous redistribution of data
 *
 * @param[in]     redist     redistribution structure
 * @param[in]     num_arrays number of base addresses in src_data and dst_data
 * @param[in]     src_data   array containing the addresses of the first
 *                           elements of the input data
 * @param[in,out] dst_data   array containing the addresses of the first
 *                           elements of the output data
117
118
 * @param[out] request pointer to a request object that can be used to complete
 *          an asynchronous exchange
119
120
121
 *
 * @remark The above implies that NULL or any other invalid pointer
 * must not be used in either @a src_data or @a dst_data.
122
123
 * @par See Also
 *   \ref correct_addresses
124
 */
125
126
127
void xt_redist_a_exchange(Xt_redist redist, int num_arrays,
                          const void **src_data, void **dst_data,
                          Xt_request *request);
128

129
/**
Thomas Jahns's avatar
Thomas Jahns committed
130
 * synchronous redistribution of data - single array case
131
 *
Moritz Hanke's avatar
Moritz Hanke committed
132
133
134
 * @param[in]     redist   redistribution structure
 * @param[in]     src_data address of the first element of the input data
 * @param[in,out] dst_data address of the first element of the output data
135
136
137
 *
 * @remark The above implies that NULL or any other invalid pointer
 * must not be used in either @a src_data or @a dst_data.
138
 */
139
void xt_redist_s_exchange1(Xt_redist redist, const void *src_data, void *dst_data);
140

141
142
143
144
145
146
/**
 * asynchronous redistribution of data - single array case
 *
 * @param[in]     redist   redistribution structure
 * @param[in]     src_data address of the first element of the input data
 * @param[in,out] dst_data address of the first element of the output data
147
148
 * @param[out] request pointer to a request object that can be used to complete
 *          an asynchronous exchange
149
150
151
152
 *
 * @remark The above implies that NULL or any other invalid pointer
 * must not be used in either @a src_data or @a dst_data.
 */
153
154
void xt_redist_a_exchange1(Xt_redist redist, const void *src_data,
                           void *dst_data, Xt_request *request);
155

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/**
 * gets the number of messages send from the local process in an exchange
 * operation
 *
 * @param[in] redist redistribution structure
 * @return number of messages sent in the exchange operation
 */
int xt_redist_get_num_send_msg(Xt_redist redist);

/**
 * gets the number of messages received by the local process in an exchange
 * operation
 *
 * @param[in] redist redistribution structure
 * @return number of messages received in the exchange operation
 */
int xt_redist_get_num_recv_msg(Xt_redist redist);

174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**
 * gets a copy of the MPI_Datatype used for the data of the send operation with
 * the given rank
 *
 * @param[in] redist redistribution structure
 * @param[in] rank   MPI rank
 * \return MPI_Datatype for the data of the send operation with the given rank
 *
 * \remarks returns MPI_DATATYPE_NULL if there is no send operation with the given rank
 */
MPI_Datatype xt_redist_get_send_MPI_Datatype(Xt_redist redist, int rank);

/**
 * gets a copy of the MPI_Datatype used for the data of the recv operation with
 * the given rank
 *
 * @param[in] redist redistribution structure
 * @param[in] rank   MPI rank
 * \return MPI_Datatype for the data of the recv operation with the given rank
 *
 * \remarks returns MPI_DATATYPE_NULL if there is no recv operation with the given rank
 */
MPI_Datatype xt_redist_get_recv_MPI_Datatype(Xt_redist redist, int rank);

198
199
200
201
202
203
204
/**
 * returns a MPI communicator, which the redistribution is based on
 * @param[in] redist redistribution structure
 * \return MPI communicator, which the redistribution is based on
 */
MPI_Comm xt_redist_get_MPI_Comm(Xt_redist redist);

205
#endif // XT_REDIST_H
Thomas Jahns's avatar
Thomas Jahns committed
206

Thomas Jahns's avatar
Thomas Jahns committed
207
208
209
210
211
212
213
214
215
/*
 * Local Variables:
 * c-basic-offset: 2
 * coding: utf-8
 * indent-tabs-mode: nil
 * show-trailing-whitespace: t
 * require-trailing-newline: t
 * End:
 */