Yet Another eXchange Tool  0.9.0
xt_redist_internal.h
Go to the documentation of this file.
1 
16 /*
17  * Keywords:
18  * Maintainer: Jörg Behrens <behrens@dkrz.de>
19  * Moritz Hanke <hanke@dkrz.de>
20  * Thomas Jahns <jahns@dkrz.de>
21  * URL: https://doc.redmine.dkrz.de/yaxt/html/
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions are
25  * met:
26  *
27  * Redistributions of source code must retain the above copyright notice,
28  * this list of conditions and the following disclaimer.
29  *
30  * Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in the
32  * documentation and/or other materials provided with the distribution.
33  *
34  * Neither the name of the DKRZ GmbH nor the names of its contributors
35  * may be used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
39  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
40  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
41  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
42  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
43  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
44  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
45  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
46  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
47  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
48  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49  */
50 #ifndef XT_REDIST_INTERNAL_H
51 #define XT_REDIST_INTERNAL_H
52 
53 #ifdef HAVE_CONFIG_H
54 #include <config.h>
55 #endif
56 
57 #include <stdlib.h>
58 #include <mpi.h>
59 
60 #include "xt/xt_redist.h"
61 #include "xt/xt_request.h"
62 
64 
66 
68  void (*delete)(Xt_redist);
69  void (*s_exchange)(Xt_redist, int, const void **, void **);
70  void (*a_exchange)(Xt_redist, int, const void **, void **, Xt_request *);
71  void (*s_exchange1)(Xt_redist, const void *, void *);
72  void (*a_exchange1)(Xt_redist, const void *, void *, Xt_request *);
73  MPI_Datatype (*get_msg_MPI_Datatype)(Xt_redist, int, enum xt_msg_direction);
75  int (*get_msg_ranks)(Xt_redist, enum xt_msg_direction, int *restrict *);
77 };
78 
79 struct Xt_redist_ {
80  const struct xt_redist_vtable *vtable;
81 };
82 
83 void
85  const struct Xt_redist_msg *restrict src,
86  size_t src_stride,
87  struct Xt_redist_msg *restrict dst,
88  size_t dst_stride,
89  MPI_Comm comm);
90 
91 void xt_redist_msgs_strided_destruct(size_t n, struct Xt_redist_msg *msgs,
92  MPI_Comm comm, size_t ofs_stride);
93 
94 static inline void
95 xt_redist_msgs_free(size_t n, struct Xt_redist_msg *msgs, MPI_Comm comm)
96 {
97  xt_redist_msgs_strided_destruct(n, msgs, comm, sizeof (*msgs));
98  free(msgs);
99 }
100 
110 void xt_redist_check_comms(Xt_redist *redists, int num_redists, MPI_Comm comm);
111 
123 int xt_redist_get_msg_ranks(Xt_redist redist, enum xt_msg_direction direction,
124  int *restrict *ranks);
125 
136 MPI_Datatype xt_redist_get_MPI_Datatype(Xt_redist redist, int rank,
137  enum xt_msg_direction direction);
138 
148 MPI_Datatype
149 xt_create_compound_datatype(size_t count,
150  const MPI_Aint displacements[count],
151  const MPI_Datatype datatypes[count],
152  const int block_lengths[count],
153  MPI_Comm comm);
154 
169 unsigned
170 xt_redist_agg_msg_count(size_t num_redists, enum xt_msg_direction direction,
171  const Xt_redist redists[num_redists],
172  size_t num_ranks[num_redists],
173  int *restrict ranks[num_redists]);
174 
175 #endif
176 /*
177  * Local Variables:
178  * c-basic-offset: 2
179  * coding: utf-8
180  * indent-tabs-mode: nil
181  * show-trailing-whitespace: t
182  * require-trailing-newline: t
183  * End:
184  */
int MPI_Comm
Definition: core.h:64
const struct xt_redist_vtable * vtable
Xt_redist(* copy)(Xt_redist)
void(* a_exchange)(Xt_redist, int, const void **, void **, Xt_request *)
void(* s_exchange1)(Xt_redist, const void *, void *)
MPI_Datatype(* get_msg_MPI_Datatype)(Xt_redist, int, enum xt_msg_direction)
void(* a_exchange1)(Xt_redist, const void *, void *, Xt_request *)
int(* get_num_msg)(Xt_redist, enum xt_msg_direction)
int(* get_msg_ranks)(Xt_redist, enum xt_msg_direction, int *restrict *)
void(* s_exchange)(Xt_redist, int, const void **, void **)
MPI_Comm(* get_MPI_Comm)(Xt_redist)
struct Xt_redist_ * Xt_redist
Definition: xt_core.h:82
redistribution of data
MPI_Datatype xt_redist_get_MPI_Datatype(Xt_redist redist, int rank, enum xt_msg_direction direction)
Definition: xt_redist.c:117
static void xt_redist_msgs_free(size_t n, struct Xt_redist_msg *msgs, MPI_Comm comm)
int xt_redist_get_msg_ranks(Xt_redist redist, enum xt_msg_direction direction, int *restrict *ranks)
Definition: xt_redist.c:128
xt_msg_direction
@ RECV
@ SEND
void xt_redist_msgs_strided_copy(size_t n, const struct Xt_redist_msg *restrict src, size_t src_stride, struct Xt_redist_msg *restrict dst, size_t dst_stride, MPI_Comm comm)
Definition: xt_redist.c:136
unsigned xt_redist_agg_msg_count(size_t num_redists, enum xt_msg_direction direction, const Xt_redist redists[num_redists], size_t num_ranks[num_redists], int *restrict ranks[num_redists])
Definition: xt_redist.c:217
void xt_redist_check_comms(Xt_redist *redists, int num_redists, MPI_Comm comm)
Definition: xt_redist.c:169
MPI_Datatype xt_create_compound_datatype(size_t count, const MPI_Aint displacements[count], const MPI_Datatype datatypes[count], const int block_lengths[count], MPI_Comm comm)
Definition: xt_redist.c:239
void xt_redist_msgs_strided_destruct(size_t n, struct Xt_redist_msg *msgs, MPI_Comm comm, size_t ofs_stride)
Definition: xt_redist.c:156