OpenMPI 0.1.1

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

- File List
- Globals

mtl_portals_recv_short.h
1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2006 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * $COPYRIGHT$
13 *
14 * Additional copyrights may follow
15 *
16 * $HEADER$
17 */
18
19 #ifndef OMPI_MTL_PORTALS_RECV_SHORT_H
20 #define OMPI_MTL_PORTALS_RECV_SHORT_H
21
22 struct ompi_mtl_portals_recv_short_block_t {
23 opal_list_item_t base;
24
25 mca_mtl_portals_module_t *mtl;
26
27 void *start;
28 size_t length;
29 ptl_handle_me_t me_h;
30 ptl_handle_md_t md_h;
31
32 volatile bool full;
33 volatile int32_t pending;
34 };
35 typedef struct ompi_mtl_portals_recv_short_block_t ompi_mtl_portals_recv_short_block_t;
36 OBJ_CLASS_DECLARATION(ompi_mtl_portals_recv_short_block_t);
37
38 extern int
39 ompi_mtl_portals_recv_short_enable(mca_mtl_portals_module_t *mtl);
40
41 extern int
42 ompi_mtl_portals_recv_short_disable(mca_mtl_portals_module_t *mtl);
43
44 /**
45 * Create a block of memory for receiving send messages. Must call
46 * activate_block on the returned block of memory before it will be
47 * active with the POrtals library
48 *
49 * Module lock must be held before calling this function
50 */
51 extern ompi_mtl_portals_recv_short_block_t*
52 ompi_mtl_portals_recv_short_block_init(mca_mtl_portals_module_t *mtl);
53
54
55 /**
56 * Free a block of memory. Will remove the match entry, then progress
57 * Portals until the pending count is returned to 0. Will then free
58 * all resources associated with block.
59 *
60 * Module lock must be held before calling this function
61 */
62 extern int
63 ompi_mtl_portals_recv_short_block_free(ompi_mtl_portals_recv_short_block_t *block);
64
65 /**
66 * activate a block. Blocks that are full (have gone inactive) can be
67 * re-activated with this call. There is no need to hold the lock
68 * before calling this function
69 */
70 static inline int
71 ompi_mtl_portals_activate_block(ompi_mtl_portals_recv_short_block_t *block)
72 {
73 int ret;
74 ptl_process_id_t any_proc = { PTL_NID_ANY, PTL_PID_ANY };
75 ptl_md_t md;
76 uint64_t match_bits = PTL_SHORT_MSG;
77 uint64_t ignore_bits = PTL_CONTEXT_MASK | PTL_SOURCE_MASK | PTL_TAG_MASK;
78
79 /* if we have pending operations, something very, very, very bad
80 has happened... */
81 assert(block->pending == 0);
82
83 if (NULL == block->start) return OMPI_ERROR;
84
85 md.start = block->start;
86 md.length = block->length;
87 md.threshold = PTL_MD_THRESH_INF;
88 md.max_size = block->mtl->eager_limit;
89 md.options = PTL_MD_OP_PUT | PTL_MD_MAX_SIZE | PTL_MD_ACK_DISABLE;
90 md.user_ptr = block;
91 md.eq_handle = block->mtl->ptl_unex_eq_h;
92
93 block->pending = 0;
94 block->full = false;
95
96 /* make sure that everyone sees the update on full value */
97 opal_atomic_mb();
98
99 ret = PtlMEMDPost(ompi_mtl_portals.ptl_ni_h,
100 ompi_mtl_portals.ptl_send_catchall_me_h,
101 any_proc,
102 match_bits,
103 ignore_bits,
104 PTL_UNLINK,
105 PTL_INS_BEFORE,
106 md,
107 PTL_UNLINK,
108 &(block->me_h),
109 &(block->md_h),
110 ompi_mtl_portals.ptl_empty_eq_h);
111 if (PTL_OK != ret) return OMPI_ERROR;
112
113 return OMPI_SUCCESS;
114 }
115
116
117 static inline void
118 ompi_mtl_portals_return_block_part(mca_mtl_portals_module_t *mtl,
119 ompi_mtl_portals_recv_short_block_t *block)
120 {
121 int ret;
122
123 OPAL_THREAD_ADD32(&(block->pending), -1);
124 if (block->full == true) {
125 if (block->pending == 0) {
126 ret = ompi_mtl_portals_activate_block(block);
127 if (OMPI_SUCCESS != ret) {
128 /* BWB - now what? */
129 }
130 }
131 }
132 }
133
134 #endif /* OMPI_MTL_PORTALS_RECV_SHORT_H */
OPAL_THREAD_ADD32
#define OPAL_THREAD_ADD32(x, y)
Use an atomic operation for increment/decrement if opal_using_threads() indicates that threads are in...
Definition: mutex.h:367
ompi_mtl_portals_recv_short_block_t
Definition: mtl_portals_recv_short.h:22
opal_list_item_t
Definition: opal_list.h:98
opal_atomic_mb
void opal_atomic_mb(void)
Memory barrier.
block
Definition: t-test2.c:52
mca_mtl_portals_module_t
Definition: mtl_portals.h:34
OBJ_CLASS_DECLARATION
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236