OpenMPI  0.1.1
osc_rdma_replyreq.h
1 /*
2  * Copyright (c) 2004-2005 The Trustees of Indiana University.
3  * All rights reserved.
4  * Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
5  * All rights reserved.
6  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
7  * University of Stuttgart. All rights reserved.
8  * Copyright (c) 2004-2005 The Regents of the University of California.
9  * All rights reserved.
10  * Copyright (c) 2007 Los Alamos National Security, LLC. All rights
11  * reserved.
12  * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
13  * $COPYRIGHT$
14  *
15  * Additional copyrights may follow
16  *
17  * $HEADER$
18  */
19 
20 #ifndef OMPI_OSC_RDMA_REPLYREQ_H
21 #define OMPI_OSC_RDMA_REPLYREQ_H
22 
23 #include "osc_rdma.h"
24 #include "osc_rdma_longreq.h"
25 
26 #include "opal/class/opal_list.h"
27 #include "ompi/datatype/ompi_datatype.h"
28 #include "opal/datatype/opal_convertor.h"
29 #include "ompi/communicator/communicator.h"
30 #include "ompi/proc/proc.h"
31 #include "ompi/memchecker.h"
32 
33 
35  opal_list_item_t super;
36 
37  /** pointer to the module that created the replyreq */
39 
40  /** Datatype for the target side of the operation */
42  /** Convertor for the target. Always setup for send. */
44  /** packed size of message on the target side */
46 
47  /** rank in module's communicator for origin of operation */
49  /** pointer to the proc structure for the origin of the operation */
51 
52  ompi_ptr_t rep_origin_sendreq;
53 };
56 
57 
58 /** allocate and populate a replyreq structure. datatype is
59  RETAINed for the life of the replyreq */
60 int
61 ompi_osc_rdma_replyreq_alloc_init(ompi_osc_rdma_module_t *module,
62  int origin,
63  ompi_ptr_t origin_request,
64  OPAL_PTRDIFF_TYPE target_displacement,
65  int target_count,
66  struct ompi_datatype_t *datatype,
67  ompi_osc_rdma_replyreq_t **replyreq);
68 
69 
70 static inline int
71 ompi_osc_rdma_replyreq_alloc(ompi_osc_rdma_module_t *module,
72  int origin_rank,
73  ompi_osc_rdma_replyreq_t **replyreq)
74 {
75  int ret;
77  ompi_proc_t *proc = ompi_comm_peer_lookup( module->m_comm, origin_rank );
78 
79  /* BWB - FIX ME - is this really the right return code? */
80  if (NULL == proc) return OMPI_ERR_OUT_OF_RESOURCE;
81 
82  OPAL_FREE_LIST_GET(&mca_osc_rdma_component.c_replyreqs,
83  item, ret);
84  if (OMPI_SUCCESS != ret) return ret;
85  *replyreq = (ompi_osc_rdma_replyreq_t*) item;
86 
87  (*replyreq)->rep_module = module;
88  (*replyreq)->rep_origin_rank = origin_rank;
89  (*replyreq)->rep_origin_proc = proc;
90 
91  return OMPI_SUCCESS;
92 }
93 
94 
95 static inline int
96 ompi_osc_rdma_replyreq_init_target(ompi_osc_rdma_replyreq_t *replyreq,
97  void *target_addr,
98  int target_count,
99  struct ompi_datatype_t *target_dt)
100 {
101  OBJ_RETAIN(target_dt);
102  replyreq->rep_target_datatype = target_dt;
103 
104  opal_convertor_copy_and_prepare_for_send(replyreq->rep_origin_proc->proc_convertor,
105  &(target_dt->super),
106  target_count,
107  target_addr,
108  0,
109  &(replyreq->rep_target_convertor));
110  opal_convertor_get_packed_size(&replyreq->rep_target_convertor,
111  &replyreq->rep_target_bytes_packed);
112 
113  return OMPI_SUCCESS;
114 }
115 
116 
117 static inline int
118 ompi_osc_rdma_replyreq_init_origin(ompi_osc_rdma_replyreq_t *replyreq,
119  ompi_ptr_t origin_request)
120 {
121  replyreq->rep_origin_sendreq = origin_request;
122 
123  return OMPI_SUCCESS;
124 }
125 
126 
127 static inline int
128 ompi_osc_rdma_replyreq_free(ompi_osc_rdma_replyreq_t *replyreq)
129 {
130  MEMCHECKER(
131  memchecker_convertor_call(&opal_memchecker_base_mem_defined,
132  &replyreq->rep_target_convertor);
133  );
134  opal_convertor_cleanup(&replyreq->rep_target_convertor);
135 
136  OBJ_RELEASE(replyreq->rep_target_datatype);
137 
138  OPAL_FREE_LIST_RETURN(&mca_osc_rdma_component.c_replyreqs,
139  (opal_list_item_t*) replyreq);
140 
141  return OMPI_SUCCESS;
142 }
143 
144 #endif /* OMPI_OSC_RDMA_REPLYREQ_H */
Definition: osc_rdma_replyreq.h:34
Definition: osc_rdma.h:111
Definition: ompi_datatype.h:68
Definition: types.h:52
The opal_list_t interface is used to provide a generic doubly-linked list container for Open MPI...
Process identification structure interface.
Remote Open MPI process structure.
Definition: proc.h:56
#define OBJ_RETAIN(object)
Retain an object (by incrementing its reference count)
Definition: opal_object.h:278
opal_convertor_t rep_target_convertor
Convertor for the target.
Definition: osc_rdma_replyreq.h:43
ompi_osc_rdma_module_t * rep_module
pointer to the module that created the replyreq
Definition: osc_rdma_replyreq.h:38
Definition: opal_list.h:98
#define OBJ_RELEASE(object)
Release an object (by decrementing its reference count).
Definition: opal_object.h:324
opal_free_list_t c_replyreqs
free list of ompi_osc_rdma_replyreq_t structures
Definition: osc_rdma.h:66
Definition: opal_free_list.h:47
opal_datatype_t super
Base opal_datatype_t superclass.
Definition: ompi_datatype.h:69
ompi_proc_t * rep_origin_proc
pointer to the proc structure for the origin of the operation
Definition: osc_rdma_replyreq.h:50
Definition: opal_convertor.h:90
struct opal_convertor_t * proc_convertor
Base convertor for the proc described by this process.
Definition: proc.h:70
struct ompi_datatype_t * rep_target_datatype
Datatype for the target side of the operation.
Definition: osc_rdma_replyreq.h:41
int rep_origin_rank
rank in module's communicator for origin of operation
Definition: osc_rdma_replyreq.h:48
ompi_communicator_t * m_comm
communicator created with this window
Definition: osc_rdma.h:130
size_t rep_target_bytes_packed
packed size of message on the target side
Definition: osc_rdma_replyreq.h:45
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236