File: memory.h

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (167 lines) | stat: -rw-r--r-- 6,907 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2005 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2005 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2009      Cisco Systems, Inc.  All rights reserved.
 * Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
 *                         reserved.
 * Copyright (c) 2016      Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

/* NOTE: This framework accommodates two kinds of memory hooks systems:

   1. Those that only require being setup once and then will
      automatically call back to internal component/module functions
      as required (e.g., the ptmalloc2 component).  It is expected
      that such components will have a NULL value for memoryc_process
      and empty (base) implementations of memoryc_register and
      memoryc_deregister.

   2. Those that must be queried periodically to find out if something
      has happened to the registered memory mappings (e.g., the
      ummunot component).  It is expected that such components will
      have complete implementations for memoryc_process,
      memoryc_register, and memoryc_deregister.

   There will only be one of these components compiled in to Open MPI
   (it will be compiled in libopen-pal; it will never be a DSO).  so
   the componente will rule "yes, I can run" or "no, I cannot run".
   If it elects not to run, then there is no memory manager support in
   this process.

   Because there will only be one memory manager component in the
   process, there is no need for a separate module structure --
   everything is in the component for simplicity.

   Note that there is an interface relevant to this framework that is
   not described in this file: the opal_memory_changed() macro.  This
   macro should return 1 if an asynchronous agent has noticed that
   memory mappings have changed.  The macro should be as cheap/fast as
   possible (which is why it's a macro).  If it returns 1, the
   memoryc_process() function pointer (below), will be invoked.  If
   the component does not provide this macro, then a default macro is
   used that always returns 0 and therefore memoryc_process() will
   never be invoked (and can legally be NULL).
*/

#ifndef OPAL_MCA_MEMORY_MEMORY_H
#define OPAL_MCA_MEMORY_MEMORY_H

#include "opal_config.h"

#include "opal/mca/base/base.h"
#include "opal/mca/mca.h"

BEGIN_C_DECLS

/**
 * Prototype for doing something once memory changes have been
 * detected.  This function is assumed to do whatever is necessary to
 * a) figured out what has changed, and b) adjust OMPI as relevant
 * (e.g., call opal_mem_hooks_release_hook).  It only needs to be
 * supplied for components that provide opal_memory_changed() macros
 * that can return non-zero.
 */
typedef int (*opal_memory_base_component_process_fn_t)(void);

/**
 * Prototype for a function that is invoked when the memory base is
 * trying to select a component. This functionality is required.
 */
typedef int (*opal_memory_base_component_query_fn_t)(int *priority);

/**
 * Prototype for a function that is invoked when Open MPI starts to
 * "care" about a specific memory region.  That is, Open MPI declares
 * that it wants to be notified if the memory mapping for this region
 * changes.
 *
 * If a component does not want/need to provide this functionality, it
 * can use the value opal_memory_base_register_empty (an empty
 * implementation of this function).
 */
typedef int (*opal_memory_base_component_register_fn_t)(void *base, size_t len, uint64_t cookie);

/**
 * Prototype for a function that is the opposite of
 * opal_memory_base_component_register_fn_t: this function is invoked
 * when Open MPI stops to "caring" about a specific memory region.
 * That is, Open MPI declares that it no longer wants to be notified
 * if the memory mapping for this region changes.
 *
 * The parameters of this function will exactly match parameters that
 * were previously passed to the call to
 * opal_memory_base_component_register_fn_t.
 *
 * If a component does not want/need to provide this functionality, it
 * can use the value opal_memory_base_deregister_empty (an empty
 * implementation of this function).
 */
typedef int (*opal_memory_base_component_deregister_fn_t)(void *base, size_t len, uint64_t cookie);

/**
 * Prototype for a function that set the memory alignment
 */
typedef void (*opal_memory_base_component_set_alignment_fn_t)(int use_memalign,
                                                              size_t memalign_threshold);

/**
 * Function to be called when initializing malloc hooks
 */
typedef void (*opal_memory_base_component_init_hook_fn_t)(void);

/**
 * Structure for memory components.
 */
typedef struct opal_memory_base_component_2_0_0_t {
    /** MCA base component */
    mca_base_component_t memoryc_version;
    /** MCA base data */
    mca_base_component_data_t memoryc_data;

    opal_memory_base_component_query_fn_t memoryc_query;

    /** This function will be called when the malloc hooks are
     * initialized. It may be NULL if no hooks are needed. */
    opal_memory_base_component_init_hook_fn_t memoryc_init_hook;

    /** Function to call when something has changed, as indicated by
        opal_memory_changed().  Will be ignored if the component does
        not provide an opal_memory_changed() macro that returns
        nonzero.  */
    opal_memory_base_component_process_fn_t memoryc_process;

    /** Function invoked when Open MPI starts "caring" about a
        specific memory region */
    opal_memory_base_component_register_fn_t memoryc_register;
    /** Function invoked when Open MPI stops "caring" about a
        specific memory region */
    opal_memory_base_component_deregister_fn_t memoryc_deregister;
    /** Function invoked in order to set malloc'ed memory alignment */
    opal_memory_base_component_set_alignment_fn_t memoryc_set_alignment;
} opal_memory_base_component_2_0_0_t;

OPAL_DECLSPEC extern opal_memory_base_component_2_0_0_t *opal_memory;

END_C_DECLS

/*
 * Macro for use in components that are of type memory
 */
#define OPAL_MEMORY_BASE_VERSION_2_0_0 OPAL_MCA_BASE_VERSION_2_1_0("memory", 2, 0, 0)

#endif /* OPAL_MCA_MEMORY_MEMORY_H */