File: pml_cm_recvreq.h

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (385 lines) | stat: -rw-r--r-- 22,150 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2013 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2006 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2012      Sandia National Laboratories.  All rights reserved.
 * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
 *                         reserved.
 * Copyright (c) 2017      Intel, Inc. All rights reserved
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#ifndef PML_CM_RECVREQ_H
#define PML_CM_RECVREQ_H

#include "pml_cm_request.h"
#include "ompi/mca/pml/base/pml_base_recvreq.h"
#include "ompi/mca/mtl/mtl.h"

struct mca_pml_cm_thin_recv_request_t {
    mca_pml_cm_request_t req_base;
    mca_mtl_request_t req_mtl;            /**< the mtl specific memory. This field should be the last in the struct */
};
typedef struct mca_pml_cm_thin_recv_request_t mca_pml_cm_thin_recv_request_t;
OBJ_CLASS_DECLARATION(mca_pml_cm_thin_recv_request_t);

struct mca_pml_cm_hvy_recv_request_t {
    mca_pml_cm_request_t req_base;
    void *req_addr;                       /**< pointer to application buffer */
    size_t req_count;                     /**< count of user datatype elements */
    int32_t req_peer;                     /**< peer process - rank w/in this communicator */
    int32_t req_tag;                      /**< user defined tag */
    void *req_buff;                       /**< pointer to send buffer - may not be application buffer */
    size_t req_bytes_packed;              /**< packed size of a message given the datatype and count */
    bool req_blocking;
    mca_mtl_request_t req_mtl;            /**< the mtl specific memory. This field should be the last in the struct */
};
typedef struct mca_pml_cm_hvy_recv_request_t mca_pml_cm_hvy_recv_request_t;

OBJ_CLASS_DECLARATION(mca_pml_cm_hvy_recv_request_t);

/**
 *  Allocate a recv request from the modules free list.
 *
 *  @param rc (OUT)  OMPI_SUCCESS or error status on failure.
 *  @return          Receive request.
 */
#define MCA_PML_CM_THIN_RECV_REQUEST_ALLOC(recvreq)                            \
do {                                                                           \
    recvreq = (mca_pml_cm_thin_recv_request_t*)                                \
      opal_free_list_get (&mca_pml_base_recv_requests);                        \
    recvreq->req_base.req_pml_type = MCA_PML_CM_REQUEST_RECV_THIN;             \
    recvreq->req_mtl.ompi_req = (ompi_request_t*) recvreq;                     \
    recvreq->req_mtl.completion_callback = mca_pml_cm_recv_request_completion; \
 } while (0)

#define MCA_PML_CM_HVY_RECV_REQUEST_ALLOC(recvreq)                             \
do {                                                                           \
    recvreq = (mca_pml_cm_hvy_recv_request_t*)                                 \
      opal_free_list_get (&mca_pml_base_recv_requests);                        \
    recvreq->req_base.req_pml_type = MCA_PML_CM_REQUEST_RECV_HEAVY;            \
    recvreq->req_mtl.ompi_req = (ompi_request_t*) recvreq;                     \
    recvreq->req_mtl.completion_callback = mca_pml_cm_recv_request_completion; \
 } while (0)


/**
 * Initialize a receive request with call parameters.
 *
 * @param request (IN)       Receive request.
 * @param addr (IN)          User buffer.
 * @param count (IN)         Number of elements of indicated datatype.
 * @param datatype (IN)      User defined datatype.
 * @param src (IN)           Source rank w/in the communicator.
 * @param comm (IN)          Communicator.
 * @param persistent (IN)    Is this a ersistent request.
 */
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
#define MCA_PML_CM_THIN_RECV_REQUEST_INIT( request,                     \
                                           ompi_proc,                   \
                                           comm,                        \
                                           src,                         \
                                           datatype,                    \
                                           addr,                        \
                                           count,                       \
                                           flags )                      \
