OpenMPI  0.1.1
osc_pt2pt_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) 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_REPLYREQ_H
19 #define OMPI_OSC_PT2PT_REPLYREQ_H
20 
21 #include "osc_pt2pt.h"
22 #include "osc_pt2pt_longreq.h"
23 
24 #include "opal/types.h"
25 #include "opal/class/opal_list.h"
26 #include "ompi/datatype/ompi_datatype.h"
27 #include "opal/datatype/opal_convertor.h"
28 #include "ompi/communicator/communicator.h"
29 #include "ompi/proc/proc.h"
30 #include "ompi/memchecker.h"
31 
32 
34  opal_list_item_t super;
35 
36  /** pointer to the module that created the replyreq */
38 
39  /** Datatype for the target side of the operation */
41  /** Convertor for the target. Always setup for send. */
43  /** packed size of message on the target side */
45 
46  /** rank in module's communicator for origin of operation */
48  /** pointer to the proc structure for the origin of the operation */
50 
51  ompi_ptr_t rep_origin_sendreq;
52 };
55 
56 
57 /** allocate and populate a replyreq structure. datatype is
58  RETAINed for the life of the replyreq */
59 int
60 ompi_osc_pt2pt_replyreq_alloc_init(ompi_osc_pt2pt_module_t *module,
61  int origin,
62  ompi_ptr_t origin_request,
63  OPAL_PTRDIFF_TYPE target_displacement,
64  int target_count,
65  struct ompi_datatype_t *datatype,
66  ompi_osc_pt2pt_replyreq_t **replyreq);
67 
68 
69 static inline int
70 ompi_osc_pt2pt_replyreq_alloc(ompi_osc_pt2pt_module_t *module,
71  int origin_rank,
72  ompi_osc_pt2pt_replyreq_t **replyreq)
73 {
74  int ret;
76  ompi_proc_t *proc = ompi_comm_peer_lookup( module->p2p_comm, origin_rank );
77 
78  /* BWB - FIX ME - is this really the right return code? */
79  if (NULL == proc) return OMPI_ERR_OUT_OF_RESOURCE;
80 
81  OPAL_FREE_LIST_GET(&mca_osc_pt2pt_component.p2p_c_replyreqs,
82  item, ret);
83  if (OMPI_SUCCESS != ret) return ret;
84  *replyreq = (ompi_osc_pt2pt_replyreq_t*) item;
85 
86  (*replyreq)->rep_module = module;
87  (*replyreq)->rep_origin_rank = origin_rank;
88  (*replyreq)->rep_origin_proc = proc;
89 
90  return OMPI_SUCCESS;
91 }
92 
93 
94 static inline int
95 ompi_osc_pt2pt_replyreq_init_target(ompi_osc_pt2pt_replyreq_t *replyreq,
96  void *target_addr,
97  int target_count,
98  struct ompi_datatype_t *target_dt)
99 {
100  OBJ_RETAIN(target_dt);
101  replyreq->rep_target_datatype = target_dt;
102 
103  opal_convertor_copy_and_prepare_for_send(replyreq->rep_origin_proc->proc_convertor,
104  &(target_dt->super),
105  target_count,
106  target_addr,
107  0,
108  &(replyreq->rep_target_convertor));
109  opal_convertor_get_packed_size(&replyreq->rep_target_convertor,
110  &replyreq->rep_target_bytes_packed);
111 
112  return OMPI_SUCCESS;
113 }
114 
115 
116 static inline int
117 ompi_osc_pt2pt_replyreq_init_origin(ompi_osc_pt2pt_replyreq_t *replyreq,
118  ompi_ptr_t origin_request)
119 {
120  replyreq->rep_origin_sendreq = origin_request;
121 
122  return OMPI_SUCCESS;
123 }
124 
125 
126 static inline int
127 ompi_osc_pt2pt_replyreq_free(ompi_osc_pt2pt_replyreq_t *replyreq)
128 {
129  MEMCHECKER(
130  memchecker_convertor_call(&opal_memchecker_base_mem_defined,
131  &replyreq->rep_target_convertor);
132  );
133  opal_convertor_cleanup(&replyreq->rep_target_convertor);
134 
135  OBJ_RELEASE(replyreq->rep_target_datatype);
136 
137  OPAL_FREE_LIST_RETURN(&mca_osc_pt2pt_component.p2p_c_replyreqs,
138  (opal_list_item_t*) replyreq);
139 
140  return OMPI_SUCCESS;
141 }
142 
143 #endif /* OMPI_OSC_PT2PT_REPLYREQ_H */
struct ompi_datatype_t * rep_target_datatype
Datatype for the target side of the operation.
Definition: osc_pt2pt_replyreq.h:40
int rep_origin_rank
rank in module's communicator for origin of operation
Definition: osc_pt2pt_replyreq.h:47
Definition: ompi_datatype.h:68
opal_convertor_t rep_target_convertor
Convertor for the target.
Definition: osc_pt2pt_replyreq.h:42
Definition: types.h:52
Definition: osc_pt2pt.h:57
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
Definition: opal_list.h:98
#define OBJ_RELEASE(object)
Release an object (by decrementing its reference count).
Definition: opal_object.h:324
Definition: opal_free_list.h:47
opal_datatype_t super
Base opal_datatype_t superclass.
Definition: ompi_datatype.h:69
ompi_communicator_t * p2p_comm
communicator created with this window
Definition: osc_pt2pt.h:74
Definition: opal_convertor.h:90
ompi_proc_t * rep_origin_proc
pointer to the proc structure for the origin of the operation
Definition: osc_pt2pt_replyreq.h:49
ompi_osc_pt2pt_module_t * rep_module
pointer to the module that created the replyreq
Definition: osc_pt2pt_replyreq.h:37
struct opal_convertor_t * proc_convertor
Base convertor for the proc described by this process.
Definition: proc.h:70
Definition: osc_pt2pt_replyreq.h:33
opal_free_list_t p2p_c_replyreqs
free list of ompi_osc_pt2pt_replyreq_t structures
Definition: osc_pt2pt.h:48
size_t rep_target_bytes_packed
packed size of message on the target side
Definition: osc_pt2pt_replyreq.h:44
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236