Yet Another eXchange Tool  DO_NOT_EDIT_HERE
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 <mpi.h>
58 
59 #include "xt/xt_redist.h"
60 
62 
63 struct Xt_redist_msg {
64 
65  int rank;
66  MPI_Datatype datatype;
67 };
68 
70 
71  Xt_redist (*copy)(Xt_redist);
72  void (*delete)(Xt_redist);
73  void (*s_exchange)(Xt_redist, int, const void **, void **);
74  void (*s_exchange1)(Xt_redist, const void *, void *);
75  MPI_Datatype (*get_send_MPI_Datatype)(Xt_redist, int);
76  MPI_Datatype (*get_recv_MPI_Datatype)(Xt_redist, int);
77  int (*get_msg_ranks)(Xt_redist, enum xt_msg_direction, int**);
78  MPI_Comm (*get_MPI_Comm)(Xt_redist);
79 };
80 
81 struct Xt_redist_ {
82  const struct xt_redist_vtable *vtable;
83 };
84 
85 extern void
86 (*xt_redist_s_exchange_internal)(const void *src_data, void *dst_data,
87  int nsend, int nrecv,
88  struct Xt_redist_msg * send_msgs,
89  struct Xt_redist_msg * recv_msgs,
90  MPI_Comm comm);
91 
92 void
94  struct Xt_redist_msg *restrict src,
95  size_t src_stride,
96  struct Xt_redist_msg *restrict dst,
97  size_t dst_stride,
98  MPI_Comm comm);
99 
100 void xt_redist_msgs_strided_destruct(size_t n, struct Xt_redist_msg *msgs,
101  MPI_Comm comm, size_t ofs_stride);
102 
103 static inline void
104 xt_redist_msgs_free(size_t n, struct Xt_redist_msg *msgs, MPI_Comm comm)
105 {
106  xt_redist_msgs_strided_destruct(n, msgs, comm, sizeof (*msgs));
107  free(msgs);
108 }
109 
110 void xt_redist_check_comms(Xt_redist *redists, int num_redists, MPI_Comm comm);
111 
112 int xt_redist_get_msg_ranks(Xt_redist redist, enum xt_msg_direction direction,
113  int **ranks);
114 
115 size_t
116 xt_ranks_uniq_count(size_t num_rank_sets,
117  size_t *restrict num_ranks,
118  const int *ranks[num_rank_sets]);
119 
120 MPI_Datatype
121 xt_create_compound_datatype(size_t num_redists,
122  const MPI_Aint displacements[num_redists],
123  const MPI_Datatype datatypes[num_redists],
124  const int block_lengths[num_redists],
125  MPI_Comm comm);
126 
127 #endif
128 /*
129  * Local Variables:
130  * c-basic-offset: 2
131  * coding: utf-8
132  * indent-tabs-mode: nil
133  * show-trailing-whitespace: t
134  * require-trailing-newline: t
135  * End:
136  */
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:124
xt_msg_direction
void xt_redist_msgs_strided_copy(size_t n, 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:105
const struct xt_redist_vtable * vtable
MPI_Datatype xt_create_compound_datatype(size_t num_redists, const MPI_Aint displacements[num_redists], const MPI_Datatype datatypes[num_redists], const int block_lengths[num_redists], MPI_Comm comm)
Definition: xt_redist.c:181
static void xt_redist_msgs_free(size_t n, struct Xt_redist_msg *msgs, MPI_Comm comm)
void xt_redist_check_comms(Xt_redist *redists, int num_redists, MPI_Comm comm)
Definition: xt_redist.c:137
redistribution of data
size_t xt_ranks_uniq_count(size_t num_rank_sets, size_t *restrict num_ranks, const int *ranks[num_rank_sets])
Definition: xt_redist.c:152
struct Xt_redist_ * Xt_redist
Definition: xt_core.h:82
MPI_Datatype datatype
void(* xt_redist_s_exchange_internal)(const void *src_data, void *dst_data, int nsend, int nrecv, struct Xt_redist_msg *send_msgs, struct Xt_redist_msg *recv_msgs, MPI_Comm comm)
int MPI_Comm
Definition: core.h:64
int xt_redist_get_msg_ranks(Xt_redist redist, enum xt_msg_direction direction, int **ranks)
Definition: xt_redist.c:97