OpenMPI  0.1.1
osc_pt2pt_sendreq.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) 2010 Cisco Systems, Inc. All rights reserved.
11  * $COPYRIGHT$
12  *
13  * Additional copyrights may follow
14  *
15  * $HEADER$
16  */
17 
18 #ifndef OMPI_OSC_PT2PT_SENDREQ_H
19 #define OMPI_OSC_PT2PT_SENDREQ_H
20 
21 #include "osc_pt2pt.h"
22 #include "osc_pt2pt_longreq.h"
23 
24 #include "opal/class/opal_list.h"
25 #include "ompi/datatype/ompi_datatype.h"
26 #include "opal/datatype/opal_convertor.h"
27 #include "ompi/communicator/communicator.h"
28 #include "ompi/proc/proc.h"
29 #include "ompi/memchecker.h"
30 
31 typedef enum {
32  OMPI_OSC_PT2PT_GET,
33  OMPI_OSC_PT2PT_ACC,
34  OMPI_OSC_PT2PT_PUT
35 } ompi_osc_pt2pt_req_type_t;
36 
37 
39  ompi_request_t super;
40 
41  /** type of sendreq (from ompi_osc_pt2pt_req_type_t) */
42  ompi_osc_pt2pt_req_type_t req_type;
43  /** pointer to the module that created the sendreq */
45 
46  /** Datatype for the origin side of the operation */
48  /** Convertor for the origin side of the operation. Setup for
49  either send (Put / Accumulate) or receive (Get) */
51  /** packed size of message on the origin side */
53 
54  /** rank in module's communicator for target of operation */
56  /** pointer to the proc structure for the target of the operation */
58 
59  /** displacement on target */
60  OPAL_PTRDIFF_TYPE req_target_disp;
61  /** datatype count on target */
63  /** datatype on target */
65 
66  /** op index on the target */
67  int req_op_id;
68 };
71 
72 
73 /** allocate and populate a sendreq structure. Both datatypes are
74  RETAINed for the life of the sendreq */
75 int
76 ompi_osc_pt2pt_sendreq_alloc_init(ompi_osc_pt2pt_req_type_t req_type,
77  void *origin_addr, int origin_count,
78  struct ompi_datatype_t *origin_dt,
79  int target,
80  OPAL_PTRDIFF_TYPE target_disp,
81  int target_count,
82  struct ompi_datatype_t *target_datatype,
84  ompi_osc_pt2pt_sendreq_t **sendreq);
85 
86 static inline int
87 ompi_osc_pt2pt_sendreq_alloc(ompi_osc_pt2pt_module_t *module,
88  int target_rank,
89  ompi_osc_pt2pt_sendreq_t **sendreq)
90 {
91  int ret;
93  ompi_proc_t *proc = ompi_comm_peer_lookup( module->p2p_comm, target_rank );
94 
95  /* BWB - FIX ME - is this really the right return code? */
96  if (NULL == proc) return OMPI_ERR_OUT_OF_RESOURCE;
97 
98  OPAL_FREE_LIST_GET(&mca_osc_pt2pt_component.p2p_c_sendreqs,
99  item, ret);
100  if (OMPI_SUCCESS != ret) return ret;
101  *sendreq = (ompi_osc_pt2pt_sendreq_t*) item;
102 
103  (*sendreq)->req_module = module;
104  (*sendreq)->req_target_rank = target_rank;
105  (*sendreq)->req_target_proc = proc;
106 
107  return OMPI_SUCCESS;
108 }
109 
110 
111 static inline int
112 ompi_osc_pt2pt_sendreq_init_origin(ompi_osc_pt2pt_sendreq_t *sendreq,
113  ompi_osc_pt2pt_req_type_t req_type,
114  void *origin_addr,
115  int origin_count,
116  struct ompi_datatype_t *origin_dt)
117 {
118  OBJ_RETAIN(origin_dt);
119  sendreq->req_origin_datatype = origin_dt;
120  sendreq->req_type = req_type;
121 
122  if (req_type != OMPI_OSC_PT2PT_GET) {
123  opal_convertor_copy_and_prepare_for_send(sendreq->req_target_proc->proc_convertor,
124  &(origin_dt->super),
125  origin_count,
126  origin_addr,
127  0,
128  &(sendreq->req_origin_convertor));
129  opal_convertor_get_packed_size(&sendreq->req_origin_convertor,
130  &sendreq->req_origin_bytes_packed);
131  } else {
132  opal_convertor_copy_and_prepare_for_recv(sendreq->req_target_proc->proc_convertor,
133  &(origin_dt->super),
134  origin_count,
135  origin_addr,
136  0,
137  &(sendreq->req_origin_convertor));
138  opal_convertor_get_packed_size(&sendreq->req_origin_convertor,
139  &sendreq->req_origin_bytes_packed);
140  }
141 
142  return OMPI_SUCCESS;
143 }
144 
145 
146 static inline int
147 ompi_osc_pt2pt_sendreq_init_target(ompi_osc_pt2pt_sendreq_t *sendreq,
148  OPAL_PTRDIFF_TYPE target_disp,
149  int target_count,
150  struct ompi_datatype_t *target_datatype)
151 {
152  OBJ_RETAIN(target_datatype);
153 
154  sendreq->req_target_disp = target_disp;
155  sendreq->req_target_count = target_count;
156  sendreq->req_target_datatype = target_datatype;
157 
158  return OMPI_SUCCESS;
159 }
160 
161 
162 static inline int
163 ompi_osc_pt2pt_sendreq_free(ompi_osc_pt2pt_sendreq_t *sendreq)
164 {
165  MEMCHECKER(
166  memchecker_convertor_call(&opal_memchecker_base_mem_defined,
167  &sendreq->req_origin_convertor);
168  );
169  opal_convertor_cleanup(&sendreq->req_origin_convertor);
170 
173 
174  OPAL_FREE_LIST_RETURN(&mca_osc_pt2pt_component.p2p_c_sendreqs,
175  (opal_list_item_t*) sendreq);
176 
177  return OMPI_SUCCESS;
178 }
179 
180 #endif /* OMPI_OSC_PT2PT_SENDREQ_H */
ompi_osc_pt2pt_req_type_t req_type
type of sendreq (from ompi_osc_pt2pt_req_type_t)
Definition: osc_pt2pt_sendreq.h:42
Definition: ompi_datatype.h:68
int req_op_id
op index on the target
Definition: osc_pt2pt_sendreq.h:67
ompi_osc_pt2pt_module_t * req_module
pointer to the module that created the sendreq
Definition: osc_pt2pt_sendreq.h:44
Definition: osc_pt2pt.h:57
struct ompi_datatype_t * req_origin_datatype
Datatype for the origin side of the operation.
Definition: osc_pt2pt_sendreq.h:47
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
size_t req_origin_bytes_packed
packed size of message on the origin side
Definition: osc_pt2pt_sendreq.h:52
#define OBJ_RETAIN(object)
Retain an object (by incrementing its reference count)
Definition: opal_object.h:278
opal_convertor_t req_origin_convertor
Convertor for the origin side of the operation.
Definition: osc_pt2pt_sendreq.h:50
OPAL_PTRDIFF_TYPE req_target_disp
displacement on target
Definition: osc_pt2pt_sendreq.h:60
Definition: opal_list.h:98
ompi_proc_t * req_target_proc
pointer to the proc structure for the target of the operation
Definition: osc_pt2pt_sendreq.h:57
#define OBJ_RELEASE(object)
Release an object (by decrementing its reference count).
Definition: opal_object.h:324
Definition: opal_free_list.h:47
Definition: osc_pt2pt_sendreq.h:38
opal_datatype_t super
Base opal_datatype_t superclass.
Definition: ompi_datatype.h:69
opal_free_list_t p2p_c_sendreqs
free list of ompi_osc_pt2pt_sendreq_t structures
Definition: osc_pt2pt.h:46
int req_target_count
datatype count on target
Definition: osc_pt2pt_sendreq.h:62
ompi_communicator_t * p2p_comm
communicator created with this window
Definition: osc_pt2pt.h:74
Definition: opal_convertor.h:90
struct opal_convertor_t * proc_convertor
Base convertor for the proc described by this process.
Definition: proc.h:70
int req_target_rank
rank in module's communicator for target of operation
Definition: osc_pt2pt_sendreq.h:55
struct ompi_datatype_t * req_target_datatype
datatype on target
Definition: osc_pt2pt_sendreq.h:64
Main top-level request struct definition.
Definition: request.h:100
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236