1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2018 Los Alamos National Security, LLC. All rights
4 * reserved.
5 * $COPYRIGHT$
6 *
7 * Additional copyrights may follow
8 *
9 * $HEADER$
10 */
11
12 #if !defined(MCA_BTL_UCT_FRAG_H)
13 #define MCA_BTL_UCT_FRAG_H
14
15 #include "btl_uct.h"
16
mca_btl_uct_frag_alloc(mca_btl_uct_module_t * uct_btl,opal_free_list_t * fl,mca_btl_base_endpoint_t * endpoint)17 static inline mca_btl_uct_base_frag_t *mca_btl_uct_frag_alloc (mca_btl_uct_module_t *uct_btl, opal_free_list_t *fl,
18 mca_btl_base_endpoint_t *endpoint)
19 {
20 mca_btl_uct_base_frag_t *frag = (mca_btl_uct_base_frag_t *) opal_free_list_get (fl);
21 if (OPAL_LIKELY(NULL != frag)) {
22 frag->free_list = fl;
23 frag->endpoint = endpoint;
24 frag->btl = uct_btl;
25 }
26
27 return frag;
28 }
29
mca_btl_uct_frag_return(mca_btl_uct_base_frag_t * frag)30 static inline void mca_btl_uct_frag_return (mca_btl_uct_base_frag_t *frag)
31 {
32 opal_free_list_return (frag->free_list, &frag->base.super);
33 }
34
mca_btl_uct_frag_complete(mca_btl_uct_base_frag_t * frag,int rc)35 static inline void mca_btl_uct_frag_complete (mca_btl_uct_base_frag_t *frag, int rc) {
36 mca_btl_uct_module_t *uct_btl = frag->btl;
37
38 /* call callback if specified */
39 if (frag->base.des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK) {
40 frag->base.des_cbfunc(&uct_btl->super, frag->endpoint, &frag->base, rc);
41 }
42
43 if (OPAL_LIKELY(frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP)) {
44 mca_btl_uct_frag_return (frag);
45 }
46 }
47
mca_btl_uct_frag_alloc_short(mca_btl_uct_module_t * uct_btl,mca_btl_base_endpoint_t * endpoint)48 static inline mca_btl_uct_base_frag_t *mca_btl_uct_frag_alloc_short (mca_btl_uct_module_t *uct_btl, mca_btl_base_endpoint_t *endpoint)
49 {
50 return mca_btl_uct_frag_alloc (uct_btl, &uct_btl->short_frags, endpoint);
51 }
52
mca_btl_uct_frag_alloc_eager(mca_btl_uct_module_t * uct_btl,mca_btl_base_endpoint_t * endpoint)53 static inline mca_btl_uct_base_frag_t *mca_btl_uct_frag_alloc_eager (mca_btl_uct_module_t *uct_btl, mca_btl_base_endpoint_t *endpoint)
54 {
55 return mca_btl_uct_frag_alloc (uct_btl, &uct_btl->eager_frags, endpoint);
56 }
57
mca_btl_uct_frag_alloc_max(mca_btl_uct_module_t * uct_btl,mca_btl_base_endpoint_t * endpoint)58 static inline mca_btl_uct_base_frag_t *mca_btl_uct_frag_alloc_max (mca_btl_uct_module_t *uct_btl, mca_btl_base_endpoint_t *endpoint)
59 {
60 return mca_btl_uct_frag_alloc (uct_btl, &uct_btl->max_frags, endpoint);
61 }
62
63 #endif /* !defined(MCA_BTL_UCT_FRAG_H) */
64