OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

btl_ugni_endpoint.h
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights
4 * reserved.
5 * Copyright (c) 2011 UT-Battelle, LLC. All rights reserved.
6 * $COPYRIGHT$
7 *
8 * Additional copyrights may follow
9 *
10 * $HEADER$
11 */
12
13 #ifndef MCA_BTL_UGNI_ENDPOINT_H
14 #define MCA_BTL_UGNI_ENDPOINT_H
15
16 #include "btl_ugni.h"
17
18 typedef struct mca_btl_ugni_smsg_mbox_t {
19 ompi_free_list_item_t super;
20 gni_smsg_attr_t smsg_attrib;
21 } mca_btl_ugni_smsg_mbox_t;
22
23 OBJ_CLASS_DECLARATION(mca_btl_ugni_smsg_mbox_t);
24
25 typedef struct mca_btl_base_endpoint_t {
26 opal_object_t super;
27
28 ompi_common_ugni_endpoint_t *common;
29
30 mca_btl_ugni_module_t *btl;
31
32 gni_smsg_attr_t remote_smsg_attrib;
33
34 mca_btl_ugni_smsg_mbox_t *mailbox;
35
36 opal_list_t pending_list;
37 opal_list_t pending_smsg_sends;
38 } mca_btl_base_endpoint_t;
39
40 OBJ_CLASS_DECLARATION(mca_btl_base_endpoint_t);
41
42 #define MCA_BTL_UGNI_EP_STATE(ep) ((ep)->common->state)
43
44
45 int mca_btl_ugni_ep_connect_progress (mca_btl_base_endpoint_t *ep);
46 int mca_btl_ugni_ep_disconnect (mca_btl_base_endpoint_t *ep, bool send_disconnect);
47
48 static inline int mca_btl_ugni_init_ep (mca_btl_base_endpoint_t **ep,
49 mca_btl_ugni_module_t *btl,
50 ompi_proc_t *peer_proc) {
51 mca_btl_base_endpoint_t *endpoint;
52 int rc;
53
54 endpoint = OBJ_NEW(mca_btl_base_endpoint_t);
55 assert (endpoint != NULL);
56
57 rc = ompi_common_ugni_endpoint_for_proc (btl->device, peer_proc, &endpoint->common);
58 if (OMPI_SUCCESS != rc) {
59 assert (0);
60 return rc;
61 }
62
63 endpoint->btl = btl;
64 endpoint->common->btl_ctx = (void *) endpoint;
65
66 *ep = endpoint;
67
68 return OMPI_SUCCESS;
69 }
70
71 static inline void mca_btl_ugni_release_ep (mca_btl_base_endpoint_t *ep) {
72 int rc;
73
74 rc = mca_btl_ugni_ep_disconnect (ep, false);
75 if (OMPI_SUCCESS == rc) {
76 BTL_VERBOSE(("btl/ugni error disconnecting endpoint"));
77 }
78
79 ompi_common_ugni_endpoint_return (ep->common);
80
81 OBJ_RELEASE(ep);
82 }
83
84 static inline int mca_btl_ugni_check_endpoint_state (mca_btl_base_endpoint_t *ep) {
85 int rc;
86
87 if (OPAL_LIKELY(OMPI_COMMON_UGNI_CONNECTED == ep->common->state)) {
88 return OMPI_SUCCESS;
89 }
90
91 OPAL_THREAD_LOCK(&ep->common->lock);
92
93 switch (ep->common->state) {
94 case OMPI_COMMON_UGNI_INIT:
95 rc = mca_btl_ugni_ep_connect_progress (ep);
96 if (OMPI_SUCCESS != rc) {
97 break;
98 }
99 case OMPI_COMMON_UGNI_CONNECTING:
100 rc = OMPI_ERR_RESOURCE_BUSY;
101 break;
102 default:
103 rc = OMPI_SUCCESS;
104 }
105
106 OPAL_THREAD_UNLOCK(&ep->common->lock);
107
108 return rc;
109 }
110
111 static inline int mca_btl_ugni_wildcard_ep_post (mca_btl_ugni_module_t *ugni_module) {
112 int rc;
113
114 memset (&ugni_module->wc_local_attr, 0, sizeof (ugni_module->wc_local_attr));
115 rc = GNI_EpPostDataWId (ugni_module->wildcard_ep, &ugni_module->wc_local_attr, sizeof (ugni_module->wc_local_attr),
116 &ugni_module->wc_remote_attr, sizeof (ugni_module->wc_remote_attr),
117 MCA_BTL_UGNI_CONNECT_WILDCARD_ID | ORTE_PROC_MY_NAME->vpid);
118
119 return ompi_common_rc_ugni_to_ompi (rc);
120 }
121
122 static inline int mca_btl_ugni_directed_ep_post (mca_btl_base_endpoint_t *ep) {
123 int rc;
124 rc = GNI_EpPostDataWId (ep->common->ep_handle, &ep->mailbox->smsg_attrib, sizeof (ep->mailbox->smsg_attrib),
125 &ep->remote_smsg_attrib, sizeof (ep->remote_smsg_attrib),
126 MCA_BTL_UGNI_CONNECT_DIRECTED_ID | ep->common->ep_rem_id);
127
128 return ompi_common_rc_ugni_to_ompi (rc);
129 }
130
131 #endif /* MCA_BTL_UGNI_ENDPOINT_H */
ompi_common_ugni_endpoint_t::btl_ctx
void * btl_ctx
btl context for this endpoint
Definition: common_ugni_ep.h:34
mca_btl_ugni_smsg_mbox_t
Definition: btl_ugni_endpoint.h:18
mca_btl_ugni_module_t
Definition: btl_ugni.h:51
ompi_proc_t
Remote Open MPI process structure.
Definition: proc.h:56
OPAL_THREAD_LOCK
#define OPAL_THREAD_LOCK(mutex)
Lock a mutex if opal_using_threads() says that multiple threads may be active in the process...
Definition: mutex.h:223
OBJ_RELEASE
#define OBJ_RELEASE(object)
Release an object (by decrementing its reference count).
Definition: opal_object.h:324
OPAL_THREAD_UNLOCK
#define OPAL_THREAD_UNLOCK(mutex)
Unlock a mutex if opal_using_threads() says that multiple threads may be active in the process...
Definition: mutex.h:309
ompi_common_ugni_endpoint_t::ep_rem_id
uint32_t ep_rem_id
remote information
Definition: common_ugni_ep.h:30
ompi_common_ugni_endpoint_t::ep_handle
gni_ep_handle_t ep_handle
uGNI handle for this endpoint
Definition: common_ugni_ep.h:28
mca_btl_base_endpoint_t
State of ELAN endpoint connection.
Definition: btl_elan_endpoint.h:33
ompi_free_list_item_t
Definition: ompi_free_list.h:62
opal_object_t
Base object.
Definition: opal_object.h:182
ORTE_PROC_MY_NAME
#define ORTE_PROC_MY_NAME
instantiated in orte/runtime/orte_init.c
Definition: orte_globals.h:72
opal_list_t
Definition: opal_list.h:147
ompi_common_ugni_endpoint_t
Definition: common_ugni_ep.h:26
OBJ_CLASS_DECLARATION
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236
ompi_common_ugni_endpoint_t::state
ompi_common_ugni_endpoint_state_t state
bind/connection state
Definition: common_ugni_ep.h:29