OpenMPI  0.1.1
maffinity.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2008 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$
13  *
14  * Additional copyrights may follow
15  *
16  * $HEADER$
17  */
18 /**
19  * @file
20  *
21  * maffinity (memory affinity) framework component interface
22  * definitions.
23  *
24  * Intent
25  *
26  * Simple component to set memory affinity for pages. Note that this
27  * framework assumes that processor affinity is being used (it doesn't
28  * make much sense to use memory affinity unless processes are bound
29  * to specific processors, otherwise the processes may move around and
30  * the memory may end up being remote).
31  *
32  * maffinity components are typically used with shared memory
33  * operations, but can be used elsewhere as well. The idea is to get
34  * memory physically located with the process that is going to use it.
35  * For memory allocated to a processor-bound process, functions such
36  * as malloc() do this naturally. However, when working with memory
37  * shared by multiple processes on a NUMA machine, it can be extremely
38  * advantageous to ensure that pages containing the data structures
39  * for a given process are physically local to the processor where
40  * that process is bound.
41  *
42  * One process will allocate a large shared memory block and all will
43  * need to participate to make pages local to specific processors.
44  *
45  * There is one main module function
46  * (opal_maffinity_base_module_set_fn_t) that takes an array of
47  * segment descriptions within the block. Each process will get a
48  * different set of segment descriptions (i.e., the segments belonging
49  * to that process). Components then do whatever is necessary to make
50  * pages local to their respective processes (i.e., the processors
51  * where the processes are running).
52  */
53 
54 #ifndef OPAL_MAFFINITY_H
55 #define OPAL_MAFFINITY_H
56 
57 #include "opal_config.h"
58 
59 #include "opal/mca/mca.h"
60 #include "opal/mca/base/base.h"
62 
63 /**
64  * Module initialization function. Should return OPAL_SUCCESS.
65  */
67 
68 
69 /**
70  * Module function to set memory affinity. Take an array of
71  * maffinity_base_segment_t instances to describe which memory should
72  * physically reside with which process.
73  *
74  * This function is intended to be invoked by each process immediately
75  * after they mmap / attach the shared memory. In some cases, it will
76  * be a no-op for some processes (i.e., machines where a single
77  * function call in the creating process sets the memory affinity for
78  * the entire region), but in other cases all processes will need to
79  * participate (e.g., the first_use component, each each process will
80  * "touch" the pages that are supposed to be local to them).
81  */
83  (opal_maffinity_base_segment_t *segments, size_t num_segments);
84 
85 /**
86  * translate memory node name (such as "mem0") to memory node id
87  */
89  (char *node_name, int *node_id);
90 
91 /**
92  * bind memory to node
93  */
95  (opal_maffinity_base_segment_t *segments, size_t num_segments, int node_id);
96 
97 /**
98  * Structure for maffinity components.
99  */
101  /** MCA base component */
103  /** MCA base data */
105 };
106 /**
107  * Convenience typedef
108  */
110 
111 
112 /**
113  * Structure for maffinity modules
114  */
116  /** Module initialization function */
118 
119  /** Set memory affinity */
122  opal_maffinity_base_module_bind_fn_t maff_module_bind;
123 };
124 /**
125  * Convenience typedef
126  */
128 
129 
130 /*
131  * Macro for use in components that are of type maffinity
132  */
133 #define OPAL_MAFFINITY_BASE_VERSION_2_0_0 \
134  MCA_BASE_VERSION_2_0_0, \
135  "maffinity", 2, 0, 0
136 
137 #endif /* OPAL_MAFFINITY_H */
int(* opal_maffinity_base_module_init_1_0_0_fn_t)(void)
Module initialization function.
Definition: maffinity.h:66
int(* opal_maffinity_base_module_node_name_to_id_fn_t)(char *node_name, int *node_id)
translate memory node name (such as "mem0") to memory node id
Definition: maffinity.h:89
Common type for all MCA components.
Definition: mca.h:250
mca_base_component_t base_version
MCA base component.
Definition: maffinity.h:102
Structure for maffinity components.
Definition: maffinity.h:100
int(* opal_maffinity_base_module_set_fn_t)(opal_maffinity_base_segment_t *segments, size_t num_segments)
Module function to set memory affinity.
Definition: maffinity.h:83
Top-level interface for all MCA components.
opal_maffinity_base_module_set_fn_t maff_module_set
Set memory affinity.
Definition: maffinity.h:120
Meta data for MCA v2.0.0 components.
Definition: mca.h:309
Struct used with opal_maffinity_base_module_set_fn_t.
Definition: maffinity_types.h:46
Structure for maffinity modules.
Definition: maffinity.h:115
mca_base_component_data_t base_data
MCA base data.
Definition: maffinity.h:104
int(* opal_maffinity_base_module_bind_fn_t)(opal_maffinity_base_segment_t *segments, size_t num_segments, int node_id)
bind memory to node
Definition: maffinity.h:95
Common types used in the maffinity framework.
opal_maffinity_base_module_init_1_0_0_fn_t maff_module_init
Module initialization function.
Definition: maffinity.h:117