root/opal/util/proc.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. opal_process_name_ntoh_intr
  2. opal_process_name_hton_intr

   1 /*
   2  * Copyright (c) 2013      The University of Tennessee and The University
   3  *                         of Tennessee Research Foundation.  All rights
   4  *                         reserved.
   5  * Copyright (c) 2013      Inria.  All rights reserved.
   6  * Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
   7  * Copyright (c) 2014-2016 Research Organization for Information Science
   8  *                         and Technology (RIST). All rights reserved.
   9  * Copyright (c) 2017      Cisco Systems, Inc.  All rights reserved
  10  * $COPYRIGHT$
  11  *
  12  * Additional copyrights may follow
  13  *
  14  * $HEADER$
  15  */
  16 
  17 #ifndef OPAL_PROC_H
  18 #define OPAL_PROC_H
  19 
  20 #include "opal_config.h"
  21 #include "opal/class/opal_list.h"
  22 #include "opal/mca/hwloc/hwloc-internal.h"
  23 #include "opal/types.h"
  24 #include "opal/dss/dss.h"
  25 
  26 
  27 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
  28 #include <arpa/inet.h>
  29 #endif
  30 
  31 /**
  32  * This is a transparent handle proposed to the upper layer as a mean
  33  * to store whatever information it needs in order to efficiently
  34  * retrieve the RTE process naming scheme, and get access to the RTE
  35  * information associated with it. The only direct usage of this type
  36  * is to be copied from one structure to another, otherwise it should
  37  * only be used via the accessors defined below.
  38  */
  39 #define OPAL_JOBID_T        OPAL_UINT32
  40 #define OPAL_JOBID_MAX      UINT32_MAX-2
  41 #define OPAL_JOBID_MIN      0
  42 #define OPAL_JOBID_INVALID  (OPAL_JOBID_MAX + 2)
  43 #define OPAL_JOBID_WILDCARD (OPAL_JOBID_MAX + 1)
  44 
  45 #define OPAL_VPID_T         OPAL_UINT32
  46 #define OPAL_VPID_MAX       UINT32_MAX-2
  47 #define OPAL_VPID_MIN       0
  48 #define OPAL_VPID_INVALID   (OPAL_VPID_MAX + 2)
  49 #define OPAL_VPID_WILDCARD  (OPAL_VPID_MAX + 1)
  50 
  51 #define OPAL_PROC_MY_NAME           (opal_proc_local_get()->proc_name)
  52 #define OPAL_PROC_MY_HOSTNAME       (opal_proc_local_get()->proc_hostname)
  53 
  54 #define OPAL_NAME_WILDCARD      (&opal_name_wildcard)
  55 OPAL_DECLSPEC extern opal_process_name_t opal_name_wildcard;
  56 #define OPAL_NAME_INVALID       (&opal_name_invalid)
  57 OPAL_DECLSPEC extern opal_process_name_t opal_name_invalid;
  58 
  59 
  60 #define OPAL_NAME_ARGS(n) \
  61     (unsigned long) ((NULL == n) ? (unsigned long)OPAL_JOBID_INVALID : (unsigned long)(n)->jobid), \
  62     (unsigned long) ((NULL == n) ? (unsigned long)OPAL_VPID_INVALID : (unsigned long)(n)->vpid) \
  63 
  64 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT && !defined(WORDS_BIGENDIAN)
  65 #define OPAL_PROCESS_NAME_NTOH(guid) opal_process_name_ntoh_intr(&(guid))
  66 static inline __opal_attribute_always_inline__ void
  67 opal_process_name_ntoh_intr(opal_process_name_t *name)
  68 {
  69     name->jobid = ntohl(name->jobid);
  70     name->vpid = ntohl(name->vpid);
  71 }
  72 #define OPAL_PROCESS_NAME_HTON(guid) opal_process_name_hton_intr(&(guid))
  73 static inline __opal_attribute_always_inline__ void
  74 opal_process_name_hton_intr(opal_process_name_t *name)
  75 {
  76     name->jobid = htonl(name->jobid);
  77     name->vpid = htonl(name->vpid);
  78 }
  79 #else
  80 #define OPAL_PROCESS_NAME_NTOH(guid)
  81 #define OPAL_PROCESS_NAME_HTON(guid)
  82 #endif
  83 
  84 typedef struct opal_proc_t {
  85     /** allow proc to be placed on a list */
  86     opal_list_item_t                super;
  87     /** this process' name */
  88     opal_process_name_t             proc_name;
  89     /** architecture of this process */
  90     uint32_t                        proc_arch;
  91     /** flags for this proc */
  92     opal_hwloc_locality_t           proc_flags;
  93     /** Base convertor for the proc described by this process */
  94     struct opal_convertor_t*        proc_convertor;
  95     /** A pointer to the name of this host - data is
  96      * actually stored outside of this framework.  */
  97     char*                           proc_hostname;
  98 } opal_proc_t;
  99 OBJ_CLASS_DECLARATION(opal_proc_t);
 100 
 101 typedef struct {
 102     opal_list_item_t super;
 103     opal_process_name_t name;
 104 } opal_namelist_t;
 105 OBJ_CLASS_DECLARATION(opal_namelist_t);
 106 
 107 typedef struct opal_process_info_t {
 108     char *nodename;                     /**< string name for this node */
 109     char *job_session_dir;              /**< Session directory for job */
 110     char *proc_session_dir;             /**< Session directory for the process */
 111     int32_t num_local_peers;            /**< number of procs from my job that share my node with me */
 112     int32_t my_local_rank;              /**< local rank on this node within my job */
 113     char *cpuset;                       /**< String-representation of bitmap where we are bound */
 114 } opal_process_info_t;
 115 OPAL_DECLSPEC extern opal_process_info_t opal_process_info;
 116 
 117 OPAL_DECLSPEC extern opal_proc_t* opal_proc_local_get(void);
 118 OPAL_DECLSPEC extern int opal_proc_local_set(opal_proc_t* proc);
 119 OPAL_DECLSPEC extern void opal_proc_set_name(opal_process_name_t *name);
 120 
 121 /**
 122  * Compare two processor name and return an integer greater than,
 123  * equal to, or less than 0, according as the proc_name of proc1
 124  * is greater than, equal to, or less than the proc_name of proc2.
 125  */
 126 typedef int (*opal_compare_proc_fct_t)(const opal_process_name_t, const opal_process_name_t);
 127 OPAL_DECLSPEC extern opal_compare_proc_fct_t opal_compare_proc;
 128 
 129 /* Provide print functions that will be overwritten by the RTE layer */
 130 OPAL_DECLSPEC extern char* (*opal_process_name_print)(const opal_process_name_t);
 131 OPAL_DECLSPEC extern int (*opal_convert_string_to_process_name)(opal_process_name_t *name,
 132                                                                 const char* name_string);
 133 OPAL_DECLSPEC extern int (*opal_convert_process_name_to_string)(char** name_string,
 134                                                                 const opal_process_name_t *name);
 135 OPAL_DECLSPEC extern char* (*opal_vpid_print)(const opal_vpid_t);
 136 OPAL_DECLSPEC extern char* (*opal_jobid_print)(const opal_jobid_t);
 137 OPAL_DECLSPEC extern int (*opal_snprintf_jobid)(char* name_string, size_t size, opal_jobid_t jobid);
 138 OPAL_DECLSPEC extern int (*opal_convert_string_to_jobid)(opal_jobid_t *jobid, const char *jobid_string);
 139 
 140 /**
 141  * Lookup an opal_proc_t by name
 142  *
 143  * @param name (IN) name to lookup
 144  */
 145 OPAL_DECLSPEC extern struct opal_proc_t *(*opal_proc_for_name) (const opal_process_name_t name);
 146 
 147 #define OPAL_NAME_PRINT(OPAL_PN)    opal_process_name_print(OPAL_PN)
 148 #define OPAL_JOBID_PRINT(OPAL_PN)   opal_jobid_print(OPAL_PN)
 149 #define OPAL_VPID_PRINT(OPAL_PN)    opal_vpid_print(OPAL_PN)
 150 
 151 /* provide a safe way to retrieve the hostname of a proc, including
 152  * our own. This is to be used by all BTLs so we don't retrieve hostnames
 153  * unless needed. The returned value MUST NOT be free'd as it is
 154  * owned by the proc_t */
 155 OPAL_DECLSPEC char* opal_get_proc_hostname(const opal_proc_t *proc);
 156 
 157 #endif  /* OPAL_PROC_H */

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