Yet Another eXchange Tool 0.11.4
Loading...
Searching...
No Matches
xt_request_msgs_ddt_packed.c
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#ifdef HAVE_CONFIG_H
47#include <config.h>
48#endif
49
50#include <assert.h>
51#include <stdlib.h>
52#include <string.h>
53
54#include "core/ppm_xfuncs.h"
55#include "xt/xt_mpi.h"
56
58#include "xt_config_internal.h"
59#include "xt_mpi_internal.h"
60#include "xt_request_internal.h"
61#include "xt_ddt_internal.h"
62#include "xt_request_internal.h"
64
73
74static void
76{
77 (void)request;
79 struct Xt_request_msgs_ddt_packed *request_msgs_ddt_packed = ebuf;
80 int n_packed = request_msgs_ddt_packed->n_packed,
81 n_tmp_buffers = request_msgs_ddt_packed->n_tmp_buffers;
82 void **buffers = request_msgs_ddt_packed->buffers;
83 Xt_ddt *ddts = request_msgs_ddt_packed->ddts;
84 void *dst_data = request_msgs_ddt_packed->dst_data;
85 enum xt_memtype pmemtype = request_msgs_ddt_packed->packed_memtype;
86 for (int i = 0; i < n_packed; ++i) {
88 xt_gpu_free(buffers[i], pmemtype);
90 }
91 for (int i = n_packed; i < n_packed + n_tmp_buffers; ++i)
92 xt_gpu_free(buffers[i], request_msgs_ddt_packed->tmp_memtype);
93 free(ddts);
94}
95
96
99 const MPI_Request requests[n_requests],
100 MPI_Comm comm, int n_packed,
101 int n_tmp_buffers,
102 Xt_ddt packed_ddts[n_packed],
103 void *packed_data[n_packed],
104 void *tmp_buffers[n_tmp_buffers],
105 void * dst_data,
107 enum xt_memtype tmp_memtype) {
108
109 assert(n_requests >= 0 && n_packed >= 0 && n_tmp_buffers >= 0);
110 size_t hdr_size = sizeof(struct Xt_request_msgs_ddt_packed),
111 bufp_size
112 = ((size_t)n_packed + (size_t)n_tmp_buffers) * sizeof(void *);
113
114 struct Xt_config_ conf = xt_default_config;
116 Xt_request request
117 = xt_request_msgs_ebuf_alloc(n_requests, comm, hdr_size+bufp_size, &conf);
118 MPI_Request *requests_
120 memcpy(requests_, requests,
121 (size_t)n_requests * sizeof(*requests_));
122 struct Xt_request_msgs_ddt_packed *ebuf
124 ebuf->n_packed = n_packed;
126 Xt_ddt *ddts = ebuf->ddts = xmalloc((size_t)n_packed * sizeof(*ddts));
127 for (int i = 0; i < n_packed; ++i) {
128 ddts[i] = packed_ddts[i];
130 }
132 ebuf->tmp_memtype = tmp_memtype;
133 memcpy(ebuf->buffers, packed_data,
134 (size_t)n_packed * sizeof(*ebuf->buffers));
135 memcpy(ebuf->buffers + n_packed, tmp_buffers,
136 (size_t)n_tmp_buffers * sizeof(*ebuf->buffers));
137 ebuf->dst_data = dst_data;
140 return request;
141}
142
143
144/*
145 * Local Variables:
146 * c-basic-offset: 2
147 * coding: utf-8
148 * indent-tabs-mode: nil
149 * show-trailing-whitespace: t
150 * require-trailing-newline: t
151 * End:
152 */
int MPI_Comm
Definition core.h:64
add versions of standard API functions not returning on error
#define xmalloc(size)
Definition ppm_xfuncs.h:70
struct Xt_config_ xt_default_config
Definition xt_config.c:204
void xt_config_set_redist_mthread_mode(Xt_config config, int mode)
Definition xt_config.c:347
@ XT_MT_NONE
Definition xt_config.h:140
implementation of configuration object
void xt_ddt_unpack_internal(Xt_ddt ddt, const void *src, void *dst, enum xt_memtype memtype)
Definition xt_ddt.c:553
void xt_ddt_delete(Xt_ddt ddt)
void xt_ddt_inc_ref_count(Xt_ddt ddt)
internal utility routines for manual handling of MPI DDT's
void xt_gpu_free(void *ptr, enum xt_memtype memtype)
Definition xt_gpu.c:187
xt_memtype
Definition xt_gpu.h:68
utility routines for MPI
Provide non-public declarations common to all requests.
Xt_request xt_request_msgs_ddt_packed_new(int n_requests, const MPI_Request requests[n_requests], MPI_Comm comm, int n_packed, int n_tmp_buffers, Xt_ddt packed_ddts[n_packed], void *packed_data[n_packed], void *tmp_buffers[n_tmp_buffers], void *dst_data, enum xt_memtype packed_memtype, enum xt_memtype tmp_memtype)
static void xt_request_msgs_packed_ddt_finalize(Xt_request request, void *ebuf)
void xt_request_msgs_ebuf_set_finalizer(Xt_request request, Xt_request_msgs_ebuf_finalizer finalizer)
Xt_request xt_request_msgs_ebuf_alloc(int n_requests, MPI_Comm comm, size_t extra_buf_size, Xt_config config)
MPI_Request * xt_request_msgs_ebuf_get_req_ptr(Xt_request request)
void * xt_request_msgs_ebuf_get_extra_buf(Xt_request request)
internal interfaces for xt_request_msgs_ebuf