root/opal/mca/memory/base/memory_base_open.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. empty_process
  2. empty_query
  3. opal_memory_base_malloc_init_hook
  4. opal_memory_base_open

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2009      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2016      Research Organization for Information Science
  15  *                         and Technology (RIST). All rights reserved.
  16  * Copyright (c) 2016      Los Alamos National Security, LLC. All rights
  17  *                         reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 
  25 
  26 #include "opal_config.h"
  27 
  28 #include "opal/constants.h"
  29 #include "opal/mca/mca.h"
  30 #include "opal/mca/base/base.h"
  31 #include "opal/mca/memory/memory.h"
  32 #include "opal/mca/memory/base/base.h"
  33 #include "opal/mca/memory/base/empty.h"
  34 
  35 
  36 /*
  37  * The following file was created by configure.  It contains extern
  38  * statements and the definition of an array of pointers to each
  39  * component's public mca_base_component_t struct.
  40  */
  41 #include "opal/mca/memory/base/static-components.h"
  42 
  43 static int empty_process(void)
  44 {
  45     return OPAL_SUCCESS;
  46 }
  47 
  48 static int empty_query (int *priority)
  49 {
  50     *priority = 0;
  51     return OPAL_SUCCESS;
  52 }
  53 
  54 /*
  55  * Local variables
  56  */
  57 static opal_memory_base_component_2_0_0_t empty_component = {
  58     /* Empty / safe functions to call if no memory componet is selected */
  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,
  64 };
  65 
  66 
  67 /*
  68  * Globals
  69  */
  70 opal_memory_base_component_2_0_0_t *opal_memory = &empty_component;
  71 
  72 
  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 }
  79 
  80 /*
  81  * Function for finding and opening either all MCA components, or the one
  82  * that was specifically requested via a MCA parameter.
  83  */
  84 static int opal_memory_base_open(mca_base_open_flag_t flags)
  85 {
  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;
  89     int ret;
  90 
  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 */
 111     ret = mca_base_framework_components_open (&opal_memory_base_framework, flags);
 112     if (ret != OPAL_SUCCESS) {
 113         return ret;
 114     }
 115 
 116     /* All done */
 117     return OPAL_SUCCESS;
 118 }
 119 
 120 /* Use default register/close functions */
 121 MCA_BASE_FRAMEWORK_DECLARE(opal, memory, "memory hooks", NULL, opal_memory_base_open, NULL,
 122                            mca_memory_base_static_components, 0);

/* [<][>][^][v][top][bottom][index][help] */