do {                                                                    \
    OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, false);            \
    (request)->req_base.req_ompi.req_mpi_object.comm = comm;            \
    (request)->req_base.req_pml_complete = false;                       \
    (request)->req_base.req_free_called = false;                        \
    request->req_base.req_comm = comm;                                  \
    request->req_base.req_datatype = datatype;                          \
    OBJ_RETAIN(comm);                                                   \
    OMPI_DATATYPE_RETAIN(datatype);                                     \
                                                                        \
    if( MPI_ANY_SOURCE == src ) {                                       \
        ompi_proc = ompi_proc_local_proc;                               \
    } else {                                                            \
        ompi_proc = ompi_comm_peer_lookup( comm, src );                 \
    }                                                                   \
    MCA_PML_CM_SWITCH_ACCELERATOR_CONVERTOR_OFF(flags, datatype, count);       \
    opal_convertor_copy_and_prepare_for_recv(                           \
                                  ompi_proc->super.proc_convertor,      \
                                  &(datatype->super),                   \
                                  count,                                \
                                  addr,                                 \
                                  flags,                                \
                                  &(request)->req_base.req_convertor ); \
} while(0)
#else
#define MCA_PML_CM_THIN_RECV_REQUEST_INIT( request,                     \
                                           ompi_proc,                   \
                                           comm,                        \
                                           src,                         \
                                           datatype,                    \
                                           addr,                        \
                                           count,                       \
                                           flags )                      \
do {                                                                    \
    OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, false);            \
    (request)->req_base.req_ompi.req_mpi_object.comm = comm;            \
    (request)->req_base.req_pml_complete = false;                       \
    (request)->req_base.req_free_called = false;                        \
    request->req_base.req_comm = comm;                                  \
    request->req_base.req_datatype = datatype;                          \
    OBJ_RETAIN(comm);                                                   \
    OMPI_DATATYPE_RETAIN(datatype);                                     \
                                                                        \
    MCA_PML_CM_SWITCH_ACCELERATOR_CONVERTOR_OFF(flags, datatype, count);       \
    opal_convertor_copy_and_prepare_for_recv(                           \
        ompi_mpi_local_convertor,                                       \
        &(datatype->super),                                             \
        count,                                                          \
        addr,                                                           \
        flags,                                                          \
        &(request)->req_base.req_convertor );                           \
} while(0)
#endif

#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
#define MCA_PML_CM_HVY_RECV_REQUEST_INIT( request,                      \
                                          ompi_proc,                    \
                                          comm,                         \
                                          tag,                          \
                                          src,                          \
                                          datatype,                     \
                                          addr,                         \
                                          count,                        \
                                          flags,                        \
                                          persistent)                   \
do {                                                                    \
    OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, persistent);       \
    (request)->req_base.req_ompi.req_mpi_object.comm = comm;            \
    (request)->req_base.req_pml_complete = OPAL_INT_TO_BOOL(persistent); \
    (request)->req_base.req_free_called = false;                        \
    request->req_base.req_comm = comm;                                  \
    request->req_base.req_datatype = datatype;                          \
    request->req_tag = tag;                                             \
    request->req_peer = src;                                            \
    request->req_addr = addr;                                           \
    request->req_count = count;                                         \
    OBJ_RETAIN(comm);                                                   \
    OMPI_DATATYPE_RETAIN(datatype);                                     \
                                                                        \
    if( MPI_ANY_SOURCE == src ) {                                       \
        ompi_proc = ompi_proc_local_proc;                               \
    } else {                                                            \
        ompi_proc = ompi_comm_peer_lookup( comm, src );                 \
    }                                                                   \
    MCA_PML_CM_SWITCH_ACCELERATOR_CONVERTOR_OFF(flags, datatype, count);       \
    opal_convertor_copy_and_prepare_for_recv(                           \
                                  ompi_proc->super.proc_convertor,      \
                                  &(datatype->super),                   \
                                  count,                                \
                                  addr,                                 \
                                  flags,                                \
                                  &(request)->req_base.req_convertor ); \
 } while(0)
#else
#define MCA_PML_CM_HVY_RECV_REQUEST_INIT( request,                      \
                                          ompi_proc,                    \
                                          comm,                         \
                                          tag,                          \
                                          src,                          \
                                          datatype,                     \
                                          addr,                         \
                                          count,                        \
                                          flags,                        \
                                          persistent)                   \
