OpenMPI  0.1.1
btl_ugni_smsg.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 #if !defined(MCA_BTL_UGNI_SMSG_H)
14 #define MCA_BTL_UGNI_SMSG_H
15 
16 #include "btl_ugni.h"
17 #include "btl_ugni_endpoint.h"
18 
19 typedef enum {
20  MCA_BTL_UGNI_TAG_SEND,
21  MCA_BTL_UGNI_TAG_DISCONNECT,
22  MCA_BTL_UGNI_TAG_PUT_INIT,
23  MCA_BTL_UGNI_TAG_GET_INIT,
24  MCA_BTL_UGNI_TAG_RDMA_COMPLETE
25 } mca_btl_ugni_smsg_tag_t;
26 
27 static inline int ompi_mca_btl_ugni_smsg_send (mca_btl_ugni_base_frag_t *frag,
28  const bool ignore_local_comp,
29  void *hdr, size_t hdr_len,
30  void *payload, size_t payload_len,
31  mca_btl_ugni_smsg_tag_t tag) {
32  gni_return_t grc;
33  int rc;
34 
35  if (!ignore_local_comp) {
36  rc = opal_hash_table_set_value_uint32 (&frag->endpoint->btl->pending_smsg_frags,
37  frag->msg_id, (void *) frag);
38  if (OPAL_UNLIKELY(OPAL_SUCCESS != rc)) {
39  return rc;
40  }
41  }
42 
43  grc = GNI_SmsgSendWTag (frag->endpoint->common->ep_handle, hdr, hdr_len, payload, payload_len,
44  ignore_local_comp ? (uint32_t)-1 : frag->msg_id, tag);
45  if (OPAL_UNLIKELY(GNI_RC_SUCCESS != grc)) {
46  BTL_VERBOSE(("GNI_SmsgSendWTag failed with rc = %d", rc));
47 
48  opal_hash_table_remove_value_uint32 (&frag->endpoint->btl->pending_smsg_frags,
49  frag->msg_id);
50 
51  if (OPAL_LIKELY(GNI_RC_NOT_DONE == grc)) {
52  BTL_VERBOSE(("out of credits"));
53 
54  return OMPI_ERR_OUT_OF_RESOURCE;
55  }
56 
57  return OMPI_ERROR;
58  }
59 
60  return OMPI_SUCCESS;
61 }
62 
63 #endif /* MCA_BTL_UGNI_SMSG_H */
OPAL_DECLSPEC int opal_hash_table_set_value_uint32(opal_hash_table_t *table, uint32_t key, void *value)
Set value based on uint32_t key.
Definition: opal_hash_table.c:153
Definition: btl_ugni_frag.h:43
gni_ep_handle_t ep_handle
uGNI handle for this endpoint
Definition: common_ugni_ep.h:28
OPAL_DECLSPEC int opal_hash_table_remove_value_uint32(opal_hash_table_t *table, uint32_t key)
Remove value based on uint32_t key.
Definition: opal_hash_table.c:189