Yet Another eXchange Tool 0.11.3
Loading...
Searching...
No Matches
xt_mpi_ddt_wrap.h
Go to the documentation of this file.
1
12/*
13 * Keywords:
14 * Maintainer: Jörg Behrens <behrens@dkrz.de>
15 * Moritz Hanke <hanke@dkrz.de>
16 * Thomas Jahns <jahns@dkrz.de>
17 * URL: https://dkrz-sw.gitlab-pages.dkrz.de/yaxt/
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions are
21 * met:
22 *
23 * Redistributions of source code must retain the above copyright notice,
24 * this list of conditions and the following disclaimer.
25 *
26 * Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 *
30 * Neither the name of the DKRZ GmbH nor the names of its contributors
31 * may be used to endorse or promote products derived from this software
32 * without specific prior written permission.
33 *
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
35 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
36 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
37 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
38 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
39 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
40 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
41 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
42 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 */
46#ifndef XT_MPI_DDT_WRAP_H
47#define XT_MPI_DDT_WRAP_H
48
49#ifdef HAVE_CONFIG_H
50#include <config.h>
51#endif
52
53#ifdef XT_MPI_TYPE_CREATE_INDEXED_BLOCK_CONST_DISP
54# define Xt_Type_create_indexed_block(count, blocklength, disp, \
55 oldtype, newtype, comm) \
56 xt_mpi_call(MPI_Type_create_indexed_block(count, blocklength, disp, \
57 oldtype, newtype), comm)
58#else
59# define Xt_Type_create_indexed_block(count, blocklength, disp, \
60 oldtype, newtype, comm) \
61 xt_mpi_call(MPI_Type_create_indexed_block(count, blocklength, \
62 (int *)(intptr_t)disp, \
63 oldtype, newtype), comm)
64#endif
65
66#if MPI_VERSION < 3
67static inline int
68XtMPI_Type_create_hindexed_block(int count, int blocklength,
69 const MPI_Aint array_of_displacements[],
70 MPI_Datatype oldtype, MPI_Datatype *newtype)
71{
72 size_t count_ = count > 0 ? (size_t)count : 0;
73 enum { bl_auto_max = 32 };
74 int blocklengths_auto[bl_auto_max];
75 int *restrict blocklengths
76 = count_ > bl_auto_max
77 ? xmalloc(count_ * sizeof (*blocklengths))
78 : blocklengths_auto;
79 for (size_t i = 0; i < count_; ++i)
80 blocklengths[i] = blocklength;
81 int rc = MPI_Type_create_hindexed(count, blocklengths,
82 CAST_MPI_SEND_BUF(array_of_displacements),
83 oldtype, newtype);
84 if (count_ > bl_auto_max)
85 free(blocklengths);
86 return rc;
87}
88
89# define MPI_Type_create_hindexed_block XtMPI_Type_create_hindexed_block
90# define XT_MPI_TYPE_CREATE_HINDEXED_BLOCK_CONST_DISP
91# define Xt_Type_create_hindexed_block(count, blocklength, \
92 array_of_displacements, \
93 oldtype, newtype, comm) \
94 xt_mpi_call(XtMPI_Type_create_hindexed_block(count, blocklength, \
95 array_of_displacements, \
96 oldtype, newtype), comm)
98#elif defined XT_MPI_TYPE_CREATE_HINDEXED_BLOCK_CONST_DISP
99# define Xt_Type_create_hindexed_block(count, blocklength, \
100 array_of_displacements, \
101 oldtype, newtype, comm) \
102 xt_mpi_call(MPI_Type_create_hindexed_block(count, blocklength, \
103 array_of_displacements, \
104 oldtype, newtype), comm)
105#else
106# define Xt_Type_create_hindexed_block(count, blocklength, \
107 array_of_displacements, \
108 oldtype, newtype, comm) \
109 xt_mpi_call(MPI_Type_create_hindexed_block( \
110 count, blocklength, \
111 (MPI_Aint *)(intptr_t)array_of_displacements, \
112 oldtype, newtype), comm)
113#endif
114
115#ifdef XT_MPI_TYPE_INDEXED_CONST_ARRAY_ARGS
116# define Xt_Type_indexed(count, blocklength, disp, oldtype, newtype, \
117 comm) \
118 xt_mpi_call(MPI_Type_indexed(count, blocklength, \
119 disp, oldtype, newtype), comm)
120#else
121# define Xt_Type_indexed(count, blocklength, disp, oldtype, newtype, \
122 comm) \
123 xt_mpi_call(MPI_Type_indexed(count, (int *)(intptr_t)blocklength, \
124 (int *)(intptr_t)disp, oldtype, \
125 newtype), comm)
126#endif
127
128#ifdef XT_MPI_TYPE_CREATE_HINDEXED_CONST_ARRAY_ARGS
129# define Xt_Type_create_hindexed(count, blocklength, disp, oldtype, \
130 newtype, comm) \
131 xt_mpi_call(MPI_Type_create_hindexed(count, blocklength, \
132 disp, oldtype, newtype), comm)
133#else
134# define Xt_Type_create_hindexed(count, blocklength, disp, oldtype, \
135 newtype, comm) \
136 xt_mpi_call(MPI_Type_create_hindexed(count, \
137 (int *)(intptr_t)blocklength, \
138 (MPI_Aint *)(intptr_t)disp, \
139 oldtype, newtype), comm)
140#endif
141
142#ifdef XT_MPI_TYPE_CREATE_STRUCT_CONST_ARRAY_ARGS
143# define Xt_Type_create_struct(count, array_of_blocklengths, \
144 array_of_displacements, \
145 array_of_types, \
146 newtype, comm) \
147 xt_mpi_call(MPI_Type_create_struct( \
148 count, array_of_blocklengths, \
149 array_of_displacements, \
150 array_of_types, \
151 newtype), comm)
152#else
153# define Xt_Type_create_struct(count, array_of_blocklengths, \
154 array_of_displacements, \
155 array_of_types, \
156 newtype, comm) \
157 xt_mpi_call(MPI_Type_create_struct( \
158 count, (int *)(intptr_t)array_of_blocklengths, \
159 (MPI_Aint*)(intptr_t)array_of_displacements, \
160 (MPI_Datatype *)(intptr_t)array_of_types, \
161 newtype), comm)
162#endif
163
164#ifdef XT_MPI_TYPE_INDEXED_CONST_ARRAY_ARGS
165# define Xt_Type_create_subarray(ndims, array_of_sizes, \
166 array_of_subsizes, array_of_starts, \
167 order, oldtype, newtype, comm) \
168 xt_mpi_call(MPI_Type_create_subarray(ndims, array_of_sizes, \
169 array_of_subsizes, \
170 array_of_starts, \
171 order, oldtype, newtype), comm)
172#else
173# define Xt_Type_create_subarray(ndims, array_of_sizes, \
174 array_of_subsizes, array_of_starts, \
175 order, oldtype, newtype, comm) \
176 xt_mpi_call(MPI_Type_create_subarray( \
177 ndims, (int *)(intptr_t)array_of_sizes, \
178 (int *)(intptr_t)array_of_subsizes, \
179 (int *)(intptr_t)array_of_starts, \
180 order, oldtype, newtype), comm)
181#endif
182
183#endif // XT_MPI_DDT_WRAP_H
184
185/*
186 * Local Variables:
187 * c-basic-offset: 2
188 * coding: utf-8
189 * indent-tabs-mode: nil
190 * show-trailing-whitespace: t
191 * require-trailing-newline: t
192 * End:
193 */
#define xmalloc(size)
Definition ppm_xfuncs.h:70
int MPI_Type_create_hindexed(int count, XT_MPI2_CONST int array_of_blocklengths[], XT_MPI2_CONST MPI_Aint array_of_displacements[], MPI_Datatype oldtype, MPI_Datatype *newtype)
@ MPI_COMBINER_HINDEXED_BLOCK
static int XtMPI_Type_create_hindexed_block(int count, int blocklength, const MPI_Aint array_of_displacements[], MPI_Datatype oldtype, MPI_Datatype *newtype)