do {                                                                    \
    OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, persistent);       \
    (request)->req_base.req_ompi.req_mpi_object.comm = comm;            \
    (request)->req_base.req_pml_complete = OPAL_INT_TO_BOOL(persistent); \
    (request)->req_base.req_free_called = false;                        \
    request->req_base.req_comm = comm;                                  \
    request->req_base.req_datatype = datatype;                          \
    request->req_tag = tag;                                             \
    request->req_peer = src;                                            \
    request->req_addr = addr;                                           \
    request->req_count = count;                                         \
    OBJ_RETAIN(comm);                                                   \
    OMPI_DATATYPE_RETAIN(datatype);                                     \
                                                                        \
    MCA_PML_CM_SWITCH_ACCELERATOR_CONVERTOR_OFF(flags, datatype, count);       \
    opal_convertor_copy_and_prepare_for_recv(                           \
        ompi_mpi_local_convertor,                                       \
        &(datatype->super),                                             \
        count,                                                          \
        addr,                                                           \
        flags,                                                          \
        &(request)->req_base.req_convertor );                           \
 } while(0)
#endif

/**
 * Start an initialized request.
 *
 * @param request  Receive request.
 * @return         OMPI_SUCESS or error status on failure.
 */
#define MCA_PML_CM_THIN_RECV_REQUEST_START(request, comm, tag, src, ret) \
do {                                                                    \
    /* init/re-init the request */                                      \
    request->req_base.req_pml_complete = false;                         \
    request->req_base.req_ompi.req_complete = false;                    \
    request->req_base.req_ompi.req_state = OMPI_REQUEST_ACTIVE;         \
                                                                        \
    /* always set the req_status.MPI_TAG to ANY_TAG before starting the \
     * request. This field is used if cancelled to find out if the request \
     * has been matched or not.                                         \
     */                                                                 \
    request->req_base.req_ompi.req_status.MPI_TAG = OMPI_ANY_TAG;       \
    request->req_base.req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS;     \
    request->req_base.req_ompi.req_status._cancelled = 0;               \
    ret = OMPI_MTL_CALL(irecv(ompi_mtl,                                 \
                              comm,                                     \
                              src,                                      \
                              tag,                                      \
                              &recvreq->req_base.req_convertor,         \
                              &recvreq->req_mtl));                      \
} while (0)

#define MCA_PML_CM_THIN_RECV_REQUEST_MATCHED_START(request, message, ret) \
do {                                                                    \
    /* init/re-init the request */                                      \
    request->req_base.req_pml_complete = false;                         \
    request->req_base.req_ompi.req_complete = false;                    \
    request->req_base.req_ompi.req_state = OMPI_REQUEST_ACTIVE;         \
                                                                        \
    /* always set the req_status.MPI_TAG to ANY_TAG before starting the \
     * request. This field is used if cancelled to find out if the request \
     * has been matched or not.                                         \
     */                                                                 \
    request->req_base.req_ompi.req_status.MPI_TAG = OMPI_ANY_TAG;       \
    request->req_base.req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS;     \
    request->req_base.req_ompi.req_status._cancelled = 0;               \
    ret = OMPI_MTL_CALL(imrecv(ompi_mtl,                                \
                               &recvreq->req_base.req_convertor,        \
                               message,                                 \
                               &recvreq->req_mtl));                     \
} while (0)


#define MCA_PML_CM_HVY_RECV_REQUEST_START(request, ret)                 \
do {                                                                    \
/*     opal_output(0, "posting hvy request %d\n", request);                */ \
    /* init/re-init the request */                                      \
    request->req_base.req_pml_complete = false;                         \
    request->req_base.req_ompi.req_complete = false;                    \
    request->req_base.req_ompi.req_state = OMPI_REQUEST_ACTIVE;         \
                                                                        \
    /* always set the req_status.MPI_TAG to ANY_TAG before starting the \
     * request. This field is used if cancelled to find out if the request \
     * has been matched or not.                                         \
     */                                                                 \
    request->req_base.req_ompi.req_status.MPI_TAG = OMPI_ANY_TAG;       \
    request->req_base.req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS;     \
    request->req_base.req_ompi.req_status._cancelled = 0;               \
    ret = OMPI_MTL_CALL(irecv(ompi_mtl,                                 \
                              request->req_base.req_comm,               \
                              request->req_peer,                        \
                              request->req_tag,                         \
                              &recvreq->req_base.req_convertor,         \
                              &recvreq->req_mtl));                      \
} while (0)


