|
3 | 3 | * Copyright (c) 2011-2018 Los Alamos National Security, LLC. All rights
|
4 | 4 | * reserved.
|
5 | 5 | * Copyright (c) 2020 Google, LLC. All rights reserved.
|
| 6 | + * Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights |
| 7 | + * reserved. |
6 | 8 | * $COPYRIGHT$
|
7 | 9 | *
|
8 | 10 | * Additional copyrights may follow
|
|
13 | 15 | /**
|
14 | 16 | * This file provides support for active-message (send/recv) based RDMA.
|
15 | 17 | * It can be used with any btl that provides a minimum of send support but
|
16 |
| - * can also be used with partial-RDMA BTLs (put only, get only, etc). It |
17 |
| - * will provide support for any RDMA or atomic operation not currently |
18 |
| - * supported by the supplied BTL. For more info see the description of |
19 |
| - * mca_btl_base_am_rdma_init. |
| 18 | + * can also be used with partial-RDMA BTLs (put only, get only, etc) |
| 19 | + * to provide a complete RDMA interface. |
| 20 | + * |
| 21 | + * There are two modes of using this interface, depending on your |
| 22 | + * requirements: |
| 23 | + * |
| 24 | + * First, this interface can be used to provide a complete |
| 25 | + * put/get/atomic interface for BTLs which do not natively provide |
| 26 | + * such an interface. In this mode, active message rdma functions are |
| 27 | + * only used if the underlying implementation does not already provide |
| 28 | + * the required functionality. For example, if a BTL natively |
| 29 | + * supports put but not get, the interface would provide an emulated |
| 30 | + * get. The registration, completion and atomicity semantics of the |
| 31 | + * BTL remain the native interface's capabilities. That is, if the |
| 32 | + * native interface does not provide remote completion or atomics that |
| 33 | + * are atomic with processor atomics, neither will the interface after |
| 34 | + * initializing the am rdma interface for that BTL. This mode will |
| 35 | + * likely give better performance than the second mode for transfers |
| 36 | + * that fit within the BTL's native semantics. In this mode, the BTL |
| 37 | + * interface is updated so that the btl_{put, get, atomic_fop, |
| 38 | + * atomic_cswap} function pointers are usage. However, the btl |
| 39 | + * capability flags will not be updated to indicate native support of |
| 40 | + * the emulated functionality (for example, if btl_get() is emulated, |
| 41 | + * MCA_BTL_FLAGS_GET will not be set). Instead, the emulated flags |
| 42 | + * will be set (MCA_BTL_FLAGS_PUT_AM, MCA_BTL_FLAGS_GET_AM, |
| 43 | + * MCA_BTL_FLAGS_ATOMIC_AM_FOP, etc.). |
| 44 | + * |
| 45 | + * Second, this interface can be used to provide different |
| 46 | + * sementicsthan a BTL natively provides. This mode is not |
| 47 | + * transparent to the caller (unlike the first mode). Instead, the |
| 48 | + * caller must manage calling the active message put/get/atomic |
| 49 | + * interface directly (rather than through the BTL function pointers). |
| 50 | + * For interfaces which require strict remote completion or require |
| 51 | + * implicit memory registration, this can greatly simplify the code, |
| 52 | + * in return for marginally more management complexity and lower |
| 53 | + * performance. |
| 54 | + * |
| 55 | + * While the calling convention and initialization are different, the |
| 56 | + * communication routines uses by the active message rdma |
| 57 | + * implementation are identical in both modes of operation. |
20 | 58 | */
|
21 | 59 |
|
22 | 60 | #include "opal_config.h"
|
|
28 | 66 | /**
|
29 | 67 | * @brief initialize active-message RDMA/atomic support
|
30 | 68 | *
|
31 |
| - * @inout btl btl module to augment |
| 69 | + * @param btl[in,out] btl module to augment |
| 70 | + * |
| 71 | + * @retval OPAL_SUCCESS btl successfully updated, btl already |
| 72 | + * updated, or btl has all available |
| 73 | + * functionality natively. |
| 74 | + * @retval OPAL_ERR_TEMP_OUT_OF_RESOURCE Allocating BTL-level data |
| 75 | + * structure failed. |
32 | 76 | *
|
33 | 77 | * This function adds functionality to the btl for any missing RDMA/atomic
|
34 | 78 | * operation. Atomic operations are entirely emulated using send/recv and
|
35 | 79 | * work best with a btl that also has async-progress enabled. Put/get
|
36 | 80 | * support will use either send/recv or get (for put)/put (for get) (if
|
37 | 81 | * available).
|
| 82 | + * |
| 83 | + * Note that calling this function will change the BTL interface. |
| 84 | + * Care must be taken to not call this function outside of early |
| 85 | + * initialization routines. |
38 | 86 | */
|
39 | 87 | int mca_btl_base_am_rdma_init(mca_btl_base_module_t *btl);
|
40 | 88 |
|
| 89 | +struct mca_btl_base_am_rdma_module_t; |
| 90 | + |
| 91 | +typedef int (*mca_btl_base_am_rdma_module_put_fn_t)( |
| 92 | + struct mca_btl_base_am_rdma_module_t *am_btl, struct mca_btl_base_endpoint_t *endpoint, |
| 93 | + void *local_address, uint64_t remote_address, |
| 94 | + struct mca_btl_base_registration_handle_t *local_handle, |
| 95 | + struct mca_btl_base_registration_handle_t *remote_handle, size_t size, int flags, int order, |
| 96 | + mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata); |
| 97 | + |
| 98 | +typedef int (*mca_btl_base_am_rdma_module_get_fn_t)( |
| 99 | + struct mca_btl_base_am_rdma_module_t *am_btl, struct mca_btl_base_endpoint_t *endpoint, |
| 100 | + void *local_address, uint64_t remote_address, |
| 101 | + struct mca_btl_base_registration_handle_t *local_handle, |
| 102 | + struct mca_btl_base_registration_handle_t *remote_handle, size_t size, int flags, int order, |
| 103 | + mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata); |
| 104 | + |
| 105 | +typedef int (*mca_btl_base_am_rdma_module_atomic_fop64_fn_t)( |
| 106 | + struct mca_btl_base_am_rdma_module_t *am_btl, struct mca_btl_base_endpoint_t *endpoint, |
| 107 | + void *local_address, uint64_t remote_address, |
| 108 | + struct mca_btl_base_registration_handle_t *local_handle, |
| 109 | + struct mca_btl_base_registration_handle_t *remote_handle, mca_btl_base_atomic_op_t op, |
| 110 | + uint64_t operand, int flags, int order, mca_btl_base_rdma_completion_fn_t cbfunc, |
| 111 | + void *cbcontext, void *cbdata); |
| 112 | + |
| 113 | +typedef int (*mca_btl_base_am_rdma_module_atomic_cswap64_fn_t)( |
| 114 | + struct mca_btl_base_am_rdma_module_t *am_btl, struct mca_btl_base_endpoint_t *endpoint, |
| 115 | + void *local_address, uint64_t remote_address, |
| 116 | + struct mca_btl_base_registration_handle_t *local_handle, |
| 117 | + struct mca_btl_base_registration_handle_t *remote_handle, uint64_t compare, uint64_t value, |
| 118 | + int flags, int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata); |
| 119 | + |
| 120 | +struct mca_btl_base_am_rdma_module_t { |
| 121 | + opal_object_t super; |
| 122 | + mca_btl_base_module_t *btl; |
| 123 | + bool use_rdma_put; |
| 124 | + bool use_rdma_get; |
| 125 | + |
| 126 | + size_t am_btl_put_limit; |
| 127 | + size_t am_btl_put_alignment; |
| 128 | + size_t am_btl_get_limit; |
| 129 | + size_t am_btl_get_alignment; |
| 130 | + |
| 131 | + mca_btl_base_am_rdma_module_put_fn_t am_btl_put; |
| 132 | + mca_btl_base_am_rdma_module_get_fn_t am_btl_get; |
| 133 | + mca_btl_base_am_rdma_module_atomic_fop64_fn_t am_btl_atomic_fop; |
| 134 | + mca_btl_base_am_rdma_module_atomic_cswap64_fn_t am_btl_atomic_cswap; |
| 135 | +}; |
| 136 | +typedef struct mca_btl_base_am_rdma_module_t mca_btl_base_am_rdma_module_t; |
| 137 | + |
| 138 | +OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_btl_base_am_rdma_module_t); |
| 139 | + |
| 140 | + |
| 141 | +/** |
| 142 | + * @brief create active-message RDMA/atomics functions |
| 143 | + */ |
| 144 | +int opal_btl_base_am_rdma_create(mca_btl_base_module_t *btl, |
| 145 | + uint32_t flags_requested, |
| 146 | + bool no_memory_registration, |
| 147 | + mca_btl_base_am_rdma_module_t **am_module); |
| 148 | + |
| 149 | +int opal_btl_base_am_rdma_destroy(mca_btl_base_am_rdma_module_t *am_module); |
| 150 | + |
41 | 151 | #endif /* OPAL_MCA_BTL_BASE_AM_RDMA_H */
|
0 commit comments