Skip to content

Commit d0c0cb7

Browse files
authored
Merge pull request #7913 from hjelmn/btl_base_atomics_are_awesome
btl: change argument type of BTL receive callbacks
2 parents 677b662 + 88f51fb commit d0c0cb7

22 files changed

+262
-259
lines changed

ompi/mca/pml/ob1/pml_ob1.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ void mca_pml_ob1_process_pending_rdma(void);
311311
* Compute the total number of bytes on supplied descriptor
312312
*/
313313
static inline size_t
314-
mca_pml_ob1_compute_segment_length_base(mca_btl_base_segment_t *segments,
315-
size_t count, size_t hdrlen)
314+
mca_pml_ob1_compute_segment_length_base (const mca_btl_base_segment_t *segments,
315+
size_t count, size_t hdrlen)
316316
{
317317
size_t i, length = 0;
318318

@@ -323,7 +323,7 @@ mca_pml_ob1_compute_segment_length_base(mca_btl_base_segment_t *segments,
323323
}
324324

325325
static inline size_t
326-
mca_pml_ob1_compute_segment_length_remote (size_t seg_size, void *segments,
326+
mca_pml_ob1_compute_segment_length_remote (size_t seg_size, const void *segments,
327327
size_t count, ompi_proc_t *rem_proc)
328328
{
329329
mca_btl_base_segment_t *segment = (mca_btl_base_segment_t *) segments;

ompi/mca/pml/ob1/pml_ob1_recvfrag.c

Lines changed: 93 additions & 119 deletions
Large diffs are not rendered by default.

ompi/mca/pml/ob1/pml_ob1_recvfrag.h

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
1515
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2020 Google, LLC. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -113,60 +114,49 @@ do { \
113114
* Callback from BTL on receipt of a recv_frag (match).
114115
*/
115116

116-
extern void mca_pml_ob1_recv_frag_callback_match( mca_btl_base_module_t *btl,
117-
mca_btl_base_tag_t tag,
118-
mca_btl_base_descriptor_t* descriptor,
119-
void* cbdata );
117+
extern void mca_pml_ob1_recv_frag_callback_match (mca_btl_base_module_t *btl,
118+
const mca_btl_base_receive_descriptor_t *descriptor);
120119

121120
/**
122121
* Callback from BTL on receipt of a recv_frag (rndv).
123122
*/
124123

125-
extern void mca_pml_ob1_recv_frag_callback_rndv( mca_btl_base_module_t *btl,
126-
mca_btl_base_tag_t tag,
127-
mca_btl_base_descriptor_t* descriptor,
128-
void* cbdata );
124+
extern void mca_pml_ob1_recv_frag_callback_rndv (mca_btl_base_module_t *btl,
125+
const mca_btl_base_receive_descriptor_t *descriptor);
129126
/**
130127
* Callback from BTL on receipt of a recv_frag (rget).
131128
*/
132129

133-
extern void mca_pml_ob1_recv_frag_callback_rget( mca_btl_base_module_t *btl,
134-
mca_btl_base_tag_t tag,
135-
mca_btl_base_descriptor_t* descriptor,
136-
void* cbdata );
130+
extern void mca_pml_ob1_recv_frag_callback_rget (mca_btl_base_module_t *btl,
131+
const mca_btl_base_receive_descriptor_t *descriptor);
137132

138133
/**
139134
* Callback from BTL on receipt of a recv_frag (ack).
140135
*/
141136

142-
extern void mca_pml_ob1_recv_frag_callback_ack( mca_btl_base_module_t *btl,
143-
mca_btl_base_tag_t tag,
144-
mca_btl_base_descriptor_t* descriptor,
145-
void* cbdata );
137+
extern void mca_pml_ob1_recv_frag_callback_ack (mca_btl_base_module_t *btl,
138+
const mca_btl_base_receive_descriptor_t *descriptor);
139+
146140
/**
147141
* Callback from BTL on receipt of a recv_frag (frag).
148142
*/
149143

150-
extern void mca_pml_ob1_recv_frag_callback_frag( mca_btl_base_module_t *btl,
151-
mca_btl_base_tag_t tag,
152-
mca_btl_base_descriptor_t* descriptor,
153-
void* cbdata );
144+
extern void mca_pml_ob1_recv_frag_callback_frag (mca_btl_base_module_t *btl,
145+
const mca_btl_base_receive_descriptor_t *descriptor);
146+
154147
/**
155148
* Callback from BTL on receipt of a recv_frag (put).
156149
*/
157150

158-
extern void mca_pml_ob1_recv_frag_callback_put( mca_btl_base_module_t *btl,
159-
mca_btl_base_tag_t tag,
160-
mca_btl_base_descriptor_t* descriptor,
161-
void* cbdata );
151+
extern void mca_pml_ob1_recv_frag_callback_put (mca_btl_base_module_t *btl,
152+
const mca_btl_base_receive_descriptor_t *descriptor);
153+
162154
/**
163155
* Callback from BTL on receipt of a recv_frag (fin).
164156
*/
165157

166-
extern void mca_pml_ob1_recv_frag_callback_fin( mca_btl_base_module_t *btl,
167-
mca_btl_base_tag_t tag,
168-
mca_btl_base_descriptor_t* descriptor,
169-
void* cbdata );
158+
extern void mca_pml_ob1_recv_frag_callback_fin (mca_btl_base_module_t *btl,
159+
const mca_btl_base_receive_descriptor_t *descriptor);
170160

171161
/**
172162
* Extract the next fragment from the cant_match ordered list. This fragment

ompi/mca/pml/ob1/pml_ob1_recvreq.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* and Technology (RIST). All rights reserved.
2121
* Copyright (c) 2018 Sandia National Laboratories
2222
* All rights reserved.
23+
* Copyright (c) 2020 Google, LLC. All rights reserved.
2324
* $COPYRIGHT$
2425
*
2526
* Additional copyrights may follow
@@ -517,7 +518,7 @@ int mca_pml_ob1_recv_request_get_frag (mca_pml_ob1_rdma_frag_t *frag)
517518

518519
void mca_pml_ob1_recv_request_progress_frag( mca_pml_ob1_recv_request_t* recvreq,
519520
mca_btl_base_module_t* btl,
520-
mca_btl_base_segment_t* segments,
521+
const mca_btl_base_segment_t* segments,
521522
size_t num_segments )
522523
{
523524
size_t bytes_received, data_offset = 0;
@@ -652,7 +653,7 @@ void mca_pml_ob1_recv_request_frag_copy_finished( mca_btl_base_module_t* btl,
652653

653654
void mca_pml_ob1_recv_request_progress_rget( mca_pml_ob1_recv_request_t* recvreq,
654655
mca_btl_base_module_t* btl,
655-
mca_btl_base_segment_t* segments,
656+
const mca_btl_base_segment_t* segments,
656657
size_t num_segments )
657658
{
658659
mca_pml_ob1_rget_hdr_t* hdr = (mca_pml_ob1_rget_hdr_t*)segments->seg_addr.pval;
@@ -806,7 +807,7 @@ void mca_pml_ob1_recv_request_progress_rget( mca_pml_ob1_recv_request_t* recvreq
806807

807808
void mca_pml_ob1_recv_request_progress_rndv( mca_pml_ob1_recv_request_t* recvreq,
808809
mca_btl_base_module_t* btl,
809-
mca_btl_base_segment_t* segments,
810+
const mca_btl_base_segment_t* segments,
810811
size_t num_segments )
811812
{
812813
size_t bytes_received = 0;
@@ -876,7 +877,7 @@ void mca_pml_ob1_recv_request_progress_rndv( mca_pml_ob1_recv_request_t* recvreq
876877
*/
877878
void mca_pml_ob1_recv_request_progress_match( mca_pml_ob1_recv_request_t* recvreq,
878879
mca_btl_base_module_t* btl,
879-
mca_btl_base_segment_t* segments,
880+
const mca_btl_base_segment_t* segments,
880881
size_t num_segments )
881882
{
882883
size_t bytes_received, data_offset = 0;
@@ -932,7 +933,7 @@ void mca_pml_ob1_recv_request_progress_match( mca_pml_ob1_recv_request_t* recvre
932933

933934
void mca_pml_ob1_recv_request_matched_probe( mca_pml_ob1_recv_request_t* recvreq,
934935
mca_btl_base_module_t* btl,
935-
mca_btl_base_segment_t* segments,
936+
const mca_btl_base_segment_t* segments,
936937
size_t num_segments )
937938
{
938939
size_t bytes_packed = 0;

ompi/mca/pml/ob1/pml_ob1_recvreq.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* reserved.
1616
* Copyright (c) 2014 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2020 Google, LLC. All rights reserved.
1819
*
1920
* $COPYRIGHT$
2021
*
@@ -239,7 +240,7 @@ static inline void prepare_recv_req_converter(mca_pml_ob1_recv_request_t *req)
239240
recv_req_matched(request, hdr)
240241

241242
static inline void recv_req_matched(mca_pml_ob1_recv_request_t *req,
242-
mca_pml_ob1_match_hdr_t *hdr)
243+
const mca_pml_ob1_match_hdr_t *hdr)
243244
{
244245
req->req_recv.req_base.req_ompi.req_status.MPI_SOURCE = hdr->hdr_src;
245246
req->req_recv.req_base.req_ompi.req_status.MPI_TAG = hdr->hdr_tag;
@@ -278,7 +279,7 @@ do {
278279
uint32_t iov_count = 0; \
279280
size_t max_data = bytes_received; \
280281
size_t n, offset = seg_offset; \
281-
mca_btl_base_segment_t* segment = segments; \
282+
const mca_btl_base_segment_t *segment = segments; \
282283
\
283284
for( n = 0; n < num_segments; n++, segment++ ) { \
284285
if(offset >= segment->seg_len) { \
@@ -314,7 +315,7 @@ do {
314315
void mca_pml_ob1_recv_request_progress_match(
315316
mca_pml_ob1_recv_request_t* req,
316317
struct mca_btl_base_module_t* btl,
317-
mca_btl_base_segment_t* segments,
318+
const mca_btl_base_segment_t* segments,
318319
size_t num_segments);
319320

320321
/**
@@ -324,7 +325,7 @@ void mca_pml_ob1_recv_request_progress_match(
324325
void mca_pml_ob1_recv_request_progress_frag(
325326
mca_pml_ob1_recv_request_t* req,
326327
struct mca_btl_base_module_t* btl,
327-
mca_btl_base_segment_t* segments,
328+
const mca_btl_base_segment_t* segments,
328329
size_t num_segments);
329330

330331
#if OPAL_CUDA_SUPPORT
@@ -347,7 +348,7 @@ void mca_pml_ob1_recv_request_frag_copy_finished(struct mca_btl_base_module_t* b
347348
void mca_pml_ob1_recv_request_progress_rndv(
348349
mca_pml_ob1_recv_request_t* req,
349350
struct mca_btl_base_module_t* btl,
350-
mca_btl_base_segment_t* segments,
351+
const mca_btl_base_segment_t* segments,
351352
size_t num_segments);
352353

353354
/**
@@ -357,7 +358,7 @@ void mca_pml_ob1_recv_request_progress_rndv(
357358
void mca_pml_ob1_recv_request_progress_rget(
358359
mca_pml_ob1_recv_request_t* req,
359360
struct mca_btl_base_module_t* btl,
360-
mca_btl_base_segment_t* segments,
361+
const mca_btl_base_segment_t* segments,
361362
size_t num_segments);
362363

363364
/**
@@ -367,7 +368,7 @@ void mca_pml_ob1_recv_request_progress_rget(
367368
void mca_pml_ob1_recv_request_matched_probe(
368369
mca_pml_ob1_recv_request_t* req,
369370
struct mca_btl_base_module_t* btl,
370-
mca_btl_base_segment_t* segments,
371+
const mca_btl_base_segment_t* segments,
371372
size_t num_segments);
372373

373374
/**

ompi/mca/pml/ob1/pml_ob1_sendreq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,9 +1216,9 @@ int mca_pml_ob1_send_request_put_frag( mca_pml_ob1_rdma_frag_t *frag )
12161216
* (3) Queue the RDMA put
12171217
*/
12181218

1219-
void mca_pml_ob1_send_request_put( mca_pml_ob1_send_request_t* sendreq,
1220-
mca_btl_base_module_t* btl,
1221-
mca_pml_ob1_rdma_hdr_t* hdr )
1219+
void mca_pml_ob1_send_request_put (mca_pml_ob1_send_request_t *sendreq,
1220+
mca_btl_base_module_t *btl,
1221+
const mca_pml_ob1_rdma_hdr_t *hdr)
12221222
{
12231223
mca_bml_base_endpoint_t *bml_endpoint = sendreq->req_endpoint;
12241224
mca_pml_ob1_rdma_frag_t* frag;

ompi/mca/pml/ob1/pml_ob1_sendreq.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ mca_pml_ob1_send_request_start( mca_pml_ob1_send_request_t* sendreq )
512512
* Initiate a put scheduled by the receiver.
513513
*/
514514

515-
void mca_pml_ob1_send_request_put( mca_pml_ob1_send_request_t* sendreq,
516-
mca_btl_base_module_t* btl,
517-
mca_pml_ob1_rdma_hdr_t* hdr );
515+
void mca_pml_ob1_send_request_put (mca_pml_ob1_send_request_t *sendreq,
516+
mca_btl_base_module_t *btl,
517+
const mca_pml_ob1_rdma_hdr_t *hdr);
518518

519519
int mca_pml_ob1_send_request_put_frag(mca_pml_ob1_rdma_frag_t* frag);
520520

opal/mca/btl/btl.h

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,12 @@ typedef struct mca_btl_base_segment_t mca_btl_base_segment_t;
450450
#define MCA_BTL_BASE_SEGMENT_NTOH(s)
451451
#endif
452452
/**
453-
* A descriptor that holds the parameters to a send/put/get
453+
* @brief Descriptor to hold outgoing send messages
454+
*
455+
* This descriptor holds the parameters to perform a send
454456
* operation along w/ a callback routine that is called on
455457
* completion of the request.
456-
* Note: receive callbacks will store the incomming data segments in
457-
* des_segments
458458
*/
459-
460459
struct mca_btl_base_descriptor_t {
461460
opal_free_list_item_t super;
462461
mca_btl_base_segment_t *des_segments; /**< local segments */
@@ -519,6 +518,28 @@ OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_btl_base_descriptor_t);
519518
*/
520519
#define MCA_BTL_REG_HANDLE_MAX_SIZE 256
521520

521+
/**
522+
* @brief Descriptor for incoming messages
523+
*
524+
* This descriptor holds the information on incoming messages. The
525+
* data this descriptor describes is only valid during a callback.
526+
*/
527+
struct mca_btl_base_receive_descriptor_t {
528+
/** Incoming endpoint. May be NULL if the endpoint is not readily
529+
* available for this BTL. */
530+
struct mca_btl_base_endpoint_t *endpoint;
531+
/** Local segment data. Copy this data if it is needed after the
532+
* receive callback returns. **/
533+
const mca_btl_base_segment_t *des_segments;
534+
/** Number of segment is des_segments */
535+
size_t des_segment_count;
536+
mca_btl_base_tag_t tag;
537+
/** Callback data supplied at callback registration time. */
538+
void *cbdata;
539+
};
540+
typedef struct mca_btl_base_receive_descriptor_t mca_btl_base_receive_descriptor_t;
541+
542+
522543
/*
523544
* BTL base header, stores the tag at a minimum
524545
*/
@@ -581,25 +602,20 @@ typedef int (*mca_btl_base_component_progress_fn_t)(void);
581602
/**
582603
* Callback function that is called asynchronously on receipt
583604
* of data by the transport layer.
584-
* Note that the the mca_btl_base_descriptor_t is only valid within the
605+
* Note that the the mca_btl_base_receive_descriptor_t is only valid within the
585606
* completion function, this implies that all data payload in the
586607
* mca_btl_base_descriptor_t must be copied out within this callback or
587608
* forfeited back to the BTL.
588609
* Note also that descriptor segments (des_segments) must be base
589610
* segments for all callbacks.
590611
*
591612
* @param[IN] btl BTL module
592-
* @param[IN] tag The active message receive callback tag value
593613
* @param[IN] descriptor The BTL descriptor (contains the receive payload)
594-
* @param[IN] cbdata Opaque callback data
595614
*/
596615

597616
typedef void (*mca_btl_base_module_recv_cb_fn_t)(
598-
struct mca_btl_base_module_t* btl,
599-
mca_btl_base_tag_t tag,
600-
mca_btl_base_descriptor_t* descriptor,
601-
void* cbdata
602-
);
617+
struct mca_btl_base_module_t *btl,
618+
const mca_btl_base_receive_descriptor_t *descriptor);
603619

604620
typedef struct mca_btl_active_message_callback_t {
605621
mca_btl_base_module_recv_cb_fn_t cbfunc;
@@ -1262,22 +1278,29 @@ struct mca_btl_base_module_t {
12621278
};
12631279
typedef struct mca_btl_base_module_t mca_btl_base_module_t;
12641280

1281+
#define MCA_BTL_BASE_MAJOR_VERSION 3
1282+
#define MCA_BTL_BASE_MINOR_VERSION 2
1283+
#define MCA_BTL_BASE_PATCH_VERSION 0
1284+
12651285
/*
1266-
* Macro for use in modules that are of type btl v3.1.0
1286+
* Macro for use in modules that are of type btl v3.2.0
12671287
*/
1268-
#define MCA_BTL_BASE_VERSION_3_1_0 \
1269-
OPAL_MCA_BASE_VERSION_2_1_0("btl", 3, 1, 0)
1288+
#define MCA_BTL_BASE_VERSION_3_2_0 \
1289+
OPAL_MCA_BASE_VERSION_2_1_0("btl", \
1290+
MCA_BTL_BASE_MAJOR_VERSION, \
1291+
MCA_BTL_BASE_MINOR_VERSION, \
1292+
MCA_BTL_BASE_PATCH_VERSION)
12701293

12711294
#define MCA_BTL_DEFAULT_VERSION(name) \
1272-
MCA_BTL_BASE_VERSION_3_1_0, \
1295+
MCA_BTL_BASE_VERSION_3_2_0, \
12731296
.mca_component_name = name, \
12741297
MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, \
12751298
OPAL_RELEASE_VERSION)
12761299

12771300
/**
12781301
* Convinience macro for detecting the BTL interface version.
12791302
*/
1280-
#define BTL_VERSION 310
1303+
#define BTL_VERSION 320
12811304

12821305
END_C_DECLS
12831306

0 commit comments

Comments
 (0)