OpenMPI 0.1.1

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

- File List
- Globals

common_sm.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-2005 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 (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
13 * Copyright (c) 2010-2011 Los Alamos National Security, LLC.
14 * All rights reserved.
15 * $COPYRIGHT$
16 *
17 * Additional copyrights may follow
18 *
19 * $HEADER$
20 */
21
22 #ifndef _COMMON_SM_H_
23 #define _COMMON_SM_H_
24
25 #include "ompi_config.h"
26
27 #include "opal/mca/mca.h"
28 #include "opal/class/opal_object.h"
29 #include "opal/class/opal_list.h"
30 #include "opal/sys/atomic.h"
31 #include "opal/mca/shmem/shmem.h"
32
33 #include "ompi/mca/mpool/mpool.h"
34 #include "ompi/proc/proc.h"
35 #include "ompi/group/group.h"
36 #include "ompi/mca/btl/base/base.h"
37 #include "ompi/mca/btl/base/btl_base_error.h"
38
39 BEGIN_C_DECLS
40
41 struct mca_mpool_base_module_t;
42
43 typedef struct mca_common_sm_seg_header_t {
44 /* lock to control atomic access */
45 opal_atomic_lock_t seg_lock;
46 /* indicates whether or not the segment is ready for use */
47 volatile int32_t seg_inited;
48 /* number of local processes that are attached to the shared memory segment.
49 * this is primarily used as a way of determining whether or not it is safe
50 * to unlink the shared memory backing store. for example, once seg_att
51 * is equal to the number of local processes, then we can safely unlink.
52 */
53 volatile size_t seg_num_procs_inited;
54 /* offset to next available memory location available for allocation */
55 size_t seg_offset;
56 /* total size of the segment */
57 size_t seg_size;
58 } mca_common_sm_seg_header_t;
59
60 typedef struct mca_common_sm_module_t {
61 /* double link list element */
62 opal_list_item_t super;
63 /* pointer to header embedded in the shared memory segment */
64 mca_common_sm_seg_header_t *module_seg;
65 /* base address of the segment */
66 unsigned char *module_seg_addr;
67 /* base address of data segment */
68 unsigned char *module_data_addr;
69 /* shared memory backing facility object that encapsulates shmem info */
70 opal_shmem_ds_t shmem_ds;
71 } mca_common_sm_module_t;
72
73 OBJ_CLASS_DECLARATION(mca_common_sm_module_t);
74
75 /**
76 * This routine is used to set up a shared memory segment (whether
77 * it's an mmaped file or a SYSV IPC segment). It is assumed that
78 * the shared memory segment does not exist before any of the current
79 * set of processes try and open it.
80 *
81 * @param procs - array of (ompi_proc_t *)'s to create this shared
82 * memory segment for. This array must be writable; it may be edited
83 * (in undefined ways) if the array contains procs that are not on
84 * this host. It is assumed that the caller will simply free this
85 * array upon return. (INOUT)
86 *
87 * @param num_procs - length of the procs array (IN)
88 *
89 * @param size - size of the segment, in bytes (IN)
90 *
91 * @param name - unique string identifier of this segment (IN)
92 *
93 * @param size_ctl_structure size of the control structure at
94 * the head of the segment. The control structure
95 * is assumed to have mca_common_sm_seg_header_t
96 * as its first segment (IN)
97 *
98 * @param data_set_alignment alignment of the data segment. this
99 * follows the control structure. If this
100 * value if 0, then assume that there will
101 * be no data segment following the control
102 * structure. (IN)
103 *
104 * @returnvalue pointer to control structure at head of shared memory segment.
105 */
106 OMPI_DECLSPEC extern mca_common_sm_module_t *
107 mca_common_sm_init(ompi_proc_t **procs,
108 size_t num_procs,
109 size_t size,
110 char *file_name,
111 size_t size_ctl_structure,
112 size_t data_seg_alignment);
113
114 /**
115 * This routine is used to set up a shared memory segment (whether
116 * it's an mmaped file or a SYSV IPC segment). It is assumed that
117 * the shared memory segment does not exist before any of the current
118 * set of processes try and open it.
119 *
120 * This routine is the same as mca_common_sm_mmap_init() except that
121 * it takes an (ompi_group_t *) parameter to specify the peers rather
122 * than an array of procs. Unlike mca_common_sm_mmap_init(), the
123 * group must contain *only* local peers, or this function will return
124 * NULL and not create any shared memory segment.
125 */
126 OMPI_DECLSPEC extern mca_common_sm_module_t *
127 mca_common_sm_init_group(ompi_group_t *group,
128 size_t size,
129 char *file_name,
130 size_t size_ctl_structure,
131 size_t data_seg_alignment);
132
133 /**
134 * callback from the sm mpool
135 */
136 OMPI_DECLSPEC extern void *
137 mca_common_sm_seg_alloc(struct mca_mpool_base_module_t *mpool,
138 size_t* size,
139 mca_mpool_base_registration_t **registration);
140
141 /**
142 * This function will release all local resources attached to the
143 * shared memory segment. We assume that the operating system will
144 * release the memory resources when the last process release it.
145 *
146 * @param mca_common_sm_module - instance that is shared between
147 * components that use shared memory.
148 *
149 * @return OMPI_SUCCESS if everything was okay, otherwise return OMPI_ERROR.
150 */
151
152 OMPI_DECLSPEC extern int
153 mca_common_sm_fini(mca_common_sm_module_t *mca_common_sm_module);
154
155 /**
156 * instance that is shared between components that use shared memory.
157 */
158 OMPI_DECLSPEC extern mca_common_sm_module_t *mca_common_sm_module;
159
160 END_C_DECLS
161
162 #endif /* _COMMON_SM_H_ */
163
mca_common_sm_module_t
Definition: common_sm.h:60
opal_list.h
The opal_list_t interface is used to provide a generic doubly-linked list container for Open MPI...
mca_mpool_base_registration_t
Definition: mpool.h:44
proc.h
Process identification structure interface.
ompi_proc_t
Remote Open MPI process structure.
Definition: proc.h:56
opal_atomic_lock_t
Volatile lock object (with optional padding).
Definition: atomic.h:102
mca.h
Top-level interface for all MCA components.
opal_list_item_t
Definition: opal_list.h:98
opal_shmem_ds_t
Definition: shmem_types.h:107
mca_common_sm_seg_header_t
Definition: common_sm.h:43
ompi_group_t
Group structure Currently we have four formats for storing the process pointers that are members of t...
Definition: group.h:79
mpool.h
Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana University Research and Techno...
base.h
group.h
Infrastructure for MPI group support.
atomic.h
Atomic operations.
opal_object.h
A simple C-language object-oriented system with single inheritance and ownership-based memory managem...
shmem.h
shmem (shared memory backing facility) framework component interface definitions. ...
OBJ_CLASS_DECLARATION
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236
mca_mpool_base_module_t
mpool module descriptor.
Definition: mpool.h:174