Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:47:27

0001 /*
0002  * Copyright (c) 2010      Cisco Systems, Inc.  All rights reserved.
0003  * Copyright (c) 2012      Los Alamos National Security, Inc. All rights reserved.
0004  * Copyright (c) 2014-2020 Intel, Inc.  All rights reserved.
0005  * Copyright (c) 2015      Research Organization for Information Science
0006  *                         and Technology (RIST). All rights reserved.
0007  * Copyright (c) 2021-2022 Nanook Consulting.  All rights reserved.
0008  * Copyright (c) 2023      Triad National Security, LLC. All rights reserved.
0009  * $COPYRIGHT$
0010  *
0011  * Additional copyrights may follow
0012  *
0013  * $HEADER$
0014  */
0015 
0016 #ifndef PMIX_HASH_H
0017 #define PMIX_HASH_H
0018 
0019 #include "src/include/pmix_config.h"
0020 
0021 #include "src/class/pmix_hash_table.h"
0022 #include "src/include/pmix_globals.h"
0023 #include "src/mca/bfrops/bfrops_types.h"
0024 
0025 BEGIN_C_DECLS
0026 
0027 /* store a value in the given hash table for the specified
0028  * rank index.*/
0029 PMIX_EXPORT pmix_status_t pmix_hash_store(pmix_hash_table_t *table,
0030                                           pmix_rank_t rank, pmix_kval_t *kin,
0031                                           pmix_info_t *qualifiers, size_t nquals,
0032                                           pmix_keyindex_t *kidx);
0033 
0034 /* Fetch the value for a specified key and rank from within
0035  * the given hash_table */
0036 PMIX_EXPORT pmix_status_t pmix_hash_fetch(pmix_hash_table_t *table, pmix_rank_t rank,
0037                                           const char *key,
0038                                           pmix_info_t *qualifiers, size_t nquals,
0039                                           pmix_list_t *kvals,
0040                                           pmix_keyindex_t *kidx);
0041 
0042 /* remove the specified key-value from the given hash_table.
0043  * A NULL key will result in removal of all data for the
0044  * given rank. A rank of PMIX_RANK_WILDCARD indicates that
0045  * the specified key  is to be removed from the data for all
0046  * ranks in the table. Combining key=NULL with rank=PMIX_RANK_WILDCARD
0047  * will therefore result in removal of all data from the
0048  * table */
0049 PMIX_EXPORT pmix_status_t pmix_hash_remove_data(pmix_hash_table_t *table,
0050                                                 pmix_rank_t rank,
0051                                                 const char *key,
0052                                                 pmix_keyindex_t *kidx);
0053 
0054 PMIX_EXPORT void pmix_hash_register_key(uint32_t inid,
0055                                         pmix_regattr_input_t *ptr,
0056                                         pmix_keyindex_t *kidx);
0057 
0058 PMIX_EXPORT pmix_regattr_input_t* pmix_hash_lookup_key(uint32_t inid,
0059                                                        const char *key,
0060                                                        pmix_keyindex_t *kidx);
0061 
0062 #define PMIX_HASH_TRACE_KEY_ACTUAL(s, r, k, id, tbl, v)                     \
0063 do {                                                                        \
0064     const char *_k;                                                         \
0065     char *_v;                                                               \
0066     pmix_regattr_input_t *_p;                                               \
0067     if (NULL == (k) && UINT32_MAX != id) {                                  \
0068         _p = pmix_hash_lookup_key((id), NULL, NULL);                        \
0069         if (NULL == _p) {                                                   \
0070             _k = "KEY NOT FOUND";                                           \
0071         } else {                                                            \
0072             _k = _p->string;                                                \
0073         }                                                                   \
0074     } else if (NULL != (k)) {                                               \
0075         _k = (k);                                                           \
0076     } else {                                                                \
0077         _k = NULL;                                                          \
0078     }                                                                       \
0079     if (NULL != _k) {                                                       \
0080         if (0 == strcmp((s), _k)) {                                         \
0081             if (NULL != (v)) {                                              \
0082                 _v = PMIx_Value_string(v);                                  \
0083             } else {                                                        \
0084                 _v = strdup("\tValue is NULL");                             \
0085             }                                                               \
0086             pmix_output(0, "[%s:%s:%d] %s: Rank %s Key %s\n%s\n\n",         \
0087                         __FILE__, __func__, __LINE__,                       \
0088                         (tbl)->ht_label, PMIX_RANK_PRINT(r),                \
0089                         PMIx_Get_attribute_name(_k), _v);                   \
0090             free(_v);                                                       \
0091         }                                                                   \
0092     }                                                                       \
0093 } while(0)
0094 
0095 #define PMIX_HASH_TRACE_KEY(c, r, s, k, id, v, tbl)             \
0096 do {                                                            \
0097     if (0 == strcasecmp(c, "SERVER") &&                         \
0098         PMIX_PEER_IS_SERVER(pmix_globals.mypeer)) {             \
0099         PMIX_HASH_TRACE_KEY_ACTUAL(s, r, k, id, tbl, v);           \
0100     } else if (0 == strcasecmp(c, "CLIENT") &&                  \
0101                !PMIX_PEER_IS_SERVER(pmix_globals.mypeer)) {     \
0102         PMIX_HASH_TRACE_KEY_ACTUAL(s, r, k, id, tbl, v);        \
0103     }                                                           \
0104 } while (0)
0105 
0106 END_C_DECLS
0107 
0108 #endif /* PMIX_HASH_H */