2727
2828#include "opal/mca/mca.h"
2929#include "opal/mca/base/base.h"
30+ #include "opal/mca/base/mca_base_pvar.h"
3031#include "opal/mca/rcache/rcache.h"
3132#include "opal/mca/rcache/base/base.h"
3233#include "opal/memoryhooks/memory.h"
3334#include "opal/constants.h"
3435#include "rcache_base_mem_cb.h"
3536
37+ /* two-level macro for stringifying a number */
38+ #define STRINGIFYX (x ) #x
39+ #define STRINGIFY (x ) STRINGIFYX(x)
40+
3641/*
3742 * The following file was created by configure. It contains extern
3843 * statements and the definition of an array of pointers to each
@@ -59,12 +64,19 @@ static void mca_rcache_base_registration_constructor( mca_rcache_base_registrati
5964OBJ_CLASS_INSTANCE (mca_rcache_base_registration_t , opal_free_list_item_t ,
6065 mca_rcache_base_registration_constructor , NULL );
6166
67+ #define TREE_ITEMS_MIN 2048
68+ #define TREE_ITEMS_MAX 16384
69+ #define TREE_ITEMS_INC 2048
6270
6371/*
6472 * Global variables
6573 */
6674opal_list_t mca_rcache_base_modules = {{0 }};
67-
75+ opal_free_list_t mca_rcache_base_vma_tree_items = {{0 }};
76+ bool mca_rcache_base_vma_tree_items_inited = false;
77+ unsigned int mca_rcache_base_vma_tree_items_min = TREE_ITEMS_MIN ;
78+ int mca_rcache_base_vma_tree_items_max = TREE_ITEMS_MAX ;
79+ unsigned int mca_rcache_base_vma_tree_items_inc = TREE_ITEMS_INC ;
6880
6981OBJ_CLASS_INSTANCE (mca_rcache_base_selected_module_t , opal_list_item_t , NULL , NULL );
7082
@@ -100,8 +112,11 @@ static int mca_rcache_base_close(void)
100112 time between now and end of application (even post main()!) */
101113 (void ) mca_base_framework_close (& opal_memory_base_framework );
102114 }
103- /* All done */
104115
116+ OBJ_DESTRUCT (& mca_rcache_base_vma_tree_items );
117+ mca_rcache_base_vma_tree_items_inited = false;
118+
119+ /* All done */
105120 /* Close all remaining available components */
106121 return mca_base_framework_components_close (& opal_rcache_base_framework , NULL );
107122}
@@ -117,11 +132,42 @@ static int mca_rcache_base_open(mca_base_open_flag_t flags)
117132
118133 OBJ_CONSTRUCT (& mca_rcache_base_modules , opal_list_t );
119134
135+ /* the free list is only initialized when a VMA tree is created */
136+ OBJ_CONSTRUCT (& mca_rcache_base_vma_tree_items , opal_free_list_t );
137+
120138 /* Open up all available components */
121139 return mca_base_framework_components_open (& opal_rcache_base_framework , flags );
122140}
123141
124- MCA_BASE_FRAMEWORK_DECLARE (opal , rcache , "OPAL Registration Cache" , NULL ,
142+ static int mca_rcache_base_register_mca_variables (mca_base_register_flag_t flags )
143+ {
144+
145+ mca_rcache_base_vma_tree_items_min = TREE_ITEMS_MIN ;
146+ (void ) mca_base_framework_var_register (& opal_rcache_base_framework , "vma_tree_items_min" ,
147+ "Minimum number of VMA tree items to allocate (default: "
148+ STRINGIFY (TREE_ITEMS_MIN ) ")" , MCA_BASE_VAR_TYPE_UNSIGNED_INT ,
149+ NULL , MCA_BASE_VAR_BIND_NO_OBJECT , 0 , OPAL_INFO_LVL_6 ,
150+ MCA_BASE_VAR_SCOPE_READONLY , & mca_rcache_base_vma_tree_items_min );
151+
152+ mca_rcache_base_vma_tree_items_max = TREE_ITEMS_MAX ;
153+ (void ) mca_base_framework_var_register (& opal_rcache_base_framework , "vma_tree_items_max" ,
154+ "Maximum number of VMA tree items to allocate (default: "
155+ STRINGIFY (TREE_ITEMS_MAX ) ", -1: unlimited)" , MCA_BASE_VAR_TYPE_INT ,
156+ NULL , MCA_BASE_VAR_BIND_NO_OBJECT , 0 , OPAL_INFO_LVL_6 ,
157+ MCA_BASE_VAR_SCOPE_READONLY , & mca_rcache_base_vma_tree_items_max );
158+
159+ mca_rcache_base_vma_tree_items_inc = TREE_ITEMS_INC ;
160+ (void ) mca_base_framework_var_register (& opal_rcache_base_framework , "vma_tree_items_inc" ,
161+ "Number of VMA tree items to allocate at a time (default: "
162+ STRINGIFY (TREE_ITEMS_INC ) ")" , MCA_BASE_VAR_TYPE_UNSIGNED_INT ,
163+ NULL , MCA_BASE_VAR_BIND_NO_OBJECT , 0 , OPAL_INFO_LVL_6 ,
164+ MCA_BASE_VAR_SCOPE_READONLY , & mca_rcache_base_vma_tree_items_inc );
165+
166+ return OPAL_SUCCESS ;
167+ }
168+
169+ MCA_BASE_FRAMEWORK_DECLARE (opal , rcache , "OPAL Registration Cache" ,
170+ mca_rcache_base_register_mca_variables ,
125171 mca_rcache_base_open , mca_rcache_base_close ,
126172 mca_rcache_base_static_components , 0 );
127173
0 commit comments