root/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/base/pnet_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. pmix_pnet_close
  2. pmix_pnet_open
  3. lpcon
  4. lpdes
  5. ndcon
  6. nddes
  7. jcon
  8. jdes
  9. rcon
  10. rdes

   1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2009 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) 2012-2013 Los Alamos National Security, Inc.  All rights reserved.
  14  * Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
  15  * Copyright (c) 2015-2016 Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 /** @file:
  24  *
  25  */
  26 #include <src/include/pmix_config.h>
  27 
  28 #include <pmix_common.h>
  29 
  30 #ifdef HAVE_STRING_H
  31 #include <string.h>
  32 #endif
  33 
  34 #include "src/class/pmix_list.h"
  35 #include "src/mca/base/base.h"
  36 #include "src/mca/pnet/base/base.h"
  37 
  38 /*
  39  * The following file was created by configure.  It contains extern
  40  * statements and the definition of an array of pointers to each
  41  * component's public mca_base_component_t struct.
  42  */
  43 
  44 #include "src/mca/pnet/base/static-components.h"
  45 
  46 /* Instantiate the global vars */
  47 pmix_pnet_globals_t pmix_pnet_globals = {{0}};
  48 pmix_pnet_API_module_t pmix_pnet = {
  49     .allocate = pmix_pnet_base_allocate,
  50     .setup_local_network = pmix_pnet_base_setup_local_network,
  51     .setup_fork = pmix_pnet_base_setup_fork,
  52     .child_finalized = pmix_pnet_base_child_finalized,
  53     .local_app_finalized = pmix_pnet_base_local_app_finalized,
  54     .deregister_nspace = pmix_pnet_base_deregister_nspace,
  55     .collect_inventory = pmix_pnet_base_collect_inventory,
  56     .deliver_inventory = pmix_pnet_base_deliver_inventory
  57 };
  58 
  59 static pmix_status_t pmix_pnet_close(void)
  60 {
  61   pmix_pnet_base_active_module_t *active, *prev;
  62 
  63     if (!pmix_pnet_globals.initialized) {
  64         return PMIX_SUCCESS;
  65     }
  66     pmix_pnet_globals.initialized = false;
  67 
  68     PMIX_LIST_FOREACH_SAFE(active, prev, &pmix_pnet_globals.actives, pmix_pnet_base_active_module_t) {
  69       pmix_list_remove_item(&pmix_pnet_globals.actives, &active->super);
  70       if (NULL != active->module->finalize) {
  71         active->module->finalize();
  72       }
  73       PMIX_RELEASE(active);
  74     }
  75     PMIX_DESTRUCT(&pmix_pnet_globals.actives);
  76 
  77     PMIX_LIST_DESTRUCT(&pmix_pnet_globals.jobs);
  78     PMIX_LIST_DESTRUCT(&pmix_pnet_globals.nodes);
  79 
  80     PMIX_DESTRUCT_LOCK(&pmix_pnet_globals.lock);
  81     return pmix_mca_base_framework_components_close(&pmix_pnet_base_framework, NULL);
  82 }
  83 
  84 static pmix_status_t pmix_pnet_open(pmix_mca_base_open_flag_t flags)
  85 {
  86     /* initialize globals */
  87     pmix_pnet_globals.initialized = true;
  88     PMIX_CONSTRUCT_LOCK(&pmix_pnet_globals.lock);
  89     pmix_pnet_globals.lock.active = false;
  90     PMIX_CONSTRUCT(&pmix_pnet_globals.actives, pmix_list_t);
  91     PMIX_CONSTRUCT(&pmix_pnet_globals.jobs, pmix_list_t);
  92     PMIX_CONSTRUCT(&pmix_pnet_globals.nodes, pmix_list_t);
  93 
  94     /* Open up all available components */
  95     return pmix_mca_base_framework_components_open(&pmix_pnet_base_framework, flags);
  96 }
  97 
  98 PMIX_MCA_BASE_FRAMEWORK_DECLARE(pmix, pnet, "PMIx Network Operations",
  99                                 NULL, pmix_pnet_open, pmix_pnet_close,
 100                                 mca_pnet_base_static_components, 0);
 101 
 102 PMIX_CLASS_INSTANCE(pmix_pnet_base_active_module_t,
 103                     pmix_list_item_t,
 104                     NULL, NULL);
 105 
 106 static void lpcon(pmix_pnet_local_procs_t *p)
 107 {
 108     p->nspace = NULL;
 109     p->ranks = NULL;
 110     p->np = 0;
 111 }
 112 static void lpdes(pmix_pnet_local_procs_t *p)
 113 {
 114     if (NULL != p->nspace) {
 115         free(p->nspace);
 116     }
 117     if (NULL != p->ranks) {
 118         free(p->ranks);
 119     }
 120 }
 121 PMIX_CLASS_INSTANCE(pmix_pnet_local_procs_t,
 122                     pmix_list_item_t,
 123                     lpcon, lpdes);
 124 
 125 static void ndcon(pmix_pnet_node_t *p)
 126 {
 127     p->name = NULL;
 128     PMIX_CONSTRUCT(&p->local_jobs, pmix_list_t);
 129     PMIX_CONSTRUCT(&p->resources, pmix_list_t);
 130 }
 131 static void nddes(pmix_pnet_node_t *p)
 132 {
 133     if (NULL != p->name) {
 134         free(p->name);
 135     }
 136     PMIX_LIST_DESTRUCT(&p->local_jobs);
 137     PMIX_LIST_DESTRUCT(&p->resources);
 138 }
 139 PMIX_CLASS_INSTANCE(pmix_pnet_node_t,
 140                     pmix_list_item_t,
 141                     ndcon, nddes);
 142 
 143 static void jcon(pmix_pnet_job_t *p)
 144 {
 145     p->nspace = NULL;
 146     PMIX_CONSTRUCT(&p->nodes, pmix_pointer_array_t);
 147     pmix_pointer_array_init(&p->nodes, 1, INT_MAX, 1);
 148 }
 149 static void jdes(pmix_pnet_job_t *p)
 150 {
 151     int n;
 152     pmix_pnet_node_t *nd;
 153 
 154     if (NULL != p->nspace) {
 155         free(p->nspace);
 156     }
 157     for (n=0; n < p->nodes.size; n++) {
 158         if (NULL != (nd = (pmix_pnet_node_t*)pmix_pointer_array_get_item(&p->nodes, n))) {
 159             pmix_pointer_array_set_item(&p->nodes, n, NULL);
 160             PMIX_RELEASE(nd);
 161         }
 162     }
 163     PMIX_DESTRUCT(&p->nodes);
 164 }
 165 PMIX_CLASS_INSTANCE(pmix_pnet_job_t,
 166                     pmix_list_item_t,
 167                     jcon, jdes);
 168 
 169 static void rcon(pmix_pnet_resource_t *p)
 170 {
 171     p->name = NULL;
 172     PMIX_CONSTRUCT(&p->resources, pmix_list_t);
 173 }
 174 static void rdes(pmix_pnet_resource_t *p)
 175 {
 176     if (NULL != p->name) {
 177         free(p->name);
 178     }
 179     PMIX_LIST_DESTRUCT(&p->resources);
 180 }
 181 PMIX_CLASS_INSTANCE(pmix_pnet_resource_t,
 182                     pmix_list_item_t,
 183                     rcon, rdes);

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