/**
 * Mark the request as completed at MPI level for internal purposes.
 *
 *  @param recvreq (IN)  Receive request.
 */
#define MCA_PML_CM_THIN_RECV_REQUEST_MPI_COMPLETE( recvreq )            \
do {                                                                    \
    ompi_request_complete(  &(recvreq->req_base.req_ompi), true );      \
 } while (0)


/**
 *  Return a recv request to the modules free list.
 *
 *  @param recvreq (IN)  Receive request.
 */
#define MCA_PML_CM_THIN_RECV_REQUEST_PML_COMPLETE(recvreq)              \
do {                                                                    \
    assert( false == recvreq->req_base.req_pml_complete );              \
                                                                        \
    if( true == recvreq->req_base.req_free_called ) {                   \
        MCA_PML_CM_THIN_RECV_REQUEST_RETURN( recvreq );                 \
    } else {                                                            \
        recvreq->req_base.req_pml_complete = true;                      \
        ompi_request_complete( &(recvreq->req_base.req_ompi), true );   \
    }                                                                   \
 } while(0)




/**
 *  Return a recv request to the modules free list.
 *
 *  @param recvreq (IN)  Receive request.
 */
#define MCA_PML_CM_HVY_RECV_REQUEST_PML_COMPLETE(recvreq)               \
do {                                                                    \
    assert( false == recvreq->req_base.req_pml_complete );              \
                                                                        \
    if( true == recvreq->req_base.req_free_called ) {                   \
        MCA_PML_CM_HVY_RECV_REQUEST_RETURN( recvreq );                  \
    } else {                                                            \
        /* initialize request status */                                 \
        if(recvreq->req_base.req_ompi.req_persistent) {                 \
            /* rewind convertor */                                      \
            size_t offset = 0;                                          \
            opal_convertor_set_position(&recvreq->req_base.req_convertor, &offset); \
        }                                                               \
        recvreq->req_base.req_pml_complete = true;                      \
        ompi_request_complete(  &(recvreq->req_base.req_ompi), true );  \
    }                                                                   \
 } while(0)


/**
 *  Free the PML receive request
 */
#define MCA_PML_CM_HVY_RECV_REQUEST_RETURN(recvreq)                     \
{                                                                       \
    OBJ_RELEASE((recvreq)->req_base.req_comm);                          \
    OMPI_DATATYPE_RELEASE((recvreq)->req_base.req_datatype);            \
    OMPI_REQUEST_FINI(&(recvreq)->req_base.req_ompi);                   \
    opal_convertor_cleanup( &((recvreq)->req_base.req_convertor) );     \
    opal_free_list_return ( &mca_pml_base_recv_requests,                \
                           (opal_free_list_item_t*)(recvreq));          \
}

/**
 *  Free the PML receive request
 */
#define MCA_PML_CM_THIN_RECV_REQUEST_RETURN(recvreq)                    \
{                                                                       \
    OBJ_RELEASE((recvreq)->req_base.req_comm);                          \
    OMPI_DATATYPE_RELEASE((recvreq)->req_base.req_datatype);            \
    OMPI_REQUEST_FINI(&(recvreq)->req_base.req_ompi);                   \
    opal_convertor_cleanup( &((recvreq)->req_base.req_convertor) );     \
    opal_free_list_return ( &mca_pml_base_recv_requests,                \
                           (opal_free_list_item_t*)(recvreq));          \
}

extern void mca_pml_cm_recv_request_completion(struct mca_mtl_request_t *mtl_request);

#endif