root/opal/mca/rcache/grdma/rcache_grdma_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. grdma_open
  2. grdma_register
  3. grdma_close
  4. grdma_init

   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) 2006      Voltaire. All rights reserved.
  14  * Copyright (c) 2007-2014 Cisco Systems, Inc.  All rights reserved.
  15  * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
  16  *                         reserved.
  17  *
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 
  25 #define OPAL_DISABLE_ENABLE_MEM_DEBUG 1
  26 #include "opal_config.h"
  27 #include "opal/mca/base/base.h"
  28 #include "opal/runtime/opal_params.h"
  29 #include "rcache_grdma.h"
  30 #ifdef HAVE_UNISTD_H
  31 #include <unistd.h>
  32 #endif
  33 #include <stdlib.h>
  34 #include <fcntl.h>
  35 
  36 /*
  37  * Local functions
  38  */
  39 static int grdma_open(void);
  40 static int grdma_close(void);
  41 static int grdma_register(void);
  42 static mca_rcache_base_module_t* grdma_init(
  43         struct mca_rcache_base_resources_t* resources);
  44 
  45 mca_rcache_grdma_component_t mca_rcache_grdma_component = {
  46     {
  47       /* First, the mca_base_component_t struct containing meta
  48          information about the component itself */
  49 
  50         .rcache_version = {
  51             MCA_RCACHE_BASE_VERSION_3_0_0,
  52 
  53             .mca_component_name = "grdma",
  54             MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
  55                                   OPAL_RELEASE_VERSION),
  56             .mca_open_component = grdma_open,
  57             .mca_close_component = grdma_close,
  58             .mca_register_component_params = grdma_register,
  59         },
  60         .rcache_data = {
  61             /* The component is checkpoint ready */
  62             MCA_BASE_METADATA_PARAM_CHECKPOINT
  63         },
  64 
  65         .rcache_init = grdma_init,
  66     }
  67 };
  68 
  69 /**
  70   * component open/close/init function
  71   */
  72 static int grdma_open(void)
  73 {
  74     OBJ_CONSTRUCT(&mca_rcache_grdma_component.caches, opal_list_t);
  75 
  76     return OPAL_SUCCESS;
  77 }
  78 
  79 
  80 static int grdma_register(void)
  81 {
  82     mca_rcache_grdma_component.print_stats = false;
  83     (void) mca_base_component_var_register(&mca_rcache_grdma_component.super.rcache_version,
  84                                            "print_stats", "print registration cache usage statistics at the end of the run",
  85                                            MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
  86                                            OPAL_INFO_LVL_9,
  87                                            MCA_BASE_VAR_SCOPE_READONLY,
  88                                            &mca_rcache_grdma_component.print_stats);
  89 
  90     return OPAL_SUCCESS;
  91 }
  92 
  93 
  94 static int grdma_close(void)
  95 {
  96     OPAL_LIST_DESTRUCT(&mca_rcache_grdma_component.caches);
  97     return OPAL_SUCCESS;
  98 }
  99 
 100 
 101 static mca_rcache_base_module_t *
 102 grdma_init(struct mca_rcache_base_resources_t *resources)
 103 {
 104     mca_rcache_grdma_module_t *rcache_module;
 105     mca_rcache_grdma_cache_t *cache = NULL, *item;
 106 
 107     /* Set this here (vs in component.c) because
 108        opal_leave_pinned* may have been set after MCA params were
 109        read (e.g., by the openib btl) */
 110     mca_rcache_grdma_component.leave_pinned = (int)
 111         (1 == opal_leave_pinned || opal_leave_pinned_pipeline);
 112 
 113     /* find the specified pool */
 114     OPAL_LIST_FOREACH(item, &mca_rcache_grdma_component.caches, mca_rcache_grdma_cache_t) {
 115         if (0 == strcmp (item->cache_name, resources->cache_name)) {
 116             cache = item;
 117             break;
 118         }
 119     }
 120 
 121     if (NULL == cache) {
 122         /* create new cache */
 123         cache = OBJ_NEW(mca_rcache_grdma_cache_t);
 124         if (NULL == cache) {
 125             return NULL;
 126         }
 127 
 128         cache->cache_name = strdup (resources->cache_name);
 129 
 130         opal_list_append (&mca_rcache_grdma_component.caches, &cache->super);
 131     }
 132 
 133     rcache_module = (mca_rcache_grdma_module_t *) malloc (sizeof (*rcache_module));
 134 
 135     rcache_module->resources = *resources;
 136 
 137     mca_rcache_grdma_module_init (rcache_module, cache);
 138 
 139     return &rcache_module->super;
 140 }

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