1313 * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
1414 * Copyright (c) 2016 Research Organization for Information Science
1515 * and Technology (RIST). All rights reserved.
16+ * Copyright (c) 2016 Los Alamos National Security, LLC. All rights
17+ * reserved.
1618 * $COPYRIGHT$
1719 *
1820 * Additional copyrights may follow
@@ -43,20 +45,22 @@ static int empty_process(void)
4345 return OPAL_SUCCESS ;
4446}
4547
48+ static int empty_query (int * priority )
49+ {
50+ * priority = 0 ;
51+ return OPAL_SUCCESS ;
52+ }
4653
4754/*
4855 * Local variables
4956 */
5057static opal_memory_base_component_2_0_0_t empty_component = {
51- /* Don't care about the version info */
52- { 0 , },
53- /* Don't care about the data */
54- { 0 , },
5558 /* Empty / safe functions to call if no memory componet is selected */
56- empty_process ,
57- opal_memory_base_component_register_empty ,
58- opal_memory_base_component_deregister_empty ,
59- opal_memory_base_component_set_alignment_empty ,
59+ .memoryc_query = empty_query ,
60+ .memoryc_process = empty_process ,
61+ .memoryc_register = opal_memory_base_component_register_empty ,
62+ .memoryc_deregister = opal_memory_base_component_deregister_empty ,
63+ .memoryc_set_alignment = opal_memory_base_component_set_alignment_empty ,
6064};
6165
6266
@@ -66,30 +70,49 @@ static opal_memory_base_component_2_0_0_t empty_component = {
6670opal_memory_base_component_2_0_0_t * opal_memory = & empty_component ;
6771
6872
73+ void opal_memory_base_malloc_init_hook (void )
74+ {
75+ if (opal_memory -> memoryc_init_hook ) {
76+ opal_memory -> memoryc_init_hook ();
77+ }
78+ }
6979
7080/*
7181 * Function for finding and opening either all MCA components, or the one
7282 * that was specifically requested via a MCA parameter.
7383 */
7484static int opal_memory_base_open (mca_base_open_flag_t flags )
7585{
86+ mca_base_component_list_item_t * item , * next ;
87+ opal_memory_base_component_2_0_0_t * tmp ;
88+ int priority , highest_priority = 0 ;
7689 int ret ;
7790
78- /* Open up all available components */
91+ /* can only be zero or one */
92+ OPAL_LIST_FOREACH (item , & opal_memory_base_framework .framework_components , mca_base_component_list_item_t ) {
93+ tmp = (opal_memory_base_component_2_0_0_t * ) item -> cli_component ;
94+ ret = tmp -> memoryc_query (& priority );
95+ if (OPAL_SUCCESS != ret || priority < highest_priority ) {
96+ continue ;
97+ }
98+
99+ highest_priority = priority ;
100+ opal_memory = tmp ;
101+ }
102+
103+ OPAL_LIST_FOREACH_SAFE (item , next , & opal_memory_base_framework .framework_components , mca_base_component_list_item_t ) {
104+ if ((void * ) opal_memory != (void * ) item -> cli_component ) {
105+ mca_base_component_unload (item -> cli_component , opal_memory_base_framework .framework_output );
106+ opal_list_remove_item (& opal_memory_base_framework .framework_components , & item -> super );
107+ }
108+ }
109+
110+ /* open remaining component */
79111 ret = mca_base_framework_components_open (& opal_memory_base_framework , flags );
80112 if (ret != OPAL_SUCCESS ) {
81113 return ret ;
82114 }
83115
84- /* can only be zero or one */
85- if (opal_list_get_size (& opal_memory_base_framework .framework_components ) == 1 ) {
86- mca_base_component_list_item_t * item ;
87- item = (mca_base_component_list_item_t * )
88- opal_list_get_first (& opal_memory_base_framework .framework_components );
89- opal_memory = (opal_memory_base_component_2_0_0_t * )
90- item -> cli_component ;
91- }
92-
93116 /* All done */
94117 return OPAL_SUCCESS ;
95118}
0 commit comments